documentation.d.ts 3.0 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984
  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. * Checks if the navigator object exists
  283. * @returns true if the navigator object exists
  284. */
  285. static IsNavigatorAvailable(): boolean;
  286. /**
  287. * Extracts text content from a DOM element hierarchy
  288. * @param element defines the root element
  289. * @returns a string
  290. */
  291. static GetDOMTextContent(element: HTMLElement): string;
  292. }
  293. }
  294. declare module BABYLON {
  295. /**
  296. * Logger used througouht the application to allow configuration of
  297. * the log level required for the messages.
  298. */
  299. export class Logger {
  300. /**
  301. * No log
  302. */
  303. static readonly NoneLogLevel: number;
  304. /**
  305. * Only message logs
  306. */
  307. static readonly MessageLogLevel: number;
  308. /**
  309. * Only warning logs
  310. */
  311. static readonly WarningLogLevel: number;
  312. /**
  313. * Only error logs
  314. */
  315. static readonly ErrorLogLevel: number;
  316. /**
  317. * All logs
  318. */
  319. static readonly AllLogLevel: number;
  320. private static _LogCache;
  321. /**
  322. * Gets a value indicating the number of loading errors
  323. * @ignorenaming
  324. */
  325. static errorsCount: number;
  326. /**
  327. * Callback called when a new log is added
  328. */
  329. static OnNewCacheEntry: (entry: string) => void;
  330. private static _AddLogEntry;
  331. private static _FormatMessage;
  332. private static _LogDisabled;
  333. private static _LogEnabled;
  334. private static _WarnDisabled;
  335. private static _WarnEnabled;
  336. private static _ErrorDisabled;
  337. private static _ErrorEnabled;
  338. /**
  339. * Log a message to the console
  340. */
  341. static Log: (message: string) => void;
  342. /**
  343. * Write a warning message to the console
  344. */
  345. static Warn: (message: string) => void;
  346. /**
  347. * Write an error message to the console
  348. */
  349. static Error: (message: string) => void;
  350. /**
  351. * Gets current log cache (list of logs)
  352. */
  353. static readonly LogCache: string;
  354. /**
  355. * Clears the log cache
  356. */
  357. static ClearLogCache(): void;
  358. /**
  359. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  360. */
  361. static LogLevels: number;
  362. }
  363. }
  364. declare module BABYLON {
  365. /** @hidden */
  366. export class _TypeStore {
  367. /** @hidden */
  368. static RegisteredTypes: {
  369. [key: string]: Object;
  370. };
  371. /** @hidden */
  372. static GetClass(fqdn: string): any;
  373. }
  374. }
  375. declare module BABYLON {
  376. /**
  377. * Class containing a set of static utilities functions for deep copy.
  378. */
  379. export class DeepCopier {
  380. /**
  381. * Tries to copy an object by duplicating every property
  382. * @param source defines the source object
  383. * @param destination defines the target object
  384. * @param doNotCopyList defines a list of properties to avoid
  385. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  386. */
  387. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  388. }
  389. }
  390. declare module BABYLON {
  391. /**
  392. * Class containing a set of static utilities functions for precision date
  393. */
  394. export class PrecisionDate {
  395. /**
  396. * Gets either window.performance.now() if supported or Date.now() else
  397. */
  398. static readonly Now: number;
  399. }
  400. }
  401. declare module BABYLON {
  402. /** @hidden */
  403. export class _DevTools {
  404. static WarnImport(name: string): string;
  405. }
  406. }
  407. declare module BABYLON {
  408. /**
  409. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  410. */
  411. export class WebRequest {
  412. private _xhr;
  413. /**
  414. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  415. * i.e. when loading files, where the server/service expects an Authorization header
  416. */
  417. static CustomRequestHeaders: {
  418. [key: string]: string;
  419. };
  420. /**
  421. * Add callback functions in this array to update all the requests before they get sent to the network
  422. */
  423. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  424. private _injectCustomRequestHeaders;
  425. /**
  426. * Gets or sets a function to be called when loading progress changes
  427. */
  428. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  429. /**
  430. * Returns client's state
  431. */
  432. readonly readyState: number;
  433. /**
  434. * Returns client's status
  435. */
  436. readonly status: number;
  437. /**
  438. * Returns client's status as a text
  439. */
  440. readonly statusText: string;
  441. /**
  442. * Returns client's response
  443. */
  444. readonly response: any;
  445. /**
  446. * Returns client's response url
  447. */
  448. readonly responseURL: string;
  449. /**
  450. * Returns client's response as text
  451. */
  452. readonly responseText: string;
  453. /**
  454. * Gets or sets the expected response type
  455. */
  456. responseType: XMLHttpRequestResponseType;
  457. /** @hidden */
  458. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  459. /** @hidden */
  460. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  461. /**
  462. * Cancels any network activity
  463. */
  464. abort(): void;
  465. /**
  466. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  467. * @param body defines an optional request body
  468. */
  469. send(body?: Document | BodyInit | null): void;
  470. /**
  471. * Sets the request method, request URL
  472. * @param method defines the method to use (GET, POST, etc..)
  473. * @param url defines the url to connect with
  474. */
  475. open(method: string, url: string): void;
  476. }
  477. }
  478. declare module BABYLON {
  479. /**
  480. * File request interface
  481. */
  482. export interface IFileRequest {
  483. /**
  484. * Raised when the request is complete (success or error).
  485. */
  486. onCompleteObservable: Observable<IFileRequest>;
  487. /**
  488. * Aborts the request for a file.
  489. */
  490. abort: () => void;
  491. }
  492. }
  493. declare module BABYLON {
  494. /**
  495. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  496. */
  497. export class PerformanceMonitor {
  498. private _enabled;
  499. private _rollingFrameTime;
  500. private _lastFrameTimeMs;
  501. /**
  502. * constructor
  503. * @param frameSampleSize The number of samples required to saturate the sliding window
  504. */
  505. constructor(frameSampleSize?: number);
  506. /**
  507. * Samples current frame
  508. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  509. */
  510. sampleFrame(timeMs?: number): void;
  511. /**
  512. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  513. */
  514. readonly averageFrameTime: number;
  515. /**
  516. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  517. */
  518. readonly averageFrameTimeVariance: number;
  519. /**
  520. * Returns the frame time of the most recent frame
  521. */
  522. readonly instantaneousFrameTime: number;
  523. /**
  524. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  525. */
  526. readonly averageFPS: number;
  527. /**
  528. * Returns the average framerate in frames per second using the most recent frame time
  529. */
  530. readonly instantaneousFPS: number;
  531. /**
  532. * Returns true if enough samples have been taken to completely fill the sliding window
  533. */
  534. readonly isSaturated: boolean;
  535. /**
  536. * Enables contributions to the sliding window sample set
  537. */
  538. enable(): void;
  539. /**
  540. * Disables contributions to the sliding window sample set
  541. * Samples will not be interpolated over the disabled period
  542. */
  543. disable(): void;
  544. /**
  545. * Returns true if sampling is enabled
  546. */
  547. readonly isEnabled: boolean;
  548. /**
  549. * Resets performance monitor
  550. */
  551. reset(): void;
  552. }
  553. /**
  554. * RollingAverage
  555. *
  556. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  557. */
  558. export class RollingAverage {
  559. /**
  560. * Current average
  561. */
  562. average: number;
  563. /**
  564. * Current variance
  565. */
  566. variance: number;
  567. protected _samples: Array<number>;
  568. protected _sampleCount: number;
  569. protected _pos: number;
  570. protected _m2: number;
  571. /**
  572. * constructor
  573. * @param length The number of samples required to saturate the sliding window
  574. */
  575. constructor(length: number);
  576. /**
  577. * Adds a sample to the sample set
  578. * @param v The sample value
  579. */
  580. add(v: number): void;
  581. /**
  582. * Returns previously added values or null if outside of history or outside the sliding window domain
  583. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  584. * @return Value previously recorded with add() or null if outside of range
  585. */
  586. history(i: number): number;
  587. /**
  588. * Returns true if enough samples have been taken to completely fill the sliding window
  589. * @return true if sample-set saturated
  590. */
  591. isSaturated(): boolean;
  592. /**
  593. * Resets the rolling average (equivalent to 0 samples taken so far)
  594. */
  595. reset(): void;
  596. /**
  597. * Wraps a value around the sample range boundaries
  598. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  599. * @return Wrapped position in sample range
  600. */
  601. protected _wrapPosition(i: number): number;
  602. }
  603. }
  604. declare module BABYLON {
  605. /**
  606. * This class implement a typical dictionary using a string as key and the generic type T as value.
  607. * The underlying implementation relies on an associative array to ensure the best performances.
  608. * The value can be anything including 'null' but except 'undefined'
  609. */
  610. export class StringDictionary<T> {
  611. /**
  612. * This will clear this dictionary and copy the content from the 'source' one.
  613. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  614. * @param source the dictionary to take the content from and copy to this dictionary
  615. */
  616. copyFrom(source: StringDictionary<T>): void;
  617. /**
  618. * Get a value based from its key
  619. * @param key the given key to get the matching value from
  620. * @return the value if found, otherwise undefined is returned
  621. */
  622. get(key: string): T | undefined;
  623. /**
  624. * Get a value from its key or add it if it doesn't exist.
  625. * This method will ensure you that a given key/data will be present in the dictionary.
  626. * @param key the given key to get the matching value from
  627. * @param factory the factory that will create the value if the key is not present in the dictionary.
  628. * The factory will only be invoked if there's no data for the given key.
  629. * @return the value corresponding to the key.
  630. */
  631. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  632. /**
  633. * Get a value from its key if present in the dictionary otherwise add it
  634. * @param key the key to get the value from
  635. * @param val if there's no such key/value pair in the dictionary add it with this value
  636. * @return the value corresponding to the key
  637. */
  638. getOrAdd(key: string, val: T): T;
  639. /**
  640. * Check if there's a given key in the dictionary
  641. * @param key the key to check for
  642. * @return true if the key is present, false otherwise
  643. */
  644. contains(key: string): boolean;
  645. /**
  646. * Add a new key and its corresponding value
  647. * @param key the key to add
  648. * @param value the value corresponding to the key
  649. * @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
  650. */
  651. add(key: string, value: T): boolean;
  652. /**
  653. * Update a specific value associated to a key
  654. * @param key defines the key to use
  655. * @param value defines the value to store
  656. * @returns true if the value was updated (or false if the key was not found)
  657. */
  658. set(key: string, value: T): boolean;
  659. /**
  660. * Get the element of the given key and remove it from the dictionary
  661. * @param key defines the key to search
  662. * @returns the value associated with the key or null if not found
  663. */
  664. getAndRemove(key: string): Nullable<T>;
  665. /**
  666. * Remove a key/value from the dictionary.
  667. * @param key the key to remove
  668. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  669. */
  670. remove(key: string): boolean;
  671. /**
  672. * Clear the whole content of the dictionary
  673. */
  674. clear(): void;
  675. /**
  676. * Gets the current count
  677. */
  678. readonly count: number;
  679. /**
  680. * Execute a callback on each key/val of the dictionary.
  681. * Note that you can remove any element in this dictionary in the callback implementation
  682. * @param callback the callback to execute on a given key/value pair
  683. */
  684. forEach(callback: (key: string, val: T) => void): void;
  685. /**
  686. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  687. * If the callback returns null or undefined the method will iterate to the next key/value pair
  688. * Note that you can remove any element in this dictionary in the callback implementation
  689. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  690. * @returns the first item
  691. */
  692. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  693. private _count;
  694. private _data;
  695. }
  696. }
  697. declare module BABYLON {
  698. /**
  699. * Class used to store gfx data (like WebGLBuffer)
  700. */
  701. export class DataBuffer {
  702. /**
  703. * Gets or sets the number of objects referencing this buffer
  704. */
  705. references: number;
  706. /** Gets or sets the size of the underlying buffer */
  707. capacity: number;
  708. /**
  709. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  710. */
  711. is32Bits: boolean;
  712. /**
  713. * Gets the underlying buffer
  714. */
  715. readonly underlyingResource: any;
  716. }
  717. }
  718. declare module BABYLON {
  719. /**
  720. * Class used to store data that will be store in GPU memory
  721. */
  722. export class Buffer {
  723. private _engine;
  724. private _buffer;
  725. /** @hidden */
  726. _data: Nullable<DataArray>;
  727. private _updatable;
  728. private _instanced;
  729. /**
  730. * Gets the byte stride.
  731. */
  732. readonly byteStride: number;
  733. /**
  734. * Constructor
  735. * @param engine the engine
  736. * @param data the data to use for this buffer
  737. * @param updatable whether the data is updatable
  738. * @param stride the stride (optional)
  739. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  740. * @param instanced whether the buffer is instanced (optional)
  741. * @param useBytes set to true if the stride in in bytes (optional)
  742. */
  743. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  744. /**
  745. * Create a new VertexBuffer based on the current buffer
  746. * @param kind defines the vertex buffer kind (position, normal, etc.)
  747. * @param offset defines offset in the buffer (0 by default)
  748. * @param size defines the size in floats of attributes (position is 3 for instance)
  749. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  750. * @param instanced defines if the vertex buffer contains indexed data
  751. * @param useBytes defines if the offset and stride are in bytes
  752. * @returns the new vertex buffer
  753. */
  754. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  755. /**
  756. * Gets a boolean indicating if the Buffer is updatable?
  757. * @returns true if the buffer is updatable
  758. */
  759. isUpdatable(): boolean;
  760. /**
  761. * Gets current buffer's data
  762. * @returns a DataArray or null
  763. */
  764. getData(): Nullable<DataArray>;
  765. /**
  766. * Gets underlying native buffer
  767. * @returns underlying native buffer
  768. */
  769. getBuffer(): Nullable<DataBuffer>;
  770. /**
  771. * Gets the stride in float32 units (i.e. byte stride / 4).
  772. * May not be an integer if the byte stride is not divisible by 4.
  773. * DEPRECATED. Use byteStride instead.
  774. * @returns the stride in float32 units
  775. */
  776. getStrideSize(): number;
  777. /**
  778. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  779. * @param data defines the data to store
  780. */
  781. create(data?: Nullable<DataArray>): void;
  782. /** @hidden */
  783. _rebuild(): void;
  784. /**
  785. * Update current buffer data
  786. * @param data defines the data to store
  787. */
  788. update(data: DataArray): void;
  789. /**
  790. * Updates the data directly.
  791. * @param data the new data
  792. * @param offset the new offset
  793. * @param vertexCount the vertex count (optional)
  794. * @param useBytes set to true if the offset is in bytes
  795. */
  796. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  797. /**
  798. * Release all resources
  799. */
  800. dispose(): void;
  801. }
  802. /**
  803. * Specialized buffer used to store vertex data
  804. */
  805. export class VertexBuffer {
  806. /** @hidden */
  807. _buffer: Buffer;
  808. private _kind;
  809. private _size;
  810. private _ownsBuffer;
  811. private _instanced;
  812. private _instanceDivisor;
  813. /**
  814. * The byte type.
  815. */
  816. static readonly BYTE: number;
  817. /**
  818. * The unsigned byte type.
  819. */
  820. static readonly UNSIGNED_BYTE: number;
  821. /**
  822. * The short type.
  823. */
  824. static readonly SHORT: number;
  825. /**
  826. * The unsigned short type.
  827. */
  828. static readonly UNSIGNED_SHORT: number;
  829. /**
  830. * The integer type.
  831. */
  832. static readonly INT: number;
  833. /**
  834. * The unsigned integer type.
  835. */
  836. static readonly UNSIGNED_INT: number;
  837. /**
  838. * The float type.
  839. */
  840. static readonly FLOAT: number;
  841. /**
  842. * Gets or sets the instance divisor when in instanced mode
  843. */
  844. instanceDivisor: number;
  845. /**
  846. * Gets the byte stride.
  847. */
  848. readonly byteStride: number;
  849. /**
  850. * Gets the byte offset.
  851. */
  852. readonly byteOffset: number;
  853. /**
  854. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  855. */
  856. readonly normalized: boolean;
  857. /**
  858. * Gets the data type of each component in the array.
  859. */
  860. readonly type: number;
  861. /**
  862. * Constructor
  863. * @param engine the engine
  864. * @param data the data to use for this vertex buffer
  865. * @param kind the vertex buffer kind
  866. * @param updatable whether the data is updatable
  867. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  868. * @param stride the stride (optional)
  869. * @param instanced whether the buffer is instanced (optional)
  870. * @param offset the offset of the data (optional)
  871. * @param size the number of components (optional)
  872. * @param type the type of the component (optional)
  873. * @param normalized whether the data contains normalized data (optional)
  874. * @param useBytes set to true if stride and offset are in bytes (optional)
  875. */
  876. 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);
  877. /** @hidden */
  878. _rebuild(): void;
  879. /**
  880. * Returns the kind of the VertexBuffer (string)
  881. * @returns a string
  882. */
  883. getKind(): string;
  884. /**
  885. * Gets a boolean indicating if the VertexBuffer is updatable?
  886. * @returns true if the buffer is updatable
  887. */
  888. isUpdatable(): boolean;
  889. /**
  890. * Gets current buffer's data
  891. * @returns a DataArray or null
  892. */
  893. getData(): Nullable<DataArray>;
  894. /**
  895. * Gets underlying native buffer
  896. * @returns underlying native buffer
  897. */
  898. getBuffer(): Nullable<DataBuffer>;
  899. /**
  900. * Gets the stride in float32 units (i.e. byte stride / 4).
  901. * May not be an integer if the byte stride is not divisible by 4.
  902. * DEPRECATED. Use byteStride instead.
  903. * @returns the stride in float32 units
  904. */
  905. getStrideSize(): number;
  906. /**
  907. * Returns the offset as a multiple of the type byte length.
  908. * DEPRECATED. Use byteOffset instead.
  909. * @returns the offset in bytes
  910. */
  911. getOffset(): number;
  912. /**
  913. * Returns the number of components per vertex attribute (integer)
  914. * @returns the size in float
  915. */
  916. getSize(): number;
  917. /**
  918. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  919. * @returns true if this buffer is instanced
  920. */
  921. getIsInstanced(): boolean;
  922. /**
  923. * Returns the instancing divisor, zero for non-instanced (integer).
  924. * @returns a number
  925. */
  926. getInstanceDivisor(): number;
  927. /**
  928. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  929. * @param data defines the data to store
  930. */
  931. create(data?: DataArray): void;
  932. /**
  933. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  934. * This function will create a new buffer if the current one is not updatable
  935. * @param data defines the data to store
  936. */
  937. update(data: DataArray): void;
  938. /**
  939. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  940. * Returns the directly updated WebGLBuffer.
  941. * @param data the new data
  942. * @param offset the new offset
  943. * @param useBytes set to true if the offset is in bytes
  944. */
  945. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  946. /**
  947. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  948. */
  949. dispose(): void;
  950. /**
  951. * Enumerates each value of this vertex buffer as numbers.
  952. * @param count the number of values to enumerate
  953. * @param callback the callback function called for each value
  954. */
  955. forEach(count: number, callback: (value: number, index: number) => void): void;
  956. /**
  957. * Positions
  958. */
  959. static readonly PositionKind: string;
  960. /**
  961. * Normals
  962. */
  963. static readonly NormalKind: string;
  964. /**
  965. * Tangents
  966. */
  967. static readonly TangentKind: string;
  968. /**
  969. * Texture coordinates
  970. */
  971. static readonly UVKind: string;
  972. /**
  973. * Texture coordinates 2
  974. */
  975. static readonly UV2Kind: string;
  976. /**
  977. * Texture coordinates 3
  978. */
  979. static readonly UV3Kind: string;
  980. /**
  981. * Texture coordinates 4
  982. */
  983. static readonly UV4Kind: string;
  984. /**
  985. * Texture coordinates 5
  986. */
  987. static readonly UV5Kind: string;
  988. /**
  989. * Texture coordinates 6
  990. */
  991. static readonly UV6Kind: string;
  992. /**
  993. * Colors
  994. */
  995. static readonly ColorKind: string;
  996. /**
  997. * Matrix indices (for bones)
  998. */
  999. static readonly MatricesIndicesKind: string;
  1000. /**
  1001. * Matrix weights (for bones)
  1002. */
  1003. static readonly MatricesWeightsKind: string;
  1004. /**
  1005. * Additional matrix indices (for bones)
  1006. */
  1007. static readonly MatricesIndicesExtraKind: string;
  1008. /**
  1009. * Additional matrix weights (for bones)
  1010. */
  1011. static readonly MatricesWeightsExtraKind: string;
  1012. /**
  1013. * Deduces the stride given a kind.
  1014. * @param kind The kind string to deduce
  1015. * @returns The deduced stride
  1016. */
  1017. static DeduceStride(kind: string): number;
  1018. /**
  1019. * Gets the byte length of the given type.
  1020. * @param type the type
  1021. * @returns the number of bytes
  1022. */
  1023. static GetTypeByteLength(type: number): number;
  1024. /**
  1025. * Enumerates each value of the given parameters as numbers.
  1026. * @param data the data to enumerate
  1027. * @param byteOffset the byte offset of the data
  1028. * @param byteStride the byte stride of the data
  1029. * @param componentCount the number of components per element
  1030. * @param componentType the type of the component
  1031. * @param count the number of values to enumerate
  1032. * @param normalized whether the data is normalized
  1033. * @param callback the callback function called for each value
  1034. */
  1035. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  1036. private static _GetFloatValue;
  1037. }
  1038. }
  1039. declare module BABYLON {
  1040. /**
  1041. * Scalar computation library
  1042. */
  1043. export class Scalar {
  1044. /**
  1045. * Two pi constants convenient for computation.
  1046. */
  1047. static TwoPi: number;
  1048. /**
  1049. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1050. * @param a number
  1051. * @param b number
  1052. * @param epsilon (default = 1.401298E-45)
  1053. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1054. */
  1055. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1056. /**
  1057. * Returns a string : the upper case translation of the number i to hexadecimal.
  1058. * @param i number
  1059. * @returns the upper case translation of the number i to hexadecimal.
  1060. */
  1061. static ToHex(i: number): string;
  1062. /**
  1063. * Returns -1 if value is negative and +1 is value is positive.
  1064. * @param value the value
  1065. * @returns the value itself if it's equal to zero.
  1066. */
  1067. static Sign(value: number): number;
  1068. /**
  1069. * Returns the value itself if it's between min and max.
  1070. * Returns min if the value is lower than min.
  1071. * Returns max if the value is greater than max.
  1072. * @param value the value to clmap
  1073. * @param min the min value to clamp to (default: 0)
  1074. * @param max the max value to clamp to (default: 1)
  1075. * @returns the clamped value
  1076. */
  1077. static Clamp(value: number, min?: number, max?: number): number;
  1078. /**
  1079. * the log2 of value.
  1080. * @param value the value to compute log2 of
  1081. * @returns the log2 of value.
  1082. */
  1083. static Log2(value: number): number;
  1084. /**
  1085. * Loops the value, so that it is never larger than length and never smaller than 0.
  1086. *
  1087. * This is similar to the modulo operator but it works with floating point numbers.
  1088. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1089. * With t = 5 and length = 2.5, the result would be 0.0.
  1090. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1091. * @param value the value
  1092. * @param length the length
  1093. * @returns the looped value
  1094. */
  1095. static Repeat(value: number, length: number): number;
  1096. /**
  1097. * Normalize the value between 0.0 and 1.0 using min and max values
  1098. * @param value value to normalize
  1099. * @param min max to normalize between
  1100. * @param max min to normalize between
  1101. * @returns the normalized value
  1102. */
  1103. static Normalize(value: number, min: number, max: number): number;
  1104. /**
  1105. * Denormalize the value from 0.0 and 1.0 using min and max values
  1106. * @param normalized value to denormalize
  1107. * @param min max to denormalize between
  1108. * @param max min to denormalize between
  1109. * @returns the denormalized value
  1110. */
  1111. static Denormalize(normalized: number, min: number, max: number): number;
  1112. /**
  1113. * Calculates the shortest difference between two given angles given in degrees.
  1114. * @param current current angle in degrees
  1115. * @param target target angle in degrees
  1116. * @returns the delta
  1117. */
  1118. static DeltaAngle(current: number, target: number): number;
  1119. /**
  1120. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1121. * @param tx value
  1122. * @param length length
  1123. * @returns The returned value will move back and forth between 0 and length
  1124. */
  1125. static PingPong(tx: number, length: number): number;
  1126. /**
  1127. * Interpolates between min and max with smoothing at the limits.
  1128. *
  1129. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1130. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1131. * @param from from
  1132. * @param to to
  1133. * @param tx value
  1134. * @returns the smooth stepped value
  1135. */
  1136. static SmoothStep(from: number, to: number, tx: number): number;
  1137. /**
  1138. * Moves a value current towards target.
  1139. *
  1140. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1141. * Negative values of maxDelta pushes the value away from target.
  1142. * @param current current value
  1143. * @param target target value
  1144. * @param maxDelta max distance to move
  1145. * @returns resulting value
  1146. */
  1147. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1148. /**
  1149. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1150. *
  1151. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1152. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1153. * @param current current value
  1154. * @param target target value
  1155. * @param maxDelta max distance to move
  1156. * @returns resulting angle
  1157. */
  1158. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1159. /**
  1160. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1161. * @param start start value
  1162. * @param end target value
  1163. * @param amount amount to lerp between
  1164. * @returns the lerped value
  1165. */
  1166. static Lerp(start: number, end: number, amount: number): number;
  1167. /**
  1168. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1169. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1170. * @param start start value
  1171. * @param end target value
  1172. * @param amount amount to lerp between
  1173. * @returns the lerped value
  1174. */
  1175. static LerpAngle(start: number, end: number, amount: number): number;
  1176. /**
  1177. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1178. * @param a start value
  1179. * @param b target value
  1180. * @param value value between a and b
  1181. * @returns the inverseLerp value
  1182. */
  1183. static InverseLerp(a: number, b: number, value: number): number;
  1184. /**
  1185. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1186. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1187. * @param value1 spline value
  1188. * @param tangent1 spline value
  1189. * @param value2 spline value
  1190. * @param tangent2 spline value
  1191. * @param amount input value
  1192. * @returns hermite result
  1193. */
  1194. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1195. /**
  1196. * Returns a random float number between and min and max values
  1197. * @param min min value of random
  1198. * @param max max value of random
  1199. * @returns random value
  1200. */
  1201. static RandomRange(min: number, max: number): number;
  1202. /**
  1203. * This function returns percentage of a number in a given range.
  1204. *
  1205. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1206. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1207. * @param number to convert to percentage
  1208. * @param min min range
  1209. * @param max max range
  1210. * @returns the percentage
  1211. */
  1212. static RangeToPercent(number: number, min: number, max: number): number;
  1213. /**
  1214. * This function returns number that corresponds to the percentage in a given range.
  1215. *
  1216. * PercentToRange(0.34,0,100) will return 34.
  1217. * @param percent to convert to number
  1218. * @param min min range
  1219. * @param max max range
  1220. * @returns the number
  1221. */
  1222. static PercentToRange(percent: number, min: number, max: number): number;
  1223. /**
  1224. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1225. * @param angle The angle to normalize in radian.
  1226. * @return The converted angle.
  1227. */
  1228. static NormalizeRadians(angle: number): number;
  1229. }
  1230. }
  1231. declare module BABYLON {
  1232. /**
  1233. * Constant used to convert a value to gamma space
  1234. * @ignorenaming
  1235. */
  1236. export const ToGammaSpace: number;
  1237. /**
  1238. * Constant used to convert a value to linear space
  1239. * @ignorenaming
  1240. */
  1241. export const ToLinearSpace = 2.2;
  1242. /**
  1243. * Constant used to define the minimal number value in Babylon.js
  1244. * @ignorenaming
  1245. */
  1246. let Epsilon: number;
  1247. }
  1248. declare module BABYLON {
  1249. /**
  1250. * Class used to represent a viewport on screen
  1251. */
  1252. export class Viewport {
  1253. /** viewport left coordinate */
  1254. x: number;
  1255. /** viewport top coordinate */
  1256. y: number;
  1257. /**viewport width */
  1258. width: number;
  1259. /** viewport height */
  1260. height: number;
  1261. /**
  1262. * Creates a Viewport object located at (x, y) and sized (width, height)
  1263. * @param x defines viewport left coordinate
  1264. * @param y defines viewport top coordinate
  1265. * @param width defines the viewport width
  1266. * @param height defines the viewport height
  1267. */
  1268. constructor(
  1269. /** viewport left coordinate */
  1270. x: number,
  1271. /** viewport top coordinate */
  1272. y: number,
  1273. /**viewport width */
  1274. width: number,
  1275. /** viewport height */
  1276. height: number);
  1277. /**
  1278. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1279. * @param renderWidth defines the rendering width
  1280. * @param renderHeight defines the rendering height
  1281. * @returns a new Viewport
  1282. */
  1283. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1284. /**
  1285. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1286. * @param renderWidth defines the rendering width
  1287. * @param renderHeight defines the rendering height
  1288. * @param ref defines the target viewport
  1289. * @returns the current viewport
  1290. */
  1291. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1292. /**
  1293. * Returns a new Viewport copied from the current one
  1294. * @returns a new Viewport
  1295. */
  1296. clone(): Viewport;
  1297. }
  1298. }
  1299. declare module BABYLON {
  1300. /**
  1301. * Class containing a set of static utilities functions for arrays.
  1302. */
  1303. export class ArrayTools {
  1304. /**
  1305. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1306. * @param size the number of element to construct and put in the array
  1307. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1308. * @returns a new array filled with new objects
  1309. */
  1310. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1311. }
  1312. }
  1313. declare module BABYLON {
  1314. /**
  1315. * @hidden
  1316. */
  1317. export interface IColor4Like {
  1318. r: float;
  1319. g: float;
  1320. b: float;
  1321. a: float;
  1322. }
  1323. /**
  1324. * @hidden
  1325. */
  1326. export interface IColor3Like {
  1327. r: float;
  1328. g: float;
  1329. b: float;
  1330. }
  1331. /**
  1332. * @hidden
  1333. */
  1334. export interface IVector4Like {
  1335. x: float;
  1336. y: float;
  1337. z: float;
  1338. w: float;
  1339. }
  1340. /**
  1341. * @hidden
  1342. */
  1343. export interface IVector3Like {
  1344. x: float;
  1345. y: float;
  1346. z: float;
  1347. }
  1348. /**
  1349. * @hidden
  1350. */
  1351. export interface IVector2Like {
  1352. x: float;
  1353. y: float;
  1354. }
  1355. /**
  1356. * @hidden
  1357. */
  1358. export interface IMatrixLike {
  1359. toArray(): DeepImmutable<Float32Array>;
  1360. updateFlag: int;
  1361. }
  1362. /**
  1363. * @hidden
  1364. */
  1365. export interface IViewportLike {
  1366. x: float;
  1367. y: float;
  1368. width: float;
  1369. height: float;
  1370. }
  1371. /**
  1372. * @hidden
  1373. */
  1374. export interface IPlaneLike {
  1375. normal: IVector3Like;
  1376. d: float;
  1377. normalize(): void;
  1378. }
  1379. }
  1380. declare module BABYLON {
  1381. /**
  1382. * Class representing a vector containing 2 coordinates
  1383. */
  1384. export class Vector2 {
  1385. /** defines the first coordinate */
  1386. x: number;
  1387. /** defines the second coordinate */
  1388. y: number;
  1389. /**
  1390. * Creates a new Vector2 from the given x and y coordinates
  1391. * @param x defines the first coordinate
  1392. * @param y defines the second coordinate
  1393. */
  1394. constructor(
  1395. /** defines the first coordinate */
  1396. x?: number,
  1397. /** defines the second coordinate */
  1398. y?: number);
  1399. /**
  1400. * Gets a string with the Vector2 coordinates
  1401. * @returns a string with the Vector2 coordinates
  1402. */
  1403. toString(): string;
  1404. /**
  1405. * Gets class name
  1406. * @returns the string "Vector2"
  1407. */
  1408. getClassName(): string;
  1409. /**
  1410. * Gets current vector hash code
  1411. * @returns the Vector2 hash code as a number
  1412. */
  1413. getHashCode(): number;
  1414. /**
  1415. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1416. * @param array defines the source array
  1417. * @param index defines the offset in source array
  1418. * @returns the current Vector2
  1419. */
  1420. toArray(array: FloatArray, index?: number): Vector2;
  1421. /**
  1422. * Copy the current vector to an array
  1423. * @returns a new array with 2 elements: the Vector2 coordinates.
  1424. */
  1425. asArray(): number[];
  1426. /**
  1427. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1428. * @param source defines the source Vector2
  1429. * @returns the current updated Vector2
  1430. */
  1431. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1432. /**
  1433. * Sets the Vector2 coordinates with the given floats
  1434. * @param x defines the first coordinate
  1435. * @param y defines the second coordinate
  1436. * @returns the current updated Vector2
  1437. */
  1438. copyFromFloats(x: number, y: number): Vector2;
  1439. /**
  1440. * Sets the Vector2 coordinates with the given floats
  1441. * @param x defines the first coordinate
  1442. * @param y defines the second coordinate
  1443. * @returns the current updated Vector2
  1444. */
  1445. set(x: number, y: number): Vector2;
  1446. /**
  1447. * Add another vector with the current one
  1448. * @param otherVector defines the other vector
  1449. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1450. */
  1451. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1452. /**
  1453. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1454. * @param otherVector defines the other vector
  1455. * @param result defines the target vector
  1456. * @returns the unmodified current Vector2
  1457. */
  1458. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1459. /**
  1460. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1461. * @param otherVector defines the other vector
  1462. * @returns the current updated Vector2
  1463. */
  1464. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1465. /**
  1466. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1467. * @param otherVector defines the other vector
  1468. * @returns a new Vector2
  1469. */
  1470. addVector3(otherVector: Vector3): Vector2;
  1471. /**
  1472. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1473. * @param otherVector defines the other vector
  1474. * @returns a new Vector2
  1475. */
  1476. subtract(otherVector: Vector2): Vector2;
  1477. /**
  1478. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1479. * @param otherVector defines the other vector
  1480. * @param result defines the target vector
  1481. * @returns the unmodified current Vector2
  1482. */
  1483. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1484. /**
  1485. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1486. * @param otherVector defines the other vector
  1487. * @returns the current updated Vector2
  1488. */
  1489. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1490. /**
  1491. * Multiplies in place the current Vector2 coordinates by the given ones
  1492. * @param otherVector defines the other vector
  1493. * @returns the current updated Vector2
  1494. */
  1495. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1496. /**
  1497. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1498. * @param otherVector defines the other vector
  1499. * @returns a new Vector2
  1500. */
  1501. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1502. /**
  1503. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1504. * @param otherVector defines the other vector
  1505. * @param result defines the target vector
  1506. * @returns the unmodified current Vector2
  1507. */
  1508. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1509. /**
  1510. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1511. * @param x defines the first coordinate
  1512. * @param y defines the second coordinate
  1513. * @returns a new Vector2
  1514. */
  1515. multiplyByFloats(x: number, y: number): Vector2;
  1516. /**
  1517. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1518. * @param otherVector defines the other vector
  1519. * @returns a new Vector2
  1520. */
  1521. divide(otherVector: Vector2): Vector2;
  1522. /**
  1523. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1524. * @param otherVector defines the other vector
  1525. * @param result defines the target vector
  1526. * @returns the unmodified current Vector2
  1527. */
  1528. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1529. /**
  1530. * Divides the current Vector2 coordinates by the given ones
  1531. * @param otherVector defines the other vector
  1532. * @returns the current updated Vector2
  1533. */
  1534. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1535. /**
  1536. * Gets a new Vector2 with current Vector2 negated coordinates
  1537. * @returns a new Vector2
  1538. */
  1539. negate(): Vector2;
  1540. /**
  1541. * Multiply the Vector2 coordinates by scale
  1542. * @param scale defines the scaling factor
  1543. * @returns the current updated Vector2
  1544. */
  1545. scaleInPlace(scale: number): Vector2;
  1546. /**
  1547. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1548. * @param scale defines the scaling factor
  1549. * @returns a new Vector2
  1550. */
  1551. scale(scale: number): Vector2;
  1552. /**
  1553. * Scale the current Vector2 values by a factor to a given Vector2
  1554. * @param scale defines the scale factor
  1555. * @param result defines the Vector2 object where to store the result
  1556. * @returns the unmodified current Vector2
  1557. */
  1558. scaleToRef(scale: number, result: Vector2): Vector2;
  1559. /**
  1560. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1561. * @param scale defines the scale factor
  1562. * @param result defines the Vector2 object where to store the result
  1563. * @returns the unmodified current Vector2
  1564. */
  1565. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1566. /**
  1567. * Gets a boolean if two vectors are equals
  1568. * @param otherVector defines the other vector
  1569. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1570. */
  1571. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1572. /**
  1573. * Gets a boolean if two vectors are equals (using an epsilon value)
  1574. * @param otherVector defines the other vector
  1575. * @param epsilon defines the minimal distance to consider equality
  1576. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1577. */
  1578. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1579. /**
  1580. * Gets a new Vector2 from current Vector2 floored values
  1581. * @returns a new Vector2
  1582. */
  1583. floor(): Vector2;
  1584. /**
  1585. * Gets a new Vector2 from current Vector2 floored values
  1586. * @returns a new Vector2
  1587. */
  1588. fract(): Vector2;
  1589. /**
  1590. * Gets the length of the vector
  1591. * @returns the vector length (float)
  1592. */
  1593. length(): number;
  1594. /**
  1595. * Gets the vector squared length
  1596. * @returns the vector squared length (float)
  1597. */
  1598. lengthSquared(): number;
  1599. /**
  1600. * Normalize the vector
  1601. * @returns the current updated Vector2
  1602. */
  1603. normalize(): Vector2;
  1604. /**
  1605. * Gets a new Vector2 copied from the Vector2
  1606. * @returns a new Vector2
  1607. */
  1608. clone(): Vector2;
  1609. /**
  1610. * Gets a new Vector2(0, 0)
  1611. * @returns a new Vector2
  1612. */
  1613. static Zero(): Vector2;
  1614. /**
  1615. * Gets a new Vector2(1, 1)
  1616. * @returns a new Vector2
  1617. */
  1618. static One(): Vector2;
  1619. /**
  1620. * Gets a new Vector2 set from the given index element of the given array
  1621. * @param array defines the data source
  1622. * @param offset defines the offset in the data source
  1623. * @returns a new Vector2
  1624. */
  1625. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1626. /**
  1627. * Sets "result" from the given index element of the given array
  1628. * @param array defines the data source
  1629. * @param offset defines the offset in the data source
  1630. * @param result defines the target vector
  1631. */
  1632. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1633. /**
  1634. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1635. * @param value1 defines 1st point of control
  1636. * @param value2 defines 2nd point of control
  1637. * @param value3 defines 3rd point of control
  1638. * @param value4 defines 4th point of control
  1639. * @param amount defines the interpolation factor
  1640. * @returns a new Vector2
  1641. */
  1642. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1643. /**
  1644. * 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".
  1645. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1646. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1647. * @param value defines the value to clamp
  1648. * @param min defines the lower limit
  1649. * @param max defines the upper limit
  1650. * @returns a new Vector2
  1651. */
  1652. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1653. /**
  1654. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1655. * @param value1 defines the 1st control point
  1656. * @param tangent1 defines the outgoing tangent
  1657. * @param value2 defines the 2nd control point
  1658. * @param tangent2 defines the incoming tangent
  1659. * @param amount defines the interpolation factor
  1660. * @returns a new Vector2
  1661. */
  1662. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1663. /**
  1664. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1665. * @param start defines the start vector
  1666. * @param end defines the end vector
  1667. * @param amount defines the interpolation factor
  1668. * @returns a new Vector2
  1669. */
  1670. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1671. /**
  1672. * Gets the dot product of the vector "left" and the vector "right"
  1673. * @param left defines first vector
  1674. * @param right defines second vector
  1675. * @returns the dot product (float)
  1676. */
  1677. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1678. /**
  1679. * Returns a new Vector2 equal to the normalized given vector
  1680. * @param vector defines the vector to normalize
  1681. * @returns a new Vector2
  1682. */
  1683. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1684. /**
  1685. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1686. * @param left defines 1st vector
  1687. * @param right defines 2nd vector
  1688. * @returns a new Vector2
  1689. */
  1690. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1691. /**
  1692. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1693. * @param left defines 1st vector
  1694. * @param right defines 2nd vector
  1695. * @returns a new Vector2
  1696. */
  1697. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1698. /**
  1699. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1700. * @param vector defines the vector to transform
  1701. * @param transformation defines the matrix to apply
  1702. * @returns a new Vector2
  1703. */
  1704. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1705. /**
  1706. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1707. * @param vector defines the vector to transform
  1708. * @param transformation defines the matrix to apply
  1709. * @param result defines the target vector
  1710. */
  1711. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1712. /**
  1713. * Determines if a given vector is included in a triangle
  1714. * @param p defines the vector to test
  1715. * @param p0 defines 1st triangle point
  1716. * @param p1 defines 2nd triangle point
  1717. * @param p2 defines 3rd triangle point
  1718. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1719. */
  1720. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1721. /**
  1722. * Gets the distance between the vectors "value1" and "value2"
  1723. * @param value1 defines first vector
  1724. * @param value2 defines second vector
  1725. * @returns the distance between vectors
  1726. */
  1727. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1728. /**
  1729. * Returns the squared distance between the vectors "value1" and "value2"
  1730. * @param value1 defines first vector
  1731. * @param value2 defines second vector
  1732. * @returns the squared distance between vectors
  1733. */
  1734. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1735. /**
  1736. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1737. * @param value1 defines first vector
  1738. * @param value2 defines second vector
  1739. * @returns a new Vector2
  1740. */
  1741. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1742. /**
  1743. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1744. * @param p defines the middle point
  1745. * @param segA defines one point of the segment
  1746. * @param segB defines the other point of the segment
  1747. * @returns the shortest distance
  1748. */
  1749. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1750. }
  1751. /**
  1752. * Classed used to store (x,y,z) vector representation
  1753. * A Vector3 is the main object used in 3D geometry
  1754. * It can represent etiher the coordinates of a point the space, either a direction
  1755. * Reminder: js uses a left handed forward facing system
  1756. */
  1757. export class Vector3 {
  1758. /**
  1759. * Defines the first coordinates (on X axis)
  1760. */
  1761. x: number;
  1762. /**
  1763. * Defines the second coordinates (on Y axis)
  1764. */
  1765. y: number;
  1766. /**
  1767. * Defines the third coordinates (on Z axis)
  1768. */
  1769. z: number;
  1770. private static _UpReadOnly;
  1771. private static _ZeroReadOnly;
  1772. /**
  1773. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1774. * @param x defines the first coordinates (on X axis)
  1775. * @param y defines the second coordinates (on Y axis)
  1776. * @param z defines the third coordinates (on Z axis)
  1777. */
  1778. constructor(
  1779. /**
  1780. * Defines the first coordinates (on X axis)
  1781. */
  1782. x?: number,
  1783. /**
  1784. * Defines the second coordinates (on Y axis)
  1785. */
  1786. y?: number,
  1787. /**
  1788. * Defines the third coordinates (on Z axis)
  1789. */
  1790. z?: number);
  1791. /**
  1792. * Creates a string representation of the Vector3
  1793. * @returns a string with the Vector3 coordinates.
  1794. */
  1795. toString(): string;
  1796. /**
  1797. * Gets the class name
  1798. * @returns the string "Vector3"
  1799. */
  1800. getClassName(): string;
  1801. /**
  1802. * Creates the Vector3 hash code
  1803. * @returns a number which tends to be unique between Vector3 instances
  1804. */
  1805. getHashCode(): number;
  1806. /**
  1807. * Creates an array containing three elements : the coordinates of the Vector3
  1808. * @returns a new array of numbers
  1809. */
  1810. asArray(): number[];
  1811. /**
  1812. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1813. * @param array defines the destination array
  1814. * @param index defines the offset in the destination array
  1815. * @returns the current Vector3
  1816. */
  1817. toArray(array: FloatArray, index?: number): Vector3;
  1818. /**
  1819. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1820. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1821. */
  1822. toQuaternion(): Quaternion;
  1823. /**
  1824. * Adds the given vector to the current Vector3
  1825. * @param otherVector defines the second operand
  1826. * @returns the current updated Vector3
  1827. */
  1828. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1829. /**
  1830. * Adds the given coordinates to the current Vector3
  1831. * @param x defines the x coordinate of the operand
  1832. * @param y defines the y coordinate of the operand
  1833. * @param z defines the z coordinate of the operand
  1834. * @returns the current updated Vector3
  1835. */
  1836. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1837. /**
  1838. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1839. * @param otherVector defines the second operand
  1840. * @returns the resulting Vector3
  1841. */
  1842. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1843. /**
  1844. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1845. * @param otherVector defines the second operand
  1846. * @param result defines the Vector3 object where to store the result
  1847. * @returns the current Vector3
  1848. */
  1849. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1850. /**
  1851. * Subtract the given vector from the current Vector3
  1852. * @param otherVector defines the second operand
  1853. * @returns the current updated Vector3
  1854. */
  1855. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1856. /**
  1857. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1858. * @param otherVector defines the second operand
  1859. * @returns the resulting Vector3
  1860. */
  1861. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1862. /**
  1863. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1864. * @param otherVector defines the second operand
  1865. * @param result defines the Vector3 object where to store the result
  1866. * @returns the current Vector3
  1867. */
  1868. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1869. /**
  1870. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1871. * @param x defines the x coordinate of the operand
  1872. * @param y defines the y coordinate of the operand
  1873. * @param z defines the z coordinate of the operand
  1874. * @returns the resulting Vector3
  1875. */
  1876. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1877. /**
  1878. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1879. * @param x defines the x coordinate of the operand
  1880. * @param y defines the y coordinate of the operand
  1881. * @param z defines the z coordinate of the operand
  1882. * @param result defines the Vector3 object where to store the result
  1883. * @returns the current Vector3
  1884. */
  1885. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1886. /**
  1887. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1888. * @returns a new Vector3
  1889. */
  1890. negate(): Vector3;
  1891. /**
  1892. * Multiplies the Vector3 coordinates by the float "scale"
  1893. * @param scale defines the multiplier factor
  1894. * @returns the current updated Vector3
  1895. */
  1896. scaleInPlace(scale: number): Vector3;
  1897. /**
  1898. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1899. * @param scale defines the multiplier factor
  1900. * @returns a new Vector3
  1901. */
  1902. scale(scale: number): Vector3;
  1903. /**
  1904. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1905. * @param scale defines the multiplier factor
  1906. * @param result defines the Vector3 object where to store the result
  1907. * @returns the current Vector3
  1908. */
  1909. scaleToRef(scale: number, result: Vector3): Vector3;
  1910. /**
  1911. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1912. * @param scale defines the scale factor
  1913. * @param result defines the Vector3 object where to store the result
  1914. * @returns the unmodified current Vector3
  1915. */
  1916. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1917. /**
  1918. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1919. * @param otherVector defines the second operand
  1920. * @returns true if both vectors are equals
  1921. */
  1922. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1923. /**
  1924. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1925. * @param otherVector defines the second operand
  1926. * @param epsilon defines the minimal distance to define values as equals
  1927. * @returns true if both vectors are distant less than epsilon
  1928. */
  1929. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1930. /**
  1931. * Returns true if the current Vector3 coordinates equals the given floats
  1932. * @param x defines the x coordinate of the operand
  1933. * @param y defines the y coordinate of the operand
  1934. * @param z defines the z coordinate of the operand
  1935. * @returns true if both vectors are equals
  1936. */
  1937. equalsToFloats(x: number, y: number, z: number): boolean;
  1938. /**
  1939. * Multiplies the current Vector3 coordinates by the given ones
  1940. * @param otherVector defines the second operand
  1941. * @returns the current updated Vector3
  1942. */
  1943. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1944. /**
  1945. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1946. * @param otherVector defines the second operand
  1947. * @returns the new Vector3
  1948. */
  1949. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1950. /**
  1951. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1952. * @param otherVector defines the second operand
  1953. * @param result defines the Vector3 object where to store the result
  1954. * @returns the current Vector3
  1955. */
  1956. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1957. /**
  1958. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1959. * @param x defines the x coordinate of the operand
  1960. * @param y defines the y coordinate of the operand
  1961. * @param z defines the z coordinate of the operand
  1962. * @returns the new Vector3
  1963. */
  1964. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1965. /**
  1966. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1967. * @param otherVector defines the second operand
  1968. * @returns the new Vector3
  1969. */
  1970. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1971. /**
  1972. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1973. * @param otherVector defines the second operand
  1974. * @param result defines the Vector3 object where to store the result
  1975. * @returns the current Vector3
  1976. */
  1977. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1978. /**
  1979. * Divides the current Vector3 coordinates by the given ones.
  1980. * @param otherVector defines the second operand
  1981. * @returns the current updated Vector3
  1982. */
  1983. divideInPlace(otherVector: Vector3): Vector3;
  1984. /**
  1985. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1986. * @param other defines the second operand
  1987. * @returns the current updated Vector3
  1988. */
  1989. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1990. /**
  1991. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1992. * @param other defines the second operand
  1993. * @returns the current updated Vector3
  1994. */
  1995. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1996. /**
  1997. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1998. * @param x defines the x coordinate of the operand
  1999. * @param y defines the y coordinate of the operand
  2000. * @param z defines the z coordinate of the operand
  2001. * @returns the current updated Vector3
  2002. */
  2003. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2004. /**
  2005. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2006. * @param x defines the x coordinate of the operand
  2007. * @param y defines the y coordinate of the operand
  2008. * @param z defines the z coordinate of the operand
  2009. * @returns the current updated Vector3
  2010. */
  2011. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2012. /**
  2013. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2014. * Check if is non uniform within a certain amount of decimal places to account for this
  2015. * @param epsilon the amount the values can differ
  2016. * @returns if the the vector is non uniform to a certain number of decimal places
  2017. */
  2018. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2019. /**
  2020. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2021. */
  2022. readonly isNonUniform: boolean;
  2023. /**
  2024. * Gets a new Vector3 from current Vector3 floored values
  2025. * @returns a new Vector3
  2026. */
  2027. floor(): Vector3;
  2028. /**
  2029. * Gets a new Vector3 from current Vector3 floored values
  2030. * @returns a new Vector3
  2031. */
  2032. fract(): Vector3;
  2033. /**
  2034. * Gets the length of the Vector3
  2035. * @returns the length of the Vector3
  2036. */
  2037. length(): number;
  2038. /**
  2039. * Gets the squared length of the Vector3
  2040. * @returns squared length of the Vector3
  2041. */
  2042. lengthSquared(): number;
  2043. /**
  2044. * Normalize the current Vector3.
  2045. * Please note that this is an in place operation.
  2046. * @returns the current updated Vector3
  2047. */
  2048. normalize(): Vector3;
  2049. /**
  2050. * Reorders the x y z properties of the vector in place
  2051. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2052. * @returns the current updated vector
  2053. */
  2054. reorderInPlace(order: string): this;
  2055. /**
  2056. * Rotates the vector around 0,0,0 by a quaternion
  2057. * @param quaternion the rotation quaternion
  2058. * @param result vector to store the result
  2059. * @returns the resulting vector
  2060. */
  2061. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2062. /**
  2063. * Rotates a vector around a given point
  2064. * @param quaternion the rotation quaternion
  2065. * @param point the point to rotate around
  2066. * @param result vector to store the result
  2067. * @returns the resulting vector
  2068. */
  2069. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2070. /**
  2071. * Normalize the current Vector3 with the given input length.
  2072. * Please note that this is an in place operation.
  2073. * @param len the length of the vector
  2074. * @returns the current updated Vector3
  2075. */
  2076. normalizeFromLength(len: number): Vector3;
  2077. /**
  2078. * Normalize the current Vector3 to a new vector
  2079. * @returns the new Vector3
  2080. */
  2081. normalizeToNew(): Vector3;
  2082. /**
  2083. * Normalize the current Vector3 to the reference
  2084. * @param reference define the Vector3 to update
  2085. * @returns the updated Vector3
  2086. */
  2087. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2088. /**
  2089. * Creates a new Vector3 copied from the current Vector3
  2090. * @returns the new Vector3
  2091. */
  2092. clone(): Vector3;
  2093. /**
  2094. * Copies the given vector coordinates to the current Vector3 ones
  2095. * @param source defines the source Vector3
  2096. * @returns the current updated Vector3
  2097. */
  2098. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2099. /**
  2100. * Copies the given floats to the current Vector3 coordinates
  2101. * @param x defines the x coordinate of the operand
  2102. * @param y defines the y coordinate of the operand
  2103. * @param z defines the z coordinate of the operand
  2104. * @returns the current updated Vector3
  2105. */
  2106. copyFromFloats(x: number, y: number, z: number): Vector3;
  2107. /**
  2108. * Copies the given floats to the current Vector3 coordinates
  2109. * @param x defines the x coordinate of the operand
  2110. * @param y defines the y coordinate of the operand
  2111. * @param z defines the z coordinate of the operand
  2112. * @returns the current updated Vector3
  2113. */
  2114. set(x: number, y: number, z: number): Vector3;
  2115. /**
  2116. * Copies the given float to the current Vector3 coordinates
  2117. * @param v defines the x, y and z coordinates of the operand
  2118. * @returns the current updated Vector3
  2119. */
  2120. setAll(v: number): Vector3;
  2121. /**
  2122. * Get the clip factor between two vectors
  2123. * @param vector0 defines the first operand
  2124. * @param vector1 defines the second operand
  2125. * @param axis defines the axis to use
  2126. * @param size defines the size along the axis
  2127. * @returns the clip factor
  2128. */
  2129. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2130. /**
  2131. * Get angle between two vectors
  2132. * @param vector0 angle between vector0 and vector1
  2133. * @param vector1 angle between vector0 and vector1
  2134. * @param normal direction of the normal
  2135. * @return the angle between vector0 and vector1
  2136. */
  2137. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2138. /**
  2139. * Returns a new Vector3 set from the index "offset" of the given array
  2140. * @param array defines the source array
  2141. * @param offset defines the offset in the source array
  2142. * @returns the new Vector3
  2143. */
  2144. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2145. /**
  2146. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2147. * This function is deprecated. Use FromArray instead
  2148. * @param array defines the source array
  2149. * @param offset defines the offset in the source array
  2150. * @returns the new Vector3
  2151. */
  2152. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2153. /**
  2154. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2155. * @param array defines the source array
  2156. * @param offset defines the offset in the source array
  2157. * @param result defines the Vector3 where to store the result
  2158. */
  2159. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2160. /**
  2161. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2162. * This function is deprecated. Use FromArrayToRef instead.
  2163. * @param array defines the source array
  2164. * @param offset defines the offset in the source array
  2165. * @param result defines the Vector3 where to store the result
  2166. */
  2167. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2168. /**
  2169. * Sets the given vector "result" with the given floats.
  2170. * @param x defines the x coordinate of the source
  2171. * @param y defines the y coordinate of the source
  2172. * @param z defines the z coordinate of the source
  2173. * @param result defines the Vector3 where to store the result
  2174. */
  2175. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2176. /**
  2177. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2178. * @returns a new empty Vector3
  2179. */
  2180. static Zero(): Vector3;
  2181. /**
  2182. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2183. * @returns a new unit Vector3
  2184. */
  2185. static One(): Vector3;
  2186. /**
  2187. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2188. * @returns a new up Vector3
  2189. */
  2190. static Up(): Vector3;
  2191. /**
  2192. * Gets a up Vector3 that must not be updated
  2193. */
  2194. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2195. /**
  2196. * Gets a zero Vector3 that must not be updated
  2197. */
  2198. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2199. /**
  2200. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2201. * @returns a new down Vector3
  2202. */
  2203. static Down(): Vector3;
  2204. /**
  2205. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2206. * @returns a new forward Vector3
  2207. */
  2208. static Forward(): Vector3;
  2209. /**
  2210. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2211. * @returns a new forward Vector3
  2212. */
  2213. static Backward(): Vector3;
  2214. /**
  2215. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2216. * @returns a new right Vector3
  2217. */
  2218. static Right(): Vector3;
  2219. /**
  2220. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2221. * @returns a new left Vector3
  2222. */
  2223. static Left(): Vector3;
  2224. /**
  2225. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2226. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2227. * @param vector defines the Vector3 to transform
  2228. * @param transformation defines the transformation matrix
  2229. * @returns the transformed Vector3
  2230. */
  2231. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2232. /**
  2233. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2234. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2235. * @param vector defines the Vector3 to transform
  2236. * @param transformation defines the transformation matrix
  2237. * @param result defines the Vector3 where to store the result
  2238. */
  2239. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2240. /**
  2241. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2242. * This method computes tranformed coordinates only, not transformed direction vectors
  2243. * @param x define the x coordinate of the source vector
  2244. * @param y define the y coordinate of the source vector
  2245. * @param z define the z coordinate of the source vector
  2246. * @param transformation defines the transformation matrix
  2247. * @param result defines the Vector3 where to store the result
  2248. */
  2249. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2250. /**
  2251. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2252. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2253. * @param vector defines the Vector3 to transform
  2254. * @param transformation defines the transformation matrix
  2255. * @returns the new Vector3
  2256. */
  2257. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2258. /**
  2259. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2260. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2261. * @param vector defines the Vector3 to transform
  2262. * @param transformation defines the transformation matrix
  2263. * @param result defines the Vector3 where to store the result
  2264. */
  2265. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2266. /**
  2267. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2268. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2269. * @param x define the x coordinate of the source vector
  2270. * @param y define the y coordinate of the source vector
  2271. * @param z define the z coordinate of the source vector
  2272. * @param transformation defines the transformation matrix
  2273. * @param result defines the Vector3 where to store the result
  2274. */
  2275. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2276. /**
  2277. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2278. * @param value1 defines the first control point
  2279. * @param value2 defines the second control point
  2280. * @param value3 defines the third control point
  2281. * @param value4 defines the fourth control point
  2282. * @param amount defines the amount on the spline to use
  2283. * @returns the new Vector3
  2284. */
  2285. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2286. /**
  2287. * 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"
  2288. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2289. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2290. * @param value defines the current value
  2291. * @param min defines the lower range value
  2292. * @param max defines the upper range value
  2293. * @returns the new Vector3
  2294. */
  2295. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2296. /**
  2297. * 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"
  2298. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2299. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2300. * @param value defines the current value
  2301. * @param min defines the lower range value
  2302. * @param max defines the upper range value
  2303. * @param result defines the Vector3 where to store the result
  2304. */
  2305. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2306. /**
  2307. * Checks if a given vector is inside a specific range
  2308. * @param v defines the vector to test
  2309. * @param min defines the minimum range
  2310. * @param max defines the maximum range
  2311. */
  2312. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2313. /**
  2314. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2315. * @param value1 defines the first control point
  2316. * @param tangent1 defines the first tangent vector
  2317. * @param value2 defines the second control point
  2318. * @param tangent2 defines the second tangent vector
  2319. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2320. * @returns the new Vector3
  2321. */
  2322. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2323. /**
  2324. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2325. * @param start defines the start value
  2326. * @param end defines the end value
  2327. * @param amount max defines amount between both (between 0 and 1)
  2328. * @returns the new Vector3
  2329. */
  2330. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2331. /**
  2332. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2333. * @param start defines the start value
  2334. * @param end defines the end value
  2335. * @param amount max defines amount between both (between 0 and 1)
  2336. * @param result defines the Vector3 where to store the result
  2337. */
  2338. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2339. /**
  2340. * Returns the dot product (float) between the vectors "left" and "right"
  2341. * @param left defines the left operand
  2342. * @param right defines the right operand
  2343. * @returns the dot product
  2344. */
  2345. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2346. /**
  2347. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2348. * The cross product is then orthogonal to both "left" and "right"
  2349. * @param left defines the left operand
  2350. * @param right defines the right operand
  2351. * @returns the cross product
  2352. */
  2353. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2354. /**
  2355. * Sets the given vector "result" with the cross product of "left" and "right"
  2356. * The cross product is then orthogonal to both "left" and "right"
  2357. * @param left defines the left operand
  2358. * @param right defines the right operand
  2359. * @param result defines the Vector3 where to store the result
  2360. */
  2361. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2362. /**
  2363. * Returns a new Vector3 as the normalization of the given vector
  2364. * @param vector defines the Vector3 to normalize
  2365. * @returns the new Vector3
  2366. */
  2367. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2368. /**
  2369. * Sets the given vector "result" with the normalization of the given first vector
  2370. * @param vector defines the Vector3 to normalize
  2371. * @param result defines the Vector3 where to store the result
  2372. */
  2373. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2374. /**
  2375. * Project a Vector3 onto screen space
  2376. * @param vector defines the Vector3 to project
  2377. * @param world defines the world matrix to use
  2378. * @param transform defines the transform (view x projection) matrix to use
  2379. * @param viewport defines the screen viewport to use
  2380. * @returns the new Vector3
  2381. */
  2382. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2383. /** @hidden */
  2384. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2385. /**
  2386. * Unproject from screen space to object space
  2387. * @param source defines the screen space Vector3 to use
  2388. * @param viewportWidth defines the current width of the viewport
  2389. * @param viewportHeight defines the current height of the viewport
  2390. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2391. * @param transform defines the transform (view x projection) matrix to use
  2392. * @returns the new Vector3
  2393. */
  2394. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2395. /**
  2396. * Unproject from screen space to object space
  2397. * @param source defines the screen space Vector3 to use
  2398. * @param viewportWidth defines the current width of the viewport
  2399. * @param viewportHeight defines the current height of the viewport
  2400. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2401. * @param view defines the view matrix to use
  2402. * @param projection defines the projection matrix to use
  2403. * @returns the new Vector3
  2404. */
  2405. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2406. /**
  2407. * Unproject from screen space to object space
  2408. * @param source defines the screen space Vector3 to use
  2409. * @param viewportWidth defines the current width of the viewport
  2410. * @param viewportHeight defines the current height of the viewport
  2411. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2412. * @param view defines the view matrix to use
  2413. * @param projection defines the projection matrix to use
  2414. * @param result defines the Vector3 where to store the result
  2415. */
  2416. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2417. /**
  2418. * Unproject from screen space to object space
  2419. * @param sourceX defines the screen space x coordinate to use
  2420. * @param sourceY defines the screen space y coordinate to use
  2421. * @param sourceZ defines the screen space z coordinate to use
  2422. * @param viewportWidth defines the current width of the viewport
  2423. * @param viewportHeight defines the current height of the viewport
  2424. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2425. * @param view defines the view matrix to use
  2426. * @param projection defines the projection matrix to use
  2427. * @param result defines the Vector3 where to store the result
  2428. */
  2429. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2430. /**
  2431. * Gets the minimal coordinate values between two Vector3
  2432. * @param left defines the first operand
  2433. * @param right defines the second operand
  2434. * @returns the new Vector3
  2435. */
  2436. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2437. /**
  2438. * Gets the maximal coordinate values between two Vector3
  2439. * @param left defines the first operand
  2440. * @param right defines the second operand
  2441. * @returns the new Vector3
  2442. */
  2443. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2444. /**
  2445. * Returns the distance between the vectors "value1" and "value2"
  2446. * @param value1 defines the first operand
  2447. * @param value2 defines the second operand
  2448. * @returns the distance
  2449. */
  2450. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2451. /**
  2452. * Returns the squared distance between the vectors "value1" and "value2"
  2453. * @param value1 defines the first operand
  2454. * @param value2 defines the second operand
  2455. * @returns the squared distance
  2456. */
  2457. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2458. /**
  2459. * Returns a new Vector3 located at the center between "value1" and "value2"
  2460. * @param value1 defines the first operand
  2461. * @param value2 defines the second operand
  2462. * @returns the new Vector3
  2463. */
  2464. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2465. /**
  2466. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2467. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2468. * to something in order to rotate it from its local system to the given target system
  2469. * Note: axis1, axis2 and axis3 are normalized during this operation
  2470. * @param axis1 defines the first axis
  2471. * @param axis2 defines the second axis
  2472. * @param axis3 defines the third axis
  2473. * @returns a new Vector3
  2474. */
  2475. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2476. /**
  2477. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2478. * @param axis1 defines the first axis
  2479. * @param axis2 defines the second axis
  2480. * @param axis3 defines the third axis
  2481. * @param ref defines the Vector3 where to store the result
  2482. */
  2483. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2484. }
  2485. /**
  2486. * Vector4 class created for EulerAngle class conversion to Quaternion
  2487. */
  2488. export class Vector4 {
  2489. /** x value of the vector */
  2490. x: number;
  2491. /** y value of the vector */
  2492. y: number;
  2493. /** z value of the vector */
  2494. z: number;
  2495. /** w value of the vector */
  2496. w: number;
  2497. /**
  2498. * Creates a Vector4 object from the given floats.
  2499. * @param x x value of the vector
  2500. * @param y y value of the vector
  2501. * @param z z value of the vector
  2502. * @param w w value of the vector
  2503. */
  2504. constructor(
  2505. /** x value of the vector */
  2506. x: number,
  2507. /** y value of the vector */
  2508. y: number,
  2509. /** z value of the vector */
  2510. z: number,
  2511. /** w value of the vector */
  2512. w: number);
  2513. /**
  2514. * Returns the string with the Vector4 coordinates.
  2515. * @returns a string containing all the vector values
  2516. */
  2517. toString(): string;
  2518. /**
  2519. * Returns the string "Vector4".
  2520. * @returns "Vector4"
  2521. */
  2522. getClassName(): string;
  2523. /**
  2524. * Returns the Vector4 hash code.
  2525. * @returns a unique hash code
  2526. */
  2527. getHashCode(): number;
  2528. /**
  2529. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2530. * @returns the resulting array
  2531. */
  2532. asArray(): number[];
  2533. /**
  2534. * Populates the given array from the given index with the Vector4 coordinates.
  2535. * @param array array to populate
  2536. * @param index index of the array to start at (default: 0)
  2537. * @returns the Vector4.
  2538. */
  2539. toArray(array: FloatArray, index?: number): Vector4;
  2540. /**
  2541. * Adds the given vector to the current Vector4.
  2542. * @param otherVector the vector to add
  2543. * @returns the updated Vector4.
  2544. */
  2545. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2546. /**
  2547. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2548. * @param otherVector the vector to add
  2549. * @returns the resulting vector
  2550. */
  2551. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2552. /**
  2553. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2554. * @param otherVector the vector to add
  2555. * @param result the vector to store the result
  2556. * @returns the current Vector4.
  2557. */
  2558. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2559. /**
  2560. * Subtract in place the given vector from the current Vector4.
  2561. * @param otherVector the vector to subtract
  2562. * @returns the updated Vector4.
  2563. */
  2564. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2565. /**
  2566. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2567. * @param otherVector the vector to add
  2568. * @returns the new vector with the result
  2569. */
  2570. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2571. /**
  2572. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2573. * @param otherVector the vector to subtract
  2574. * @param result the vector to store the result
  2575. * @returns the current Vector4.
  2576. */
  2577. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2578. /**
  2579. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2580. */
  2581. /**
  2582. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2583. * @param x value to subtract
  2584. * @param y value to subtract
  2585. * @param z value to subtract
  2586. * @param w value to subtract
  2587. * @returns new vector containing the result
  2588. */
  2589. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2590. /**
  2591. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2592. * @param x value to subtract
  2593. * @param y value to subtract
  2594. * @param z value to subtract
  2595. * @param w value to subtract
  2596. * @param result the vector to store the result in
  2597. * @returns the current Vector4.
  2598. */
  2599. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2600. /**
  2601. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2602. * @returns a new vector with the negated values
  2603. */
  2604. negate(): Vector4;
  2605. /**
  2606. * Multiplies the current Vector4 coordinates by scale (float).
  2607. * @param scale the number to scale with
  2608. * @returns the updated Vector4.
  2609. */
  2610. scaleInPlace(scale: number): Vector4;
  2611. /**
  2612. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2613. * @param scale the number to scale with
  2614. * @returns a new vector with the result
  2615. */
  2616. scale(scale: number): Vector4;
  2617. /**
  2618. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2619. * @param scale the number to scale with
  2620. * @param result a vector to store the result in
  2621. * @returns the current Vector4.
  2622. */
  2623. scaleToRef(scale: number, result: Vector4): Vector4;
  2624. /**
  2625. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2626. * @param scale defines the scale factor
  2627. * @param result defines the Vector4 object where to store the result
  2628. * @returns the unmodified current Vector4
  2629. */
  2630. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2631. /**
  2632. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2633. * @param otherVector the vector to compare against
  2634. * @returns true if they are equal
  2635. */
  2636. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2637. /**
  2638. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2639. * @param otherVector vector to compare against
  2640. * @param epsilon (Default: very small number)
  2641. * @returns true if they are equal
  2642. */
  2643. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2644. /**
  2645. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2646. * @param x x value to compare against
  2647. * @param y y value to compare against
  2648. * @param z z value to compare against
  2649. * @param w w value to compare against
  2650. * @returns true if equal
  2651. */
  2652. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2653. /**
  2654. * Multiplies in place the current Vector4 by the given one.
  2655. * @param otherVector vector to multiple with
  2656. * @returns the updated Vector4.
  2657. */
  2658. multiplyInPlace(otherVector: Vector4): Vector4;
  2659. /**
  2660. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2661. * @param otherVector vector to multiple with
  2662. * @returns resulting new vector
  2663. */
  2664. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2665. /**
  2666. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2667. * @param otherVector vector to multiple with
  2668. * @param result vector to store the result
  2669. * @returns the current Vector4.
  2670. */
  2671. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2672. /**
  2673. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2674. * @param x x value multiply with
  2675. * @param y y value multiply with
  2676. * @param z z value multiply with
  2677. * @param w w value multiply with
  2678. * @returns resulting new vector
  2679. */
  2680. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2681. /**
  2682. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2683. * @param otherVector vector to devide with
  2684. * @returns resulting new vector
  2685. */
  2686. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2687. /**
  2688. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2689. * @param otherVector vector to devide with
  2690. * @param result vector to store the result
  2691. * @returns the current Vector4.
  2692. */
  2693. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2694. /**
  2695. * Divides the current Vector3 coordinates by the given ones.
  2696. * @param otherVector vector to devide with
  2697. * @returns the updated Vector3.
  2698. */
  2699. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2700. /**
  2701. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2702. * @param other defines the second operand
  2703. * @returns the current updated Vector4
  2704. */
  2705. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2706. /**
  2707. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2708. * @param other defines the second operand
  2709. * @returns the current updated Vector4
  2710. */
  2711. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2712. /**
  2713. * Gets a new Vector4 from current Vector4 floored values
  2714. * @returns a new Vector4
  2715. */
  2716. floor(): Vector4;
  2717. /**
  2718. * Gets a new Vector4 from current Vector3 floored values
  2719. * @returns a new Vector4
  2720. */
  2721. fract(): Vector4;
  2722. /**
  2723. * Returns the Vector4 length (float).
  2724. * @returns the length
  2725. */
  2726. length(): number;
  2727. /**
  2728. * Returns the Vector4 squared length (float).
  2729. * @returns the length squared
  2730. */
  2731. lengthSquared(): number;
  2732. /**
  2733. * Normalizes in place the Vector4.
  2734. * @returns the updated Vector4.
  2735. */
  2736. normalize(): Vector4;
  2737. /**
  2738. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2739. * @returns this converted to a new vector3
  2740. */
  2741. toVector3(): Vector3;
  2742. /**
  2743. * Returns a new Vector4 copied from the current one.
  2744. * @returns the new cloned vector
  2745. */
  2746. clone(): Vector4;
  2747. /**
  2748. * Updates the current Vector4 with the given one coordinates.
  2749. * @param source the source vector to copy from
  2750. * @returns the updated Vector4.
  2751. */
  2752. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2753. /**
  2754. * Updates the current Vector4 coordinates with the given floats.
  2755. * @param x float to copy from
  2756. * @param y float to copy from
  2757. * @param z float to copy from
  2758. * @param w float to copy from
  2759. * @returns the updated Vector4.
  2760. */
  2761. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2762. /**
  2763. * Updates the current Vector4 coordinates with the given floats.
  2764. * @param x float to set from
  2765. * @param y float to set from
  2766. * @param z float to set from
  2767. * @param w float to set from
  2768. * @returns the updated Vector4.
  2769. */
  2770. set(x: number, y: number, z: number, w: number): Vector4;
  2771. /**
  2772. * Copies the given float to the current Vector3 coordinates
  2773. * @param v defines the x, y, z and w coordinates of the operand
  2774. * @returns the current updated Vector3
  2775. */
  2776. setAll(v: number): Vector4;
  2777. /**
  2778. * Returns a new Vector4 set from the starting index of the given array.
  2779. * @param array the array to pull values from
  2780. * @param offset the offset into the array to start at
  2781. * @returns the new vector
  2782. */
  2783. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2784. /**
  2785. * Updates the given vector "result" from the starting index of the given array.
  2786. * @param array the array to pull values from
  2787. * @param offset the offset into the array to start at
  2788. * @param result the vector to store the result in
  2789. */
  2790. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2791. /**
  2792. * Updates the given vector "result" from the starting index of the given Float32Array.
  2793. * @param array the array to pull values from
  2794. * @param offset the offset into the array to start at
  2795. * @param result the vector to store the result in
  2796. */
  2797. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2798. /**
  2799. * Updates the given vector "result" coordinates from the given floats.
  2800. * @param x float to set from
  2801. * @param y float to set from
  2802. * @param z float to set from
  2803. * @param w float to set from
  2804. * @param result the vector to the floats in
  2805. */
  2806. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2807. /**
  2808. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2809. * @returns the new vector
  2810. */
  2811. static Zero(): Vector4;
  2812. /**
  2813. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2814. * @returns the new vector
  2815. */
  2816. static One(): Vector4;
  2817. /**
  2818. * Returns a new normalized Vector4 from the given one.
  2819. * @param vector the vector to normalize
  2820. * @returns the vector
  2821. */
  2822. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2823. /**
  2824. * Updates the given vector "result" from the normalization of the given one.
  2825. * @param vector the vector to normalize
  2826. * @param result the vector to store the result in
  2827. */
  2828. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2829. /**
  2830. * Returns a vector with the minimum values from the left and right vectors
  2831. * @param left left vector to minimize
  2832. * @param right right vector to minimize
  2833. * @returns a new vector with the minimum of the left and right vector values
  2834. */
  2835. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2836. /**
  2837. * Returns a vector with the maximum values from the left and right vectors
  2838. * @param left left vector to maximize
  2839. * @param right right vector to maximize
  2840. * @returns a new vector with the maximum of the left and right vector values
  2841. */
  2842. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2843. /**
  2844. * Returns the distance (float) between the vectors "value1" and "value2".
  2845. * @param value1 value to calulate the distance between
  2846. * @param value2 value to calulate the distance between
  2847. * @return the distance between the two vectors
  2848. */
  2849. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2850. /**
  2851. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2852. * @param value1 value to calulate the distance between
  2853. * @param value2 value to calulate the distance between
  2854. * @return the distance between the two vectors squared
  2855. */
  2856. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2857. /**
  2858. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2859. * @param value1 value to calulate the center between
  2860. * @param value2 value to calulate the center between
  2861. * @return the center between the two vectors
  2862. */
  2863. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2864. /**
  2865. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2866. * This methods computes transformed normalized direction vectors only.
  2867. * @param vector the vector to transform
  2868. * @param transformation the transformation matrix to apply
  2869. * @returns the new vector
  2870. */
  2871. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2872. /**
  2873. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2874. * This methods computes transformed normalized direction vectors only.
  2875. * @param vector the vector to transform
  2876. * @param transformation the transformation matrix to apply
  2877. * @param result the vector to store the result in
  2878. */
  2879. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2880. /**
  2881. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2882. * This methods computes transformed normalized direction vectors only.
  2883. * @param x value to transform
  2884. * @param y value to transform
  2885. * @param z value to transform
  2886. * @param w value to transform
  2887. * @param transformation the transformation matrix to apply
  2888. * @param result the vector to store the results in
  2889. */
  2890. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2891. /**
  2892. * Creates a new Vector4 from a Vector3
  2893. * @param source defines the source data
  2894. * @param w defines the 4th component (default is 0)
  2895. * @returns a new Vector4
  2896. */
  2897. static FromVector3(source: Vector3, w?: number): Vector4;
  2898. }
  2899. /**
  2900. * Class used to store quaternion data
  2901. * @see https://en.wikipedia.org/wiki/Quaternion
  2902. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2903. */
  2904. export class Quaternion {
  2905. /** defines the first component (0 by default) */
  2906. x: number;
  2907. /** defines the second component (0 by default) */
  2908. y: number;
  2909. /** defines the third component (0 by default) */
  2910. z: number;
  2911. /** defines the fourth component (1.0 by default) */
  2912. w: number;
  2913. /**
  2914. * Creates a new Quaternion from the given floats
  2915. * @param x defines the first component (0 by default)
  2916. * @param y defines the second component (0 by default)
  2917. * @param z defines the third component (0 by default)
  2918. * @param w defines the fourth component (1.0 by default)
  2919. */
  2920. constructor(
  2921. /** defines the first component (0 by default) */
  2922. x?: number,
  2923. /** defines the second component (0 by default) */
  2924. y?: number,
  2925. /** defines the third component (0 by default) */
  2926. z?: number,
  2927. /** defines the fourth component (1.0 by default) */
  2928. w?: number);
  2929. /**
  2930. * Gets a string representation for the current quaternion
  2931. * @returns a string with the Quaternion coordinates
  2932. */
  2933. toString(): string;
  2934. /**
  2935. * Gets the class name of the quaternion
  2936. * @returns the string "Quaternion"
  2937. */
  2938. getClassName(): string;
  2939. /**
  2940. * Gets a hash code for this quaternion
  2941. * @returns the quaternion hash code
  2942. */
  2943. getHashCode(): number;
  2944. /**
  2945. * Copy the quaternion to an array
  2946. * @returns a new array populated with 4 elements from the quaternion coordinates
  2947. */
  2948. asArray(): number[];
  2949. /**
  2950. * Check if two quaternions are equals
  2951. * @param otherQuaternion defines the second operand
  2952. * @return true if the current quaternion and the given one coordinates are strictly equals
  2953. */
  2954. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2955. /**
  2956. * Clone the current quaternion
  2957. * @returns a new quaternion copied from the current one
  2958. */
  2959. clone(): Quaternion;
  2960. /**
  2961. * Copy a quaternion to the current one
  2962. * @param other defines the other quaternion
  2963. * @returns the updated current quaternion
  2964. */
  2965. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2966. /**
  2967. * Updates the current quaternion with the given float coordinates
  2968. * @param x defines the x coordinate
  2969. * @param y defines the y coordinate
  2970. * @param z defines the z coordinate
  2971. * @param w defines the w coordinate
  2972. * @returns the updated current quaternion
  2973. */
  2974. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2975. /**
  2976. * Updates the current quaternion from the given float coordinates
  2977. * @param x defines the x coordinate
  2978. * @param y defines the y coordinate
  2979. * @param z defines the z coordinate
  2980. * @param w defines the w coordinate
  2981. * @returns the updated current quaternion
  2982. */
  2983. set(x: number, y: number, z: number, w: number): Quaternion;
  2984. /**
  2985. * Adds two quaternions
  2986. * @param other defines the second operand
  2987. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2988. */
  2989. add(other: DeepImmutable<Quaternion>): Quaternion;
  2990. /**
  2991. * Add a quaternion to the current one
  2992. * @param other defines the quaternion to add
  2993. * @returns the current quaternion
  2994. */
  2995. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2996. /**
  2997. * Subtract two quaternions
  2998. * @param other defines the second operand
  2999. * @returns a new quaternion as the subtraction result of the given one from the current one
  3000. */
  3001. subtract(other: Quaternion): Quaternion;
  3002. /**
  3003. * Multiplies the current quaternion by a scale factor
  3004. * @param value defines the scale factor
  3005. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3006. */
  3007. scale(value: number): Quaternion;
  3008. /**
  3009. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3010. * @param scale defines the scale factor
  3011. * @param result defines the Quaternion object where to store the result
  3012. * @returns the unmodified current quaternion
  3013. */
  3014. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3015. /**
  3016. * Multiplies in place the current quaternion by a scale factor
  3017. * @param value defines the scale factor
  3018. * @returns the current modified quaternion
  3019. */
  3020. scaleInPlace(value: number): Quaternion;
  3021. /**
  3022. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3023. * @param scale defines the scale factor
  3024. * @param result defines the Quaternion object where to store the result
  3025. * @returns the unmodified current quaternion
  3026. */
  3027. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3028. /**
  3029. * Multiplies two quaternions
  3030. * @param q1 defines the second operand
  3031. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3032. */
  3033. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3034. /**
  3035. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3036. * @param q1 defines the second operand
  3037. * @param result defines the target quaternion
  3038. * @returns the current quaternion
  3039. */
  3040. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3041. /**
  3042. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3043. * @param q1 defines the second operand
  3044. * @returns the currentupdated quaternion
  3045. */
  3046. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3047. /**
  3048. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3049. * @param ref defines the target quaternion
  3050. * @returns the current quaternion
  3051. */
  3052. conjugateToRef(ref: Quaternion): Quaternion;
  3053. /**
  3054. * Conjugates in place (1-q) the current quaternion
  3055. * @returns the current updated quaternion
  3056. */
  3057. conjugateInPlace(): Quaternion;
  3058. /**
  3059. * Conjugates in place (1-q) the current quaternion
  3060. * @returns a new quaternion
  3061. */
  3062. conjugate(): Quaternion;
  3063. /**
  3064. * Gets length of current quaternion
  3065. * @returns the quaternion length (float)
  3066. */
  3067. length(): number;
  3068. /**
  3069. * Normalize in place the current quaternion
  3070. * @returns the current updated quaternion
  3071. */
  3072. normalize(): Quaternion;
  3073. /**
  3074. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3075. * @param order is a reserved parameter and is ignore for now
  3076. * @returns a new Vector3 containing the Euler angles
  3077. */
  3078. toEulerAngles(order?: string): Vector3;
  3079. /**
  3080. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3081. * @param result defines the vector which will be filled with the Euler angles
  3082. * @param order is a reserved parameter and is ignore for now
  3083. * @returns the current unchanged quaternion
  3084. */
  3085. toEulerAnglesToRef(result: Vector3): Quaternion;
  3086. /**
  3087. * Updates the given rotation matrix with the current quaternion values
  3088. * @param result defines the target matrix
  3089. * @returns the current unchanged quaternion
  3090. */
  3091. toRotationMatrix(result: Matrix): Quaternion;
  3092. /**
  3093. * Updates the current quaternion from the given rotation matrix values
  3094. * @param matrix defines the source matrix
  3095. * @returns the current updated quaternion
  3096. */
  3097. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3098. /**
  3099. * Creates a new quaternion from a rotation matrix
  3100. * @param matrix defines the source matrix
  3101. * @returns a new quaternion created from the given rotation matrix values
  3102. */
  3103. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3104. /**
  3105. * Updates the given quaternion with the given rotation matrix values
  3106. * @param matrix defines the source matrix
  3107. * @param result defines the target quaternion
  3108. */
  3109. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3110. /**
  3111. * Returns the dot product (float) between the quaternions "left" and "right"
  3112. * @param left defines the left operand
  3113. * @param right defines the right operand
  3114. * @returns the dot product
  3115. */
  3116. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3117. /**
  3118. * Checks if the two quaternions are close to each other
  3119. * @param quat0 defines the first quaternion to check
  3120. * @param quat1 defines the second quaternion to check
  3121. * @returns true if the two quaternions are close to each other
  3122. */
  3123. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3124. /**
  3125. * Creates an empty quaternion
  3126. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3127. */
  3128. static Zero(): Quaternion;
  3129. /**
  3130. * Inverse a given quaternion
  3131. * @param q defines the source quaternion
  3132. * @returns a new quaternion as the inverted current quaternion
  3133. */
  3134. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3135. /**
  3136. * Inverse a given quaternion
  3137. * @param q defines the source quaternion
  3138. * @param result the quaternion the result will be stored in
  3139. * @returns the result quaternion
  3140. */
  3141. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3142. /**
  3143. * Creates an identity quaternion
  3144. * @returns the identity quaternion
  3145. */
  3146. static Identity(): Quaternion;
  3147. /**
  3148. * Gets a boolean indicating if the given quaternion is identity
  3149. * @param quaternion defines the quaternion to check
  3150. * @returns true if the quaternion is identity
  3151. */
  3152. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3153. /**
  3154. * Creates a quaternion from a rotation around an axis
  3155. * @param axis defines the axis to use
  3156. * @param angle defines the angle to use
  3157. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3158. */
  3159. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3160. /**
  3161. * Creates a rotation around an axis and stores it into the given quaternion
  3162. * @param axis defines the axis to use
  3163. * @param angle defines the angle to use
  3164. * @param result defines the target quaternion
  3165. * @returns the target quaternion
  3166. */
  3167. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3168. /**
  3169. * Creates a new quaternion from data stored into an array
  3170. * @param array defines the data source
  3171. * @param offset defines the offset in the source array where the data starts
  3172. * @returns a new quaternion
  3173. */
  3174. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3175. /**
  3176. * Create a quaternion from Euler rotation angles
  3177. * @param x Pitch
  3178. * @param y Yaw
  3179. * @param z Roll
  3180. * @returns the new Quaternion
  3181. */
  3182. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3183. /**
  3184. * Updates a quaternion from Euler rotation angles
  3185. * @param x Pitch
  3186. * @param y Yaw
  3187. * @param z Roll
  3188. * @param result the quaternion to store the result
  3189. * @returns the updated quaternion
  3190. */
  3191. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3192. /**
  3193. * Create a quaternion from Euler rotation vector
  3194. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3195. * @returns the new Quaternion
  3196. */
  3197. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3198. /**
  3199. * Updates a quaternion from Euler rotation vector
  3200. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3201. * @param result the quaternion to store the result
  3202. * @returns the updated quaternion
  3203. */
  3204. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3205. /**
  3206. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3207. * @param yaw defines the rotation around Y axis
  3208. * @param pitch defines the rotation around X axis
  3209. * @param roll defines the rotation around Z axis
  3210. * @returns the new quaternion
  3211. */
  3212. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3213. /**
  3214. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3215. * @param yaw defines the rotation around Y axis
  3216. * @param pitch defines the rotation around X axis
  3217. * @param roll defines the rotation around Z axis
  3218. * @param result defines the target quaternion
  3219. */
  3220. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3221. /**
  3222. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3223. * @param alpha defines the rotation around first axis
  3224. * @param beta defines the rotation around second axis
  3225. * @param gamma defines the rotation around third axis
  3226. * @returns the new quaternion
  3227. */
  3228. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3229. /**
  3230. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3231. * @param alpha defines the rotation around first axis
  3232. * @param beta defines the rotation around second axis
  3233. * @param gamma defines the rotation around third axis
  3234. * @param result defines the target quaternion
  3235. */
  3236. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3237. /**
  3238. * 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)
  3239. * @param axis1 defines the first axis
  3240. * @param axis2 defines the second axis
  3241. * @param axis3 defines the third axis
  3242. * @returns the new quaternion
  3243. */
  3244. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3245. /**
  3246. * 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
  3247. * @param axis1 defines the first axis
  3248. * @param axis2 defines the second axis
  3249. * @param axis3 defines the third axis
  3250. * @param ref defines the target quaternion
  3251. */
  3252. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3253. /**
  3254. * Interpolates between two quaternions
  3255. * @param left defines first quaternion
  3256. * @param right defines second quaternion
  3257. * @param amount defines the gradient to use
  3258. * @returns the new interpolated quaternion
  3259. */
  3260. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3261. /**
  3262. * Interpolates between two quaternions and stores it into a target quaternion
  3263. * @param left defines first quaternion
  3264. * @param right defines second quaternion
  3265. * @param amount defines the gradient to use
  3266. * @param result defines the target quaternion
  3267. */
  3268. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3269. /**
  3270. * Interpolate between two quaternions using Hermite interpolation
  3271. * @param value1 defines first quaternion
  3272. * @param tangent1 defines the incoming tangent
  3273. * @param value2 defines second quaternion
  3274. * @param tangent2 defines the outgoing tangent
  3275. * @param amount defines the target quaternion
  3276. * @returns the new interpolated quaternion
  3277. */
  3278. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3279. }
  3280. /**
  3281. * Class used to store matrix data (4x4)
  3282. */
  3283. export class Matrix {
  3284. private static _updateFlagSeed;
  3285. private static _identityReadOnly;
  3286. private _isIdentity;
  3287. private _isIdentityDirty;
  3288. private _isIdentity3x2;
  3289. private _isIdentity3x2Dirty;
  3290. /**
  3291. * Gets the update flag of the matrix which is an unique number for the matrix.
  3292. * It will be incremented every time the matrix data change.
  3293. * You can use it to speed the comparison between two versions of the same matrix.
  3294. */
  3295. updateFlag: number;
  3296. private readonly _m;
  3297. /**
  3298. * Gets the internal data of the matrix
  3299. */
  3300. readonly m: DeepImmutable<Float32Array>;
  3301. /** @hidden */
  3302. _markAsUpdated(): void;
  3303. /** @hidden */
  3304. private _updateIdentityStatus;
  3305. /**
  3306. * Creates an empty matrix (filled with zeros)
  3307. */
  3308. constructor();
  3309. /**
  3310. * Check if the current matrix is identity
  3311. * @returns true is the matrix is the identity matrix
  3312. */
  3313. isIdentity(): boolean;
  3314. /**
  3315. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3316. * @returns true is the matrix is the identity matrix
  3317. */
  3318. isIdentityAs3x2(): boolean;
  3319. /**
  3320. * Gets the determinant of the matrix
  3321. * @returns the matrix determinant
  3322. */
  3323. determinant(): number;
  3324. /**
  3325. * Returns the matrix as a Float32Array
  3326. * @returns the matrix underlying array
  3327. */
  3328. toArray(): DeepImmutable<Float32Array>;
  3329. /**
  3330. * Returns the matrix as a Float32Array
  3331. * @returns the matrix underlying array.
  3332. */
  3333. asArray(): DeepImmutable<Float32Array>;
  3334. /**
  3335. * Inverts the current matrix in place
  3336. * @returns the current inverted matrix
  3337. */
  3338. invert(): Matrix;
  3339. /**
  3340. * Sets all the matrix elements to zero
  3341. * @returns the current matrix
  3342. */
  3343. reset(): Matrix;
  3344. /**
  3345. * Adds the current matrix with a second one
  3346. * @param other defines the matrix to add
  3347. * @returns a new matrix as the addition of the current matrix and the given one
  3348. */
  3349. add(other: DeepImmutable<Matrix>): Matrix;
  3350. /**
  3351. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3352. * @param other defines the matrix to add
  3353. * @param result defines the target matrix
  3354. * @returns the current matrix
  3355. */
  3356. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3357. /**
  3358. * Adds in place the given matrix to the current matrix
  3359. * @param other defines the second operand
  3360. * @returns the current updated matrix
  3361. */
  3362. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3363. /**
  3364. * Sets the given matrix to the current inverted Matrix
  3365. * @param other defines the target matrix
  3366. * @returns the unmodified current matrix
  3367. */
  3368. invertToRef(other: Matrix): Matrix;
  3369. /**
  3370. * add a value at the specified position in the current Matrix
  3371. * @param index the index of the value within the matrix. between 0 and 15.
  3372. * @param value the value to be added
  3373. * @returns the current updated matrix
  3374. */
  3375. addAtIndex(index: number, value: number): Matrix;
  3376. /**
  3377. * mutiply the specified position in the current Matrix by a value
  3378. * @param index the index of the value within the matrix. between 0 and 15.
  3379. * @param value the value to be added
  3380. * @returns the current updated matrix
  3381. */
  3382. multiplyAtIndex(index: number, value: number): Matrix;
  3383. /**
  3384. * Inserts the translation vector (using 3 floats) in the current matrix
  3385. * @param x defines the 1st component of the translation
  3386. * @param y defines the 2nd component of the translation
  3387. * @param z defines the 3rd component of the translation
  3388. * @returns the current updated matrix
  3389. */
  3390. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3391. /**
  3392. * Adds the translation vector (using 3 floats) in the current matrix
  3393. * @param x defines the 1st component of the translation
  3394. * @param y defines the 2nd component of the translation
  3395. * @param z defines the 3rd component of the translation
  3396. * @returns the current updated matrix
  3397. */
  3398. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3399. /**
  3400. * Inserts the translation vector in the current matrix
  3401. * @param vector3 defines the translation to insert
  3402. * @returns the current updated matrix
  3403. */
  3404. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3405. /**
  3406. * Gets the translation value of the current matrix
  3407. * @returns a new Vector3 as the extracted translation from the matrix
  3408. */
  3409. getTranslation(): Vector3;
  3410. /**
  3411. * Fill a Vector3 with the extracted translation from the matrix
  3412. * @param result defines the Vector3 where to store the translation
  3413. * @returns the current matrix
  3414. */
  3415. getTranslationToRef(result: Vector3): Matrix;
  3416. /**
  3417. * Remove rotation and scaling part from the matrix
  3418. * @returns the updated matrix
  3419. */
  3420. removeRotationAndScaling(): Matrix;
  3421. /**
  3422. * Multiply two matrices
  3423. * @param other defines the second operand
  3424. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3425. */
  3426. multiply(other: DeepImmutable<Matrix>): Matrix;
  3427. /**
  3428. * Copy the current matrix from the given one
  3429. * @param other defines the source matrix
  3430. * @returns the current updated matrix
  3431. */
  3432. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3433. /**
  3434. * Populates the given array from the starting index with the current matrix values
  3435. * @param array defines the target array
  3436. * @param offset defines the offset in the target array where to start storing values
  3437. * @returns the current matrix
  3438. */
  3439. copyToArray(array: Float32Array, offset?: number): Matrix;
  3440. /**
  3441. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3442. * @param other defines the second operand
  3443. * @param result defines the matrix where to store the multiplication
  3444. * @returns the current matrix
  3445. */
  3446. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3447. /**
  3448. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3449. * @param other defines the second operand
  3450. * @param result defines the array where to store the multiplication
  3451. * @param offset defines the offset in the target array where to start storing values
  3452. * @returns the current matrix
  3453. */
  3454. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3455. /**
  3456. * Check equality between this matrix and a second one
  3457. * @param value defines the second matrix to compare
  3458. * @returns true is the current matrix and the given one values are strictly equal
  3459. */
  3460. equals(value: DeepImmutable<Matrix>): boolean;
  3461. /**
  3462. * Clone the current matrix
  3463. * @returns a new matrix from the current matrix
  3464. */
  3465. clone(): Matrix;
  3466. /**
  3467. * Returns the name of the current matrix class
  3468. * @returns the string "Matrix"
  3469. */
  3470. getClassName(): string;
  3471. /**
  3472. * Gets the hash code of the current matrix
  3473. * @returns the hash code
  3474. */
  3475. getHashCode(): number;
  3476. /**
  3477. * Decomposes the current Matrix into a translation, rotation and scaling components
  3478. * @param scale defines the scale vector3 given as a reference to update
  3479. * @param rotation defines the rotation quaternion given as a reference to update
  3480. * @param translation defines the translation vector3 given as a reference to update
  3481. * @returns true if operation was successful
  3482. */
  3483. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3484. /**
  3485. * Gets specific row of the matrix
  3486. * @param index defines the number of the row to get
  3487. * @returns the index-th row of the current matrix as a new Vector4
  3488. */
  3489. getRow(index: number): Nullable<Vector4>;
  3490. /**
  3491. * Sets the index-th row of the current matrix to the vector4 values
  3492. * @param index defines the number of the row to set
  3493. * @param row defines the target vector4
  3494. * @returns the updated current matrix
  3495. */
  3496. setRow(index: number, row: Vector4): Matrix;
  3497. /**
  3498. * Compute the transpose of the matrix
  3499. * @returns the new transposed matrix
  3500. */
  3501. transpose(): Matrix;
  3502. /**
  3503. * Compute the transpose of the matrix and store it in a given matrix
  3504. * @param result defines the target matrix
  3505. * @returns the current matrix
  3506. */
  3507. transposeToRef(result: Matrix): Matrix;
  3508. /**
  3509. * Sets the index-th row of the current matrix with the given 4 x float values
  3510. * @param index defines the row index
  3511. * @param x defines the x component to set
  3512. * @param y defines the y component to set
  3513. * @param z defines the z component to set
  3514. * @param w defines the w component to set
  3515. * @returns the updated current matrix
  3516. */
  3517. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3518. /**
  3519. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3520. * @param scale defines the scale factor
  3521. * @returns a new matrix
  3522. */
  3523. scale(scale: number): Matrix;
  3524. /**
  3525. * Scale the current matrix values by a factor to a given result matrix
  3526. * @param scale defines the scale factor
  3527. * @param result defines the matrix to store the result
  3528. * @returns the current matrix
  3529. */
  3530. scaleToRef(scale: number, result: Matrix): Matrix;
  3531. /**
  3532. * Scale the current matrix values by a factor and add the result to a given matrix
  3533. * @param scale defines the scale factor
  3534. * @param result defines the Matrix to store the result
  3535. * @returns the current matrix
  3536. */
  3537. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3538. /**
  3539. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3540. * @param ref matrix to store the result
  3541. */
  3542. toNormalMatrix(ref: Matrix): void;
  3543. /**
  3544. * Gets only rotation part of the current matrix
  3545. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3546. */
  3547. getRotationMatrix(): Matrix;
  3548. /**
  3549. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3550. * @param result defines the target matrix to store data to
  3551. * @returns the current matrix
  3552. */
  3553. getRotationMatrixToRef(result: Matrix): Matrix;
  3554. /**
  3555. * Toggles model matrix from being right handed to left handed in place and vice versa
  3556. */
  3557. toggleModelMatrixHandInPlace(): void;
  3558. /**
  3559. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3560. */
  3561. toggleProjectionMatrixHandInPlace(): void;
  3562. /**
  3563. * Creates a matrix from an array
  3564. * @param array defines the source array
  3565. * @param offset defines an offset in the source array
  3566. * @returns a new Matrix set from the starting index of the given array
  3567. */
  3568. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3569. /**
  3570. * Copy the content of an array into a given matrix
  3571. * @param array defines the source array
  3572. * @param offset defines an offset in the source array
  3573. * @param result defines the target matrix
  3574. */
  3575. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3576. /**
  3577. * Stores an array into a matrix after having multiplied each component by a given factor
  3578. * @param array defines the source array
  3579. * @param offset defines the offset in the source array
  3580. * @param scale defines the scaling factor
  3581. * @param result defines the target matrix
  3582. */
  3583. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3584. /**
  3585. * Gets an identity matrix that must not be updated
  3586. */
  3587. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3588. /**
  3589. * Stores a list of values (16) inside a given matrix
  3590. * @param initialM11 defines 1st value of 1st row
  3591. * @param initialM12 defines 2nd value of 1st row
  3592. * @param initialM13 defines 3rd value of 1st row
  3593. * @param initialM14 defines 4th value of 1st row
  3594. * @param initialM21 defines 1st value of 2nd row
  3595. * @param initialM22 defines 2nd value of 2nd row
  3596. * @param initialM23 defines 3rd value of 2nd row
  3597. * @param initialM24 defines 4th value of 2nd row
  3598. * @param initialM31 defines 1st value of 3rd row
  3599. * @param initialM32 defines 2nd value of 3rd row
  3600. * @param initialM33 defines 3rd value of 3rd row
  3601. * @param initialM34 defines 4th value of 3rd row
  3602. * @param initialM41 defines 1st value of 4th row
  3603. * @param initialM42 defines 2nd value of 4th row
  3604. * @param initialM43 defines 3rd value of 4th row
  3605. * @param initialM44 defines 4th value of 4th row
  3606. * @param result defines the target matrix
  3607. */
  3608. 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;
  3609. /**
  3610. * Creates new matrix from a list of values (16)
  3611. * @param initialM11 defines 1st value of 1st row
  3612. * @param initialM12 defines 2nd value of 1st row
  3613. * @param initialM13 defines 3rd value of 1st row
  3614. * @param initialM14 defines 4th value of 1st row
  3615. * @param initialM21 defines 1st value of 2nd row
  3616. * @param initialM22 defines 2nd value of 2nd row
  3617. * @param initialM23 defines 3rd value of 2nd row
  3618. * @param initialM24 defines 4th value of 2nd row
  3619. * @param initialM31 defines 1st value of 3rd row
  3620. * @param initialM32 defines 2nd value of 3rd row
  3621. * @param initialM33 defines 3rd value of 3rd row
  3622. * @param initialM34 defines 4th value of 3rd row
  3623. * @param initialM41 defines 1st value of 4th row
  3624. * @param initialM42 defines 2nd value of 4th row
  3625. * @param initialM43 defines 3rd value of 4th row
  3626. * @param initialM44 defines 4th value of 4th row
  3627. * @returns the new matrix
  3628. */
  3629. 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;
  3630. /**
  3631. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3632. * @param scale defines the scale vector3
  3633. * @param rotation defines the rotation quaternion
  3634. * @param translation defines the translation vector3
  3635. * @returns a new matrix
  3636. */
  3637. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3638. /**
  3639. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3640. * @param scale defines the scale vector3
  3641. * @param rotation defines the rotation quaternion
  3642. * @param translation defines the translation vector3
  3643. * @param result defines the target matrix
  3644. */
  3645. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3646. /**
  3647. * Creates a new identity matrix
  3648. * @returns a new identity matrix
  3649. */
  3650. static Identity(): Matrix;
  3651. /**
  3652. * Creates a new identity matrix and stores the result in a given matrix
  3653. * @param result defines the target matrix
  3654. */
  3655. static IdentityToRef(result: Matrix): void;
  3656. /**
  3657. * Creates a new zero matrix
  3658. * @returns a new zero matrix
  3659. */
  3660. static Zero(): Matrix;
  3661. /**
  3662. * Creates a new rotation matrix for "angle" radians around the X axis
  3663. * @param angle defines the angle (in radians) to use
  3664. * @return the new matrix
  3665. */
  3666. static RotationX(angle: number): Matrix;
  3667. /**
  3668. * Creates a new matrix as the invert of a given matrix
  3669. * @param source defines the source matrix
  3670. * @returns the new matrix
  3671. */
  3672. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3673. /**
  3674. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3675. * @param angle defines the angle (in radians) to use
  3676. * @param result defines the target matrix
  3677. */
  3678. static RotationXToRef(angle: number, result: Matrix): void;
  3679. /**
  3680. * Creates a new rotation matrix for "angle" radians around the Y axis
  3681. * @param angle defines the angle (in radians) to use
  3682. * @return the new matrix
  3683. */
  3684. static RotationY(angle: number): Matrix;
  3685. /**
  3686. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3687. * @param angle defines the angle (in radians) to use
  3688. * @param result defines the target matrix
  3689. */
  3690. static RotationYToRef(angle: number, result: Matrix): void;
  3691. /**
  3692. * Creates a new rotation matrix for "angle" radians around the Z axis
  3693. * @param angle defines the angle (in radians) to use
  3694. * @return the new matrix
  3695. */
  3696. static RotationZ(angle: number): Matrix;
  3697. /**
  3698. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3699. * @param angle defines the angle (in radians) to use
  3700. * @param result defines the target matrix
  3701. */
  3702. static RotationZToRef(angle: number, result: Matrix): void;
  3703. /**
  3704. * Creates a new rotation matrix for "angle" radians around the given axis
  3705. * @param axis defines the axis to use
  3706. * @param angle defines the angle (in radians) to use
  3707. * @return the new matrix
  3708. */
  3709. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3710. /**
  3711. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3712. * @param axis defines the axis to use
  3713. * @param angle defines the angle (in radians) to use
  3714. * @param result defines the target matrix
  3715. */
  3716. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3717. /**
  3718. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3719. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3720. * @param from defines the vector to align
  3721. * @param to defines the vector to align to
  3722. * @param result defines the target matrix
  3723. */
  3724. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3725. /**
  3726. * Creates a rotation matrix
  3727. * @param yaw defines the yaw angle in radians (Y axis)
  3728. * @param pitch defines the pitch angle in radians (X axis)
  3729. * @param roll defines the roll angle in radians (X axis)
  3730. * @returns the new rotation matrix
  3731. */
  3732. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3733. /**
  3734. * Creates a rotation matrix and stores it in a given matrix
  3735. * @param yaw defines the yaw angle in radians (Y axis)
  3736. * @param pitch defines the pitch angle in radians (X axis)
  3737. * @param roll defines the roll angle in radians (X axis)
  3738. * @param result defines the target matrix
  3739. */
  3740. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3741. /**
  3742. * Creates a scaling matrix
  3743. * @param x defines the scale factor on X axis
  3744. * @param y defines the scale factor on Y axis
  3745. * @param z defines the scale factor on Z axis
  3746. * @returns the new matrix
  3747. */
  3748. static Scaling(x: number, y: number, z: number): Matrix;
  3749. /**
  3750. * Creates a scaling matrix and stores it in a given matrix
  3751. * @param x defines the scale factor on X axis
  3752. * @param y defines the scale factor on Y axis
  3753. * @param z defines the scale factor on Z axis
  3754. * @param result defines the target matrix
  3755. */
  3756. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3757. /**
  3758. * Creates a translation matrix
  3759. * @param x defines the translation on X axis
  3760. * @param y defines the translation on Y axis
  3761. * @param z defines the translationon Z axis
  3762. * @returns the new matrix
  3763. */
  3764. static Translation(x: number, y: number, z: number): Matrix;
  3765. /**
  3766. * Creates a translation matrix and stores it in a given matrix
  3767. * @param x defines the translation on X axis
  3768. * @param y defines the translation on Y axis
  3769. * @param z defines the translationon Z axis
  3770. * @param result defines the target matrix
  3771. */
  3772. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3773. /**
  3774. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3775. * @param startValue defines the start value
  3776. * @param endValue defines the end value
  3777. * @param gradient defines the gradient factor
  3778. * @returns the new matrix
  3779. */
  3780. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3781. /**
  3782. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3783. * @param startValue defines the start value
  3784. * @param endValue defines the end value
  3785. * @param gradient defines the gradient factor
  3786. * @param result defines the Matrix object where to store data
  3787. */
  3788. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3789. /**
  3790. * Builds a new matrix whose values are computed by:
  3791. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3792. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3793. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3794. * @param startValue defines the first matrix
  3795. * @param endValue defines the second matrix
  3796. * @param gradient defines the gradient between the two matrices
  3797. * @returns the new matrix
  3798. */
  3799. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3800. /**
  3801. * Update a matrix to values which are computed by:
  3802. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3803. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3804. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3805. * @param startValue defines the first matrix
  3806. * @param endValue defines the second matrix
  3807. * @param gradient defines the gradient between the two matrices
  3808. * @param result defines the target matrix
  3809. */
  3810. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3811. /**
  3812. * 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"
  3813. * This function works in left handed mode
  3814. * @param eye defines the final position of the entity
  3815. * @param target defines where the entity should look at
  3816. * @param up defines the up vector for the entity
  3817. * @returns the new matrix
  3818. */
  3819. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3820. /**
  3821. * 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".
  3822. * This function works in left handed mode
  3823. * @param eye defines the final position of the entity
  3824. * @param target defines where the entity should look at
  3825. * @param up defines the up vector for the entity
  3826. * @param result defines the target matrix
  3827. */
  3828. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3829. /**
  3830. * 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"
  3831. * This function works in right handed mode
  3832. * @param eye defines the final position of the entity
  3833. * @param target defines where the entity should look at
  3834. * @param up defines the up vector for the entity
  3835. * @returns the new matrix
  3836. */
  3837. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3838. /**
  3839. * 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".
  3840. * This function works in right handed mode
  3841. * @param eye defines the final position of the entity
  3842. * @param target defines where the entity should look at
  3843. * @param up defines the up vector for the entity
  3844. * @param result defines the target matrix
  3845. */
  3846. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3847. /**
  3848. * Create a left-handed orthographic projection matrix
  3849. * @param width defines the viewport width
  3850. * @param height defines the viewport height
  3851. * @param znear defines the near clip plane
  3852. * @param zfar defines the far clip plane
  3853. * @returns a new matrix as a left-handed orthographic projection matrix
  3854. */
  3855. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3856. /**
  3857. * Store a left-handed orthographic projection to a given matrix
  3858. * @param width defines the viewport width
  3859. * @param height defines the viewport height
  3860. * @param znear defines the near clip plane
  3861. * @param zfar defines the far clip plane
  3862. * @param result defines the target matrix
  3863. */
  3864. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3865. /**
  3866. * Create a left-handed orthographic projection matrix
  3867. * @param left defines the viewport left coordinate
  3868. * @param right defines the viewport right coordinate
  3869. * @param bottom defines the viewport bottom coordinate
  3870. * @param top defines the viewport top coordinate
  3871. * @param znear defines the near clip plane
  3872. * @param zfar defines the far clip plane
  3873. * @returns a new matrix as a left-handed orthographic projection matrix
  3874. */
  3875. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3876. /**
  3877. * Stores a left-handed orthographic projection into a given matrix
  3878. * @param left defines the viewport left coordinate
  3879. * @param right defines the viewport right coordinate
  3880. * @param bottom defines the viewport bottom coordinate
  3881. * @param top defines the viewport top coordinate
  3882. * @param znear defines the near clip plane
  3883. * @param zfar defines the far clip plane
  3884. * @param result defines the target matrix
  3885. */
  3886. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3887. /**
  3888. * Creates a right-handed orthographic projection matrix
  3889. * @param left defines the viewport left coordinate
  3890. * @param right defines the viewport right coordinate
  3891. * @param bottom defines the viewport bottom coordinate
  3892. * @param top defines the viewport top coordinate
  3893. * @param znear defines the near clip plane
  3894. * @param zfar defines the far clip plane
  3895. * @returns a new matrix as a right-handed orthographic projection matrix
  3896. */
  3897. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3898. /**
  3899. * Stores a right-handed orthographic projection into a given matrix
  3900. * @param left defines the viewport left coordinate
  3901. * @param right defines the viewport right coordinate
  3902. * @param bottom defines the viewport bottom coordinate
  3903. * @param top defines the viewport top coordinate
  3904. * @param znear defines the near clip plane
  3905. * @param zfar defines the far clip plane
  3906. * @param result defines the target matrix
  3907. */
  3908. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3909. /**
  3910. * Creates a left-handed perspective projection matrix
  3911. * @param width defines the viewport width
  3912. * @param height defines the viewport height
  3913. * @param znear defines the near clip plane
  3914. * @param zfar defines the far clip plane
  3915. * @returns a new matrix as a left-handed perspective projection matrix
  3916. */
  3917. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3918. /**
  3919. * Creates a left-handed perspective projection matrix
  3920. * @param fov defines the horizontal field of view
  3921. * @param aspect defines the aspect ratio
  3922. * @param znear defines the near clip plane
  3923. * @param zfar defines the far clip plane
  3924. * @returns a new matrix as a left-handed perspective projection matrix
  3925. */
  3926. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3927. /**
  3928. * Stores a left-handed perspective projection into a given matrix
  3929. * @param fov defines the horizontal field of view
  3930. * @param aspect defines the aspect ratio
  3931. * @param znear defines the near clip plane
  3932. * @param zfar defines the far clip plane
  3933. * @param result defines the target matrix
  3934. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3935. */
  3936. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3937. /**
  3938. * Creates a right-handed perspective projection matrix
  3939. * @param fov defines the horizontal field of view
  3940. * @param aspect defines the aspect ratio
  3941. * @param znear defines the near clip plane
  3942. * @param zfar defines the far clip plane
  3943. * @returns a new matrix as a right-handed perspective projection matrix
  3944. */
  3945. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3946. /**
  3947. * Stores a right-handed perspective projection into a given matrix
  3948. * @param fov defines the horizontal field of view
  3949. * @param aspect defines the aspect ratio
  3950. * @param znear defines the near clip plane
  3951. * @param zfar defines the far clip plane
  3952. * @param result defines the target matrix
  3953. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3954. */
  3955. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3956. /**
  3957. * Stores a perspective projection for WebVR info a given matrix
  3958. * @param fov defines the field of view
  3959. * @param znear defines the near clip plane
  3960. * @param zfar defines the far clip plane
  3961. * @param result defines the target matrix
  3962. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3963. */
  3964. static PerspectiveFovWebVRToRef(fov: {
  3965. upDegrees: number;
  3966. downDegrees: number;
  3967. leftDegrees: number;
  3968. rightDegrees: number;
  3969. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3970. /**
  3971. * Computes a complete transformation matrix
  3972. * @param viewport defines the viewport to use
  3973. * @param world defines the world matrix
  3974. * @param view defines the view matrix
  3975. * @param projection defines the projection matrix
  3976. * @param zmin defines the near clip plane
  3977. * @param zmax defines the far clip plane
  3978. * @returns the transformation matrix
  3979. */
  3980. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3981. /**
  3982. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3983. * @param matrix defines the matrix to use
  3984. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3985. */
  3986. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3987. /**
  3988. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3989. * @param matrix defines the matrix to use
  3990. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3991. */
  3992. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3993. /**
  3994. * Compute the transpose of a given matrix
  3995. * @param matrix defines the matrix to transpose
  3996. * @returns the new matrix
  3997. */
  3998. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3999. /**
  4000. * Compute the transpose of a matrix and store it in a target matrix
  4001. * @param matrix defines the matrix to transpose
  4002. * @param result defines the target matrix
  4003. */
  4004. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4005. /**
  4006. * Computes a reflection matrix from a plane
  4007. * @param plane defines the reflection plane
  4008. * @returns a new matrix
  4009. */
  4010. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4011. /**
  4012. * Computes a reflection matrix from a plane
  4013. * @param plane defines the reflection plane
  4014. * @param result defines the target matrix
  4015. */
  4016. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4017. /**
  4018. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4019. * @param xaxis defines the value of the 1st axis
  4020. * @param yaxis defines the value of the 2nd axis
  4021. * @param zaxis defines the value of the 3rd axis
  4022. * @param result defines the target matrix
  4023. */
  4024. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4025. /**
  4026. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4027. * @param quat defines the quaternion to use
  4028. * @param result defines the target matrix
  4029. */
  4030. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4031. }
  4032. /**
  4033. * @hidden
  4034. */
  4035. export class TmpVectors {
  4036. static Vector2: Vector2[];
  4037. static Vector3: Vector3[];
  4038. static Vector4: Vector4[];
  4039. static Quaternion: Quaternion[];
  4040. static Matrix: Matrix[];
  4041. }
  4042. }
  4043. declare module BABYLON {
  4044. /** Defines the cross module used constants to avoid circular dependncies */
  4045. export class Constants {
  4046. /** Defines that alpha blending is disabled */
  4047. static readonly ALPHA_DISABLE: number;
  4048. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4049. static readonly ALPHA_ADD: number;
  4050. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4051. static readonly ALPHA_COMBINE: number;
  4052. /** Defines that alpha blending to DEST - SRC * DEST */
  4053. static readonly ALPHA_SUBTRACT: number;
  4054. /** Defines that alpha blending to SRC * DEST */
  4055. static readonly ALPHA_MULTIPLY: number;
  4056. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4057. static readonly ALPHA_MAXIMIZED: number;
  4058. /** Defines that alpha blending to SRC + DEST */
  4059. static readonly ALPHA_ONEONE: number;
  4060. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4061. static readonly ALPHA_PREMULTIPLIED: number;
  4062. /**
  4063. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4064. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4065. */
  4066. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4067. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4068. static readonly ALPHA_INTERPOLATE: number;
  4069. /**
  4070. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4071. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4072. */
  4073. static readonly ALPHA_SCREENMODE: number;
  4074. /** Defines that the ressource is not delayed*/
  4075. static readonly DELAYLOADSTATE_NONE: number;
  4076. /** Defines that the ressource was successfully delay loaded */
  4077. static readonly DELAYLOADSTATE_LOADED: number;
  4078. /** Defines that the ressource is currently delay loading */
  4079. static readonly DELAYLOADSTATE_LOADING: number;
  4080. /** Defines that the ressource is delayed and has not started loading */
  4081. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4082. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4083. static readonly NEVER: number;
  4084. /** 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 */
  4085. static readonly ALWAYS: number;
  4086. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4087. static readonly LESS: number;
  4088. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4089. static readonly EQUAL: number;
  4090. /** 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 */
  4091. static readonly LEQUAL: number;
  4092. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4093. static readonly GREATER: number;
  4094. /** 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 */
  4095. static readonly GEQUAL: number;
  4096. /** 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 */
  4097. static readonly NOTEQUAL: number;
  4098. /** Passed to stencilOperation to specify that stencil value must be kept */
  4099. static readonly KEEP: number;
  4100. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4101. static readonly REPLACE: number;
  4102. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4103. static readonly INCR: number;
  4104. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4105. static readonly DECR: number;
  4106. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4107. static readonly INVERT: number;
  4108. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4109. static readonly INCR_WRAP: number;
  4110. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4111. static readonly DECR_WRAP: number;
  4112. /** Texture is not repeating outside of 0..1 UVs */
  4113. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4114. /** Texture is repeating outside of 0..1 UVs */
  4115. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4116. /** Texture is repeating and mirrored */
  4117. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4118. /** ALPHA */
  4119. static readonly TEXTUREFORMAT_ALPHA: number;
  4120. /** LUMINANCE */
  4121. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4122. /** LUMINANCE_ALPHA */
  4123. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4124. /** RGB */
  4125. static readonly TEXTUREFORMAT_RGB: number;
  4126. /** RGBA */
  4127. static readonly TEXTUREFORMAT_RGBA: number;
  4128. /** RED */
  4129. static readonly TEXTUREFORMAT_RED: number;
  4130. /** RED (2nd reference) */
  4131. static readonly TEXTUREFORMAT_R: number;
  4132. /** RG */
  4133. static readonly TEXTUREFORMAT_RG: number;
  4134. /** RED_INTEGER */
  4135. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4136. /** RED_INTEGER (2nd reference) */
  4137. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4138. /** RG_INTEGER */
  4139. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4140. /** RGB_INTEGER */
  4141. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4142. /** RGBA_INTEGER */
  4143. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4144. /** UNSIGNED_BYTE */
  4145. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4146. /** UNSIGNED_BYTE (2nd reference) */
  4147. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4148. /** FLOAT */
  4149. static readonly TEXTURETYPE_FLOAT: number;
  4150. /** HALF_FLOAT */
  4151. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4152. /** BYTE */
  4153. static readonly TEXTURETYPE_BYTE: number;
  4154. /** SHORT */
  4155. static readonly TEXTURETYPE_SHORT: number;
  4156. /** UNSIGNED_SHORT */
  4157. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4158. /** INT */
  4159. static readonly TEXTURETYPE_INT: number;
  4160. /** UNSIGNED_INT */
  4161. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4162. /** UNSIGNED_SHORT_4_4_4_4 */
  4163. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4164. /** UNSIGNED_SHORT_5_5_5_1 */
  4165. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4166. /** UNSIGNED_SHORT_5_6_5 */
  4167. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4168. /** UNSIGNED_INT_2_10_10_10_REV */
  4169. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4170. /** UNSIGNED_INT_24_8 */
  4171. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4172. /** UNSIGNED_INT_10F_11F_11F_REV */
  4173. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4174. /** UNSIGNED_INT_5_9_9_9_REV */
  4175. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4176. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4177. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4178. /** nearest is mag = nearest and min = nearest and mip = linear */
  4179. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4180. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4181. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4182. /** Trilinear is mag = linear and min = linear and mip = linear */
  4183. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4184. /** nearest is mag = nearest and min = nearest and mip = linear */
  4185. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4186. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4187. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4188. /** Trilinear is mag = linear and min = linear and mip = linear */
  4189. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4190. /** mag = nearest and min = nearest and mip = nearest */
  4191. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4192. /** mag = nearest and min = linear and mip = nearest */
  4193. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4194. /** mag = nearest and min = linear and mip = linear */
  4195. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4196. /** mag = nearest and min = linear and mip = none */
  4197. static readonly TEXTURE_NEAREST_LINEAR: number;
  4198. /** mag = nearest and min = nearest and mip = none */
  4199. static readonly TEXTURE_NEAREST_NEAREST: number;
  4200. /** mag = linear and min = nearest and mip = nearest */
  4201. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4202. /** mag = linear and min = nearest and mip = linear */
  4203. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4204. /** mag = linear and min = linear and mip = none */
  4205. static readonly TEXTURE_LINEAR_LINEAR: number;
  4206. /** mag = linear and min = nearest and mip = none */
  4207. static readonly TEXTURE_LINEAR_NEAREST: number;
  4208. /** Explicit coordinates mode */
  4209. static readonly TEXTURE_EXPLICIT_MODE: number;
  4210. /** Spherical coordinates mode */
  4211. static readonly TEXTURE_SPHERICAL_MODE: number;
  4212. /** Planar coordinates mode */
  4213. static readonly TEXTURE_PLANAR_MODE: number;
  4214. /** Cubic coordinates mode */
  4215. static readonly TEXTURE_CUBIC_MODE: number;
  4216. /** Projection coordinates mode */
  4217. static readonly TEXTURE_PROJECTION_MODE: number;
  4218. /** Skybox coordinates mode */
  4219. static readonly TEXTURE_SKYBOX_MODE: number;
  4220. /** Inverse Cubic coordinates mode */
  4221. static readonly TEXTURE_INVCUBIC_MODE: number;
  4222. /** Equirectangular coordinates mode */
  4223. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4224. /** Equirectangular Fixed coordinates mode */
  4225. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4226. /** Equirectangular Fixed Mirrored coordinates mode */
  4227. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4228. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4229. static readonly SCALEMODE_FLOOR: number;
  4230. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4231. static readonly SCALEMODE_NEAREST: number;
  4232. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4233. static readonly SCALEMODE_CEILING: number;
  4234. /**
  4235. * The dirty texture flag value
  4236. */
  4237. static readonly MATERIAL_TextureDirtyFlag: number;
  4238. /**
  4239. * The dirty light flag value
  4240. */
  4241. static readonly MATERIAL_LightDirtyFlag: number;
  4242. /**
  4243. * The dirty fresnel flag value
  4244. */
  4245. static readonly MATERIAL_FresnelDirtyFlag: number;
  4246. /**
  4247. * The dirty attribute flag value
  4248. */
  4249. static readonly MATERIAL_AttributesDirtyFlag: number;
  4250. /**
  4251. * The dirty misc flag value
  4252. */
  4253. static readonly MATERIAL_MiscDirtyFlag: number;
  4254. /**
  4255. * The all dirty flag value
  4256. */
  4257. static readonly MATERIAL_AllDirtyFlag: number;
  4258. /**
  4259. * Returns the triangle fill mode
  4260. */
  4261. static readonly MATERIAL_TriangleFillMode: number;
  4262. /**
  4263. * Returns the wireframe mode
  4264. */
  4265. static readonly MATERIAL_WireFrameFillMode: number;
  4266. /**
  4267. * Returns the point fill mode
  4268. */
  4269. static readonly MATERIAL_PointFillMode: number;
  4270. /**
  4271. * Returns the point list draw mode
  4272. */
  4273. static readonly MATERIAL_PointListDrawMode: number;
  4274. /**
  4275. * Returns the line list draw mode
  4276. */
  4277. static readonly MATERIAL_LineListDrawMode: number;
  4278. /**
  4279. * Returns the line loop draw mode
  4280. */
  4281. static readonly MATERIAL_LineLoopDrawMode: number;
  4282. /**
  4283. * Returns the line strip draw mode
  4284. */
  4285. static readonly MATERIAL_LineStripDrawMode: number;
  4286. /**
  4287. * Returns the triangle strip draw mode
  4288. */
  4289. static readonly MATERIAL_TriangleStripDrawMode: number;
  4290. /**
  4291. * Returns the triangle fan draw mode
  4292. */
  4293. static readonly MATERIAL_TriangleFanDrawMode: number;
  4294. /**
  4295. * Stores the clock-wise side orientation
  4296. */
  4297. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4298. /**
  4299. * Stores the counter clock-wise side orientation
  4300. */
  4301. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4302. /**
  4303. * Nothing
  4304. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4305. */
  4306. static readonly ACTION_NothingTrigger: number;
  4307. /**
  4308. * On pick
  4309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4310. */
  4311. static readonly ACTION_OnPickTrigger: number;
  4312. /**
  4313. * On left pick
  4314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4315. */
  4316. static readonly ACTION_OnLeftPickTrigger: number;
  4317. /**
  4318. * On right pick
  4319. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4320. */
  4321. static readonly ACTION_OnRightPickTrigger: number;
  4322. /**
  4323. * On center pick
  4324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4325. */
  4326. static readonly ACTION_OnCenterPickTrigger: number;
  4327. /**
  4328. * On pick down
  4329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4330. */
  4331. static readonly ACTION_OnPickDownTrigger: number;
  4332. /**
  4333. * On double pick
  4334. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4335. */
  4336. static readonly ACTION_OnDoublePickTrigger: number;
  4337. /**
  4338. * On pick up
  4339. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4340. */
  4341. static readonly ACTION_OnPickUpTrigger: number;
  4342. /**
  4343. * On pick out.
  4344. * This trigger will only be raised if you also declared a OnPickDown
  4345. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4346. */
  4347. static readonly ACTION_OnPickOutTrigger: number;
  4348. /**
  4349. * On long press
  4350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4351. */
  4352. static readonly ACTION_OnLongPressTrigger: number;
  4353. /**
  4354. * On pointer over
  4355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4356. */
  4357. static readonly ACTION_OnPointerOverTrigger: number;
  4358. /**
  4359. * On pointer out
  4360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4361. */
  4362. static readonly ACTION_OnPointerOutTrigger: number;
  4363. /**
  4364. * On every frame
  4365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4366. */
  4367. static readonly ACTION_OnEveryFrameTrigger: number;
  4368. /**
  4369. * On intersection enter
  4370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4371. */
  4372. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4373. /**
  4374. * On intersection exit
  4375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4376. */
  4377. static readonly ACTION_OnIntersectionExitTrigger: number;
  4378. /**
  4379. * On key down
  4380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4381. */
  4382. static readonly ACTION_OnKeyDownTrigger: number;
  4383. /**
  4384. * On key up
  4385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4386. */
  4387. static readonly ACTION_OnKeyUpTrigger: number;
  4388. /**
  4389. * Billboard mode will only apply to Y axis
  4390. */
  4391. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4392. /**
  4393. * Billboard mode will apply to all axes
  4394. */
  4395. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4396. /**
  4397. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4398. */
  4399. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4400. /**
  4401. * Gets or sets base Assets URL
  4402. */
  4403. static PARTICLES_BaseAssetsUrl: string;
  4404. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4405. * Test order :
  4406. * Is the bounding sphere outside the frustum ?
  4407. * If not, are the bounding box vertices outside the frustum ?
  4408. * It not, then the cullable object is in the frustum.
  4409. */
  4410. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4411. /** Culling strategy : Bounding Sphere Only.
  4412. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4413. * It's also less accurate than the standard because some not visible objects can still be selected.
  4414. * Test : is the bounding sphere outside the frustum ?
  4415. * If not, then the cullable object is in the frustum.
  4416. */
  4417. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4418. /** Culling strategy : Optimistic Inclusion.
  4419. * This in an inclusion test first, then the standard exclusion test.
  4420. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4421. * 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.
  4422. * Anyway, it's as accurate as the standard strategy.
  4423. * Test :
  4424. * Is the cullable object bounding sphere center in the frustum ?
  4425. * If not, apply the default culling strategy.
  4426. */
  4427. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4428. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4429. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4430. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4431. * 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.
  4432. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4433. * Test :
  4434. * Is the cullable object bounding sphere center in the frustum ?
  4435. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4436. */
  4437. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4438. /**
  4439. * No logging while loading
  4440. */
  4441. static readonly SCENELOADER_NO_LOGGING: number;
  4442. /**
  4443. * Minimal logging while loading
  4444. */
  4445. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4446. /**
  4447. * Summary logging while loading
  4448. */
  4449. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4450. /**
  4451. * Detailled logging while loading
  4452. */
  4453. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4454. }
  4455. }
  4456. declare module BABYLON {
  4457. /**
  4458. * Class used to store and describe the pipeline context associated with an effect
  4459. */
  4460. export interface IPipelineContext {
  4461. /**
  4462. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4463. */
  4464. isAsync: boolean;
  4465. /**
  4466. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4467. */
  4468. isReady: boolean;
  4469. /** @hidden */
  4470. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4471. }
  4472. }
  4473. declare module BABYLON {
  4474. /** @hidden */
  4475. export interface IShaderProcessor {
  4476. attributeProcessor?: (attribute: string) => string;
  4477. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4478. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4479. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4480. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4481. lineProcessor?: (line: string, isFragment: boolean) => string;
  4482. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4483. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4484. }
  4485. }
  4486. declare module BABYLON {
  4487. /** @hidden */
  4488. export interface ProcessingOptions {
  4489. defines: string[];
  4490. indexParameters: any;
  4491. isFragment: boolean;
  4492. shouldUseHighPrecisionShader: boolean;
  4493. supportsUniformBuffers: boolean;
  4494. shadersRepository: string;
  4495. includesShadersStore: {
  4496. [key: string]: string;
  4497. };
  4498. processor?: IShaderProcessor;
  4499. version: string;
  4500. platformName: string;
  4501. lookForClosingBracketForUniformBuffer?: boolean;
  4502. }
  4503. }
  4504. declare module BABYLON {
  4505. /**
  4506. * Helper to manipulate strings
  4507. */
  4508. export class StringTools {
  4509. /**
  4510. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4511. * @param str Source string
  4512. * @param suffix Suffix to search for in the source string
  4513. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4514. */
  4515. static EndsWith(str: string, suffix: string): boolean;
  4516. /**
  4517. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4518. * @param str Source string
  4519. * @param suffix Suffix to search for in the source string
  4520. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4521. */
  4522. static StartsWith(str: string, suffix: string): boolean;
  4523. }
  4524. }
  4525. declare module BABYLON {
  4526. /** @hidden */
  4527. export class ShaderCodeNode {
  4528. line: string;
  4529. children: ShaderCodeNode[];
  4530. additionalDefineKey?: string;
  4531. additionalDefineValue?: string;
  4532. isValid(preprocessors: {
  4533. [key: string]: string;
  4534. }): boolean;
  4535. process(preprocessors: {
  4536. [key: string]: string;
  4537. }, options: ProcessingOptions): string;
  4538. }
  4539. }
  4540. declare module BABYLON {
  4541. /** @hidden */
  4542. export class ShaderCodeCursor {
  4543. private _lines;
  4544. lineIndex: number;
  4545. readonly currentLine: string;
  4546. readonly canRead: boolean;
  4547. lines: string[];
  4548. }
  4549. }
  4550. declare module BABYLON {
  4551. /** @hidden */
  4552. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4553. process(preprocessors: {
  4554. [key: string]: string;
  4555. }, options: ProcessingOptions): string;
  4556. }
  4557. }
  4558. declare module BABYLON {
  4559. /** @hidden */
  4560. export class ShaderDefineExpression {
  4561. isTrue(preprocessors: {
  4562. [key: string]: string;
  4563. }): boolean;
  4564. }
  4565. }
  4566. declare module BABYLON {
  4567. /** @hidden */
  4568. export class ShaderCodeTestNode extends ShaderCodeNode {
  4569. testExpression: ShaderDefineExpression;
  4570. isValid(preprocessors: {
  4571. [key: string]: string;
  4572. }): boolean;
  4573. }
  4574. }
  4575. declare module BABYLON {
  4576. /** @hidden */
  4577. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4578. define: string;
  4579. not: boolean;
  4580. constructor(define: string, not?: boolean);
  4581. isTrue(preprocessors: {
  4582. [key: string]: string;
  4583. }): boolean;
  4584. }
  4585. }
  4586. declare module BABYLON {
  4587. /** @hidden */
  4588. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4589. leftOperand: ShaderDefineExpression;
  4590. rightOperand: ShaderDefineExpression;
  4591. isTrue(preprocessors: {
  4592. [key: string]: string;
  4593. }): boolean;
  4594. }
  4595. }
  4596. declare module BABYLON {
  4597. /** @hidden */
  4598. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4599. leftOperand: ShaderDefineExpression;
  4600. rightOperand: ShaderDefineExpression;
  4601. isTrue(preprocessors: {
  4602. [key: string]: string;
  4603. }): boolean;
  4604. }
  4605. }
  4606. declare module BABYLON {
  4607. /** @hidden */
  4608. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4609. define: string;
  4610. operand: string;
  4611. testValue: string;
  4612. constructor(define: string, operand: string, testValue: string);
  4613. isTrue(preprocessors: {
  4614. [key: string]: string;
  4615. }): boolean;
  4616. }
  4617. }
  4618. declare module BABYLON {
  4619. /**
  4620. * @ignore
  4621. * Application error to support additional information when loading a file
  4622. */
  4623. export class LoadFileError extends Error {
  4624. /** defines the optional web request */
  4625. request?: WebRequest | undefined;
  4626. private static _setPrototypeOf;
  4627. /**
  4628. * Creates a new LoadFileError
  4629. * @param message defines the message of the error
  4630. * @param request defines the optional web request
  4631. */
  4632. constructor(message: string,
  4633. /** defines the optional web request */
  4634. request?: WebRequest | undefined);
  4635. }
  4636. }
  4637. declare module BABYLON {
  4638. /**
  4639. * Class used to enable access to offline support
  4640. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4641. */
  4642. export interface IOfflineProvider {
  4643. /**
  4644. * Gets a boolean indicating if scene must be saved in the database
  4645. */
  4646. enableSceneOffline: boolean;
  4647. /**
  4648. * Gets a boolean indicating if textures must be saved in the database
  4649. */
  4650. enableTexturesOffline: boolean;
  4651. /**
  4652. * Open the offline support and make it available
  4653. * @param successCallback defines the callback to call on success
  4654. * @param errorCallback defines the callback to call on error
  4655. */
  4656. open(successCallback: () => void, errorCallback: () => void): void;
  4657. /**
  4658. * Loads an image from the offline support
  4659. * @param url defines the url to load from
  4660. * @param image defines the target DOM image
  4661. */
  4662. loadImage(url: string, image: HTMLImageElement): void;
  4663. /**
  4664. * Loads a file from offline support
  4665. * @param url defines the URL to load from
  4666. * @param sceneLoaded defines a callback to call on success
  4667. * @param progressCallBack defines a callback to call when progress changed
  4668. * @param errorCallback defines a callback to call on error
  4669. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4670. */
  4671. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4672. }
  4673. }
  4674. declare module BABYLON {
  4675. /**
  4676. * Class used to help managing file picking and drag'n'drop
  4677. * File Storage
  4678. */
  4679. export class FilesInputStore {
  4680. /**
  4681. * List of files ready to be loaded
  4682. */
  4683. static FilesToLoad: {
  4684. [key: string]: File;
  4685. };
  4686. }
  4687. }
  4688. declare module BABYLON {
  4689. /**
  4690. * Class used to define a retry strategy when error happens while loading assets
  4691. */
  4692. export class RetryStrategy {
  4693. /**
  4694. * Function used to defines an exponential back off strategy
  4695. * @param maxRetries defines the maximum number of retries (3 by default)
  4696. * @param baseInterval defines the interval between retries
  4697. * @returns the strategy function to use
  4698. */
  4699. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4700. }
  4701. }
  4702. declare module BABYLON {
  4703. /**
  4704. * @hidden
  4705. */
  4706. export class FileTools {
  4707. /**
  4708. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4709. */
  4710. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4711. /**
  4712. * Gets or sets the base URL to use to load assets
  4713. */
  4714. static BaseUrl: string;
  4715. /**
  4716. * Default behaviour for cors in the application.
  4717. * It can be a string if the expected behavior is identical in the entire app.
  4718. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4719. */
  4720. static CorsBehavior: string | ((url: string | string[]) => string);
  4721. /**
  4722. * Gets or sets a function used to pre-process url before using them to load assets
  4723. */
  4724. static PreprocessUrl: (url: string) => string;
  4725. /**
  4726. * Removes unwanted characters from an url
  4727. * @param url defines the url to clean
  4728. * @returns the cleaned url
  4729. */
  4730. private static _CleanUrl;
  4731. /**
  4732. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4733. * @param url define the url we are trying
  4734. * @param element define the dom element where to configure the cors policy
  4735. */
  4736. static SetCorsBehavior(url: string | string[], element: {
  4737. crossOrigin: string | null;
  4738. }): void;
  4739. /**
  4740. * Loads an image as an HTMLImageElement.
  4741. * @param input url string, ArrayBuffer, or Blob to load
  4742. * @param onLoad callback called when the image successfully loads
  4743. * @param onError callback called when the image fails to load
  4744. * @param offlineProvider offline provider for caching
  4745. * @returns the HTMLImageElement of the loaded image
  4746. */
  4747. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4748. /**
  4749. * Loads a file
  4750. * @param fileToLoad defines the file to load
  4751. * @param callback defines the callback to call when data is loaded
  4752. * @param progressCallBack defines the callback to call during loading process
  4753. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4754. * @returns a file request object
  4755. */
  4756. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4757. /**
  4758. * Loads a file
  4759. * @param url url string, ArrayBuffer, or Blob to load
  4760. * @param onSuccess callback called when the file successfully loads
  4761. * @param onProgress callback called while file is loading (if the server supports this mode)
  4762. * @param offlineProvider defines the offline provider for caching
  4763. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4764. * @param onError callback called when the file fails to load
  4765. * @returns a file request object
  4766. */
  4767. 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;
  4768. /**
  4769. * Checks if the loaded document was accessed via `file:`-Protocol.
  4770. * @returns boolean
  4771. */
  4772. static IsFileURL(): boolean;
  4773. }
  4774. }
  4775. declare module BABYLON {
  4776. /** @hidden */
  4777. export class ShaderProcessor {
  4778. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4779. private static _ProcessPrecision;
  4780. private static _ExtractOperation;
  4781. private static _BuildSubExpression;
  4782. private static _BuildExpression;
  4783. private static _MoveCursorWithinIf;
  4784. private static _MoveCursor;
  4785. private static _EvaluatePreProcessors;
  4786. private static _PreparePreProcessors;
  4787. private static _ProcessShaderConversion;
  4788. private static _ProcessIncludes;
  4789. }
  4790. }
  4791. declare module BABYLON {
  4792. /**
  4793. * Class used to hold a RBG color
  4794. */
  4795. export class Color3 {
  4796. /**
  4797. * Defines the red component (between 0 and 1, default is 0)
  4798. */
  4799. r: number;
  4800. /**
  4801. * Defines the green component (between 0 and 1, default is 0)
  4802. */
  4803. g: number;
  4804. /**
  4805. * Defines the blue component (between 0 and 1, default is 0)
  4806. */
  4807. b: number;
  4808. /**
  4809. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4810. * @param r defines the red component (between 0 and 1, default is 0)
  4811. * @param g defines the green component (between 0 and 1, default is 0)
  4812. * @param b defines the blue component (between 0 and 1, default is 0)
  4813. */
  4814. constructor(
  4815. /**
  4816. * Defines the red component (between 0 and 1, default is 0)
  4817. */
  4818. r?: number,
  4819. /**
  4820. * Defines the green component (between 0 and 1, default is 0)
  4821. */
  4822. g?: number,
  4823. /**
  4824. * Defines the blue component (between 0 and 1, default is 0)
  4825. */
  4826. b?: number);
  4827. /**
  4828. * Creates a string with the Color3 current values
  4829. * @returns the string representation of the Color3 object
  4830. */
  4831. toString(): string;
  4832. /**
  4833. * Returns the string "Color3"
  4834. * @returns "Color3"
  4835. */
  4836. getClassName(): string;
  4837. /**
  4838. * Compute the Color3 hash code
  4839. * @returns an unique number that can be used to hash Color3 objects
  4840. */
  4841. getHashCode(): number;
  4842. /**
  4843. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4844. * @param array defines the array where to store the r,g,b components
  4845. * @param index defines an optional index in the target array to define where to start storing values
  4846. * @returns the current Color3 object
  4847. */
  4848. toArray(array: FloatArray, index?: number): Color3;
  4849. /**
  4850. * Returns a new Color4 object from the current Color3 and the given alpha
  4851. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4852. * @returns a new Color4 object
  4853. */
  4854. toColor4(alpha?: number): Color4;
  4855. /**
  4856. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4857. * @returns the new array
  4858. */
  4859. asArray(): number[];
  4860. /**
  4861. * Returns the luminance value
  4862. * @returns a float value
  4863. */
  4864. toLuminance(): number;
  4865. /**
  4866. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4867. * @param otherColor defines the second operand
  4868. * @returns the new Color3 object
  4869. */
  4870. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4871. /**
  4872. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4873. * @param otherColor defines the second operand
  4874. * @param result defines the Color3 object where to store the result
  4875. * @returns the current Color3
  4876. */
  4877. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4878. /**
  4879. * Determines equality between Color3 objects
  4880. * @param otherColor defines the second operand
  4881. * @returns true if the rgb values are equal to the given ones
  4882. */
  4883. equals(otherColor: DeepImmutable<Color3>): boolean;
  4884. /**
  4885. * Determines equality between the current Color3 object and a set of r,b,g values
  4886. * @param r defines the red component to check
  4887. * @param g defines the green component to check
  4888. * @param b defines the blue component to check
  4889. * @returns true if the rgb values are equal to the given ones
  4890. */
  4891. equalsFloats(r: number, g: number, b: number): boolean;
  4892. /**
  4893. * Multiplies in place each rgb value by scale
  4894. * @param scale defines the scaling factor
  4895. * @returns the updated Color3
  4896. */
  4897. scale(scale: number): Color3;
  4898. /**
  4899. * Multiplies the rgb values by scale and stores the result into "result"
  4900. * @param scale defines the scaling factor
  4901. * @param result defines the Color3 object where to store the result
  4902. * @returns the unmodified current Color3
  4903. */
  4904. scaleToRef(scale: number, result: Color3): Color3;
  4905. /**
  4906. * Scale the current Color3 values by a factor and add the result to a given Color3
  4907. * @param scale defines the scale factor
  4908. * @param result defines color to store the result into
  4909. * @returns the unmodified current Color3
  4910. */
  4911. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4912. /**
  4913. * Clamps the rgb values by the min and max values and stores the result into "result"
  4914. * @param min defines minimum clamping value (default is 0)
  4915. * @param max defines maximum clamping value (default is 1)
  4916. * @param result defines color to store the result into
  4917. * @returns the original Color3
  4918. */
  4919. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4920. /**
  4921. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4922. * @param otherColor defines the second operand
  4923. * @returns the new Color3
  4924. */
  4925. add(otherColor: DeepImmutable<Color3>): Color3;
  4926. /**
  4927. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  4928. * @param otherColor defines the second operand
  4929. * @param result defines Color3 object to store the result into
  4930. * @returns the unmodified current Color3
  4931. */
  4932. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4933. /**
  4934. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  4935. * @param otherColor defines the second operand
  4936. * @returns the new Color3
  4937. */
  4938. subtract(otherColor: DeepImmutable<Color3>): Color3;
  4939. /**
  4940. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  4941. * @param otherColor defines the second operand
  4942. * @param result defines Color3 object to store the result into
  4943. * @returns the unmodified current Color3
  4944. */
  4945. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4946. /**
  4947. * Copy the current object
  4948. * @returns a new Color3 copied the current one
  4949. */
  4950. clone(): Color3;
  4951. /**
  4952. * Copies the rgb values from the source in the current Color3
  4953. * @param source defines the source Color3 object
  4954. * @returns the updated Color3 object
  4955. */
  4956. copyFrom(source: DeepImmutable<Color3>): Color3;
  4957. /**
  4958. * Updates the Color3 rgb values from the given floats
  4959. * @param r defines the red component to read from
  4960. * @param g defines the green component to read from
  4961. * @param b defines the blue component to read from
  4962. * @returns the current Color3 object
  4963. */
  4964. copyFromFloats(r: number, g: number, b: number): Color3;
  4965. /**
  4966. * Updates the Color3 rgb values from the given floats
  4967. * @param r defines the red component to read from
  4968. * @param g defines the green component to read from
  4969. * @param b defines the blue component to read from
  4970. * @returns the current Color3 object
  4971. */
  4972. set(r: number, g: number, b: number): Color3;
  4973. /**
  4974. * Compute the Color3 hexadecimal code as a string
  4975. * @returns a string containing the hexadecimal representation of the Color3 object
  4976. */
  4977. toHexString(): string;
  4978. /**
  4979. * Computes a new Color3 converted from the current one to linear space
  4980. * @returns a new Color3 object
  4981. */
  4982. toLinearSpace(): Color3;
  4983. /**
  4984. * Converts current color in rgb space to HSV values
  4985. * @returns a new color3 representing the HSV values
  4986. */
  4987. toHSV(): Color3;
  4988. /**
  4989. * Converts current color in rgb space to HSV values
  4990. * @param result defines the Color3 where to store the HSV values
  4991. */
  4992. toHSVToRef(result: Color3): void;
  4993. /**
  4994. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  4995. * @param convertedColor defines the Color3 object where to store the linear space version
  4996. * @returns the unmodified Color3
  4997. */
  4998. toLinearSpaceToRef(convertedColor: Color3): Color3;
  4999. /**
  5000. * Computes a new Color3 converted from the current one to gamma space
  5001. * @returns a new Color3 object
  5002. */
  5003. toGammaSpace(): Color3;
  5004. /**
  5005. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5006. * @param convertedColor defines the Color3 object where to store the gamma space version
  5007. * @returns the unmodified Color3
  5008. */
  5009. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5010. private static _BlackReadOnly;
  5011. /**
  5012. * Convert Hue, saturation and value to a Color3 (RGB)
  5013. * @param hue defines the hue
  5014. * @param saturation defines the saturation
  5015. * @param value defines the value
  5016. * @param result defines the Color3 where to store the RGB values
  5017. */
  5018. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5019. /**
  5020. * Creates a new Color3 from the string containing valid hexadecimal values
  5021. * @param hex defines a string containing valid hexadecimal values
  5022. * @returns a new Color3 object
  5023. */
  5024. static FromHexString(hex: string): Color3;
  5025. /**
  5026. * Creates a new Color3 from the starting index of the given array
  5027. * @param array defines the source array
  5028. * @param offset defines an offset in the source array
  5029. * @returns a new Color3 object
  5030. */
  5031. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5032. /**
  5033. * Creates a new Color3 from integer values (< 256)
  5034. * @param r defines the red component to read from (value between 0 and 255)
  5035. * @param g defines the green component to read from (value between 0 and 255)
  5036. * @param b defines the blue component to read from (value between 0 and 255)
  5037. * @returns a new Color3 object
  5038. */
  5039. static FromInts(r: number, g: number, b: number): Color3;
  5040. /**
  5041. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5042. * @param start defines the start Color3 value
  5043. * @param end defines the end Color3 value
  5044. * @param amount defines the gradient value between start and end
  5045. * @returns a new Color3 object
  5046. */
  5047. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5048. /**
  5049. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5050. * @param left defines the start value
  5051. * @param right defines the end value
  5052. * @param amount defines the gradient factor
  5053. * @param result defines the Color3 object where to store the result
  5054. */
  5055. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5056. /**
  5057. * Returns a Color3 value containing a red color
  5058. * @returns a new Color3 object
  5059. */
  5060. static Red(): Color3;
  5061. /**
  5062. * Returns a Color3 value containing a green color
  5063. * @returns a new Color3 object
  5064. */
  5065. static Green(): Color3;
  5066. /**
  5067. * Returns a Color3 value containing a blue color
  5068. * @returns a new Color3 object
  5069. */
  5070. static Blue(): Color3;
  5071. /**
  5072. * Returns a Color3 value containing a black color
  5073. * @returns a new Color3 object
  5074. */
  5075. static Black(): Color3;
  5076. /**
  5077. * Gets a Color3 value containing a black color that must not be updated
  5078. */
  5079. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5080. /**
  5081. * Returns a Color3 value containing a white color
  5082. * @returns a new Color3 object
  5083. */
  5084. static White(): Color3;
  5085. /**
  5086. * Returns a Color3 value containing a purple color
  5087. * @returns a new Color3 object
  5088. */
  5089. static Purple(): Color3;
  5090. /**
  5091. * Returns a Color3 value containing a magenta color
  5092. * @returns a new Color3 object
  5093. */
  5094. static Magenta(): Color3;
  5095. /**
  5096. * Returns a Color3 value containing a yellow color
  5097. * @returns a new Color3 object
  5098. */
  5099. static Yellow(): Color3;
  5100. /**
  5101. * Returns a Color3 value containing a gray color
  5102. * @returns a new Color3 object
  5103. */
  5104. static Gray(): Color3;
  5105. /**
  5106. * Returns a Color3 value containing a teal color
  5107. * @returns a new Color3 object
  5108. */
  5109. static Teal(): Color3;
  5110. /**
  5111. * Returns a Color3 value containing a random color
  5112. * @returns a new Color3 object
  5113. */
  5114. static Random(): Color3;
  5115. }
  5116. /**
  5117. * Class used to hold a RBGA color
  5118. */
  5119. export class Color4 {
  5120. /**
  5121. * Defines the red component (between 0 and 1, default is 0)
  5122. */
  5123. r: number;
  5124. /**
  5125. * Defines the green component (between 0 and 1, default is 0)
  5126. */
  5127. g: number;
  5128. /**
  5129. * Defines the blue component (between 0 and 1, default is 0)
  5130. */
  5131. b: number;
  5132. /**
  5133. * Defines the alpha component (between 0 and 1, default is 1)
  5134. */
  5135. a: number;
  5136. /**
  5137. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5138. * @param r defines the red component (between 0 and 1, default is 0)
  5139. * @param g defines the green component (between 0 and 1, default is 0)
  5140. * @param b defines the blue component (between 0 and 1, default is 0)
  5141. * @param a defines the alpha component (between 0 and 1, default is 1)
  5142. */
  5143. constructor(
  5144. /**
  5145. * Defines the red component (between 0 and 1, default is 0)
  5146. */
  5147. r?: number,
  5148. /**
  5149. * Defines the green component (between 0 and 1, default is 0)
  5150. */
  5151. g?: number,
  5152. /**
  5153. * Defines the blue component (between 0 and 1, default is 0)
  5154. */
  5155. b?: number,
  5156. /**
  5157. * Defines the alpha component (between 0 and 1, default is 1)
  5158. */
  5159. a?: number);
  5160. /**
  5161. * Adds in place the given Color4 values to the current Color4 object
  5162. * @param right defines the second operand
  5163. * @returns the current updated Color4 object
  5164. */
  5165. addInPlace(right: DeepImmutable<Color4>): Color4;
  5166. /**
  5167. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5168. * @returns the new array
  5169. */
  5170. asArray(): number[];
  5171. /**
  5172. * Stores from the starting index in the given array the Color4 successive values
  5173. * @param array defines the array where to store the r,g,b components
  5174. * @param index defines an optional index in the target array to define where to start storing values
  5175. * @returns the current Color4 object
  5176. */
  5177. toArray(array: number[], index?: number): Color4;
  5178. /**
  5179. * Determines equality between Color4 objects
  5180. * @param otherColor defines the second operand
  5181. * @returns true if the rgba values are equal to the given ones
  5182. */
  5183. equals(otherColor: DeepImmutable<Color4>): boolean;
  5184. /**
  5185. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5186. * @param right defines the second operand
  5187. * @returns a new Color4 object
  5188. */
  5189. add(right: DeepImmutable<Color4>): Color4;
  5190. /**
  5191. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5192. * @param right defines the second operand
  5193. * @returns a new Color4 object
  5194. */
  5195. subtract(right: DeepImmutable<Color4>): Color4;
  5196. /**
  5197. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5198. * @param right defines the second operand
  5199. * @param result defines the Color4 object where to store the result
  5200. * @returns the current Color4 object
  5201. */
  5202. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5203. /**
  5204. * Creates a new Color4 with the current Color4 values multiplied by scale
  5205. * @param scale defines the scaling factor to apply
  5206. * @returns a new Color4 object
  5207. */
  5208. scale(scale: number): Color4;
  5209. /**
  5210. * Multiplies the current Color4 values by scale and stores the result in "result"
  5211. * @param scale defines the scaling factor to apply
  5212. * @param result defines the Color4 object where to store the result
  5213. * @returns the current unmodified Color4
  5214. */
  5215. scaleToRef(scale: number, result: Color4): Color4;
  5216. /**
  5217. * Scale the current Color4 values by a factor and add the result to a given Color4
  5218. * @param scale defines the scale factor
  5219. * @param result defines the Color4 object where to store the result
  5220. * @returns the unmodified current Color4
  5221. */
  5222. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5223. /**
  5224. * Clamps the rgb values by the min and max values and stores the result into "result"
  5225. * @param min defines minimum clamping value (default is 0)
  5226. * @param max defines maximum clamping value (default is 1)
  5227. * @param result defines color to store the result into.
  5228. * @returns the cuurent Color4
  5229. */
  5230. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5231. /**
  5232. * Multipy an Color4 value by another and return a new Color4 object
  5233. * @param color defines the Color4 value to multiply by
  5234. * @returns a new Color4 object
  5235. */
  5236. multiply(color: Color4): Color4;
  5237. /**
  5238. * Multipy a Color4 value by another and push the result in a reference value
  5239. * @param color defines the Color4 value to multiply by
  5240. * @param result defines the Color4 to fill the result in
  5241. * @returns the result Color4
  5242. */
  5243. multiplyToRef(color: Color4, result: Color4): Color4;
  5244. /**
  5245. * Creates a string with the Color4 current values
  5246. * @returns the string representation of the Color4 object
  5247. */
  5248. toString(): string;
  5249. /**
  5250. * Returns the string "Color4"
  5251. * @returns "Color4"
  5252. */
  5253. getClassName(): string;
  5254. /**
  5255. * Compute the Color4 hash code
  5256. * @returns an unique number that can be used to hash Color4 objects
  5257. */
  5258. getHashCode(): number;
  5259. /**
  5260. * Creates a new Color4 copied from the current one
  5261. * @returns a new Color4 object
  5262. */
  5263. clone(): Color4;
  5264. /**
  5265. * Copies the given Color4 values into the current one
  5266. * @param source defines the source Color4 object
  5267. * @returns the current updated Color4 object
  5268. */
  5269. copyFrom(source: Color4): Color4;
  5270. /**
  5271. * Copies the given float values into the current one
  5272. * @param r defines the red component to read from
  5273. * @param g defines the green component to read from
  5274. * @param b defines the blue component to read from
  5275. * @param a defines the alpha component to read from
  5276. * @returns the current updated Color4 object
  5277. */
  5278. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5279. /**
  5280. * Copies the given float values into the current one
  5281. * @param r defines the red component to read from
  5282. * @param g defines the green component to read from
  5283. * @param b defines the blue component to read from
  5284. * @param a defines the alpha component to read from
  5285. * @returns the current updated Color4 object
  5286. */
  5287. set(r: number, g: number, b: number, a: number): Color4;
  5288. /**
  5289. * Compute the Color4 hexadecimal code as a string
  5290. * @returns a string containing the hexadecimal representation of the Color4 object
  5291. */
  5292. toHexString(): string;
  5293. /**
  5294. * Computes a new Color4 converted from the current one to linear space
  5295. * @returns a new Color4 object
  5296. */
  5297. toLinearSpace(): Color4;
  5298. /**
  5299. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5300. * @param convertedColor defines the Color4 object where to store the linear space version
  5301. * @returns the unmodified Color4
  5302. */
  5303. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5304. /**
  5305. * Computes a new Color4 converted from the current one to gamma space
  5306. * @returns a new Color4 object
  5307. */
  5308. toGammaSpace(): Color4;
  5309. /**
  5310. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5311. * @param convertedColor defines the Color4 object where to store the gamma space version
  5312. * @returns the unmodified Color4
  5313. */
  5314. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5315. /**
  5316. * Creates a new Color4 from the string containing valid hexadecimal values
  5317. * @param hex defines a string containing valid hexadecimal values
  5318. * @returns a new Color4 object
  5319. */
  5320. static FromHexString(hex: string): Color4;
  5321. /**
  5322. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5323. * @param left defines the start value
  5324. * @param right defines the end value
  5325. * @param amount defines the gradient factor
  5326. * @returns a new Color4 object
  5327. */
  5328. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5329. /**
  5330. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5331. * @param left defines the start value
  5332. * @param right defines the end value
  5333. * @param amount defines the gradient factor
  5334. * @param result defines the Color4 object where to store data
  5335. */
  5336. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5337. /**
  5338. * Creates a new Color4 from a Color3 and an alpha value
  5339. * @param color3 defines the source Color3 to read from
  5340. * @param alpha defines the alpha component (1.0 by default)
  5341. * @returns a new Color4 object
  5342. */
  5343. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5344. /**
  5345. * Creates a new Color4 from the starting index element of the given array
  5346. * @param array defines the source array to read from
  5347. * @param offset defines the offset in the source array
  5348. * @returns a new Color4 object
  5349. */
  5350. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5351. /**
  5352. * Creates a new Color3 from integer values (< 256)
  5353. * @param r defines the red component to read from (value between 0 and 255)
  5354. * @param g defines the green component to read from (value between 0 and 255)
  5355. * @param b defines the blue component to read from (value between 0 and 255)
  5356. * @param a defines the alpha component to read from (value between 0 and 255)
  5357. * @returns a new Color3 object
  5358. */
  5359. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5360. /**
  5361. * Check the content of a given array and convert it to an array containing RGBA data
  5362. * If the original array was already containing count * 4 values then it is returned directly
  5363. * @param colors defines the array to check
  5364. * @param count defines the number of RGBA data to expect
  5365. * @returns an array containing count * 4 values (RGBA)
  5366. */
  5367. static CheckColors4(colors: number[], count: number): number[];
  5368. }
  5369. /**
  5370. * @hidden
  5371. */
  5372. export class TmpColors {
  5373. static Color3: Color3[];
  5374. static Color4: Color4[];
  5375. }
  5376. }
  5377. declare module BABYLON {
  5378. /**
  5379. * Class representing spherical harmonics coefficients to the 3rd degree
  5380. */
  5381. export class SphericalHarmonics {
  5382. /**
  5383. * Defines whether or not the harmonics have been prescaled for rendering.
  5384. */
  5385. preScaled: boolean;
  5386. /**
  5387. * The l0,0 coefficients of the spherical harmonics
  5388. */
  5389. l00: Vector3;
  5390. /**
  5391. * The l1,-1 coefficients of the spherical harmonics
  5392. */
  5393. l1_1: Vector3;
  5394. /**
  5395. * The l1,0 coefficients of the spherical harmonics
  5396. */
  5397. l10: Vector3;
  5398. /**
  5399. * The l1,1 coefficients of the spherical harmonics
  5400. */
  5401. l11: Vector3;
  5402. /**
  5403. * The l2,-2 coefficients of the spherical harmonics
  5404. */
  5405. l2_2: Vector3;
  5406. /**
  5407. * The l2,-1 coefficients of the spherical harmonics
  5408. */
  5409. l2_1: Vector3;
  5410. /**
  5411. * The l2,0 coefficients of the spherical harmonics
  5412. */
  5413. l20: Vector3;
  5414. /**
  5415. * The l2,1 coefficients of the spherical harmonics
  5416. */
  5417. l21: Vector3;
  5418. /**
  5419. * The l2,2 coefficients of the spherical harmonics
  5420. */
  5421. l22: Vector3;
  5422. /**
  5423. * Adds a light to the spherical harmonics
  5424. * @param direction the direction of the light
  5425. * @param color the color of the light
  5426. * @param deltaSolidAngle the delta solid angle of the light
  5427. */
  5428. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5429. /**
  5430. * Scales the spherical harmonics by the given amount
  5431. * @param scale the amount to scale
  5432. */
  5433. scaleInPlace(scale: number): void;
  5434. /**
  5435. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5436. *
  5437. * ```
  5438. * E_lm = A_l * L_lm
  5439. * ```
  5440. *
  5441. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5442. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5443. * the scaling factors are given in equation 9.
  5444. */
  5445. convertIncidentRadianceToIrradiance(): void;
  5446. /**
  5447. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5448. *
  5449. * ```
  5450. * L = (1/pi) * E * rho
  5451. * ```
  5452. *
  5453. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5454. */
  5455. convertIrradianceToLambertianRadiance(): void;
  5456. /**
  5457. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5458. * required operations at run time.
  5459. *
  5460. * This is simply done by scaling back the SH with Ylm constants parameter.
  5461. * The trigonometric part being applied by the shader at run time.
  5462. */
  5463. preScaleForRendering(): void;
  5464. /**
  5465. * Constructs a spherical harmonics from an array.
  5466. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5467. * @returns the spherical harmonics
  5468. */
  5469. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5470. /**
  5471. * Gets the spherical harmonics from polynomial
  5472. * @param polynomial the spherical polynomial
  5473. * @returns the spherical harmonics
  5474. */
  5475. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5476. }
  5477. /**
  5478. * Class representing spherical polynomial coefficients to the 3rd degree
  5479. */
  5480. export class SphericalPolynomial {
  5481. private _harmonics;
  5482. /**
  5483. * The spherical harmonics used to create the polynomials.
  5484. */
  5485. readonly preScaledHarmonics: SphericalHarmonics;
  5486. /**
  5487. * The x coefficients of the spherical polynomial
  5488. */
  5489. x: Vector3;
  5490. /**
  5491. * The y coefficients of the spherical polynomial
  5492. */
  5493. y: Vector3;
  5494. /**
  5495. * The z coefficients of the spherical polynomial
  5496. */
  5497. z: Vector3;
  5498. /**
  5499. * The xx coefficients of the spherical polynomial
  5500. */
  5501. xx: Vector3;
  5502. /**
  5503. * The yy coefficients of the spherical polynomial
  5504. */
  5505. yy: Vector3;
  5506. /**
  5507. * The zz coefficients of the spherical polynomial
  5508. */
  5509. zz: Vector3;
  5510. /**
  5511. * The xy coefficients of the spherical polynomial
  5512. */
  5513. xy: Vector3;
  5514. /**
  5515. * The yz coefficients of the spherical polynomial
  5516. */
  5517. yz: Vector3;
  5518. /**
  5519. * The zx coefficients of the spherical polynomial
  5520. */
  5521. zx: Vector3;
  5522. /**
  5523. * Adds an ambient color to the spherical polynomial
  5524. * @param color the color to add
  5525. */
  5526. addAmbient(color: Color3): void;
  5527. /**
  5528. * Scales the spherical polynomial by the given amount
  5529. * @param scale the amount to scale
  5530. */
  5531. scaleInPlace(scale: number): void;
  5532. /**
  5533. * Gets the spherical polynomial from harmonics
  5534. * @param harmonics the spherical harmonics
  5535. * @returns the spherical polynomial
  5536. */
  5537. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5538. /**
  5539. * Constructs a spherical polynomial from an array.
  5540. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5541. * @returns the spherical polynomial
  5542. */
  5543. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5544. }
  5545. }
  5546. declare module BABYLON {
  5547. /**
  5548. * Define options used to create a render target texture
  5549. */
  5550. export class RenderTargetCreationOptions {
  5551. /**
  5552. * Specifies is mipmaps must be generated
  5553. */
  5554. generateMipMaps?: boolean;
  5555. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5556. generateDepthBuffer?: boolean;
  5557. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5558. generateStencilBuffer?: boolean;
  5559. /** Defines texture type (int by default) */
  5560. type?: number;
  5561. /** Defines sampling mode (trilinear by default) */
  5562. samplingMode?: number;
  5563. /** Defines format (RGBA by default) */
  5564. format?: number;
  5565. }
  5566. }
  5567. declare module BABYLON {
  5568. /**
  5569. * @hidden
  5570. **/
  5571. export class _AlphaState {
  5572. private _isAlphaBlendDirty;
  5573. private _isBlendFunctionParametersDirty;
  5574. private _isBlendEquationParametersDirty;
  5575. private _isBlendConstantsDirty;
  5576. private _alphaBlend;
  5577. private _blendFunctionParameters;
  5578. private _blendEquationParameters;
  5579. private _blendConstants;
  5580. /**
  5581. * Initializes the state.
  5582. */
  5583. constructor();
  5584. readonly isDirty: boolean;
  5585. alphaBlend: boolean;
  5586. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5587. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5588. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5589. reset(): void;
  5590. apply(gl: WebGLRenderingContext): void;
  5591. }
  5592. }
  5593. declare module BABYLON {
  5594. /**
  5595. * @hidden
  5596. **/
  5597. export class _DepthCullingState {
  5598. private _isDepthTestDirty;
  5599. private _isDepthMaskDirty;
  5600. private _isDepthFuncDirty;
  5601. private _isCullFaceDirty;
  5602. private _isCullDirty;
  5603. private _isZOffsetDirty;
  5604. private _isFrontFaceDirty;
  5605. private _depthTest;
  5606. private _depthMask;
  5607. private _depthFunc;
  5608. private _cull;
  5609. private _cullFace;
  5610. private _zOffset;
  5611. private _frontFace;
  5612. /**
  5613. * Initializes the state.
  5614. */
  5615. constructor();
  5616. readonly isDirty: boolean;
  5617. zOffset: number;
  5618. cullFace: Nullable<number>;
  5619. cull: Nullable<boolean>;
  5620. depthFunc: Nullable<number>;
  5621. depthMask: boolean;
  5622. depthTest: boolean;
  5623. frontFace: Nullable<number>;
  5624. reset(): void;
  5625. apply(gl: WebGLRenderingContext): void;
  5626. }
  5627. }
  5628. declare module BABYLON {
  5629. /**
  5630. * @hidden
  5631. **/
  5632. export class _StencilState {
  5633. /** 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 */
  5634. static readonly ALWAYS: number;
  5635. /** Passed to stencilOperation to specify that stencil value must be kept */
  5636. static readonly KEEP: number;
  5637. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5638. static readonly REPLACE: number;
  5639. private _isStencilTestDirty;
  5640. private _isStencilMaskDirty;
  5641. private _isStencilFuncDirty;
  5642. private _isStencilOpDirty;
  5643. private _stencilTest;
  5644. private _stencilMask;
  5645. private _stencilFunc;
  5646. private _stencilFuncRef;
  5647. private _stencilFuncMask;
  5648. private _stencilOpStencilFail;
  5649. private _stencilOpDepthFail;
  5650. private _stencilOpStencilDepthPass;
  5651. readonly isDirty: boolean;
  5652. stencilFunc: number;
  5653. stencilFuncRef: number;
  5654. stencilFuncMask: number;
  5655. stencilOpStencilFail: number;
  5656. stencilOpDepthFail: number;
  5657. stencilOpStencilDepthPass: number;
  5658. stencilMask: number;
  5659. stencilTest: boolean;
  5660. constructor();
  5661. reset(): void;
  5662. apply(gl: WebGLRenderingContext): void;
  5663. }
  5664. }
  5665. declare module BABYLON {
  5666. /**
  5667. * @hidden
  5668. **/
  5669. export class _TimeToken {
  5670. _startTimeQuery: Nullable<WebGLQuery>;
  5671. _endTimeQuery: Nullable<WebGLQuery>;
  5672. _timeElapsedQuery: Nullable<WebGLQuery>;
  5673. _timeElapsedQueryEnded: boolean;
  5674. }
  5675. }
  5676. declare module BABYLON {
  5677. /**
  5678. * Class used to evalaute queries containing `and` and `or` operators
  5679. */
  5680. export class AndOrNotEvaluator {
  5681. /**
  5682. * Evaluate a query
  5683. * @param query defines the query to evaluate
  5684. * @param evaluateCallback defines the callback used to filter result
  5685. * @returns true if the query matches
  5686. */
  5687. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5688. private static _HandleParenthesisContent;
  5689. private static _SimplifyNegation;
  5690. }
  5691. }
  5692. declare module BABYLON {
  5693. /**
  5694. * Class used to store custom tags
  5695. */
  5696. export class Tags {
  5697. /**
  5698. * Adds support for tags on the given object
  5699. * @param obj defines the object to use
  5700. */
  5701. static EnableFor(obj: any): void;
  5702. /**
  5703. * Removes tags support
  5704. * @param obj defines the object to use
  5705. */
  5706. static DisableFor(obj: any): void;
  5707. /**
  5708. * Gets a boolean indicating if the given object has tags
  5709. * @param obj defines the object to use
  5710. * @returns a boolean
  5711. */
  5712. static HasTags(obj: any): boolean;
  5713. /**
  5714. * Gets the tags available on a given object
  5715. * @param obj defines the object to use
  5716. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5717. * @returns the tags
  5718. */
  5719. static GetTags(obj: any, asString?: boolean): any;
  5720. /**
  5721. * Adds tags to an object
  5722. * @param obj defines the object to use
  5723. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5724. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5725. */
  5726. static AddTagsTo(obj: any, tagsString: string): void;
  5727. /**
  5728. * @hidden
  5729. */
  5730. static _AddTagTo(obj: any, tag: string): void;
  5731. /**
  5732. * Removes specific tags from a specific object
  5733. * @param obj defines the object to use
  5734. * @param tagsString defines the tags to remove
  5735. */
  5736. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5737. /**
  5738. * @hidden
  5739. */
  5740. static _RemoveTagFrom(obj: any, tag: string): void;
  5741. /**
  5742. * Defines if tags hosted on an object match a given query
  5743. * @param obj defines the object to use
  5744. * @param tagsQuery defines the tag query
  5745. * @returns a boolean
  5746. */
  5747. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5748. }
  5749. }
  5750. declare module BABYLON {
  5751. /**
  5752. * Defines potential orientation for back face culling
  5753. */
  5754. export enum Orientation {
  5755. /**
  5756. * Clockwise
  5757. */
  5758. CW = 0,
  5759. /** Counter clockwise */
  5760. CCW = 1
  5761. }
  5762. /** Class used to represent a Bezier curve */
  5763. export class BezierCurve {
  5764. /**
  5765. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5766. * @param t defines the time
  5767. * @param x1 defines the left coordinate on X axis
  5768. * @param y1 defines the left coordinate on Y axis
  5769. * @param x2 defines the right coordinate on X axis
  5770. * @param y2 defines the right coordinate on Y axis
  5771. * @returns the interpolated value
  5772. */
  5773. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5774. }
  5775. /**
  5776. * Defines angle representation
  5777. */
  5778. export class Angle {
  5779. private _radians;
  5780. /**
  5781. * Creates an Angle object of "radians" radians (float).
  5782. * @param radians the angle in radians
  5783. */
  5784. constructor(radians: number);
  5785. /**
  5786. * Get value in degrees
  5787. * @returns the Angle value in degrees (float)
  5788. */
  5789. degrees(): number;
  5790. /**
  5791. * Get value in radians
  5792. * @returns the Angle value in radians (float)
  5793. */
  5794. radians(): number;
  5795. /**
  5796. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5797. * @param a defines first vector
  5798. * @param b defines second vector
  5799. * @returns a new Angle
  5800. */
  5801. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5802. /**
  5803. * Gets a new Angle object from the given float in radians
  5804. * @param radians defines the angle value in radians
  5805. * @returns a new Angle
  5806. */
  5807. static FromRadians(radians: number): Angle;
  5808. /**
  5809. * Gets a new Angle object from the given float in degrees
  5810. * @param degrees defines the angle value in degrees
  5811. * @returns a new Angle
  5812. */
  5813. static FromDegrees(degrees: number): Angle;
  5814. }
  5815. /**
  5816. * This represents an arc in a 2d space.
  5817. */
  5818. export class Arc2 {
  5819. /** Defines the start point of the arc */
  5820. startPoint: Vector2;
  5821. /** Defines the mid point of the arc */
  5822. midPoint: Vector2;
  5823. /** Defines the end point of the arc */
  5824. endPoint: Vector2;
  5825. /**
  5826. * Defines the center point of the arc.
  5827. */
  5828. centerPoint: Vector2;
  5829. /**
  5830. * Defines the radius of the arc.
  5831. */
  5832. radius: number;
  5833. /**
  5834. * Defines the angle of the arc (from mid point to end point).
  5835. */
  5836. angle: Angle;
  5837. /**
  5838. * Defines the start angle of the arc (from start point to middle point).
  5839. */
  5840. startAngle: Angle;
  5841. /**
  5842. * Defines the orientation of the arc (clock wise/counter clock wise).
  5843. */
  5844. orientation: Orientation;
  5845. /**
  5846. * Creates an Arc object from the three given points : start, middle and end.
  5847. * @param startPoint Defines the start point of the arc
  5848. * @param midPoint Defines the midlle point of the arc
  5849. * @param endPoint Defines the end point of the arc
  5850. */
  5851. constructor(
  5852. /** Defines the start point of the arc */
  5853. startPoint: Vector2,
  5854. /** Defines the mid point of the arc */
  5855. midPoint: Vector2,
  5856. /** Defines the end point of the arc */
  5857. endPoint: Vector2);
  5858. }
  5859. /**
  5860. * Represents a 2D path made up of multiple 2D points
  5861. */
  5862. export class Path2 {
  5863. private _points;
  5864. private _length;
  5865. /**
  5866. * If the path start and end point are the same
  5867. */
  5868. closed: boolean;
  5869. /**
  5870. * Creates a Path2 object from the starting 2D coordinates x and y.
  5871. * @param x the starting points x value
  5872. * @param y the starting points y value
  5873. */
  5874. constructor(x: number, y: number);
  5875. /**
  5876. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5877. * @param x the added points x value
  5878. * @param y the added points y value
  5879. * @returns the updated Path2.
  5880. */
  5881. addLineTo(x: number, y: number): Path2;
  5882. /**
  5883. * 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.
  5884. * @param midX middle point x value
  5885. * @param midY middle point y value
  5886. * @param endX end point x value
  5887. * @param endY end point y value
  5888. * @param numberOfSegments (default: 36)
  5889. * @returns the updated Path2.
  5890. */
  5891. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5892. /**
  5893. * Closes the Path2.
  5894. * @returns the Path2.
  5895. */
  5896. close(): Path2;
  5897. /**
  5898. * Gets the sum of the distance between each sequential point in the path
  5899. * @returns the Path2 total length (float).
  5900. */
  5901. length(): number;
  5902. /**
  5903. * Gets the points which construct the path
  5904. * @returns the Path2 internal array of points.
  5905. */
  5906. getPoints(): Vector2[];
  5907. /**
  5908. * Retreives the point at the distance aways from the starting point
  5909. * @param normalizedLengthPosition the length along the path to retreive the point from
  5910. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5911. */
  5912. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5913. /**
  5914. * Creates a new path starting from an x and y position
  5915. * @param x starting x value
  5916. * @param y starting y value
  5917. * @returns a new Path2 starting at the coordinates (x, y).
  5918. */
  5919. static StartingAt(x: number, y: number): Path2;
  5920. }
  5921. /**
  5922. * Represents a 3D path made up of multiple 3D points
  5923. */
  5924. export class Path3D {
  5925. /**
  5926. * an array of Vector3, the curve axis of the Path3D
  5927. */
  5928. path: Vector3[];
  5929. private _curve;
  5930. private _distances;
  5931. private _tangents;
  5932. private _normals;
  5933. private _binormals;
  5934. private _raw;
  5935. /**
  5936. * new Path3D(path, normal, raw)
  5937. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5938. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5939. * @param path an array of Vector3, the curve axis of the Path3D
  5940. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5941. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5942. */
  5943. constructor(
  5944. /**
  5945. * an array of Vector3, the curve axis of the Path3D
  5946. */
  5947. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5948. /**
  5949. * Returns the Path3D array of successive Vector3 designing its curve.
  5950. * @returns the Path3D array of successive Vector3 designing its curve.
  5951. */
  5952. getCurve(): Vector3[];
  5953. /**
  5954. * Returns an array populated with tangent vectors on each Path3D curve point.
  5955. * @returns an array populated with tangent vectors on each Path3D curve point.
  5956. */
  5957. getTangents(): Vector3[];
  5958. /**
  5959. * Returns an array populated with normal vectors on each Path3D curve point.
  5960. * @returns an array populated with normal vectors on each Path3D curve point.
  5961. */
  5962. getNormals(): Vector3[];
  5963. /**
  5964. * Returns an array populated with binormal vectors on each Path3D curve point.
  5965. * @returns an array populated with binormal vectors on each Path3D curve point.
  5966. */
  5967. getBinormals(): Vector3[];
  5968. /**
  5969. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5970. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5971. */
  5972. getDistances(): number[];
  5973. /**
  5974. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5975. * @param path path which all values are copied into the curves points
  5976. * @param firstNormal which should be projected onto the curve
  5977. * @returns the same object updated.
  5978. */
  5979. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  5980. private _compute;
  5981. private _getFirstNonNullVector;
  5982. private _getLastNonNullVector;
  5983. private _normalVector;
  5984. }
  5985. /**
  5986. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5987. * A Curve3 is designed from a series of successive Vector3.
  5988. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5989. */
  5990. export class Curve3 {
  5991. private _points;
  5992. private _length;
  5993. /**
  5994. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5995. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5996. * @param v1 (Vector3) the control point
  5997. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5998. * @param nbPoints (integer) the wanted number of points in the curve
  5999. * @returns the created Curve3
  6000. */
  6001. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6002. /**
  6003. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  6004. * @param v0 (Vector3) the origin point of the Cubic Bezier
  6005. * @param v1 (Vector3) the first control point
  6006. * @param v2 (Vector3) the second control point
  6007. * @param v3 (Vector3) the end point of the Cubic Bezier
  6008. * @param nbPoints (integer) the wanted number of points in the curve
  6009. * @returns the created Curve3
  6010. */
  6011. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6012. /**
  6013. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  6014. * @param p1 (Vector3) the origin point of the Hermite Spline
  6015. * @param t1 (Vector3) the tangent vector at the origin point
  6016. * @param p2 (Vector3) the end point of the Hermite Spline
  6017. * @param t2 (Vector3) the tangent vector at the end point
  6018. * @param nbPoints (integer) the wanted number of points in the curve
  6019. * @returns the created Curve3
  6020. */
  6021. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6022. /**
  6023. * Returns a Curve3 object along a CatmullRom Spline curve :
  6024. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  6025. * @param nbPoints (integer) the wanted number of points between each curve control points
  6026. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  6027. * @returns the created Curve3
  6028. */
  6029. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  6030. /**
  6031. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6032. * A Curve3 is designed from a series of successive Vector3.
  6033. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  6034. * @param points points which make up the curve
  6035. */
  6036. constructor(points: Vector3[]);
  6037. /**
  6038. * @returns the Curve3 stored array of successive Vector3
  6039. */
  6040. getPoints(): Vector3[];
  6041. /**
  6042. * @returns the computed length (float) of the curve.
  6043. */
  6044. length(): number;
  6045. /**
  6046. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  6047. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  6048. * curveA and curveB keep unchanged.
  6049. * @param curve the curve to continue from this curve
  6050. * @returns the newly constructed curve
  6051. */
  6052. continue(curve: DeepImmutable<Curve3>): Curve3;
  6053. private _computeLength;
  6054. }
  6055. }
  6056. declare module BABYLON {
  6057. /**
  6058. * This represents the main contract an easing function should follow.
  6059. * Easing functions are used throughout the animation system.
  6060. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6061. */
  6062. export interface IEasingFunction {
  6063. /**
  6064. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6065. * of the easing function.
  6066. * The link below provides some of the most common examples of easing functions.
  6067. * @see https://easings.net/
  6068. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6069. * @returns the corresponding value on the curve defined by the easing function
  6070. */
  6071. ease(gradient: number): number;
  6072. }
  6073. /**
  6074. * Base class used for every default easing function.
  6075. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6076. */
  6077. export class EasingFunction implements IEasingFunction {
  6078. /**
  6079. * Interpolation follows the mathematical formula associated with the easing function.
  6080. */
  6081. static readonly EASINGMODE_EASEIN: number;
  6082. /**
  6083. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6084. */
  6085. static readonly EASINGMODE_EASEOUT: number;
  6086. /**
  6087. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6088. */
  6089. static readonly EASINGMODE_EASEINOUT: number;
  6090. private _easingMode;
  6091. /**
  6092. * Sets the easing mode of the current function.
  6093. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6094. */
  6095. setEasingMode(easingMode: number): void;
  6096. /**
  6097. * Gets the current easing mode.
  6098. * @returns the easing mode
  6099. */
  6100. getEasingMode(): number;
  6101. /**
  6102. * @hidden
  6103. */
  6104. easeInCore(gradient: number): number;
  6105. /**
  6106. * Given an input gradient between 0 and 1, this returns the corresponding value
  6107. * of the easing function.
  6108. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6109. * @returns the corresponding value on the curve defined by the easing function
  6110. */
  6111. ease(gradient: number): number;
  6112. }
  6113. /**
  6114. * Easing function with a circle shape (see link below).
  6115. * @see https://easings.net/#easeInCirc
  6116. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6117. */
  6118. export class CircleEase extends EasingFunction implements IEasingFunction {
  6119. /** @hidden */
  6120. easeInCore(gradient: number): number;
  6121. }
  6122. /**
  6123. * Easing function with a ease back shape (see link below).
  6124. * @see https://easings.net/#easeInBack
  6125. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6126. */
  6127. export class BackEase extends EasingFunction implements IEasingFunction {
  6128. /** Defines the amplitude of the function */
  6129. amplitude: number;
  6130. /**
  6131. * Instantiates a back ease easing
  6132. * @see https://easings.net/#easeInBack
  6133. * @param amplitude Defines the amplitude of the function
  6134. */
  6135. constructor(
  6136. /** Defines the amplitude of the function */
  6137. amplitude?: number);
  6138. /** @hidden */
  6139. easeInCore(gradient: number): number;
  6140. }
  6141. /**
  6142. * Easing function with a bouncing shape (see link below).
  6143. * @see https://easings.net/#easeInBounce
  6144. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6145. */
  6146. export class BounceEase extends EasingFunction implements IEasingFunction {
  6147. /** Defines the number of bounces */
  6148. bounces: number;
  6149. /** Defines the amplitude of the bounce */
  6150. bounciness: number;
  6151. /**
  6152. * Instantiates a bounce easing
  6153. * @see https://easings.net/#easeInBounce
  6154. * @param bounces Defines the number of bounces
  6155. * @param bounciness Defines the amplitude of the bounce
  6156. */
  6157. constructor(
  6158. /** Defines the number of bounces */
  6159. bounces?: number,
  6160. /** Defines the amplitude of the bounce */
  6161. bounciness?: number);
  6162. /** @hidden */
  6163. easeInCore(gradient: number): number;
  6164. }
  6165. /**
  6166. * Easing function with a power of 3 shape (see link below).
  6167. * @see https://easings.net/#easeInCubic
  6168. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6169. */
  6170. export class CubicEase extends EasingFunction implements IEasingFunction {
  6171. /** @hidden */
  6172. easeInCore(gradient: number): number;
  6173. }
  6174. /**
  6175. * Easing function with an elastic shape (see link below).
  6176. * @see https://easings.net/#easeInElastic
  6177. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6178. */
  6179. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6180. /** Defines the number of oscillations*/
  6181. oscillations: number;
  6182. /** Defines the amplitude of the oscillations*/
  6183. springiness: number;
  6184. /**
  6185. * Instantiates an elastic easing function
  6186. * @see https://easings.net/#easeInElastic
  6187. * @param oscillations Defines the number of oscillations
  6188. * @param springiness Defines the amplitude of the oscillations
  6189. */
  6190. constructor(
  6191. /** Defines the number of oscillations*/
  6192. oscillations?: number,
  6193. /** Defines the amplitude of the oscillations*/
  6194. springiness?: number);
  6195. /** @hidden */
  6196. easeInCore(gradient: number): number;
  6197. }
  6198. /**
  6199. * Easing function with an exponential shape (see link below).
  6200. * @see https://easings.net/#easeInExpo
  6201. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6202. */
  6203. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6204. /** Defines the exponent of the function */
  6205. exponent: number;
  6206. /**
  6207. * Instantiates an exponential easing function
  6208. * @see https://easings.net/#easeInExpo
  6209. * @param exponent Defines the exponent of the function
  6210. */
  6211. constructor(
  6212. /** Defines the exponent of the function */
  6213. exponent?: number);
  6214. /** @hidden */
  6215. easeInCore(gradient: number): number;
  6216. }
  6217. /**
  6218. * Easing function with a power shape (see link below).
  6219. * @see https://easings.net/#easeInQuad
  6220. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6221. */
  6222. export class PowerEase extends EasingFunction implements IEasingFunction {
  6223. /** Defines the power of the function */
  6224. power: number;
  6225. /**
  6226. * Instantiates an power base easing function
  6227. * @see https://easings.net/#easeInQuad
  6228. * @param power Defines the power of the function
  6229. */
  6230. constructor(
  6231. /** Defines the power of the function */
  6232. power?: number);
  6233. /** @hidden */
  6234. easeInCore(gradient: number): number;
  6235. }
  6236. /**
  6237. * Easing function with a power of 2 shape (see link below).
  6238. * @see https://easings.net/#easeInQuad
  6239. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6240. */
  6241. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6242. /** @hidden */
  6243. easeInCore(gradient: number): number;
  6244. }
  6245. /**
  6246. * Easing function with a power of 4 shape (see link below).
  6247. * @see https://easings.net/#easeInQuart
  6248. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6249. */
  6250. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6251. /** @hidden */
  6252. easeInCore(gradient: number): number;
  6253. }
  6254. /**
  6255. * Easing function with a power of 5 shape (see link below).
  6256. * @see https://easings.net/#easeInQuint
  6257. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6258. */
  6259. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6260. /** @hidden */
  6261. easeInCore(gradient: number): number;
  6262. }
  6263. /**
  6264. * Easing function with a sin shape (see link below).
  6265. * @see https://easings.net/#easeInSine
  6266. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6267. */
  6268. export class SineEase extends EasingFunction implements IEasingFunction {
  6269. /** @hidden */
  6270. easeInCore(gradient: number): number;
  6271. }
  6272. /**
  6273. * Easing function with a bezier shape (see link below).
  6274. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6275. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6276. */
  6277. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6278. /** Defines the x component of the start tangent in the bezier curve */
  6279. x1: number;
  6280. /** Defines the y component of the start tangent in the bezier curve */
  6281. y1: number;
  6282. /** Defines the x component of the end tangent in the bezier curve */
  6283. x2: number;
  6284. /** Defines the y component of the end tangent in the bezier curve */
  6285. y2: number;
  6286. /**
  6287. * Instantiates a bezier function
  6288. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6289. * @param x1 Defines the x component of the start tangent in the bezier curve
  6290. * @param y1 Defines the y component of the start tangent in the bezier curve
  6291. * @param x2 Defines the x component of the end tangent in the bezier curve
  6292. * @param y2 Defines the y component of the end tangent in the bezier curve
  6293. */
  6294. constructor(
  6295. /** Defines the x component of the start tangent in the bezier curve */
  6296. x1?: number,
  6297. /** Defines the y component of the start tangent in the bezier curve */
  6298. y1?: number,
  6299. /** Defines the x component of the end tangent in the bezier curve */
  6300. x2?: number,
  6301. /** Defines the y component of the end tangent in the bezier curve */
  6302. y2?: number);
  6303. /** @hidden */
  6304. easeInCore(gradient: number): number;
  6305. }
  6306. }
  6307. declare module BABYLON {
  6308. /**
  6309. * Defines an interface which represents an animation key frame
  6310. */
  6311. export interface IAnimationKey {
  6312. /**
  6313. * Frame of the key frame
  6314. */
  6315. frame: number;
  6316. /**
  6317. * Value at the specifies key frame
  6318. */
  6319. value: any;
  6320. /**
  6321. * The input tangent for the cubic hermite spline
  6322. */
  6323. inTangent?: any;
  6324. /**
  6325. * The output tangent for the cubic hermite spline
  6326. */
  6327. outTangent?: any;
  6328. /**
  6329. * The animation interpolation type
  6330. */
  6331. interpolation?: AnimationKeyInterpolation;
  6332. }
  6333. /**
  6334. * Enum for the animation key frame interpolation type
  6335. */
  6336. export enum AnimationKeyInterpolation {
  6337. /**
  6338. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6339. */
  6340. STEP = 1
  6341. }
  6342. }
  6343. declare module BABYLON {
  6344. /**
  6345. * Represents the range of an animation
  6346. */
  6347. export class AnimationRange {
  6348. /**The name of the animation range**/
  6349. name: string;
  6350. /**The starting frame of the animation */
  6351. from: number;
  6352. /**The ending frame of the animation*/
  6353. to: number;
  6354. /**
  6355. * Initializes the range of an animation
  6356. * @param name The name of the animation range
  6357. * @param from The starting frame of the animation
  6358. * @param to The ending frame of the animation
  6359. */
  6360. constructor(
  6361. /**The name of the animation range**/
  6362. name: string,
  6363. /**The starting frame of the animation */
  6364. from: number,
  6365. /**The ending frame of the animation*/
  6366. to: number);
  6367. /**
  6368. * Makes a copy of the animation range
  6369. * @returns A copy of the animation range
  6370. */
  6371. clone(): AnimationRange;
  6372. }
  6373. }
  6374. declare module BABYLON {
  6375. /**
  6376. * Composed of a frame, and an action function
  6377. */
  6378. export class AnimationEvent {
  6379. /** The frame for which the event is triggered **/
  6380. frame: number;
  6381. /** The event to perform when triggered **/
  6382. action: (currentFrame: number) => void;
  6383. /** Specifies if the event should be triggered only once**/
  6384. onlyOnce?: boolean | undefined;
  6385. /**
  6386. * Specifies if the animation event is done
  6387. */
  6388. isDone: boolean;
  6389. /**
  6390. * Initializes the animation event
  6391. * @param frame The frame for which the event is triggered
  6392. * @param action The event to perform when triggered
  6393. * @param onlyOnce Specifies if the event should be triggered only once
  6394. */
  6395. constructor(
  6396. /** The frame for which the event is triggered **/
  6397. frame: number,
  6398. /** The event to perform when triggered **/
  6399. action: (currentFrame: number) => void,
  6400. /** Specifies if the event should be triggered only once**/
  6401. onlyOnce?: boolean | undefined);
  6402. /** @hidden */
  6403. _clone(): AnimationEvent;
  6404. }
  6405. }
  6406. declare module BABYLON {
  6407. /**
  6408. * Interface used to define a behavior
  6409. */
  6410. export interface Behavior<T> {
  6411. /** gets or sets behavior's name */
  6412. name: string;
  6413. /**
  6414. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6415. */
  6416. init(): void;
  6417. /**
  6418. * Called when the behavior is attached to a target
  6419. * @param target defines the target where the behavior is attached to
  6420. */
  6421. attach(target: T): void;
  6422. /**
  6423. * Called when the behavior is detached from its target
  6424. */
  6425. detach(): void;
  6426. }
  6427. /**
  6428. * Interface implemented by classes supporting behaviors
  6429. */
  6430. export interface IBehaviorAware<T> {
  6431. /**
  6432. * Attach a behavior
  6433. * @param behavior defines the behavior to attach
  6434. * @returns the current host
  6435. */
  6436. addBehavior(behavior: Behavior<T>): T;
  6437. /**
  6438. * Remove a behavior from the current object
  6439. * @param behavior defines the behavior to detach
  6440. * @returns the current host
  6441. */
  6442. removeBehavior(behavior: Behavior<T>): T;
  6443. /**
  6444. * Gets a behavior using its name to search
  6445. * @param name defines the name to search
  6446. * @returns the behavior or null if not found
  6447. */
  6448. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6449. }
  6450. }
  6451. declare module BABYLON {
  6452. /**
  6453. * Defines an array and its length.
  6454. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6455. */
  6456. export interface ISmartArrayLike<T> {
  6457. /**
  6458. * The data of the array.
  6459. */
  6460. data: Array<T>;
  6461. /**
  6462. * The active length of the array.
  6463. */
  6464. length: number;
  6465. }
  6466. /**
  6467. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6468. */
  6469. export class SmartArray<T> implements ISmartArrayLike<T> {
  6470. /**
  6471. * The full set of data from the array.
  6472. */
  6473. data: Array<T>;
  6474. /**
  6475. * The active length of the array.
  6476. */
  6477. length: number;
  6478. protected _id: number;
  6479. /**
  6480. * Instantiates a Smart Array.
  6481. * @param capacity defines the default capacity of the array.
  6482. */
  6483. constructor(capacity: number);
  6484. /**
  6485. * Pushes a value at the end of the active data.
  6486. * @param value defines the object to push in the array.
  6487. */
  6488. push(value: T): void;
  6489. /**
  6490. * Iterates over the active data and apply the lambda to them.
  6491. * @param func defines the action to apply on each value.
  6492. */
  6493. forEach(func: (content: T) => void): void;
  6494. /**
  6495. * Sorts the full sets of data.
  6496. * @param compareFn defines the comparison function to apply.
  6497. */
  6498. sort(compareFn: (a: T, b: T) => number): void;
  6499. /**
  6500. * Resets the active data to an empty array.
  6501. */
  6502. reset(): void;
  6503. /**
  6504. * Releases all the data from the array as well as the array.
  6505. */
  6506. dispose(): void;
  6507. /**
  6508. * Concats the active data with a given array.
  6509. * @param array defines the data to concatenate with.
  6510. */
  6511. concat(array: any): void;
  6512. /**
  6513. * Returns the position of a value in the active data.
  6514. * @param value defines the value to find the index for
  6515. * @returns the index if found in the active data otherwise -1
  6516. */
  6517. indexOf(value: T): number;
  6518. /**
  6519. * Returns whether an element is part of the active data.
  6520. * @param value defines the value to look for
  6521. * @returns true if found in the active data otherwise false
  6522. */
  6523. contains(value: T): boolean;
  6524. private static _GlobalId;
  6525. }
  6526. /**
  6527. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6528. * The data in this array can only be present once
  6529. */
  6530. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6531. private _duplicateId;
  6532. /**
  6533. * Pushes a value at the end of the active data.
  6534. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6535. * @param value defines the object to push in the array.
  6536. */
  6537. push(value: T): void;
  6538. /**
  6539. * Pushes a value at the end of the active data.
  6540. * If the data is already present, it won t be added again
  6541. * @param value defines the object to push in the array.
  6542. * @returns true if added false if it was already present
  6543. */
  6544. pushNoDuplicate(value: T): boolean;
  6545. /**
  6546. * Resets the active data to an empty array.
  6547. */
  6548. reset(): void;
  6549. /**
  6550. * Concats the active data with a given array.
  6551. * This ensures no dupplicate will be present in the result.
  6552. * @param array defines the data to concatenate with.
  6553. */
  6554. concatWithNoDuplicate(array: any): void;
  6555. }
  6556. }
  6557. declare module BABYLON {
  6558. /**
  6559. * @ignore
  6560. * This is a list of all the different input types that are available in the application.
  6561. * Fo instance: ArcRotateCameraGamepadInput...
  6562. */
  6563. export var CameraInputTypes: {};
  6564. /**
  6565. * This is the contract to implement in order to create a new input class.
  6566. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6567. */
  6568. export interface ICameraInput<TCamera extends Camera> {
  6569. /**
  6570. * Defines the camera the input is attached to.
  6571. */
  6572. camera: Nullable<TCamera>;
  6573. /**
  6574. * Gets the class name of the current intput.
  6575. * @returns the class name
  6576. */
  6577. getClassName(): string;
  6578. /**
  6579. * Get the friendly name associated with the input class.
  6580. * @returns the input friendly name
  6581. */
  6582. getSimpleName(): string;
  6583. /**
  6584. * Attach the input controls to a specific dom element to get the input from.
  6585. * @param element Defines the element the controls should be listened from
  6586. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6587. */
  6588. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6589. /**
  6590. * Detach the current controls from the specified dom element.
  6591. * @param element Defines the element to stop listening the inputs from
  6592. */
  6593. detachControl(element: Nullable<HTMLElement>): void;
  6594. /**
  6595. * Update the current camera state depending on the inputs that have been used this frame.
  6596. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6597. */
  6598. checkInputs?: () => void;
  6599. }
  6600. /**
  6601. * Represents a map of input types to input instance or input index to input instance.
  6602. */
  6603. export interface CameraInputsMap<TCamera extends Camera> {
  6604. /**
  6605. * Accessor to the input by input type.
  6606. */
  6607. [name: string]: ICameraInput<TCamera>;
  6608. /**
  6609. * Accessor to the input by input index.
  6610. */
  6611. [idx: number]: ICameraInput<TCamera>;
  6612. }
  6613. /**
  6614. * This represents the input manager used within a camera.
  6615. * It helps dealing with all the different kind of input attached to a camera.
  6616. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6617. */
  6618. export class CameraInputsManager<TCamera extends Camera> {
  6619. /**
  6620. * Defines the list of inputs attahed to the camera.
  6621. */
  6622. attached: CameraInputsMap<TCamera>;
  6623. /**
  6624. * Defines the dom element the camera is collecting inputs from.
  6625. * This is null if the controls have not been attached.
  6626. */
  6627. attachedElement: Nullable<HTMLElement>;
  6628. /**
  6629. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6630. */
  6631. noPreventDefault: boolean;
  6632. /**
  6633. * Defined the camera the input manager belongs to.
  6634. */
  6635. camera: TCamera;
  6636. /**
  6637. * Update the current camera state depending on the inputs that have been used this frame.
  6638. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6639. */
  6640. checkInputs: () => void;
  6641. /**
  6642. * Instantiate a new Camera Input Manager.
  6643. * @param camera Defines the camera the input manager blongs to
  6644. */
  6645. constructor(camera: TCamera);
  6646. /**
  6647. * Add an input method to a camera
  6648. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6649. * @param input camera input method
  6650. */
  6651. add(input: ICameraInput<TCamera>): void;
  6652. /**
  6653. * Remove a specific input method from a camera
  6654. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6655. * @param inputToRemove camera input method
  6656. */
  6657. remove(inputToRemove: ICameraInput<TCamera>): void;
  6658. /**
  6659. * Remove a specific input type from a camera
  6660. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6661. * @param inputType the type of the input to remove
  6662. */
  6663. removeByType(inputType: string): void;
  6664. private _addCheckInputs;
  6665. /**
  6666. * Attach the input controls to the currently attached dom element to listen the events from.
  6667. * @param input Defines the input to attach
  6668. */
  6669. attachInput(input: ICameraInput<TCamera>): void;
  6670. /**
  6671. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6672. * @param element Defines the dom element to collect the events from
  6673. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6674. */
  6675. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6676. /**
  6677. * Detach the current manager inputs controls from a specific dom element.
  6678. * @param element Defines the dom element to collect the events from
  6679. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6680. */
  6681. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6682. /**
  6683. * Rebuild the dynamic inputCheck function from the current list of
  6684. * defined inputs in the manager.
  6685. */
  6686. rebuildInputCheck(): void;
  6687. /**
  6688. * Remove all attached input methods from a camera
  6689. */
  6690. clear(): void;
  6691. /**
  6692. * Serialize the current input manager attached to a camera.
  6693. * This ensures than once parsed,
  6694. * the input associated to the camera will be identical to the current ones
  6695. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6696. */
  6697. serialize(serializedCamera: any): void;
  6698. /**
  6699. * Parses an input manager serialized JSON to restore the previous list of inputs
  6700. * and states associated to a camera.
  6701. * @param parsedCamera Defines the JSON to parse
  6702. */
  6703. parse(parsedCamera: any): void;
  6704. }
  6705. }
  6706. declare module BABYLON {
  6707. /**
  6708. * @hidden
  6709. */
  6710. export class IntersectionInfo {
  6711. bu: Nullable<number>;
  6712. bv: Nullable<number>;
  6713. distance: number;
  6714. faceId: number;
  6715. subMeshId: number;
  6716. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6717. }
  6718. }
  6719. declare module BABYLON {
  6720. /**
  6721. * Represens a plane by the equation ax + by + cz + d = 0
  6722. */
  6723. export class Plane {
  6724. private static _TmpMatrix;
  6725. /**
  6726. * Normal of the plane (a,b,c)
  6727. */
  6728. normal: Vector3;
  6729. /**
  6730. * d component of the plane
  6731. */
  6732. d: number;
  6733. /**
  6734. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6735. * @param a a component of the plane
  6736. * @param b b component of the plane
  6737. * @param c c component of the plane
  6738. * @param d d component of the plane
  6739. */
  6740. constructor(a: number, b: number, c: number, d: number);
  6741. /**
  6742. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6743. */
  6744. asArray(): number[];
  6745. /**
  6746. * @returns a new plane copied from the current Plane.
  6747. */
  6748. clone(): Plane;
  6749. /**
  6750. * @returns the string "Plane".
  6751. */
  6752. getClassName(): string;
  6753. /**
  6754. * @returns the Plane hash code.
  6755. */
  6756. getHashCode(): number;
  6757. /**
  6758. * Normalize the current Plane in place.
  6759. * @returns the updated Plane.
  6760. */
  6761. normalize(): Plane;
  6762. /**
  6763. * Applies a transformation the plane and returns the result
  6764. * @param transformation the transformation matrix to be applied to the plane
  6765. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6766. */
  6767. transform(transformation: DeepImmutable<Matrix>): Plane;
  6768. /**
  6769. * Calcualtte the dot product between the point and the plane normal
  6770. * @param point point to calculate the dot product with
  6771. * @returns the dot product (float) of the point coordinates and the plane normal.
  6772. */
  6773. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6774. /**
  6775. * Updates the current Plane from the plane defined by the three given points.
  6776. * @param point1 one of the points used to contruct the plane
  6777. * @param point2 one of the points used to contruct the plane
  6778. * @param point3 one of the points used to contruct the plane
  6779. * @returns the updated Plane.
  6780. */
  6781. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6782. /**
  6783. * Checks if the plane is facing a given direction
  6784. * @param direction the direction to check if the plane is facing
  6785. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6786. * @returns True is the vector "direction" is the same side than the plane normal.
  6787. */
  6788. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6789. /**
  6790. * Calculates the distance to a point
  6791. * @param point point to calculate distance to
  6792. * @returns the signed distance (float) from the given point to the Plane.
  6793. */
  6794. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6795. /**
  6796. * Creates a plane from an array
  6797. * @param array the array to create a plane from
  6798. * @returns a new Plane from the given array.
  6799. */
  6800. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6801. /**
  6802. * Creates a plane from three points
  6803. * @param point1 point used to create the plane
  6804. * @param point2 point used to create the plane
  6805. * @param point3 point used to create the plane
  6806. * @returns a new Plane defined by the three given points.
  6807. */
  6808. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6809. /**
  6810. * Creates a plane from an origin point and a normal
  6811. * @param origin origin of the plane to be constructed
  6812. * @param normal normal of the plane to be constructed
  6813. * @returns a new Plane the normal vector to this plane at the given origin point.
  6814. * Note : the vector "normal" is updated because normalized.
  6815. */
  6816. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6817. /**
  6818. * Calculates the distance from a plane and a point
  6819. * @param origin origin of the plane to be constructed
  6820. * @param normal normal of the plane to be constructed
  6821. * @param point point to calculate distance to
  6822. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6823. */
  6824. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6825. }
  6826. }
  6827. declare module BABYLON {
  6828. /**
  6829. * Class used to store bounding sphere information
  6830. */
  6831. export class BoundingSphere {
  6832. /**
  6833. * Gets the center of the bounding sphere in local space
  6834. */
  6835. readonly center: Vector3;
  6836. /**
  6837. * Radius of the bounding sphere in local space
  6838. */
  6839. radius: number;
  6840. /**
  6841. * Gets the center of the bounding sphere in world space
  6842. */
  6843. readonly centerWorld: Vector3;
  6844. /**
  6845. * Radius of the bounding sphere in world space
  6846. */
  6847. radiusWorld: number;
  6848. /**
  6849. * Gets the minimum vector in local space
  6850. */
  6851. readonly minimum: Vector3;
  6852. /**
  6853. * Gets the maximum vector in local space
  6854. */
  6855. readonly maximum: Vector3;
  6856. private _worldMatrix;
  6857. private static readonly TmpVector3;
  6858. /**
  6859. * Creates a new bounding sphere
  6860. * @param min defines the minimum vector (in local space)
  6861. * @param max defines the maximum vector (in local space)
  6862. * @param worldMatrix defines the new world matrix
  6863. */
  6864. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6865. /**
  6866. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6867. * @param min defines the new minimum vector (in local space)
  6868. * @param max defines the new maximum vector (in local space)
  6869. * @param worldMatrix defines the new world matrix
  6870. */
  6871. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6872. /**
  6873. * Scale the current bounding sphere by applying a scale factor
  6874. * @param factor defines the scale factor to apply
  6875. * @returns the current bounding box
  6876. */
  6877. scale(factor: number): BoundingSphere;
  6878. /**
  6879. * Gets the world matrix of the bounding box
  6880. * @returns a matrix
  6881. */
  6882. getWorldMatrix(): DeepImmutable<Matrix>;
  6883. /** @hidden */
  6884. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6885. /**
  6886. * Tests if the bounding sphere is intersecting the frustum planes
  6887. * @param frustumPlanes defines the frustum planes to test
  6888. * @returns true if there is an intersection
  6889. */
  6890. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6891. /**
  6892. * Tests if the bounding sphere center is in between the frustum planes.
  6893. * Used for optimistic fast inclusion.
  6894. * @param frustumPlanes defines the frustum planes to test
  6895. * @returns true if the sphere center is in between the frustum planes
  6896. */
  6897. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6898. /**
  6899. * Tests if a point is inside the bounding sphere
  6900. * @param point defines the point to test
  6901. * @returns true if the point is inside the bounding sphere
  6902. */
  6903. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6904. /**
  6905. * Checks if two sphere intersct
  6906. * @param sphere0 sphere 0
  6907. * @param sphere1 sphere 1
  6908. * @returns true if the speres intersect
  6909. */
  6910. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6911. }
  6912. }
  6913. declare module BABYLON {
  6914. /**
  6915. * Class used to store bounding box information
  6916. */
  6917. export class BoundingBox implements ICullable {
  6918. /**
  6919. * Gets the 8 vectors representing the bounding box in local space
  6920. */
  6921. readonly vectors: Vector3[];
  6922. /**
  6923. * Gets the center of the bounding box in local space
  6924. */
  6925. readonly center: Vector3;
  6926. /**
  6927. * Gets the center of the bounding box in world space
  6928. */
  6929. readonly centerWorld: Vector3;
  6930. /**
  6931. * Gets the extend size in local space
  6932. */
  6933. readonly extendSize: Vector3;
  6934. /**
  6935. * Gets the extend size in world space
  6936. */
  6937. readonly extendSizeWorld: Vector3;
  6938. /**
  6939. * Gets the OBB (object bounding box) directions
  6940. */
  6941. readonly directions: Vector3[];
  6942. /**
  6943. * Gets the 8 vectors representing the bounding box in world space
  6944. */
  6945. readonly vectorsWorld: Vector3[];
  6946. /**
  6947. * Gets the minimum vector in world space
  6948. */
  6949. readonly minimumWorld: Vector3;
  6950. /**
  6951. * Gets the maximum vector in world space
  6952. */
  6953. readonly maximumWorld: Vector3;
  6954. /**
  6955. * Gets the minimum vector in local space
  6956. */
  6957. readonly minimum: Vector3;
  6958. /**
  6959. * Gets the maximum vector in local space
  6960. */
  6961. readonly maximum: Vector3;
  6962. private _worldMatrix;
  6963. private static readonly TmpVector3;
  6964. /**
  6965. * @hidden
  6966. */
  6967. _tag: number;
  6968. /**
  6969. * Creates a new bounding box
  6970. * @param min defines the minimum vector (in local space)
  6971. * @param max defines the maximum vector (in local space)
  6972. * @param worldMatrix defines the new world matrix
  6973. */
  6974. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6975. /**
  6976. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6977. * @param min defines the new minimum vector (in local space)
  6978. * @param max defines the new maximum vector (in local space)
  6979. * @param worldMatrix defines the new world matrix
  6980. */
  6981. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6982. /**
  6983. * Scale the current bounding box by applying a scale factor
  6984. * @param factor defines the scale factor to apply
  6985. * @returns the current bounding box
  6986. */
  6987. scale(factor: number): BoundingBox;
  6988. /**
  6989. * Gets the world matrix of the bounding box
  6990. * @returns a matrix
  6991. */
  6992. getWorldMatrix(): DeepImmutable<Matrix>;
  6993. /** @hidden */
  6994. _update(world: DeepImmutable<Matrix>): void;
  6995. /**
  6996. * Tests if the bounding box is intersecting the frustum planes
  6997. * @param frustumPlanes defines the frustum planes to test
  6998. * @returns true if there is an intersection
  6999. */
  7000. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7001. /**
  7002. * Tests if the bounding box is entirely inside the frustum planes
  7003. * @param frustumPlanes defines the frustum planes to test
  7004. * @returns true if there is an inclusion
  7005. */
  7006. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7007. /**
  7008. * Tests if a point is inside the bounding box
  7009. * @param point defines the point to test
  7010. * @returns true if the point is inside the bounding box
  7011. */
  7012. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7013. /**
  7014. * Tests if the bounding box intersects with a bounding sphere
  7015. * @param sphere defines the sphere to test
  7016. * @returns true if there is an intersection
  7017. */
  7018. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7019. /**
  7020. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7021. * @param min defines the min vector to use
  7022. * @param max defines the max vector to use
  7023. * @returns true if there is an intersection
  7024. */
  7025. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7026. /**
  7027. * Tests if two bounding boxes are intersections
  7028. * @param box0 defines the first box to test
  7029. * @param box1 defines the second box to test
  7030. * @returns true if there is an intersection
  7031. */
  7032. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7033. /**
  7034. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7035. * @param minPoint defines the minimum vector of the bounding box
  7036. * @param maxPoint defines the maximum vector of the bounding box
  7037. * @param sphereCenter defines the sphere center
  7038. * @param sphereRadius defines the sphere radius
  7039. * @returns true if there is an intersection
  7040. */
  7041. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7042. /**
  7043. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7044. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7045. * @param frustumPlanes defines the frustum planes to test
  7046. * @return true if there is an inclusion
  7047. */
  7048. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7049. /**
  7050. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7051. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7052. * @param frustumPlanes defines the frustum planes to test
  7053. * @return true if there is an intersection
  7054. */
  7055. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7056. }
  7057. }
  7058. declare module BABYLON {
  7059. /** @hidden */
  7060. export class Collider {
  7061. /** Define if a collision was found */
  7062. collisionFound: boolean;
  7063. /**
  7064. * Define last intersection point in local space
  7065. */
  7066. intersectionPoint: Vector3;
  7067. /**
  7068. * Define last collided mesh
  7069. */
  7070. collidedMesh: Nullable<AbstractMesh>;
  7071. private _collisionPoint;
  7072. private _planeIntersectionPoint;
  7073. private _tempVector;
  7074. private _tempVector2;
  7075. private _tempVector3;
  7076. private _tempVector4;
  7077. private _edge;
  7078. private _baseToVertex;
  7079. private _destinationPoint;
  7080. private _slidePlaneNormal;
  7081. private _displacementVector;
  7082. /** @hidden */
  7083. _radius: Vector3;
  7084. /** @hidden */
  7085. _retry: number;
  7086. private _velocity;
  7087. private _basePoint;
  7088. private _epsilon;
  7089. /** @hidden */
  7090. _velocityWorldLength: number;
  7091. /** @hidden */
  7092. _basePointWorld: Vector3;
  7093. private _velocityWorld;
  7094. private _normalizedVelocity;
  7095. /** @hidden */
  7096. _initialVelocity: Vector3;
  7097. /** @hidden */
  7098. _initialPosition: Vector3;
  7099. private _nearestDistance;
  7100. private _collisionMask;
  7101. collisionMask: number;
  7102. /**
  7103. * Gets the plane normal used to compute the sliding response (in local space)
  7104. */
  7105. readonly slidePlaneNormal: Vector3;
  7106. /** @hidden */
  7107. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7108. /** @hidden */
  7109. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7110. /** @hidden */
  7111. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7112. /** @hidden */
  7113. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7114. /** @hidden */
  7115. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7116. /** @hidden */
  7117. _getResponse(pos: Vector3, vel: Vector3): void;
  7118. }
  7119. }
  7120. declare module BABYLON {
  7121. /**
  7122. * Interface for cullable objects
  7123. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7124. */
  7125. export interface ICullable {
  7126. /**
  7127. * Checks if the object or part of the object is in the frustum
  7128. * @param frustumPlanes Camera near/planes
  7129. * @returns true if the object is in frustum otherwise false
  7130. */
  7131. isInFrustum(frustumPlanes: Plane[]): boolean;
  7132. /**
  7133. * Checks if a cullable object (mesh...) is in the camera frustum
  7134. * Unlike isInFrustum this cheks the full bounding box
  7135. * @param frustumPlanes Camera near/planes
  7136. * @returns true if the object is in frustum otherwise false
  7137. */
  7138. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7139. }
  7140. /**
  7141. * Info for a bounding data of a mesh
  7142. */
  7143. export class BoundingInfo implements ICullable {
  7144. /**
  7145. * Bounding box for the mesh
  7146. */
  7147. readonly boundingBox: BoundingBox;
  7148. /**
  7149. * Bounding sphere for the mesh
  7150. */
  7151. readonly boundingSphere: BoundingSphere;
  7152. private _isLocked;
  7153. private static readonly TmpVector3;
  7154. /**
  7155. * Constructs bounding info
  7156. * @param minimum min vector of the bounding box/sphere
  7157. * @param maximum max vector of the bounding box/sphere
  7158. * @param worldMatrix defines the new world matrix
  7159. */
  7160. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7161. /**
  7162. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7163. * @param min defines the new minimum vector (in local space)
  7164. * @param max defines the new maximum vector (in local space)
  7165. * @param worldMatrix defines the new world matrix
  7166. */
  7167. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7168. /**
  7169. * min vector of the bounding box/sphere
  7170. */
  7171. readonly minimum: Vector3;
  7172. /**
  7173. * max vector of the bounding box/sphere
  7174. */
  7175. readonly maximum: Vector3;
  7176. /**
  7177. * If the info is locked and won't be updated to avoid perf overhead
  7178. */
  7179. isLocked: boolean;
  7180. /**
  7181. * Updates the bounding sphere and box
  7182. * @param world world matrix to be used to update
  7183. */
  7184. update(world: DeepImmutable<Matrix>): void;
  7185. /**
  7186. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7187. * @param center New center of the bounding info
  7188. * @param extend New extend of the bounding info
  7189. * @returns the current bounding info
  7190. */
  7191. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7192. /**
  7193. * Scale the current bounding info by applying a scale factor
  7194. * @param factor defines the scale factor to apply
  7195. * @returns the current bounding info
  7196. */
  7197. scale(factor: number): BoundingInfo;
  7198. /**
  7199. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7200. * @param frustumPlanes defines the frustum to test
  7201. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7202. * @returns true if the bounding info is in the frustum planes
  7203. */
  7204. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7205. /**
  7206. * Gets the world distance between the min and max points of the bounding box
  7207. */
  7208. readonly diagonalLength: number;
  7209. /**
  7210. * Checks if a cullable object (mesh...) is in the camera frustum
  7211. * Unlike isInFrustum this cheks the full bounding box
  7212. * @param frustumPlanes Camera near/planes
  7213. * @returns true if the object is in frustum otherwise false
  7214. */
  7215. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7216. /** @hidden */
  7217. _checkCollision(collider: Collider): boolean;
  7218. /**
  7219. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7220. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7221. * @param point the point to check intersection with
  7222. * @returns if the point intersects
  7223. */
  7224. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7225. /**
  7226. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7227. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7228. * @param boundingInfo the bounding info to check intersection with
  7229. * @param precise if the intersection should be done using OBB
  7230. * @returns if the bounding info intersects
  7231. */
  7232. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7233. }
  7234. }
  7235. declare module BABYLON {
  7236. /**
  7237. * Extracts minimum and maximum values from a list of indexed positions
  7238. * @param positions defines the positions to use
  7239. * @param indices defines the indices to the positions
  7240. * @param indexStart defines the start index
  7241. * @param indexCount defines the end index
  7242. * @param bias defines bias value to add to the result
  7243. * @return minimum and maximum values
  7244. */
  7245. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7246. minimum: Vector3;
  7247. maximum: Vector3;
  7248. };
  7249. /**
  7250. * Extracts minimum and maximum values from a list of positions
  7251. * @param positions defines the positions to use
  7252. * @param start defines the start index in the positions array
  7253. * @param count defines the number of positions to handle
  7254. * @param bias defines bias value to add to the result
  7255. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7256. * @return minimum and maximum values
  7257. */
  7258. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7259. minimum: Vector3;
  7260. maximum: Vector3;
  7261. };
  7262. }
  7263. declare module BABYLON {
  7264. /**
  7265. * Enum that determines the text-wrapping mode to use.
  7266. */
  7267. export enum InspectableType {
  7268. /**
  7269. * Checkbox for booleans
  7270. */
  7271. Checkbox = 0,
  7272. /**
  7273. * Sliders for numbers
  7274. */
  7275. Slider = 1,
  7276. /**
  7277. * Vector3
  7278. */
  7279. Vector3 = 2,
  7280. /**
  7281. * Quaternions
  7282. */
  7283. Quaternion = 3,
  7284. /**
  7285. * Color3
  7286. */
  7287. Color3 = 4,
  7288. /**
  7289. * String
  7290. */
  7291. String = 5
  7292. }
  7293. /**
  7294. * Interface used to define custom inspectable properties.
  7295. * This interface is used by the inspector to display custom property grids
  7296. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7297. */
  7298. export interface IInspectable {
  7299. /**
  7300. * Gets the label to display
  7301. */
  7302. label: string;
  7303. /**
  7304. * Gets the name of the property to edit
  7305. */
  7306. propertyName: string;
  7307. /**
  7308. * Gets the type of the editor to use
  7309. */
  7310. type: InspectableType;
  7311. /**
  7312. * Gets the minimum value of the property when using in "slider" mode
  7313. */
  7314. min?: number;
  7315. /**
  7316. * Gets the maximum value of the property when using in "slider" mode
  7317. */
  7318. max?: number;
  7319. /**
  7320. * Gets the setp to use when using in "slider" mode
  7321. */
  7322. step?: number;
  7323. }
  7324. }
  7325. declare module BABYLON {
  7326. /**
  7327. * Class used to provide helper for timing
  7328. */
  7329. export class TimingTools {
  7330. /**
  7331. * Polyfill for setImmediate
  7332. * @param action defines the action to execute after the current execution block
  7333. */
  7334. static SetImmediate(action: () => void): void;
  7335. }
  7336. }
  7337. declare module BABYLON {
  7338. /**
  7339. * Class used to enable instatition of objects by class name
  7340. */
  7341. export class InstantiationTools {
  7342. /**
  7343. * Use this object to register external classes like custom textures or material
  7344. * to allow the laoders to instantiate them
  7345. */
  7346. static RegisteredExternalClasses: {
  7347. [key: string]: Object;
  7348. };
  7349. /**
  7350. * Tries to instantiate a new object from a given class name
  7351. * @param className defines the class name to instantiate
  7352. * @returns the new object or null if the system was not able to do the instantiation
  7353. */
  7354. static Instantiate(className: string): any;
  7355. }
  7356. }
  7357. declare module BABYLON {
  7358. /**
  7359. * This represents the required contract to create a new type of texture loader.
  7360. */
  7361. export interface IInternalTextureLoader {
  7362. /**
  7363. * Defines wether the loader supports cascade loading the different faces.
  7364. */
  7365. supportCascades: boolean;
  7366. /**
  7367. * This returns if the loader support the current file information.
  7368. * @param extension defines the file extension of the file being loaded
  7369. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7370. * @param fallback defines the fallback internal texture if any
  7371. * @param isBase64 defines whether the texture is encoded as a base64
  7372. * @param isBuffer defines whether the texture data are stored as a buffer
  7373. * @returns true if the loader can load the specified file
  7374. */
  7375. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7376. /**
  7377. * Transform the url before loading if required.
  7378. * @param rootUrl the url of the texture
  7379. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7380. * @returns the transformed texture
  7381. */
  7382. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7383. /**
  7384. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7385. * @param rootUrl the url of the texture
  7386. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7387. * @returns the fallback texture
  7388. */
  7389. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7390. /**
  7391. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7392. * @param data contains the texture data
  7393. * @param texture defines the BabylonJS internal texture
  7394. * @param createPolynomials will be true if polynomials have been requested
  7395. * @param onLoad defines the callback to trigger once the texture is ready
  7396. * @param onError defines the callback to trigger in case of error
  7397. */
  7398. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7399. /**
  7400. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7401. * @param data contains the texture data
  7402. * @param texture defines the BabylonJS internal texture
  7403. * @param callback defines the method to call once ready to upload
  7404. */
  7405. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7406. }
  7407. }
  7408. declare module BABYLON {
  7409. interface Engine {
  7410. /**
  7411. * Creates a depth stencil cube texture.
  7412. * This is only available in WebGL 2.
  7413. * @param size The size of face edge in the cube texture.
  7414. * @param options The options defining the cube texture.
  7415. * @returns The cube texture
  7416. */
  7417. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7418. /**
  7419. * Creates a cube texture
  7420. * @param rootUrl defines the url where the files to load is located
  7421. * @param scene defines the current scene
  7422. * @param files defines the list of files to load (1 per face)
  7423. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7424. * @param onLoad defines an optional callback raised when the texture is loaded
  7425. * @param onError defines an optional callback raised if there is an issue to load the texture
  7426. * @param format defines the format of the data
  7427. * @param forcedExtension defines the extension to use to pick the right loader
  7428. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7429. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7430. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7431. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7432. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7433. * @returns the cube texture as an InternalTexture
  7434. */
  7435. 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;
  7436. /**
  7437. * Creates a cube texture
  7438. * @param rootUrl defines the url where the files to load is located
  7439. * @param scene defines the current scene
  7440. * @param files defines the list of files to load (1 per face)
  7441. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7442. * @param onLoad defines an optional callback raised when the texture is loaded
  7443. * @param onError defines an optional callback raised if there is an issue to load the texture
  7444. * @param format defines the format of the data
  7445. * @param forcedExtension defines the extension to use to pick the right loader
  7446. * @returns the cube texture as an InternalTexture
  7447. */
  7448. 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;
  7449. /**
  7450. * Creates a cube texture
  7451. * @param rootUrl defines the url where the files to load is located
  7452. * @param scene defines the current scene
  7453. * @param files defines the list of files to load (1 per face)
  7454. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7455. * @param onLoad defines an optional callback raised when the texture is loaded
  7456. * @param onError defines an optional callback raised if there is an issue to load the texture
  7457. * @param format defines the format of the data
  7458. * @param forcedExtension defines the extension to use to pick the right loader
  7459. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7460. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7461. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7462. * @returns the cube texture as an InternalTexture
  7463. */
  7464. 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;
  7465. /** @hidden */
  7466. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7467. /** @hidden */
  7468. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7469. /** @hidden */
  7470. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7471. /** @hidden */
  7472. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7473. }
  7474. }
  7475. declare module BABYLON {
  7476. /**
  7477. * Class for creating a cube texture
  7478. */
  7479. export class CubeTexture extends BaseTexture {
  7480. private _delayedOnLoad;
  7481. /**
  7482. * The url of the texture
  7483. */
  7484. url: string;
  7485. /**
  7486. * Gets or sets the center of the bounding box associated with the cube texture.
  7487. * It must define where the camera used to render the texture was set
  7488. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7489. */
  7490. boundingBoxPosition: Vector3;
  7491. private _boundingBoxSize;
  7492. /**
  7493. * Gets or sets the size of the bounding box associated with the cube texture
  7494. * When defined, the cubemap will switch to local mode
  7495. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7496. * @example https://www.babylonjs-playground.com/#RNASML
  7497. */
  7498. /**
  7499. * Returns the bounding box size
  7500. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7501. */
  7502. boundingBoxSize: Vector3;
  7503. protected _rotationY: number;
  7504. /**
  7505. * Sets texture matrix rotation angle around Y axis in radians.
  7506. */
  7507. /**
  7508. * Gets texture matrix rotation angle around Y axis radians.
  7509. */
  7510. rotationY: number;
  7511. /**
  7512. * Are mip maps generated for this texture or not.
  7513. */
  7514. readonly noMipmap: boolean;
  7515. private _noMipmap;
  7516. private _files;
  7517. private _extensions;
  7518. private _textureMatrix;
  7519. private _format;
  7520. private _createPolynomials;
  7521. /** @hidden */
  7522. _prefiltered: boolean;
  7523. /**
  7524. * Creates a cube texture from an array of image urls
  7525. * @param files defines an array of image urls
  7526. * @param scene defines the hosting scene
  7527. * @param noMipmap specifies if mip maps are not used
  7528. * @returns a cube texture
  7529. */
  7530. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7531. /**
  7532. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7533. * @param url defines the url of the prefiltered texture
  7534. * @param scene defines the scene the texture is attached to
  7535. * @param forcedExtension defines the extension of the file if different from the url
  7536. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7537. * @return the prefiltered texture
  7538. */
  7539. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7540. /**
  7541. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7542. * as prefiltered data.
  7543. * @param rootUrl defines the url of the texture or the root name of the six images
  7544. * @param scene defines the scene the texture is attached to
  7545. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7546. * @param noMipmap defines if mipmaps should be created or not
  7547. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7548. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7549. * @param onError defines a callback triggered in case of error during load
  7550. * @param format defines the internal format to use for the texture once loaded
  7551. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7552. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7553. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7554. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7555. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7556. * @return the cube texture
  7557. */
  7558. 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);
  7559. /**
  7560. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7561. */
  7562. readonly isPrefiltered: boolean;
  7563. /**
  7564. * Get the current class name of the texture useful for serialization or dynamic coding.
  7565. * @returns "CubeTexture"
  7566. */
  7567. getClassName(): string;
  7568. /**
  7569. * Update the url (and optional buffer) of this texture if url was null during construction.
  7570. * @param url the url of the texture
  7571. * @param forcedExtension defines the extension to use
  7572. * @param onLoad callback called when the texture is loaded (defaults to null)
  7573. */
  7574. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7575. /**
  7576. * Delays loading of the cube texture
  7577. * @param forcedExtension defines the extension to use
  7578. */
  7579. delayLoad(forcedExtension?: string): void;
  7580. /**
  7581. * Returns the reflection texture matrix
  7582. * @returns the reflection texture matrix
  7583. */
  7584. getReflectionTextureMatrix(): Matrix;
  7585. /**
  7586. * Sets the reflection texture matrix
  7587. * @param value Reflection texture matrix
  7588. */
  7589. setReflectionTextureMatrix(value: Matrix): void;
  7590. /**
  7591. * Parses text to create a cube texture
  7592. * @param parsedTexture define the serialized text to read from
  7593. * @param scene defines the hosting scene
  7594. * @param rootUrl defines the root url of the cube texture
  7595. * @returns a cube texture
  7596. */
  7597. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7598. /**
  7599. * Makes a clone, or deep copy, of the cube texture
  7600. * @returns a new cube texture
  7601. */
  7602. clone(): CubeTexture;
  7603. }
  7604. }
  7605. declare module BABYLON {
  7606. /**
  7607. * Manages the defines for the Material
  7608. */
  7609. export class MaterialDefines {
  7610. /** @hidden */
  7611. protected _keys: string[];
  7612. private _isDirty;
  7613. /** @hidden */
  7614. _renderId: number;
  7615. /** @hidden */
  7616. _areLightsDirty: boolean;
  7617. /** @hidden */
  7618. _areLightsDisposed: boolean;
  7619. /** @hidden */
  7620. _areAttributesDirty: boolean;
  7621. /** @hidden */
  7622. _areTexturesDirty: boolean;
  7623. /** @hidden */
  7624. _areFresnelDirty: boolean;
  7625. /** @hidden */
  7626. _areMiscDirty: boolean;
  7627. /** @hidden */
  7628. _areImageProcessingDirty: boolean;
  7629. /** @hidden */
  7630. _normals: boolean;
  7631. /** @hidden */
  7632. _uvs: boolean;
  7633. /** @hidden */
  7634. _needNormals: boolean;
  7635. /** @hidden */
  7636. _needUVs: boolean;
  7637. [id: string]: any;
  7638. /**
  7639. * Specifies if the material needs to be re-calculated
  7640. */
  7641. readonly isDirty: boolean;
  7642. /**
  7643. * Marks the material to indicate that it has been re-calculated
  7644. */
  7645. markAsProcessed(): void;
  7646. /**
  7647. * Marks the material to indicate that it needs to be re-calculated
  7648. */
  7649. markAsUnprocessed(): void;
  7650. /**
  7651. * Marks the material to indicate all of its defines need to be re-calculated
  7652. */
  7653. markAllAsDirty(): void;
  7654. /**
  7655. * Marks the material to indicate that image processing needs to be re-calculated
  7656. */
  7657. markAsImageProcessingDirty(): void;
  7658. /**
  7659. * Marks the material to indicate the lights need to be re-calculated
  7660. * @param disposed Defines whether the light is dirty due to dispose or not
  7661. */
  7662. markAsLightDirty(disposed?: boolean): void;
  7663. /**
  7664. * Marks the attribute state as changed
  7665. */
  7666. markAsAttributesDirty(): void;
  7667. /**
  7668. * Marks the texture state as changed
  7669. */
  7670. markAsTexturesDirty(): void;
  7671. /**
  7672. * Marks the fresnel state as changed
  7673. */
  7674. markAsFresnelDirty(): void;
  7675. /**
  7676. * Marks the misc state as changed
  7677. */
  7678. markAsMiscDirty(): void;
  7679. /**
  7680. * Rebuilds the material defines
  7681. */
  7682. rebuild(): void;
  7683. /**
  7684. * Specifies if two material defines are equal
  7685. * @param other - A material define instance to compare to
  7686. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7687. */
  7688. isEqual(other: MaterialDefines): boolean;
  7689. /**
  7690. * Clones this instance's defines to another instance
  7691. * @param other - material defines to clone values to
  7692. */
  7693. cloneTo(other: MaterialDefines): void;
  7694. /**
  7695. * Resets the material define values
  7696. */
  7697. reset(): void;
  7698. /**
  7699. * Converts the material define values to a string
  7700. * @returns - String of material define information
  7701. */
  7702. toString(): string;
  7703. }
  7704. }
  7705. declare module BABYLON {
  7706. /**
  7707. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7708. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7709. * 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;
  7710. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7711. */
  7712. export class ColorCurves {
  7713. private _dirty;
  7714. private _tempColor;
  7715. private _globalCurve;
  7716. private _highlightsCurve;
  7717. private _midtonesCurve;
  7718. private _shadowsCurve;
  7719. private _positiveCurve;
  7720. private _negativeCurve;
  7721. private _globalHue;
  7722. private _globalDensity;
  7723. private _globalSaturation;
  7724. private _globalExposure;
  7725. /**
  7726. * Gets the global Hue value.
  7727. * 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).
  7728. */
  7729. /**
  7730. * Sets the global Hue value.
  7731. * 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).
  7732. */
  7733. globalHue: number;
  7734. /**
  7735. * Gets the global Density value.
  7736. * 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.
  7737. * Values less than zero provide a filter of opposite hue.
  7738. */
  7739. /**
  7740. * Sets the global Density value.
  7741. * 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.
  7742. * Values less than zero provide a filter of opposite hue.
  7743. */
  7744. globalDensity: number;
  7745. /**
  7746. * Gets the global Saturation value.
  7747. * 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.
  7748. */
  7749. /**
  7750. * Sets the global Saturation value.
  7751. * 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.
  7752. */
  7753. globalSaturation: number;
  7754. /**
  7755. * Gets the global Exposure value.
  7756. * 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.
  7757. */
  7758. /**
  7759. * Sets the global Exposure value.
  7760. * 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.
  7761. */
  7762. globalExposure: number;
  7763. private _highlightsHue;
  7764. private _highlightsDensity;
  7765. private _highlightsSaturation;
  7766. private _highlightsExposure;
  7767. /**
  7768. * Gets the highlights Hue value.
  7769. * 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).
  7770. */
  7771. /**
  7772. * Sets the highlights Hue value.
  7773. * 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).
  7774. */
  7775. highlightsHue: number;
  7776. /**
  7777. * Gets the highlights Density value.
  7778. * 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.
  7779. * Values less than zero provide a filter of opposite hue.
  7780. */
  7781. /**
  7782. * Sets the highlights Density value.
  7783. * 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.
  7784. * Values less than zero provide a filter of opposite hue.
  7785. */
  7786. highlightsDensity: number;
  7787. /**
  7788. * Gets the highlights Saturation value.
  7789. * 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.
  7790. */
  7791. /**
  7792. * Sets the highlights Saturation value.
  7793. * 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.
  7794. */
  7795. highlightsSaturation: number;
  7796. /**
  7797. * Gets the highlights Exposure value.
  7798. * 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.
  7799. */
  7800. /**
  7801. * Sets the highlights Exposure value.
  7802. * 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.
  7803. */
  7804. highlightsExposure: number;
  7805. private _midtonesHue;
  7806. private _midtonesDensity;
  7807. private _midtonesSaturation;
  7808. private _midtonesExposure;
  7809. /**
  7810. * Gets the midtones Hue value.
  7811. * 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).
  7812. */
  7813. /**
  7814. * Sets the midtones Hue value.
  7815. * 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).
  7816. */
  7817. midtonesHue: number;
  7818. /**
  7819. * Gets the midtones Density value.
  7820. * 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.
  7821. * Values less than zero provide a filter of opposite hue.
  7822. */
  7823. /**
  7824. * Sets the midtones Density value.
  7825. * 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.
  7826. * Values less than zero provide a filter of opposite hue.
  7827. */
  7828. midtonesDensity: number;
  7829. /**
  7830. * Gets the midtones Saturation value.
  7831. * 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.
  7832. */
  7833. /**
  7834. * Sets the midtones Saturation value.
  7835. * 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.
  7836. */
  7837. midtonesSaturation: number;
  7838. /**
  7839. * Gets the midtones Exposure value.
  7840. * 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.
  7841. */
  7842. /**
  7843. * Sets the midtones Exposure value.
  7844. * 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.
  7845. */
  7846. midtonesExposure: number;
  7847. private _shadowsHue;
  7848. private _shadowsDensity;
  7849. private _shadowsSaturation;
  7850. private _shadowsExposure;
  7851. /**
  7852. * Gets the shadows Hue value.
  7853. * 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).
  7854. */
  7855. /**
  7856. * Sets the shadows Hue value.
  7857. * 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).
  7858. */
  7859. shadowsHue: number;
  7860. /**
  7861. * Gets the shadows Density value.
  7862. * 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.
  7863. * Values less than zero provide a filter of opposite hue.
  7864. */
  7865. /**
  7866. * Sets the shadows Density value.
  7867. * 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.
  7868. * Values less than zero provide a filter of opposite hue.
  7869. */
  7870. shadowsDensity: number;
  7871. /**
  7872. * Gets the shadows Saturation value.
  7873. * 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.
  7874. */
  7875. /**
  7876. * Sets the shadows Saturation value.
  7877. * 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.
  7878. */
  7879. shadowsSaturation: number;
  7880. /**
  7881. * Gets the shadows Exposure value.
  7882. * 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.
  7883. */
  7884. /**
  7885. * Sets the shadows Exposure value.
  7886. * 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.
  7887. */
  7888. shadowsExposure: number;
  7889. /**
  7890. * Returns the class name
  7891. * @returns The class name
  7892. */
  7893. getClassName(): string;
  7894. /**
  7895. * Binds the color curves to the shader.
  7896. * @param colorCurves The color curve to bind
  7897. * @param effect The effect to bind to
  7898. * @param positiveUniform The positive uniform shader parameter
  7899. * @param neutralUniform The neutral uniform shader parameter
  7900. * @param negativeUniform The negative uniform shader parameter
  7901. */
  7902. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7903. /**
  7904. * Prepare the list of uniforms associated with the ColorCurves effects.
  7905. * @param uniformsList The list of uniforms used in the effect
  7906. */
  7907. static PrepareUniforms(uniformsList: string[]): void;
  7908. /**
  7909. * Returns color grading data based on a hue, density, saturation and exposure value.
  7910. * @param filterHue The hue of the color filter.
  7911. * @param filterDensity The density of the color filter.
  7912. * @param saturation The saturation.
  7913. * @param exposure The exposure.
  7914. * @param result The result data container.
  7915. */
  7916. private getColorGradingDataToRef;
  7917. /**
  7918. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7919. * @param value The input slider value in range [-100,100].
  7920. * @returns Adjusted value.
  7921. */
  7922. private static applyColorGradingSliderNonlinear;
  7923. /**
  7924. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7925. * @param hue The hue (H) input.
  7926. * @param saturation The saturation (S) input.
  7927. * @param brightness The brightness (B) input.
  7928. * @result An RGBA color represented as Vector4.
  7929. */
  7930. private static fromHSBToRef;
  7931. /**
  7932. * Returns a value clamped between min and max
  7933. * @param value The value to clamp
  7934. * @param min The minimum of value
  7935. * @param max The maximum of value
  7936. * @returns The clamped value.
  7937. */
  7938. private static clamp;
  7939. /**
  7940. * Clones the current color curve instance.
  7941. * @return The cloned curves
  7942. */
  7943. clone(): ColorCurves;
  7944. /**
  7945. * Serializes the current color curve instance to a json representation.
  7946. * @return a JSON representation
  7947. */
  7948. serialize(): any;
  7949. /**
  7950. * Parses the color curve from a json representation.
  7951. * @param source the JSON source to parse
  7952. * @return The parsed curves
  7953. */
  7954. static Parse(source: any): ColorCurves;
  7955. }
  7956. }
  7957. declare module BABYLON {
  7958. /**
  7959. * Interface to follow in your material defines to integrate easily the
  7960. * Image proccessing functions.
  7961. * @hidden
  7962. */
  7963. export interface IImageProcessingConfigurationDefines {
  7964. IMAGEPROCESSING: boolean;
  7965. VIGNETTE: boolean;
  7966. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7967. VIGNETTEBLENDMODEOPAQUE: boolean;
  7968. TONEMAPPING: boolean;
  7969. TONEMAPPING_ACES: boolean;
  7970. CONTRAST: boolean;
  7971. EXPOSURE: boolean;
  7972. COLORCURVES: boolean;
  7973. COLORGRADING: boolean;
  7974. COLORGRADING3D: boolean;
  7975. SAMPLER3DGREENDEPTH: boolean;
  7976. SAMPLER3DBGRMAP: boolean;
  7977. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7978. }
  7979. /**
  7980. * @hidden
  7981. */
  7982. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  7983. IMAGEPROCESSING: boolean;
  7984. VIGNETTE: boolean;
  7985. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7986. VIGNETTEBLENDMODEOPAQUE: boolean;
  7987. TONEMAPPING: boolean;
  7988. TONEMAPPING_ACES: boolean;
  7989. CONTRAST: boolean;
  7990. COLORCURVES: boolean;
  7991. COLORGRADING: boolean;
  7992. COLORGRADING3D: boolean;
  7993. SAMPLER3DGREENDEPTH: boolean;
  7994. SAMPLER3DBGRMAP: boolean;
  7995. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7996. EXPOSURE: boolean;
  7997. constructor();
  7998. }
  7999. /**
  8000. * This groups together the common properties used for image processing either in direct forward pass
  8001. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8002. * or not.
  8003. */
  8004. export class ImageProcessingConfiguration {
  8005. /**
  8006. * Default tone mapping applied in BabylonJS.
  8007. */
  8008. static readonly TONEMAPPING_STANDARD: number;
  8009. /**
  8010. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8011. * to other engines rendering to increase portability.
  8012. */
  8013. static readonly TONEMAPPING_ACES: number;
  8014. /**
  8015. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8016. */
  8017. colorCurves: Nullable<ColorCurves>;
  8018. private _colorCurvesEnabled;
  8019. /**
  8020. * Gets wether the color curves effect is enabled.
  8021. */
  8022. /**
  8023. * Sets wether the color curves effect is enabled.
  8024. */
  8025. colorCurvesEnabled: boolean;
  8026. private _colorGradingTexture;
  8027. /**
  8028. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8029. */
  8030. /**
  8031. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8032. */
  8033. colorGradingTexture: Nullable<BaseTexture>;
  8034. private _colorGradingEnabled;
  8035. /**
  8036. * Gets wether the color grading effect is enabled.
  8037. */
  8038. /**
  8039. * Sets wether the color grading effect is enabled.
  8040. */
  8041. colorGradingEnabled: boolean;
  8042. private _colorGradingWithGreenDepth;
  8043. /**
  8044. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8045. */
  8046. /**
  8047. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8048. */
  8049. colorGradingWithGreenDepth: boolean;
  8050. private _colorGradingBGR;
  8051. /**
  8052. * Gets wether the color grading texture contains BGR values.
  8053. */
  8054. /**
  8055. * Sets wether the color grading texture contains BGR values.
  8056. */
  8057. colorGradingBGR: boolean;
  8058. /** @hidden */
  8059. _exposure: number;
  8060. /**
  8061. * Gets the Exposure used in the effect.
  8062. */
  8063. /**
  8064. * Sets the Exposure used in the effect.
  8065. */
  8066. exposure: number;
  8067. private _toneMappingEnabled;
  8068. /**
  8069. * Gets wether the tone mapping effect is enabled.
  8070. */
  8071. /**
  8072. * Sets wether the tone mapping effect is enabled.
  8073. */
  8074. toneMappingEnabled: boolean;
  8075. private _toneMappingType;
  8076. /**
  8077. * Gets the type of tone mapping effect.
  8078. */
  8079. /**
  8080. * Sets the type of tone mapping effect used in BabylonJS.
  8081. */
  8082. toneMappingType: number;
  8083. protected _contrast: number;
  8084. /**
  8085. * Gets the contrast used in the effect.
  8086. */
  8087. /**
  8088. * Sets the contrast used in the effect.
  8089. */
  8090. contrast: number;
  8091. /**
  8092. * Vignette stretch size.
  8093. */
  8094. vignetteStretch: number;
  8095. /**
  8096. * Vignette centre X Offset.
  8097. */
  8098. vignetteCentreX: number;
  8099. /**
  8100. * Vignette centre Y Offset.
  8101. */
  8102. vignetteCentreY: number;
  8103. /**
  8104. * Vignette weight or intensity of the vignette effect.
  8105. */
  8106. vignetteWeight: number;
  8107. /**
  8108. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8109. * if vignetteEnabled is set to true.
  8110. */
  8111. vignetteColor: Color4;
  8112. /**
  8113. * Camera field of view used by the Vignette effect.
  8114. */
  8115. vignetteCameraFov: number;
  8116. private _vignetteBlendMode;
  8117. /**
  8118. * Gets the vignette blend mode allowing different kind of effect.
  8119. */
  8120. /**
  8121. * Sets the vignette blend mode allowing different kind of effect.
  8122. */
  8123. vignetteBlendMode: number;
  8124. private _vignetteEnabled;
  8125. /**
  8126. * Gets wether the vignette effect is enabled.
  8127. */
  8128. /**
  8129. * Sets wether the vignette effect is enabled.
  8130. */
  8131. vignetteEnabled: boolean;
  8132. private _applyByPostProcess;
  8133. /**
  8134. * Gets wether the image processing is applied through a post process or not.
  8135. */
  8136. /**
  8137. * Sets wether the image processing is applied through a post process or not.
  8138. */
  8139. applyByPostProcess: boolean;
  8140. private _isEnabled;
  8141. /**
  8142. * Gets wether the image processing is enabled or not.
  8143. */
  8144. /**
  8145. * Sets wether the image processing is enabled or not.
  8146. */
  8147. isEnabled: boolean;
  8148. /**
  8149. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8150. */
  8151. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8152. /**
  8153. * Method called each time the image processing information changes requires to recompile the effect.
  8154. */
  8155. protected _updateParameters(): void;
  8156. /**
  8157. * Gets the current class name.
  8158. * @return "ImageProcessingConfiguration"
  8159. */
  8160. getClassName(): string;
  8161. /**
  8162. * Prepare the list of uniforms associated with the Image Processing effects.
  8163. * @param uniforms The list of uniforms used in the effect
  8164. * @param defines the list of defines currently in use
  8165. */
  8166. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8167. /**
  8168. * Prepare the list of samplers associated with the Image Processing effects.
  8169. * @param samplersList The list of uniforms used in the effect
  8170. * @param defines the list of defines currently in use
  8171. */
  8172. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8173. /**
  8174. * Prepare the list of defines associated to the shader.
  8175. * @param defines the list of defines to complete
  8176. * @param forPostProcess Define if we are currently in post process mode or not
  8177. */
  8178. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8179. /**
  8180. * Returns true if all the image processing information are ready.
  8181. * @returns True if ready, otherwise, false
  8182. */
  8183. isReady(): boolean;
  8184. /**
  8185. * Binds the image processing to the shader.
  8186. * @param effect The effect to bind to
  8187. * @param aspectRatio Define the current aspect ratio of the effect
  8188. */
  8189. bind(effect: Effect, aspectRatio?: number): void;
  8190. /**
  8191. * Clones the current image processing instance.
  8192. * @return The cloned image processing
  8193. */
  8194. clone(): ImageProcessingConfiguration;
  8195. /**
  8196. * Serializes the current image processing instance to a json representation.
  8197. * @return a JSON representation
  8198. */
  8199. serialize(): any;
  8200. /**
  8201. * Parses the image processing from a json representation.
  8202. * @param source the JSON source to parse
  8203. * @return The parsed image processing
  8204. */
  8205. static Parse(source: any): ImageProcessingConfiguration;
  8206. private static _VIGNETTEMODE_MULTIPLY;
  8207. private static _VIGNETTEMODE_OPAQUE;
  8208. /**
  8209. * Used to apply the vignette as a mix with the pixel color.
  8210. */
  8211. static readonly VIGNETTEMODE_MULTIPLY: number;
  8212. /**
  8213. * Used to apply the vignette as a replacement of the pixel color.
  8214. */
  8215. static readonly VIGNETTEMODE_OPAQUE: number;
  8216. }
  8217. }
  8218. declare module BABYLON {
  8219. /** @hidden */
  8220. export var postprocessVertexShader: {
  8221. name: string;
  8222. shader: string;
  8223. };
  8224. }
  8225. declare module BABYLON {
  8226. /** Defines supported spaces */
  8227. export enum Space {
  8228. /** Local (object) space */
  8229. LOCAL = 0,
  8230. /** World space */
  8231. WORLD = 1,
  8232. /** Bone space */
  8233. BONE = 2
  8234. }
  8235. /** Defines the 3 main axes */
  8236. export class Axis {
  8237. /** X axis */
  8238. static X: Vector3;
  8239. /** Y axis */
  8240. static Y: Vector3;
  8241. /** Z axis */
  8242. static Z: Vector3;
  8243. }
  8244. }
  8245. declare module BABYLON {
  8246. /**
  8247. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8248. * This is the base of the follow, arc rotate cameras and Free camera
  8249. * @see http://doc.babylonjs.com/features/cameras
  8250. */
  8251. export class TargetCamera extends Camera {
  8252. private static _RigCamTransformMatrix;
  8253. private static _TargetTransformMatrix;
  8254. private static _TargetFocalPoint;
  8255. /**
  8256. * Define the current direction the camera is moving to
  8257. */
  8258. cameraDirection: Vector3;
  8259. /**
  8260. * Define the current rotation the camera is rotating to
  8261. */
  8262. cameraRotation: Vector2;
  8263. /**
  8264. * When set, the up vector of the camera will be updated by the rotation of the camera
  8265. */
  8266. updateUpVectorFromRotation: boolean;
  8267. private _tmpQuaternion;
  8268. /**
  8269. * Define the current rotation of the camera
  8270. */
  8271. rotation: Vector3;
  8272. /**
  8273. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8274. */
  8275. rotationQuaternion: Quaternion;
  8276. /**
  8277. * Define the current speed of the camera
  8278. */
  8279. speed: number;
  8280. /**
  8281. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8282. * around all axis.
  8283. */
  8284. noRotationConstraint: boolean;
  8285. /**
  8286. * Define the current target of the camera as an object or a position.
  8287. */
  8288. lockedTarget: any;
  8289. /** @hidden */
  8290. _currentTarget: Vector3;
  8291. /** @hidden */
  8292. _initialFocalDistance: number;
  8293. /** @hidden */
  8294. _viewMatrix: Matrix;
  8295. /** @hidden */
  8296. _camMatrix: Matrix;
  8297. /** @hidden */
  8298. _cameraTransformMatrix: Matrix;
  8299. /** @hidden */
  8300. _cameraRotationMatrix: Matrix;
  8301. /** @hidden */
  8302. _referencePoint: Vector3;
  8303. /** @hidden */
  8304. _transformedReferencePoint: Vector3;
  8305. protected _globalCurrentTarget: Vector3;
  8306. protected _globalCurrentUpVector: Vector3;
  8307. /** @hidden */
  8308. _reset: () => void;
  8309. private _defaultUp;
  8310. /**
  8311. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8312. * This is the base of the follow, arc rotate cameras and Free camera
  8313. * @see http://doc.babylonjs.com/features/cameras
  8314. * @param name Defines the name of the camera in the scene
  8315. * @param position Defines the start position of the camera in the scene
  8316. * @param scene Defines the scene the camera belongs to
  8317. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8318. */
  8319. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8320. /**
  8321. * Gets the position in front of the camera at a given distance.
  8322. * @param distance The distance from the camera we want the position to be
  8323. * @returns the position
  8324. */
  8325. getFrontPosition(distance: number): Vector3;
  8326. /** @hidden */
  8327. _getLockedTargetPosition(): Nullable<Vector3>;
  8328. private _storedPosition;
  8329. private _storedRotation;
  8330. private _storedRotationQuaternion;
  8331. /**
  8332. * Store current camera state of the camera (fov, position, rotation, etc..)
  8333. * @returns the camera
  8334. */
  8335. storeState(): Camera;
  8336. /**
  8337. * Restored camera state. You must call storeState() first
  8338. * @returns whether it was successful or not
  8339. * @hidden
  8340. */
  8341. _restoreStateValues(): boolean;
  8342. /** @hidden */
  8343. _initCache(): void;
  8344. /** @hidden */
  8345. _updateCache(ignoreParentClass?: boolean): void;
  8346. /** @hidden */
  8347. _isSynchronizedViewMatrix(): boolean;
  8348. /** @hidden */
  8349. _computeLocalCameraSpeed(): number;
  8350. /**
  8351. * Defines the target the camera should look at.
  8352. * @param target Defines the new target as a Vector or a mesh
  8353. */
  8354. setTarget(target: Vector3): void;
  8355. /**
  8356. * Return the current target position of the camera. This value is expressed in local space.
  8357. * @returns the target position
  8358. */
  8359. getTarget(): Vector3;
  8360. /** @hidden */
  8361. _decideIfNeedsToMove(): boolean;
  8362. /** @hidden */
  8363. _updatePosition(): void;
  8364. /** @hidden */
  8365. _checkInputs(): void;
  8366. protected _updateCameraRotationMatrix(): void;
  8367. /**
  8368. * 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)
  8369. * @returns the current camera
  8370. */
  8371. private _rotateUpVectorWithCameraRotationMatrix;
  8372. private _cachedRotationZ;
  8373. private _cachedQuaternionRotationZ;
  8374. /** @hidden */
  8375. _getViewMatrix(): Matrix;
  8376. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8377. /**
  8378. * @hidden
  8379. */
  8380. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8381. /**
  8382. * @hidden
  8383. */
  8384. _updateRigCameras(): void;
  8385. private _getRigCamPositionAndTarget;
  8386. /**
  8387. * Gets the current object class name.
  8388. * @return the class name
  8389. */
  8390. getClassName(): string;
  8391. }
  8392. }
  8393. declare module BABYLON {
  8394. /**
  8395. * Gather the list of keyboard event types as constants.
  8396. */
  8397. export class KeyboardEventTypes {
  8398. /**
  8399. * The keydown event is fired when a key becomes active (pressed).
  8400. */
  8401. static readonly KEYDOWN: number;
  8402. /**
  8403. * The keyup event is fired when a key has been released.
  8404. */
  8405. static readonly KEYUP: number;
  8406. }
  8407. /**
  8408. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8409. */
  8410. export class KeyboardInfo {
  8411. /**
  8412. * Defines the type of event (KeyboardEventTypes)
  8413. */
  8414. type: number;
  8415. /**
  8416. * Defines the related dom event
  8417. */
  8418. event: KeyboardEvent;
  8419. /**
  8420. * Instantiates a new keyboard info.
  8421. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8422. * @param type Defines the type of event (KeyboardEventTypes)
  8423. * @param event Defines the related dom event
  8424. */
  8425. constructor(
  8426. /**
  8427. * Defines the type of event (KeyboardEventTypes)
  8428. */
  8429. type: number,
  8430. /**
  8431. * Defines the related dom event
  8432. */
  8433. event: KeyboardEvent);
  8434. }
  8435. /**
  8436. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8437. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8438. */
  8439. export class KeyboardInfoPre extends KeyboardInfo {
  8440. /**
  8441. * Defines the type of event (KeyboardEventTypes)
  8442. */
  8443. type: number;
  8444. /**
  8445. * Defines the related dom event
  8446. */
  8447. event: KeyboardEvent;
  8448. /**
  8449. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8450. */
  8451. skipOnPointerObservable: boolean;
  8452. /**
  8453. * Instantiates a new keyboard pre info.
  8454. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8455. * @param type Defines the type of event (KeyboardEventTypes)
  8456. * @param event Defines the related dom event
  8457. */
  8458. constructor(
  8459. /**
  8460. * Defines the type of event (KeyboardEventTypes)
  8461. */
  8462. type: number,
  8463. /**
  8464. * Defines the related dom event
  8465. */
  8466. event: KeyboardEvent);
  8467. }
  8468. }
  8469. declare module BABYLON {
  8470. /**
  8471. * Manage the keyboard inputs to control the movement of a free camera.
  8472. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8473. */
  8474. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8475. /**
  8476. * Defines the camera the input is attached to.
  8477. */
  8478. camera: FreeCamera;
  8479. /**
  8480. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8481. */
  8482. keysUp: number[];
  8483. /**
  8484. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8485. */
  8486. keysDown: number[];
  8487. /**
  8488. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8489. */
  8490. keysLeft: number[];
  8491. /**
  8492. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8493. */
  8494. keysRight: number[];
  8495. private _keys;
  8496. private _onCanvasBlurObserver;
  8497. private _onKeyboardObserver;
  8498. private _engine;
  8499. private _scene;
  8500. /**
  8501. * Attach the input controls to a specific dom element to get the input from.
  8502. * @param element Defines the element the controls should be listened from
  8503. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8504. */
  8505. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8506. /**
  8507. * Detach the current controls from the specified dom element.
  8508. * @param element Defines the element to stop listening the inputs from
  8509. */
  8510. detachControl(element: Nullable<HTMLElement>): void;
  8511. /**
  8512. * Update the current camera state depending on the inputs that have been used this frame.
  8513. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8514. */
  8515. checkInputs(): void;
  8516. /**
  8517. * Gets the class name of the current intput.
  8518. * @returns the class name
  8519. */
  8520. getClassName(): string;
  8521. /** @hidden */
  8522. _onLostFocus(): void;
  8523. /**
  8524. * Get the friendly name associated with the input class.
  8525. * @returns the input friendly name
  8526. */
  8527. getSimpleName(): string;
  8528. }
  8529. }
  8530. declare module BABYLON {
  8531. /**
  8532. * Interface describing all the common properties and methods a shadow light needs to implement.
  8533. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8534. * as well as binding the different shadow properties to the effects.
  8535. */
  8536. export interface IShadowLight extends Light {
  8537. /**
  8538. * The light id in the scene (used in scene.findLighById for instance)
  8539. */
  8540. id: string;
  8541. /**
  8542. * The position the shdow will be casted from.
  8543. */
  8544. position: Vector3;
  8545. /**
  8546. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8547. */
  8548. direction: Vector3;
  8549. /**
  8550. * The transformed position. Position of the light in world space taking parenting in account.
  8551. */
  8552. transformedPosition: Vector3;
  8553. /**
  8554. * The transformed direction. Direction of the light in world space taking parenting in account.
  8555. */
  8556. transformedDirection: Vector3;
  8557. /**
  8558. * The friendly name of the light in the scene.
  8559. */
  8560. name: string;
  8561. /**
  8562. * Defines the shadow projection clipping minimum z value.
  8563. */
  8564. shadowMinZ: number;
  8565. /**
  8566. * Defines the shadow projection clipping maximum z value.
  8567. */
  8568. shadowMaxZ: number;
  8569. /**
  8570. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8571. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8572. */
  8573. computeTransformedInformation(): boolean;
  8574. /**
  8575. * Gets the scene the light belongs to.
  8576. * @returns The scene
  8577. */
  8578. getScene(): Scene;
  8579. /**
  8580. * Callback defining a custom Projection Matrix Builder.
  8581. * This can be used to override the default projection matrix computation.
  8582. */
  8583. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8584. /**
  8585. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8586. * @param matrix The materix to updated with the projection information
  8587. * @param viewMatrix The transform matrix of the light
  8588. * @param renderList The list of mesh to render in the map
  8589. * @returns The current light
  8590. */
  8591. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8592. /**
  8593. * Gets the current depth scale used in ESM.
  8594. * @returns The scale
  8595. */
  8596. getDepthScale(): number;
  8597. /**
  8598. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8599. * @returns true if a cube texture needs to be use
  8600. */
  8601. needCube(): boolean;
  8602. /**
  8603. * Detects if the projection matrix requires to be recomputed this frame.
  8604. * @returns true if it requires to be recomputed otherwise, false.
  8605. */
  8606. needProjectionMatrixCompute(): boolean;
  8607. /**
  8608. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8609. */
  8610. forceProjectionMatrixCompute(): void;
  8611. /**
  8612. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8613. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8614. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8615. */
  8616. getShadowDirection(faceIndex?: number): Vector3;
  8617. /**
  8618. * Gets the minZ used for shadow according to both the scene and the light.
  8619. * @param activeCamera The camera we are returning the min for
  8620. * @returns the depth min z
  8621. */
  8622. getDepthMinZ(activeCamera: Camera): number;
  8623. /**
  8624. * Gets the maxZ used for shadow according to both the scene and the light.
  8625. * @param activeCamera The camera we are returning the max for
  8626. * @returns the depth max z
  8627. */
  8628. getDepthMaxZ(activeCamera: Camera): number;
  8629. }
  8630. /**
  8631. * Base implementation IShadowLight
  8632. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8633. */
  8634. export abstract class ShadowLight extends Light implements IShadowLight {
  8635. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8636. protected _position: Vector3;
  8637. protected _setPosition(value: Vector3): void;
  8638. /**
  8639. * Sets the position the shadow will be casted from. Also use as the light position for both
  8640. * point and spot lights.
  8641. */
  8642. /**
  8643. * Sets the position the shadow will be casted from. Also use as the light position for both
  8644. * point and spot lights.
  8645. */
  8646. position: Vector3;
  8647. protected _direction: Vector3;
  8648. protected _setDirection(value: Vector3): void;
  8649. /**
  8650. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8651. * Also use as the light direction on spot and directional lights.
  8652. */
  8653. /**
  8654. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8655. * Also use as the light direction on spot and directional lights.
  8656. */
  8657. direction: Vector3;
  8658. private _shadowMinZ;
  8659. /**
  8660. * Gets the shadow projection clipping minimum z value.
  8661. */
  8662. /**
  8663. * Sets the shadow projection clipping minimum z value.
  8664. */
  8665. shadowMinZ: number;
  8666. private _shadowMaxZ;
  8667. /**
  8668. * Sets the shadow projection clipping maximum z value.
  8669. */
  8670. /**
  8671. * Gets the shadow projection clipping maximum z value.
  8672. */
  8673. shadowMaxZ: number;
  8674. /**
  8675. * Callback defining a custom Projection Matrix Builder.
  8676. * This can be used to override the default projection matrix computation.
  8677. */
  8678. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8679. /**
  8680. * The transformed position. Position of the light in world space taking parenting in account.
  8681. */
  8682. transformedPosition: Vector3;
  8683. /**
  8684. * The transformed direction. Direction of the light in world space taking parenting in account.
  8685. */
  8686. transformedDirection: Vector3;
  8687. private _needProjectionMatrixCompute;
  8688. /**
  8689. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8690. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8691. */
  8692. computeTransformedInformation(): boolean;
  8693. /**
  8694. * Return the depth scale used for the shadow map.
  8695. * @returns the depth scale.
  8696. */
  8697. getDepthScale(): number;
  8698. /**
  8699. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8700. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8701. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8702. */
  8703. getShadowDirection(faceIndex?: number): Vector3;
  8704. /**
  8705. * Returns the ShadowLight absolute position in the World.
  8706. * @returns the position vector in world space
  8707. */
  8708. getAbsolutePosition(): Vector3;
  8709. /**
  8710. * Sets the ShadowLight direction toward the passed target.
  8711. * @param target The point to target in local space
  8712. * @returns the updated ShadowLight direction
  8713. */
  8714. setDirectionToTarget(target: Vector3): Vector3;
  8715. /**
  8716. * Returns the light rotation in euler definition.
  8717. * @returns the x y z rotation in local space.
  8718. */
  8719. getRotation(): Vector3;
  8720. /**
  8721. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8722. * @returns true if a cube texture needs to be use
  8723. */
  8724. needCube(): boolean;
  8725. /**
  8726. * Detects if the projection matrix requires to be recomputed this frame.
  8727. * @returns true if it requires to be recomputed otherwise, false.
  8728. */
  8729. needProjectionMatrixCompute(): boolean;
  8730. /**
  8731. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8732. */
  8733. forceProjectionMatrixCompute(): void;
  8734. /** @hidden */
  8735. _initCache(): void;
  8736. /** @hidden */
  8737. _isSynchronized(): boolean;
  8738. /**
  8739. * Computes the world matrix of the node
  8740. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8741. * @returns the world matrix
  8742. */
  8743. computeWorldMatrix(force?: boolean): Matrix;
  8744. /**
  8745. * Gets the minZ used for shadow according to both the scene and the light.
  8746. * @param activeCamera The camera we are returning the min for
  8747. * @returns the depth min z
  8748. */
  8749. getDepthMinZ(activeCamera: Camera): number;
  8750. /**
  8751. * Gets the maxZ used for shadow according to both the scene and the light.
  8752. * @param activeCamera The camera we are returning the max for
  8753. * @returns the depth max z
  8754. */
  8755. getDepthMaxZ(activeCamera: Camera): number;
  8756. /**
  8757. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8758. * @param matrix The materix to updated with the projection information
  8759. * @param viewMatrix The transform matrix of the light
  8760. * @param renderList The list of mesh to render in the map
  8761. * @returns The current light
  8762. */
  8763. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8764. }
  8765. }
  8766. declare module BABYLON {
  8767. /**
  8768. * "Static Class" containing the most commonly used helper while dealing with material for
  8769. * rendering purpose.
  8770. *
  8771. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8772. *
  8773. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8774. */
  8775. export class MaterialHelper {
  8776. /**
  8777. * Bind the current view position to an effect.
  8778. * @param effect The effect to be bound
  8779. * @param scene The scene the eyes position is used from
  8780. */
  8781. static BindEyePosition(effect: Effect, scene: Scene): void;
  8782. /**
  8783. * Helps preparing the defines values about the UVs in used in the effect.
  8784. * UVs are shared as much as we can accross channels in the shaders.
  8785. * @param texture The texture we are preparing the UVs for
  8786. * @param defines The defines to update
  8787. * @param key The channel key "diffuse", "specular"... used in the shader
  8788. */
  8789. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8790. /**
  8791. * Binds a texture matrix value to its corrsponding uniform
  8792. * @param texture The texture to bind the matrix for
  8793. * @param uniformBuffer The uniform buffer receivin the data
  8794. * @param key The channel key "diffuse", "specular"... used in the shader
  8795. */
  8796. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8797. /**
  8798. * Gets the current status of the fog (should it be enabled?)
  8799. * @param mesh defines the mesh to evaluate for fog support
  8800. * @param scene defines the hosting scene
  8801. * @returns true if fog must be enabled
  8802. */
  8803. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8804. /**
  8805. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8806. * @param mesh defines the current mesh
  8807. * @param scene defines the current scene
  8808. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8809. * @param pointsCloud defines if point cloud rendering has to be turned on
  8810. * @param fogEnabled defines if fog has to be turned on
  8811. * @param alphaTest defines if alpha testing has to be turned on
  8812. * @param defines defines the current list of defines
  8813. */
  8814. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8815. /**
  8816. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8817. * @param scene defines the current scene
  8818. * @param engine defines the current engine
  8819. * @param defines specifies the list of active defines
  8820. * @param useInstances defines if instances have to be turned on
  8821. * @param useClipPlane defines if clip plane have to be turned on
  8822. */
  8823. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8824. /**
  8825. * Prepares the defines for bones
  8826. * @param mesh The mesh containing the geometry data we will draw
  8827. * @param defines The defines to update
  8828. */
  8829. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8830. /**
  8831. * Prepares the defines for morph targets
  8832. * @param mesh The mesh containing the geometry data we will draw
  8833. * @param defines The defines to update
  8834. */
  8835. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8836. /**
  8837. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8838. * @param mesh The mesh containing the geometry data we will draw
  8839. * @param defines The defines to update
  8840. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8841. * @param useBones Precise whether bones should be used or not (override mesh info)
  8842. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8843. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8844. * @returns false if defines are considered not dirty and have not been checked
  8845. */
  8846. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8847. /**
  8848. * Prepares the defines related to multiview
  8849. * @param scene The scene we are intending to draw
  8850. * @param defines The defines to update
  8851. */
  8852. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8853. /**
  8854. * Prepares the defines related to the light information passed in parameter
  8855. * @param scene The scene we are intending to draw
  8856. * @param mesh The mesh the effect is compiling for
  8857. * @param light The light the effect is compiling for
  8858. * @param lightIndex The index of the light
  8859. * @param defines The defines to update
  8860. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8861. * @param state Defines the current state regarding what is needed (normals, etc...)
  8862. */
  8863. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8864. needNormals: boolean;
  8865. needRebuild: boolean;
  8866. shadowEnabled: boolean;
  8867. specularEnabled: boolean;
  8868. lightmapMode: boolean;
  8869. }): void;
  8870. /**
  8871. * Prepares the defines related to the light information passed in parameter
  8872. * @param scene The scene we are intending to draw
  8873. * @param mesh The mesh the effect is compiling for
  8874. * @param defines The defines to update
  8875. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8876. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8877. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8878. * @returns true if normals will be required for the rest of the effect
  8879. */
  8880. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8881. /**
  8882. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8883. * @param lightIndex defines the light index
  8884. * @param uniformsList The uniform list
  8885. * @param samplersList The sampler list
  8886. * @param projectedLightTexture defines if projected texture must be used
  8887. * @param uniformBuffersList defines an optional list of uniform buffers
  8888. */
  8889. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8890. /**
  8891. * Prepares the uniforms and samplers list to be used in the effect
  8892. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8893. * @param samplersList The sampler list
  8894. * @param defines The defines helping in the list generation
  8895. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8896. */
  8897. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8898. /**
  8899. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  8900. * @param defines The defines to update while falling back
  8901. * @param fallbacks The authorized effect fallbacks
  8902. * @param maxSimultaneousLights The maximum number of lights allowed
  8903. * @param rank the current rank of the Effect
  8904. * @returns The newly affected rank
  8905. */
  8906. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  8907. private static _TmpMorphInfluencers;
  8908. /**
  8909. * Prepares the list of attributes required for morph targets according to the effect defines.
  8910. * @param attribs The current list of supported attribs
  8911. * @param mesh The mesh to prepare the morph targets attributes for
  8912. * @param influencers The number of influencers
  8913. */
  8914. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  8915. /**
  8916. * Prepares the list of attributes required for morph targets according to the effect defines.
  8917. * @param attribs The current list of supported attribs
  8918. * @param mesh The mesh to prepare the morph targets attributes for
  8919. * @param defines The current Defines of the effect
  8920. */
  8921. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  8922. /**
  8923. * Prepares the list of attributes required for bones according to the effect defines.
  8924. * @param attribs The current list of supported attribs
  8925. * @param mesh The mesh to prepare the bones attributes for
  8926. * @param defines The current Defines of the effect
  8927. * @param fallbacks The current efffect fallback strategy
  8928. */
  8929. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  8930. /**
  8931. * Check and prepare the list of attributes required for instances according to the effect defines.
  8932. * @param attribs The current list of supported attribs
  8933. * @param defines The current MaterialDefines of the effect
  8934. */
  8935. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  8936. /**
  8937. * Add the list of attributes required for instances to the attribs array.
  8938. * @param attribs The current list of supported attribs
  8939. */
  8940. static PushAttributesForInstances(attribs: string[]): void;
  8941. /**
  8942. * Binds the light shadow information to the effect for the given mesh.
  8943. * @param light The light containing the generator
  8944. * @param scene The scene the lights belongs to
  8945. * @param mesh The mesh we are binding the information to render
  8946. * @param lightIndex The light index in the effect used to render the mesh
  8947. * @param effect The effect we are binding the data to
  8948. */
  8949. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  8950. /**
  8951. * Binds the light information to the effect.
  8952. * @param light The light containing the generator
  8953. * @param effect The effect we are binding the data to
  8954. * @param lightIndex The light index in the effect used to render
  8955. */
  8956. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  8957. /**
  8958. * Binds the lights information from the scene to the effect for the given mesh.
  8959. * @param light Light to bind
  8960. * @param lightIndex Light index
  8961. * @param scene The scene where the light belongs to
  8962. * @param mesh The mesh we are binding the information to render
  8963. * @param effect The effect we are binding the data to
  8964. * @param useSpecular Defines if specular is supported
  8965. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8966. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8967. */
  8968. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  8969. /**
  8970. * Binds the lights information from the scene to the effect for the given mesh.
  8971. * @param scene The scene the lights belongs to
  8972. * @param mesh The mesh we are binding the information to render
  8973. * @param effect The effect we are binding the data to
  8974. * @param defines The generated defines for the effect
  8975. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  8976. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8977. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8978. */
  8979. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  8980. private static _tempFogColor;
  8981. /**
  8982. * Binds the fog information from the scene to the effect for the given mesh.
  8983. * @param scene The scene the lights belongs to
  8984. * @param mesh The mesh we are binding the information to render
  8985. * @param effect The effect we are binding the data to
  8986. * @param linearSpace Defines if the fog effect is applied in linear space
  8987. */
  8988. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  8989. /**
  8990. * Binds the bones information from the mesh to the effect.
  8991. * @param mesh The mesh we are binding the information to render
  8992. * @param effect The effect we are binding the data to
  8993. */
  8994. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  8995. /**
  8996. * Binds the morph targets information from the mesh to the effect.
  8997. * @param abstractMesh The mesh we are binding the information to render
  8998. * @param effect The effect we are binding the data to
  8999. */
  9000. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9001. /**
  9002. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9003. * @param defines The generated defines used in the effect
  9004. * @param effect The effect we are binding the data to
  9005. * @param scene The scene we are willing to render with logarithmic scale for
  9006. */
  9007. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9008. /**
  9009. * Binds the clip plane information from the scene to the effect.
  9010. * @param scene The scene the clip plane information are extracted from
  9011. * @param effect The effect we are binding the data to
  9012. */
  9013. static BindClipPlane(effect: Effect, scene: Scene): void;
  9014. }
  9015. }
  9016. declare module BABYLON {
  9017. /** @hidden */
  9018. export var packingFunctions: {
  9019. name: string;
  9020. shader: string;
  9021. };
  9022. }
  9023. declare module BABYLON {
  9024. /** @hidden */
  9025. export var shadowMapPixelShader: {
  9026. name: string;
  9027. shader: string;
  9028. };
  9029. }
  9030. declare module BABYLON {
  9031. /** @hidden */
  9032. export var bonesDeclaration: {
  9033. name: string;
  9034. shader: string;
  9035. };
  9036. }
  9037. declare module BABYLON {
  9038. /** @hidden */
  9039. export var morphTargetsVertexGlobalDeclaration: {
  9040. name: string;
  9041. shader: string;
  9042. };
  9043. }
  9044. declare module BABYLON {
  9045. /** @hidden */
  9046. export var morphTargetsVertexDeclaration: {
  9047. name: string;
  9048. shader: string;
  9049. };
  9050. }
  9051. declare module BABYLON {
  9052. /** @hidden */
  9053. export var instancesDeclaration: {
  9054. name: string;
  9055. shader: string;
  9056. };
  9057. }
  9058. declare module BABYLON {
  9059. /** @hidden */
  9060. export var helperFunctions: {
  9061. name: string;
  9062. shader: string;
  9063. };
  9064. }
  9065. declare module BABYLON {
  9066. /** @hidden */
  9067. export var morphTargetsVertex: {
  9068. name: string;
  9069. shader: string;
  9070. };
  9071. }
  9072. declare module BABYLON {
  9073. /** @hidden */
  9074. export var instancesVertex: {
  9075. name: string;
  9076. shader: string;
  9077. };
  9078. }
  9079. declare module BABYLON {
  9080. /** @hidden */
  9081. export var bonesVertex: {
  9082. name: string;
  9083. shader: string;
  9084. };
  9085. }
  9086. declare module BABYLON {
  9087. /** @hidden */
  9088. export var shadowMapVertexShader: {
  9089. name: string;
  9090. shader: string;
  9091. };
  9092. }
  9093. declare module BABYLON {
  9094. /** @hidden */
  9095. export var depthBoxBlurPixelShader: {
  9096. name: string;
  9097. shader: string;
  9098. };
  9099. }
  9100. declare module BABYLON {
  9101. /**
  9102. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9103. */
  9104. export interface ICustomShaderOptions {
  9105. /**
  9106. * Gets or sets the custom shader name to use
  9107. */
  9108. shaderName: string;
  9109. /**
  9110. * The list of attribute names used in the shader
  9111. */
  9112. attributes?: string[];
  9113. /**
  9114. * The list of unifrom names used in the shader
  9115. */
  9116. uniforms?: string[];
  9117. /**
  9118. * The list of sampler names used in the shader
  9119. */
  9120. samplers?: string[];
  9121. /**
  9122. * The list of defines used in the shader
  9123. */
  9124. defines?: string[];
  9125. }
  9126. /**
  9127. * Interface to implement to create a shadow generator compatible with BJS.
  9128. */
  9129. export interface IShadowGenerator {
  9130. /**
  9131. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9132. * @returns The render target texture if present otherwise, null
  9133. */
  9134. getShadowMap(): Nullable<RenderTargetTexture>;
  9135. /**
  9136. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9137. * @returns The render target texture if the shadow map is present otherwise, null
  9138. */
  9139. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9140. /**
  9141. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9142. * @param subMesh The submesh we want to render in the shadow map
  9143. * @param useInstances Defines wether will draw in the map using instances
  9144. * @returns true if ready otherwise, false
  9145. */
  9146. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9147. /**
  9148. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9149. * @param defines Defines of the material we want to update
  9150. * @param lightIndex Index of the light in the enabled light list of the material
  9151. */
  9152. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9153. /**
  9154. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9155. * defined in the generator but impacting the effect).
  9156. * It implies the unifroms available on the materials are the standard BJS ones.
  9157. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9158. * @param effect The effect we are binfing the information for
  9159. */
  9160. bindShadowLight(lightIndex: string, effect: Effect): void;
  9161. /**
  9162. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9163. * (eq to shadow prjection matrix * light transform matrix)
  9164. * @returns The transform matrix used to create the shadow map
  9165. */
  9166. getTransformMatrix(): Matrix;
  9167. /**
  9168. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9169. * Cube and 2D textures for instance.
  9170. */
  9171. recreateShadowMap(): void;
  9172. /**
  9173. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9174. * @param onCompiled Callback triggered at the and of the effects compilation
  9175. * @param options Sets of optional options forcing the compilation with different modes
  9176. */
  9177. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9178. useInstances: boolean;
  9179. }>): void;
  9180. /**
  9181. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9182. * @param options Sets of optional options forcing the compilation with different modes
  9183. * @returns A promise that resolves when the compilation completes
  9184. */
  9185. forceCompilationAsync(options?: Partial<{
  9186. useInstances: boolean;
  9187. }>): Promise<void>;
  9188. /**
  9189. * Serializes the shadow generator setup to a json object.
  9190. * @returns The serialized JSON object
  9191. */
  9192. serialize(): any;
  9193. /**
  9194. * Disposes the Shadow map and related Textures and effects.
  9195. */
  9196. dispose(): void;
  9197. }
  9198. /**
  9199. * Default implementation IShadowGenerator.
  9200. * This is the main object responsible of generating shadows in the framework.
  9201. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9202. */
  9203. export class ShadowGenerator implements IShadowGenerator {
  9204. /**
  9205. * Shadow generator mode None: no filtering applied.
  9206. */
  9207. static readonly FILTER_NONE: number;
  9208. /**
  9209. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9210. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9211. */
  9212. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9213. /**
  9214. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9215. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9216. */
  9217. static readonly FILTER_POISSONSAMPLING: number;
  9218. /**
  9219. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9220. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9221. */
  9222. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9223. /**
  9224. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9225. * edge artifacts on steep falloff.
  9226. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9227. */
  9228. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9229. /**
  9230. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9231. * edge artifacts on steep falloff.
  9232. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9233. */
  9234. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9235. /**
  9236. * Shadow generator mode PCF: Percentage Closer Filtering
  9237. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9238. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9239. */
  9240. static readonly FILTER_PCF: number;
  9241. /**
  9242. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9243. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9244. * Contact Hardening
  9245. */
  9246. static readonly FILTER_PCSS: number;
  9247. /**
  9248. * Reserved for PCF and PCSS
  9249. * Highest Quality.
  9250. *
  9251. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9252. *
  9253. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9254. */
  9255. static readonly QUALITY_HIGH: number;
  9256. /**
  9257. * Reserved for PCF and PCSS
  9258. * Good tradeoff for quality/perf cross devices
  9259. *
  9260. * Execute PCF on a 3*3 kernel.
  9261. *
  9262. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9263. */
  9264. static readonly QUALITY_MEDIUM: number;
  9265. /**
  9266. * Reserved for PCF and PCSS
  9267. * The lowest quality but the fastest.
  9268. *
  9269. * Execute PCF on a 1*1 kernel.
  9270. *
  9271. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9272. */
  9273. static readonly QUALITY_LOW: number;
  9274. /** Gets or sets the custom shader name to use */
  9275. customShaderOptions: ICustomShaderOptions;
  9276. /**
  9277. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9278. */
  9279. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9280. /**
  9281. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9282. */
  9283. onAfterShadowMapRenderObservable: Observable<Effect>;
  9284. /**
  9285. * Observable triggered before a mesh is rendered in the shadow map.
  9286. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9287. */
  9288. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9289. /**
  9290. * Observable triggered after a mesh is rendered in the shadow map.
  9291. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9292. */
  9293. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9294. private _bias;
  9295. /**
  9296. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9297. */
  9298. /**
  9299. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9300. */
  9301. bias: number;
  9302. private _normalBias;
  9303. /**
  9304. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9305. */
  9306. /**
  9307. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9308. */
  9309. normalBias: number;
  9310. private _blurBoxOffset;
  9311. /**
  9312. * Gets the blur box offset: offset applied during the blur pass.
  9313. * Only useful if useKernelBlur = false
  9314. */
  9315. /**
  9316. * Sets the blur box offset: offset applied during the blur pass.
  9317. * Only useful if useKernelBlur = false
  9318. */
  9319. blurBoxOffset: number;
  9320. private _blurScale;
  9321. /**
  9322. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9323. * 2 means half of the size.
  9324. */
  9325. /**
  9326. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9327. * 2 means half of the size.
  9328. */
  9329. blurScale: number;
  9330. private _blurKernel;
  9331. /**
  9332. * Gets the blur kernel: kernel size of the blur pass.
  9333. * Only useful if useKernelBlur = true
  9334. */
  9335. /**
  9336. * Sets the blur kernel: kernel size of the blur pass.
  9337. * Only useful if useKernelBlur = true
  9338. */
  9339. blurKernel: number;
  9340. private _useKernelBlur;
  9341. /**
  9342. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9343. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9344. */
  9345. /**
  9346. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9347. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9348. */
  9349. useKernelBlur: boolean;
  9350. private _depthScale;
  9351. /**
  9352. * Gets the depth scale used in ESM mode.
  9353. */
  9354. /**
  9355. * Sets the depth scale used in ESM mode.
  9356. * This can override the scale stored on the light.
  9357. */
  9358. depthScale: number;
  9359. private _filter;
  9360. /**
  9361. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9362. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9363. */
  9364. /**
  9365. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9366. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9367. */
  9368. filter: number;
  9369. /**
  9370. * Gets if the current filter is set to Poisson Sampling.
  9371. */
  9372. /**
  9373. * Sets the current filter to Poisson Sampling.
  9374. */
  9375. usePoissonSampling: boolean;
  9376. /**
  9377. * Gets if the current filter is set to ESM.
  9378. */
  9379. /**
  9380. * Sets the current filter is to ESM.
  9381. */
  9382. useExponentialShadowMap: boolean;
  9383. /**
  9384. * Gets if the current filter is set to filtered ESM.
  9385. */
  9386. /**
  9387. * Gets if the current filter is set to filtered ESM.
  9388. */
  9389. useBlurExponentialShadowMap: boolean;
  9390. /**
  9391. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9392. * exponential to prevent steep falloff artifacts).
  9393. */
  9394. /**
  9395. * Sets the current filter to "close ESM" (using the inverse of the
  9396. * exponential to prevent steep falloff artifacts).
  9397. */
  9398. useCloseExponentialShadowMap: boolean;
  9399. /**
  9400. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9401. * exponential to prevent steep falloff artifacts).
  9402. */
  9403. /**
  9404. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9405. * exponential to prevent steep falloff artifacts).
  9406. */
  9407. useBlurCloseExponentialShadowMap: boolean;
  9408. /**
  9409. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9410. */
  9411. /**
  9412. * Sets the current filter to "PCF" (percentage closer filtering).
  9413. */
  9414. usePercentageCloserFiltering: boolean;
  9415. private _filteringQuality;
  9416. /**
  9417. * Gets the PCF or PCSS Quality.
  9418. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9419. */
  9420. /**
  9421. * Sets the PCF or PCSS Quality.
  9422. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9423. */
  9424. filteringQuality: number;
  9425. /**
  9426. * Gets if the current filter is set to "PCSS" (contact hardening).
  9427. */
  9428. /**
  9429. * Sets the current filter to "PCSS" (contact hardening).
  9430. */
  9431. useContactHardeningShadow: boolean;
  9432. private _contactHardeningLightSizeUVRatio;
  9433. /**
  9434. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9435. * Using a ratio helps keeping shape stability independently of the map size.
  9436. *
  9437. * It does not account for the light projection as it was having too much
  9438. * instability during the light setup or during light position changes.
  9439. *
  9440. * Only valid if useContactHardeningShadow is true.
  9441. */
  9442. /**
  9443. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9444. * Using a ratio helps keeping shape stability independently of the map size.
  9445. *
  9446. * It does not account for the light projection as it was having too much
  9447. * instability during the light setup or during light position changes.
  9448. *
  9449. * Only valid if useContactHardeningShadow is true.
  9450. */
  9451. contactHardeningLightSizeUVRatio: number;
  9452. private _darkness;
  9453. /** Gets or sets the actual darkness of a shadow */
  9454. darkness: number;
  9455. /**
  9456. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9457. * 0 means strongest and 1 would means no shadow.
  9458. * @returns the darkness.
  9459. */
  9460. getDarkness(): number;
  9461. /**
  9462. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9463. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9464. * @returns the shadow generator allowing fluent coding.
  9465. */
  9466. setDarkness(darkness: number): ShadowGenerator;
  9467. private _transparencyShadow;
  9468. /** Gets or sets the ability to have transparent shadow */
  9469. transparencyShadow: boolean;
  9470. /**
  9471. * Sets the ability to have transparent shadow (boolean).
  9472. * @param transparent True if transparent else False
  9473. * @returns the shadow generator allowing fluent coding
  9474. */
  9475. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9476. private _shadowMap;
  9477. private _shadowMap2;
  9478. /**
  9479. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9480. * @returns The render target texture if present otherwise, null
  9481. */
  9482. getShadowMap(): Nullable<RenderTargetTexture>;
  9483. /**
  9484. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9485. * @returns The render target texture if the shadow map is present otherwise, null
  9486. */
  9487. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9488. /**
  9489. * Gets the class name of that object
  9490. * @returns "ShadowGenerator"
  9491. */
  9492. getClassName(): string;
  9493. /**
  9494. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9495. * @param mesh Mesh to add
  9496. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9497. * @returns the Shadow Generator itself
  9498. */
  9499. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9500. /**
  9501. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9502. * @param mesh Mesh to remove
  9503. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9504. * @returns the Shadow Generator itself
  9505. */
  9506. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9507. /**
  9508. * Controls the extent to which the shadows fade out at the edge of the frustum
  9509. * Used only by directionals and spots
  9510. */
  9511. frustumEdgeFalloff: number;
  9512. private _light;
  9513. /**
  9514. * Returns the associated light object.
  9515. * @returns the light generating the shadow
  9516. */
  9517. getLight(): IShadowLight;
  9518. /**
  9519. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9520. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9521. * It might on the other hand introduce peter panning.
  9522. */
  9523. forceBackFacesOnly: boolean;
  9524. private _scene;
  9525. private _lightDirection;
  9526. private _effect;
  9527. private _viewMatrix;
  9528. private _projectionMatrix;
  9529. private _transformMatrix;
  9530. private _cachedPosition;
  9531. private _cachedDirection;
  9532. private _cachedDefines;
  9533. private _currentRenderID;
  9534. private _boxBlurPostprocess;
  9535. private _kernelBlurXPostprocess;
  9536. private _kernelBlurYPostprocess;
  9537. private _blurPostProcesses;
  9538. private _mapSize;
  9539. private _currentFaceIndex;
  9540. private _currentFaceIndexCache;
  9541. private _textureType;
  9542. private _defaultTextureMatrix;
  9543. /** @hidden */
  9544. static _SceneComponentInitialization: (scene: Scene) => void;
  9545. /**
  9546. * Creates a ShadowGenerator object.
  9547. * A ShadowGenerator is the required tool to use the shadows.
  9548. * Each light casting shadows needs to use its own ShadowGenerator.
  9549. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9550. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9551. * @param light The light object generating the shadows.
  9552. * @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.
  9553. */
  9554. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9555. private _initializeGenerator;
  9556. private _initializeShadowMap;
  9557. private _initializeBlurRTTAndPostProcesses;
  9558. private _renderForShadowMap;
  9559. private _renderSubMeshForShadowMap;
  9560. private _applyFilterValues;
  9561. /**
  9562. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9563. * @param onCompiled Callback triggered at the and of the effects compilation
  9564. * @param options Sets of optional options forcing the compilation with different modes
  9565. */
  9566. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9567. useInstances: boolean;
  9568. }>): void;
  9569. /**
  9570. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9571. * @param options Sets of optional options forcing the compilation with different modes
  9572. * @returns A promise that resolves when the compilation completes
  9573. */
  9574. forceCompilationAsync(options?: Partial<{
  9575. useInstances: boolean;
  9576. }>): Promise<void>;
  9577. /**
  9578. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9579. * @param subMesh The submesh we want to render in the shadow map
  9580. * @param useInstances Defines wether will draw in the map using instances
  9581. * @returns true if ready otherwise, false
  9582. */
  9583. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9584. /**
  9585. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9586. * @param defines Defines of the material we want to update
  9587. * @param lightIndex Index of the light in the enabled light list of the material
  9588. */
  9589. prepareDefines(defines: any, lightIndex: number): void;
  9590. /**
  9591. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9592. * defined in the generator but impacting the effect).
  9593. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9594. * @param effect The effect we are binfing the information for
  9595. */
  9596. bindShadowLight(lightIndex: string, effect: Effect): void;
  9597. /**
  9598. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9599. * (eq to shadow prjection matrix * light transform matrix)
  9600. * @returns The transform matrix used to create the shadow map
  9601. */
  9602. getTransformMatrix(): Matrix;
  9603. /**
  9604. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9605. * Cube and 2D textures for instance.
  9606. */
  9607. recreateShadowMap(): void;
  9608. private _disposeBlurPostProcesses;
  9609. private _disposeRTTandPostProcesses;
  9610. /**
  9611. * Disposes the ShadowGenerator.
  9612. * Returns nothing.
  9613. */
  9614. dispose(): void;
  9615. /**
  9616. * Serializes the shadow generator setup to a json object.
  9617. * @returns The serialized JSON object
  9618. */
  9619. serialize(): any;
  9620. /**
  9621. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9622. * @param parsedShadowGenerator The JSON object to parse
  9623. * @param scene The scene to create the shadow map for
  9624. * @returns The parsed shadow generator
  9625. */
  9626. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9627. }
  9628. }
  9629. declare module BABYLON {
  9630. /**
  9631. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9632. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9633. * 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.
  9634. */
  9635. export abstract class Light extends Node {
  9636. /**
  9637. * Falloff Default: light is falling off following the material specification:
  9638. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9639. */
  9640. static readonly FALLOFF_DEFAULT: number;
  9641. /**
  9642. * Falloff Physical: light is falling off following the inverse squared distance law.
  9643. */
  9644. static readonly FALLOFF_PHYSICAL: number;
  9645. /**
  9646. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9647. * to enhance interoperability with other engines.
  9648. */
  9649. static readonly FALLOFF_GLTF: number;
  9650. /**
  9651. * Falloff Standard: light is falling off like in the standard material
  9652. * to enhance interoperability with other materials.
  9653. */
  9654. static readonly FALLOFF_STANDARD: number;
  9655. /**
  9656. * If every light affecting the material is in this lightmapMode,
  9657. * material.lightmapTexture adds or multiplies
  9658. * (depends on material.useLightmapAsShadowmap)
  9659. * after every other light calculations.
  9660. */
  9661. static readonly LIGHTMAP_DEFAULT: number;
  9662. /**
  9663. * material.lightmapTexture as only diffuse lighting from this light
  9664. * adds only specular lighting from this light
  9665. * adds dynamic shadows
  9666. */
  9667. static readonly LIGHTMAP_SPECULAR: number;
  9668. /**
  9669. * material.lightmapTexture as only lighting
  9670. * no light calculation from this light
  9671. * only adds dynamic shadows from this light
  9672. */
  9673. static readonly LIGHTMAP_SHADOWSONLY: number;
  9674. /**
  9675. * Each light type uses the default quantity according to its type:
  9676. * point/spot lights use luminous intensity
  9677. * directional lights use illuminance
  9678. */
  9679. static readonly INTENSITYMODE_AUTOMATIC: number;
  9680. /**
  9681. * lumen (lm)
  9682. */
  9683. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9684. /**
  9685. * candela (lm/sr)
  9686. */
  9687. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9688. /**
  9689. * lux (lm/m^2)
  9690. */
  9691. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9692. /**
  9693. * nit (cd/m^2)
  9694. */
  9695. static readonly INTENSITYMODE_LUMINANCE: number;
  9696. /**
  9697. * Light type const id of the point light.
  9698. */
  9699. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9700. /**
  9701. * Light type const id of the directional light.
  9702. */
  9703. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9704. /**
  9705. * Light type const id of the spot light.
  9706. */
  9707. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9708. /**
  9709. * Light type const id of the hemispheric light.
  9710. */
  9711. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9712. /**
  9713. * Diffuse gives the basic color to an object.
  9714. */
  9715. diffuse: Color3;
  9716. /**
  9717. * Specular produces a highlight color on an object.
  9718. * Note: This is note affecting PBR materials.
  9719. */
  9720. specular: Color3;
  9721. /**
  9722. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9723. * falling off base on range or angle.
  9724. * This can be set to any values in Light.FALLOFF_x.
  9725. *
  9726. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9727. * other types of materials.
  9728. */
  9729. falloffType: number;
  9730. /**
  9731. * Strength of the light.
  9732. * Note: By default it is define in the framework own unit.
  9733. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9734. */
  9735. intensity: number;
  9736. private _range;
  9737. protected _inverseSquaredRange: number;
  9738. /**
  9739. * Defines how far from the source the light is impacting in scene units.
  9740. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9741. */
  9742. /**
  9743. * Defines how far from the source the light is impacting in scene units.
  9744. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9745. */
  9746. range: number;
  9747. /**
  9748. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9749. * of light.
  9750. */
  9751. private _photometricScale;
  9752. private _intensityMode;
  9753. /**
  9754. * Gets the photometric scale used to interpret the intensity.
  9755. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9756. */
  9757. /**
  9758. * Sets the photometric scale used to interpret the intensity.
  9759. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9760. */
  9761. intensityMode: number;
  9762. private _radius;
  9763. /**
  9764. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9765. */
  9766. /**
  9767. * sets the light radius used by PBR Materials to simulate soft area lights.
  9768. */
  9769. radius: number;
  9770. private _renderPriority;
  9771. /**
  9772. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9773. * exceeding the number allowed of the materials.
  9774. */
  9775. renderPriority: number;
  9776. private _shadowEnabled;
  9777. /**
  9778. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9779. * the current shadow generator.
  9780. */
  9781. /**
  9782. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9783. * the current shadow generator.
  9784. */
  9785. shadowEnabled: boolean;
  9786. private _includedOnlyMeshes;
  9787. /**
  9788. * Gets the only meshes impacted by this light.
  9789. */
  9790. /**
  9791. * Sets the only meshes impacted by this light.
  9792. */
  9793. includedOnlyMeshes: AbstractMesh[];
  9794. private _excludedMeshes;
  9795. /**
  9796. * Gets the meshes not impacted by this light.
  9797. */
  9798. /**
  9799. * Sets the meshes not impacted by this light.
  9800. */
  9801. excludedMeshes: AbstractMesh[];
  9802. private _excludeWithLayerMask;
  9803. /**
  9804. * Gets the layer id use to find what meshes are not impacted by the light.
  9805. * Inactive if 0
  9806. */
  9807. /**
  9808. * Sets the layer id use to find what meshes are not impacted by the light.
  9809. * Inactive if 0
  9810. */
  9811. excludeWithLayerMask: number;
  9812. private _includeOnlyWithLayerMask;
  9813. /**
  9814. * Gets the layer id use to find what meshes are impacted by the light.
  9815. * Inactive if 0
  9816. */
  9817. /**
  9818. * Sets the layer id use to find what meshes are impacted by the light.
  9819. * Inactive if 0
  9820. */
  9821. includeOnlyWithLayerMask: number;
  9822. private _lightmapMode;
  9823. /**
  9824. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9825. */
  9826. /**
  9827. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9828. */
  9829. lightmapMode: number;
  9830. /**
  9831. * Shadow generator associted to the light.
  9832. * @hidden Internal use only.
  9833. */
  9834. _shadowGenerator: Nullable<IShadowGenerator>;
  9835. /**
  9836. * @hidden Internal use only.
  9837. */
  9838. _excludedMeshesIds: string[];
  9839. /**
  9840. * @hidden Internal use only.
  9841. */
  9842. _includedOnlyMeshesIds: string[];
  9843. /**
  9844. * The current light unifom buffer.
  9845. * @hidden Internal use only.
  9846. */
  9847. _uniformBuffer: UniformBuffer;
  9848. /**
  9849. * Creates a Light object in the scene.
  9850. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9851. * @param name The firendly name of the light
  9852. * @param scene The scene the light belongs too
  9853. */
  9854. constructor(name: string, scene: Scene);
  9855. protected abstract _buildUniformLayout(): void;
  9856. /**
  9857. * Sets the passed Effect "effect" with the Light information.
  9858. * @param effect The effect to update
  9859. * @param lightIndex The index of the light in the effect to update
  9860. * @returns The light
  9861. */
  9862. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9863. /**
  9864. * Sets the passed Effect "effect" with the Light information.
  9865. * @param effect The effect to update
  9866. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9867. * @returns The light
  9868. */
  9869. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9870. /**
  9871. * Returns the string "Light".
  9872. * @returns the class name
  9873. */
  9874. getClassName(): string;
  9875. /** @hidden */
  9876. readonly _isLight: boolean;
  9877. /**
  9878. * Converts the light information to a readable string for debug purpose.
  9879. * @param fullDetails Supports for multiple levels of logging within scene loading
  9880. * @returns the human readable light info
  9881. */
  9882. toString(fullDetails?: boolean): string;
  9883. /** @hidden */
  9884. protected _syncParentEnabledState(): void;
  9885. /**
  9886. * Set the enabled state of this node.
  9887. * @param value - the new enabled state
  9888. */
  9889. setEnabled(value: boolean): void;
  9890. /**
  9891. * Returns the Light associated shadow generator if any.
  9892. * @return the associated shadow generator.
  9893. */
  9894. getShadowGenerator(): Nullable<IShadowGenerator>;
  9895. /**
  9896. * Returns a Vector3, the absolute light position in the World.
  9897. * @returns the world space position of the light
  9898. */
  9899. getAbsolutePosition(): Vector3;
  9900. /**
  9901. * Specifies if the light will affect the passed mesh.
  9902. * @param mesh The mesh to test against the light
  9903. * @return true the mesh is affected otherwise, false.
  9904. */
  9905. canAffectMesh(mesh: AbstractMesh): boolean;
  9906. /**
  9907. * Sort function to order lights for rendering.
  9908. * @param a First Light object to compare to second.
  9909. * @param b Second Light object to compare first.
  9910. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9911. */
  9912. static CompareLightsPriority(a: Light, b: Light): number;
  9913. /**
  9914. * Releases resources associated with this node.
  9915. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9916. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9917. */
  9918. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9919. /**
  9920. * Returns the light type ID (integer).
  9921. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9922. */
  9923. getTypeID(): number;
  9924. /**
  9925. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9926. * @returns the scaled intensity in intensity mode unit
  9927. */
  9928. getScaledIntensity(): number;
  9929. /**
  9930. * Returns a new Light object, named "name", from the current one.
  9931. * @param name The name of the cloned light
  9932. * @returns the new created light
  9933. */
  9934. clone(name: string): Nullable<Light>;
  9935. /**
  9936. * Serializes the current light into a Serialization object.
  9937. * @returns the serialized object.
  9938. */
  9939. serialize(): any;
  9940. /**
  9941. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9942. * This new light is named "name" and added to the passed scene.
  9943. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9944. * @param name The friendly name of the light
  9945. * @param scene The scene the new light will belong to
  9946. * @returns the constructor function
  9947. */
  9948. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9949. /**
  9950. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9951. * @param parsedLight The JSON representation of the light
  9952. * @param scene The scene to create the parsed light in
  9953. * @returns the created light after parsing
  9954. */
  9955. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9956. private _hookArrayForExcluded;
  9957. private _hookArrayForIncludedOnly;
  9958. private _resyncMeshes;
  9959. /**
  9960. * Forces the meshes to update their light related information in their rendering used effects
  9961. * @hidden Internal Use Only
  9962. */
  9963. _markMeshesAsLightDirty(): void;
  9964. /**
  9965. * Recomputes the cached photometric scale if needed.
  9966. */
  9967. private _computePhotometricScale;
  9968. /**
  9969. * Returns the Photometric Scale according to the light type and intensity mode.
  9970. */
  9971. private _getPhotometricScale;
  9972. /**
  9973. * Reorder the light in the scene according to their defined priority.
  9974. * @hidden Internal Use Only
  9975. */
  9976. _reorderLightsInScene(): void;
  9977. /**
  9978. * Prepares the list of defines specific to the light type.
  9979. * @param defines the list of defines
  9980. * @param lightIndex defines the index of the light for the effect
  9981. */
  9982. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9983. }
  9984. }
  9985. declare module BABYLON {
  9986. /**
  9987. * Interface used to define Action
  9988. */
  9989. export interface IAction {
  9990. /**
  9991. * Trigger for the action
  9992. */
  9993. trigger: number;
  9994. /** Options of the trigger */
  9995. triggerOptions: any;
  9996. /**
  9997. * Gets the trigger parameters
  9998. * @returns the trigger parameters
  9999. */
  10000. getTriggerParameter(): any;
  10001. /**
  10002. * Internal only - executes current action event
  10003. * @hidden
  10004. */
  10005. _executeCurrent(evt?: ActionEvent): void;
  10006. /**
  10007. * Serialize placeholder for child classes
  10008. * @param parent of child
  10009. * @returns the serialized object
  10010. */
  10011. serialize(parent: any): any;
  10012. /**
  10013. * Internal only
  10014. * @hidden
  10015. */
  10016. _prepare(): void;
  10017. /**
  10018. * Internal only - manager for action
  10019. * @hidden
  10020. */
  10021. _actionManager: AbstractActionManager;
  10022. /**
  10023. * Adds action to chain of actions, may be a DoNothingAction
  10024. * @param action defines the next action to execute
  10025. * @returns The action passed in
  10026. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10027. */
  10028. then(action: IAction): IAction;
  10029. }
  10030. /**
  10031. * The action to be carried out following a trigger
  10032. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10033. */
  10034. export class Action implements IAction {
  10035. /** the trigger, with or without parameters, for the action */
  10036. triggerOptions: any;
  10037. /**
  10038. * Trigger for the action
  10039. */
  10040. trigger: number;
  10041. /**
  10042. * Internal only - manager for action
  10043. * @hidden
  10044. */
  10045. _actionManager: ActionManager;
  10046. private _nextActiveAction;
  10047. private _child;
  10048. private _condition?;
  10049. private _triggerParameter;
  10050. /**
  10051. * An event triggered prior to action being executed.
  10052. */
  10053. onBeforeExecuteObservable: Observable<Action>;
  10054. /**
  10055. * Creates a new Action
  10056. * @param triggerOptions the trigger, with or without parameters, for the action
  10057. * @param condition an optional determinant of action
  10058. */
  10059. constructor(
  10060. /** the trigger, with or without parameters, for the action */
  10061. triggerOptions: any, condition?: Condition);
  10062. /**
  10063. * Internal only
  10064. * @hidden
  10065. */
  10066. _prepare(): void;
  10067. /**
  10068. * Gets the trigger parameters
  10069. * @returns the trigger parameters
  10070. */
  10071. getTriggerParameter(): any;
  10072. /**
  10073. * Internal only - executes current action event
  10074. * @hidden
  10075. */
  10076. _executeCurrent(evt?: ActionEvent): void;
  10077. /**
  10078. * Execute placeholder for child classes
  10079. * @param evt optional action event
  10080. */
  10081. execute(evt?: ActionEvent): void;
  10082. /**
  10083. * Skips to next active action
  10084. */
  10085. skipToNextActiveAction(): void;
  10086. /**
  10087. * Adds action to chain of actions, may be a DoNothingAction
  10088. * @param action defines the next action to execute
  10089. * @returns The action passed in
  10090. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10091. */
  10092. then(action: Action): Action;
  10093. /**
  10094. * Internal only
  10095. * @hidden
  10096. */
  10097. _getProperty(propertyPath: string): string;
  10098. /**
  10099. * Internal only
  10100. * @hidden
  10101. */
  10102. _getEffectiveTarget(target: any, propertyPath: string): any;
  10103. /**
  10104. * Serialize placeholder for child classes
  10105. * @param parent of child
  10106. * @returns the serialized object
  10107. */
  10108. serialize(parent: any): any;
  10109. /**
  10110. * Internal only called by serialize
  10111. * @hidden
  10112. */
  10113. protected _serialize(serializedAction: any, parent?: any): any;
  10114. /**
  10115. * Internal only
  10116. * @hidden
  10117. */
  10118. static _SerializeValueAsString: (value: any) => string;
  10119. /**
  10120. * Internal only
  10121. * @hidden
  10122. */
  10123. static _GetTargetProperty: (target: Node | Scene) => {
  10124. name: string;
  10125. targetType: string;
  10126. value: string;
  10127. };
  10128. }
  10129. }
  10130. declare module BABYLON {
  10131. /**
  10132. * A Condition applied to an Action
  10133. */
  10134. export class Condition {
  10135. /**
  10136. * Internal only - manager for action
  10137. * @hidden
  10138. */
  10139. _actionManager: ActionManager;
  10140. /**
  10141. * Internal only
  10142. * @hidden
  10143. */
  10144. _evaluationId: number;
  10145. /**
  10146. * Internal only
  10147. * @hidden
  10148. */
  10149. _currentResult: boolean;
  10150. /**
  10151. * Creates a new Condition
  10152. * @param actionManager the manager of the action the condition is applied to
  10153. */
  10154. constructor(actionManager: ActionManager);
  10155. /**
  10156. * Check if the current condition is valid
  10157. * @returns a boolean
  10158. */
  10159. isValid(): boolean;
  10160. /**
  10161. * Internal only
  10162. * @hidden
  10163. */
  10164. _getProperty(propertyPath: string): string;
  10165. /**
  10166. * Internal only
  10167. * @hidden
  10168. */
  10169. _getEffectiveTarget(target: any, propertyPath: string): any;
  10170. /**
  10171. * Serialize placeholder for child classes
  10172. * @returns the serialized object
  10173. */
  10174. serialize(): any;
  10175. /**
  10176. * Internal only
  10177. * @hidden
  10178. */
  10179. protected _serialize(serializedCondition: any): any;
  10180. }
  10181. /**
  10182. * Defines specific conditional operators as extensions of Condition
  10183. */
  10184. export class ValueCondition extends Condition {
  10185. /** path to specify the property of the target the conditional operator uses */
  10186. propertyPath: string;
  10187. /** the value compared by the conditional operator against the current value of the property */
  10188. value: any;
  10189. /** the conditional operator, default ValueCondition.IsEqual */
  10190. operator: number;
  10191. /**
  10192. * Internal only
  10193. * @hidden
  10194. */
  10195. private static _IsEqual;
  10196. /**
  10197. * Internal only
  10198. * @hidden
  10199. */
  10200. private static _IsDifferent;
  10201. /**
  10202. * Internal only
  10203. * @hidden
  10204. */
  10205. private static _IsGreater;
  10206. /**
  10207. * Internal only
  10208. * @hidden
  10209. */
  10210. private static _IsLesser;
  10211. /**
  10212. * returns the number for IsEqual
  10213. */
  10214. static readonly IsEqual: number;
  10215. /**
  10216. * Returns the number for IsDifferent
  10217. */
  10218. static readonly IsDifferent: number;
  10219. /**
  10220. * Returns the number for IsGreater
  10221. */
  10222. static readonly IsGreater: number;
  10223. /**
  10224. * Returns the number for IsLesser
  10225. */
  10226. static readonly IsLesser: number;
  10227. /**
  10228. * Internal only The action manager for the condition
  10229. * @hidden
  10230. */
  10231. _actionManager: ActionManager;
  10232. /**
  10233. * Internal only
  10234. * @hidden
  10235. */
  10236. private _target;
  10237. /**
  10238. * Internal only
  10239. * @hidden
  10240. */
  10241. private _effectiveTarget;
  10242. /**
  10243. * Internal only
  10244. * @hidden
  10245. */
  10246. private _property;
  10247. /**
  10248. * Creates a new ValueCondition
  10249. * @param actionManager manager for the action the condition applies to
  10250. * @param target for the action
  10251. * @param propertyPath path to specify the property of the target the conditional operator uses
  10252. * @param value the value compared by the conditional operator against the current value of the property
  10253. * @param operator the conditional operator, default ValueCondition.IsEqual
  10254. */
  10255. constructor(actionManager: ActionManager, target: any,
  10256. /** path to specify the property of the target the conditional operator uses */
  10257. propertyPath: string,
  10258. /** the value compared by the conditional operator against the current value of the property */
  10259. value: any,
  10260. /** the conditional operator, default ValueCondition.IsEqual */
  10261. operator?: number);
  10262. /**
  10263. * Compares the given value with the property value for the specified conditional operator
  10264. * @returns the result of the comparison
  10265. */
  10266. isValid(): boolean;
  10267. /**
  10268. * Serialize the ValueCondition into a JSON compatible object
  10269. * @returns serialization object
  10270. */
  10271. serialize(): any;
  10272. /**
  10273. * Gets the name of the conditional operator for the ValueCondition
  10274. * @param operator the conditional operator
  10275. * @returns the name
  10276. */
  10277. static GetOperatorName(operator: number): string;
  10278. }
  10279. /**
  10280. * Defines a predicate condition as an extension of Condition
  10281. */
  10282. export class PredicateCondition extends Condition {
  10283. /** defines the predicate function used to validate the condition */
  10284. predicate: () => boolean;
  10285. /**
  10286. * Internal only - manager for action
  10287. * @hidden
  10288. */
  10289. _actionManager: ActionManager;
  10290. /**
  10291. * Creates a new PredicateCondition
  10292. * @param actionManager manager for the action the condition applies to
  10293. * @param predicate defines the predicate function used to validate the condition
  10294. */
  10295. constructor(actionManager: ActionManager,
  10296. /** defines the predicate function used to validate the condition */
  10297. predicate: () => boolean);
  10298. /**
  10299. * @returns the validity of the predicate condition
  10300. */
  10301. isValid(): boolean;
  10302. }
  10303. /**
  10304. * Defines a state condition as an extension of Condition
  10305. */
  10306. export class StateCondition extends Condition {
  10307. /** Value to compare with target state */
  10308. value: string;
  10309. /**
  10310. * Internal only - manager for action
  10311. * @hidden
  10312. */
  10313. _actionManager: ActionManager;
  10314. /**
  10315. * Internal only
  10316. * @hidden
  10317. */
  10318. private _target;
  10319. /**
  10320. * Creates a new StateCondition
  10321. * @param actionManager manager for the action the condition applies to
  10322. * @param target of the condition
  10323. * @param value to compare with target state
  10324. */
  10325. constructor(actionManager: ActionManager, target: any,
  10326. /** Value to compare with target state */
  10327. value: string);
  10328. /**
  10329. * Gets a boolean indicating if the current condition is met
  10330. * @returns the validity of the state
  10331. */
  10332. isValid(): boolean;
  10333. /**
  10334. * Serialize the StateCondition into a JSON compatible object
  10335. * @returns serialization object
  10336. */
  10337. serialize(): any;
  10338. }
  10339. }
  10340. declare module BABYLON {
  10341. /**
  10342. * This defines an action responsible to toggle a boolean once triggered.
  10343. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10344. */
  10345. export class SwitchBooleanAction extends Action {
  10346. /**
  10347. * The path to the boolean property in the target object
  10348. */
  10349. propertyPath: string;
  10350. private _target;
  10351. private _effectiveTarget;
  10352. private _property;
  10353. /**
  10354. * Instantiate the action
  10355. * @param triggerOptions defines the trigger options
  10356. * @param target defines the object containing the boolean
  10357. * @param propertyPath defines the path to the boolean property in the target object
  10358. * @param condition defines the trigger related conditions
  10359. */
  10360. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10361. /** @hidden */
  10362. _prepare(): void;
  10363. /**
  10364. * Execute the action toggle the boolean value.
  10365. */
  10366. execute(): void;
  10367. /**
  10368. * Serializes the actions and its related information.
  10369. * @param parent defines the object to serialize in
  10370. * @returns the serialized object
  10371. */
  10372. serialize(parent: any): any;
  10373. }
  10374. /**
  10375. * This defines an action responsible to set a the state field of the target
  10376. * to a desired value once triggered.
  10377. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10378. */
  10379. export class SetStateAction extends Action {
  10380. /**
  10381. * The value to store in the state field.
  10382. */
  10383. value: string;
  10384. private _target;
  10385. /**
  10386. * Instantiate the action
  10387. * @param triggerOptions defines the trigger options
  10388. * @param target defines the object containing the state property
  10389. * @param value defines the value to store in the state field
  10390. * @param condition defines the trigger related conditions
  10391. */
  10392. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10393. /**
  10394. * Execute the action and store the value on the target state property.
  10395. */
  10396. execute(): void;
  10397. /**
  10398. * Serializes the actions and its related information.
  10399. * @param parent defines the object to serialize in
  10400. * @returns the serialized object
  10401. */
  10402. serialize(parent: any): any;
  10403. }
  10404. /**
  10405. * This defines an action responsible to set a property of the target
  10406. * to a desired value once triggered.
  10407. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10408. */
  10409. export class SetValueAction extends Action {
  10410. /**
  10411. * The path of the property to set in the target.
  10412. */
  10413. propertyPath: string;
  10414. /**
  10415. * The value to set in the property
  10416. */
  10417. value: any;
  10418. private _target;
  10419. private _effectiveTarget;
  10420. private _property;
  10421. /**
  10422. * Instantiate the action
  10423. * @param triggerOptions defines the trigger options
  10424. * @param target defines the object containing the property
  10425. * @param propertyPath defines the path of the property to set in the target
  10426. * @param value defines the value to set in the property
  10427. * @param condition defines the trigger related conditions
  10428. */
  10429. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10430. /** @hidden */
  10431. _prepare(): void;
  10432. /**
  10433. * Execute the action and set the targetted property to the desired value.
  10434. */
  10435. execute(): void;
  10436. /**
  10437. * Serializes the actions and its related information.
  10438. * @param parent defines the object to serialize in
  10439. * @returns the serialized object
  10440. */
  10441. serialize(parent: any): any;
  10442. }
  10443. /**
  10444. * This defines an action responsible to increment the target value
  10445. * to a desired value once triggered.
  10446. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10447. */
  10448. export class IncrementValueAction extends Action {
  10449. /**
  10450. * The path of the property to increment in the target.
  10451. */
  10452. propertyPath: string;
  10453. /**
  10454. * The value we should increment the property by.
  10455. */
  10456. value: any;
  10457. private _target;
  10458. private _effectiveTarget;
  10459. private _property;
  10460. /**
  10461. * Instantiate the action
  10462. * @param triggerOptions defines the trigger options
  10463. * @param target defines the object containing the property
  10464. * @param propertyPath defines the path of the property to increment in the target
  10465. * @param value defines the value value we should increment the property by
  10466. * @param condition defines the trigger related conditions
  10467. */
  10468. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10469. /** @hidden */
  10470. _prepare(): void;
  10471. /**
  10472. * Execute the action and increment the target of the value amount.
  10473. */
  10474. execute(): void;
  10475. /**
  10476. * Serializes the actions and its related information.
  10477. * @param parent defines the object to serialize in
  10478. * @returns the serialized object
  10479. */
  10480. serialize(parent: any): any;
  10481. }
  10482. /**
  10483. * This defines an action responsible to start an animation once triggered.
  10484. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10485. */
  10486. export class PlayAnimationAction extends Action {
  10487. /**
  10488. * Where the animation should start (animation frame)
  10489. */
  10490. from: number;
  10491. /**
  10492. * Where the animation should stop (animation frame)
  10493. */
  10494. to: number;
  10495. /**
  10496. * Define if the animation should loop or stop after the first play.
  10497. */
  10498. loop?: boolean;
  10499. private _target;
  10500. /**
  10501. * Instantiate the action
  10502. * @param triggerOptions defines the trigger options
  10503. * @param target defines the target animation or animation name
  10504. * @param from defines from where the animation should start (animation frame)
  10505. * @param end defines where the animation should stop (animation frame)
  10506. * @param loop defines if the animation should loop or stop after the first play
  10507. * @param condition defines the trigger related conditions
  10508. */
  10509. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10510. /** @hidden */
  10511. _prepare(): void;
  10512. /**
  10513. * Execute the action and play the animation.
  10514. */
  10515. execute(): void;
  10516. /**
  10517. * Serializes the actions and its related information.
  10518. * @param parent defines the object to serialize in
  10519. * @returns the serialized object
  10520. */
  10521. serialize(parent: any): any;
  10522. }
  10523. /**
  10524. * This defines an action responsible to stop an animation once triggered.
  10525. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10526. */
  10527. export class StopAnimationAction extends Action {
  10528. private _target;
  10529. /**
  10530. * Instantiate the action
  10531. * @param triggerOptions defines the trigger options
  10532. * @param target defines the target animation or animation name
  10533. * @param condition defines the trigger related conditions
  10534. */
  10535. constructor(triggerOptions: any, target: any, condition?: Condition);
  10536. /** @hidden */
  10537. _prepare(): void;
  10538. /**
  10539. * Execute the action and stop the animation.
  10540. */
  10541. execute(): void;
  10542. /**
  10543. * Serializes the actions and its related information.
  10544. * @param parent defines the object to serialize in
  10545. * @returns the serialized object
  10546. */
  10547. serialize(parent: any): any;
  10548. }
  10549. /**
  10550. * This defines an action responsible that does nothing once triggered.
  10551. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10552. */
  10553. export class DoNothingAction extends Action {
  10554. /**
  10555. * Instantiate the action
  10556. * @param triggerOptions defines the trigger options
  10557. * @param condition defines the trigger related conditions
  10558. */
  10559. constructor(triggerOptions?: any, condition?: Condition);
  10560. /**
  10561. * Execute the action and do nothing.
  10562. */
  10563. execute(): void;
  10564. /**
  10565. * Serializes the actions and its related information.
  10566. * @param parent defines the object to serialize in
  10567. * @returns the serialized object
  10568. */
  10569. serialize(parent: any): any;
  10570. }
  10571. /**
  10572. * This defines an action responsible to trigger several actions once triggered.
  10573. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10574. */
  10575. export class CombineAction extends Action {
  10576. /**
  10577. * The list of aggregated animations to run.
  10578. */
  10579. children: Action[];
  10580. /**
  10581. * Instantiate the action
  10582. * @param triggerOptions defines the trigger options
  10583. * @param children defines the list of aggregated animations to run
  10584. * @param condition defines the trigger related conditions
  10585. */
  10586. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10587. /** @hidden */
  10588. _prepare(): void;
  10589. /**
  10590. * Execute the action and executes all the aggregated actions.
  10591. */
  10592. execute(evt: ActionEvent): void;
  10593. /**
  10594. * Serializes the actions and its related information.
  10595. * @param parent defines the object to serialize in
  10596. * @returns the serialized object
  10597. */
  10598. serialize(parent: any): any;
  10599. }
  10600. /**
  10601. * This defines an action responsible to run code (external event) once triggered.
  10602. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10603. */
  10604. export class ExecuteCodeAction extends Action {
  10605. /**
  10606. * The callback function to run.
  10607. */
  10608. func: (evt: ActionEvent) => void;
  10609. /**
  10610. * Instantiate the action
  10611. * @param triggerOptions defines the trigger options
  10612. * @param func defines the callback function to run
  10613. * @param condition defines the trigger related conditions
  10614. */
  10615. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10616. /**
  10617. * Execute the action and run the attached code.
  10618. */
  10619. execute(evt: ActionEvent): void;
  10620. }
  10621. /**
  10622. * This defines an action responsible to set the parent property of the target once triggered.
  10623. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10624. */
  10625. export class SetParentAction extends Action {
  10626. private _parent;
  10627. private _target;
  10628. /**
  10629. * Instantiate the action
  10630. * @param triggerOptions defines the trigger options
  10631. * @param target defines the target containing the parent property
  10632. * @param parent defines from where the animation should start (animation frame)
  10633. * @param condition defines the trigger related conditions
  10634. */
  10635. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10636. /** @hidden */
  10637. _prepare(): void;
  10638. /**
  10639. * Execute the action and set the parent property.
  10640. */
  10641. execute(): void;
  10642. /**
  10643. * Serializes the actions and its related information.
  10644. * @param parent defines the object to serialize in
  10645. * @returns the serialized object
  10646. */
  10647. serialize(parent: any): any;
  10648. }
  10649. }
  10650. declare module BABYLON {
  10651. /**
  10652. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10653. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10654. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10655. */
  10656. export class ActionManager extends AbstractActionManager {
  10657. /**
  10658. * Nothing
  10659. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10660. */
  10661. static readonly NothingTrigger: number;
  10662. /**
  10663. * On pick
  10664. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10665. */
  10666. static readonly OnPickTrigger: number;
  10667. /**
  10668. * On left pick
  10669. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10670. */
  10671. static readonly OnLeftPickTrigger: number;
  10672. /**
  10673. * On right pick
  10674. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10675. */
  10676. static readonly OnRightPickTrigger: number;
  10677. /**
  10678. * On center pick
  10679. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10680. */
  10681. static readonly OnCenterPickTrigger: number;
  10682. /**
  10683. * On pick down
  10684. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10685. */
  10686. static readonly OnPickDownTrigger: number;
  10687. /**
  10688. * On double pick
  10689. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10690. */
  10691. static readonly OnDoublePickTrigger: number;
  10692. /**
  10693. * On pick up
  10694. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10695. */
  10696. static readonly OnPickUpTrigger: number;
  10697. /**
  10698. * On pick out.
  10699. * This trigger will only be raised if you also declared a OnPickDown
  10700. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10701. */
  10702. static readonly OnPickOutTrigger: number;
  10703. /**
  10704. * On long press
  10705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10706. */
  10707. static readonly OnLongPressTrigger: number;
  10708. /**
  10709. * On pointer over
  10710. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10711. */
  10712. static readonly OnPointerOverTrigger: number;
  10713. /**
  10714. * On pointer out
  10715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10716. */
  10717. static readonly OnPointerOutTrigger: number;
  10718. /**
  10719. * On every frame
  10720. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10721. */
  10722. static readonly OnEveryFrameTrigger: number;
  10723. /**
  10724. * On intersection enter
  10725. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10726. */
  10727. static readonly OnIntersectionEnterTrigger: number;
  10728. /**
  10729. * On intersection exit
  10730. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10731. */
  10732. static readonly OnIntersectionExitTrigger: number;
  10733. /**
  10734. * On key down
  10735. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10736. */
  10737. static readonly OnKeyDownTrigger: number;
  10738. /**
  10739. * On key up
  10740. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10741. */
  10742. static readonly OnKeyUpTrigger: number;
  10743. private _scene;
  10744. /**
  10745. * Creates a new action manager
  10746. * @param scene defines the hosting scene
  10747. */
  10748. constructor(scene: Scene);
  10749. /**
  10750. * Releases all associated resources
  10751. */
  10752. dispose(): void;
  10753. /**
  10754. * Gets hosting scene
  10755. * @returns the hosting scene
  10756. */
  10757. getScene(): Scene;
  10758. /**
  10759. * Does this action manager handles actions of any of the given triggers
  10760. * @param triggers defines the triggers to be tested
  10761. * @return a boolean indicating whether one (or more) of the triggers is handled
  10762. */
  10763. hasSpecificTriggers(triggers: number[]): boolean;
  10764. /**
  10765. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10766. * speed.
  10767. * @param triggerA defines the trigger to be tested
  10768. * @param triggerB defines the trigger to be tested
  10769. * @return a boolean indicating whether one (or more) of the triggers is handled
  10770. */
  10771. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10772. /**
  10773. * Does this action manager handles actions of a given trigger
  10774. * @param trigger defines the trigger to be tested
  10775. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10776. * @return whether the trigger is handled
  10777. */
  10778. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10779. /**
  10780. * Does this action manager has pointer triggers
  10781. */
  10782. readonly hasPointerTriggers: boolean;
  10783. /**
  10784. * Does this action manager has pick triggers
  10785. */
  10786. readonly hasPickTriggers: boolean;
  10787. /**
  10788. * Registers an action to this action manager
  10789. * @param action defines the action to be registered
  10790. * @return the action amended (prepared) after registration
  10791. */
  10792. registerAction(action: IAction): Nullable<IAction>;
  10793. /**
  10794. * Unregisters an action to this action manager
  10795. * @param action defines the action to be unregistered
  10796. * @return a boolean indicating whether the action has been unregistered
  10797. */
  10798. unregisterAction(action: IAction): Boolean;
  10799. /**
  10800. * Process a specific trigger
  10801. * @param trigger defines the trigger to process
  10802. * @param evt defines the event details to be processed
  10803. */
  10804. processTrigger(trigger: number, evt?: IActionEvent): void;
  10805. /** @hidden */
  10806. _getEffectiveTarget(target: any, propertyPath: string): any;
  10807. /** @hidden */
  10808. _getProperty(propertyPath: string): string;
  10809. /**
  10810. * Serialize this manager to a JSON object
  10811. * @param name defines the property name to store this manager
  10812. * @returns a JSON representation of this manager
  10813. */
  10814. serialize(name: string): any;
  10815. /**
  10816. * Creates a new ActionManager from a JSON data
  10817. * @param parsedActions defines the JSON data to read from
  10818. * @param object defines the hosting mesh
  10819. * @param scene defines the hosting scene
  10820. */
  10821. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10822. /**
  10823. * Get a trigger name by index
  10824. * @param trigger defines the trigger index
  10825. * @returns a trigger name
  10826. */
  10827. static GetTriggerName(trigger: number): string;
  10828. }
  10829. }
  10830. declare module BABYLON {
  10831. /**
  10832. * Class representing a ray with position and direction
  10833. */
  10834. export class Ray {
  10835. /** origin point */
  10836. origin: Vector3;
  10837. /** direction */
  10838. direction: Vector3;
  10839. /** length of the ray */
  10840. length: number;
  10841. private static readonly TmpVector3;
  10842. private _tmpRay;
  10843. /**
  10844. * Creates a new ray
  10845. * @param origin origin point
  10846. * @param direction direction
  10847. * @param length length of the ray
  10848. */
  10849. constructor(
  10850. /** origin point */
  10851. origin: Vector3,
  10852. /** direction */
  10853. direction: Vector3,
  10854. /** length of the ray */
  10855. length?: number);
  10856. /**
  10857. * Checks if the ray intersects a box
  10858. * @param minimum bound of the box
  10859. * @param maximum bound of the box
  10860. * @param intersectionTreshold extra extend to be added to the box in all direction
  10861. * @returns if the box was hit
  10862. */
  10863. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10864. /**
  10865. * Checks if the ray intersects a box
  10866. * @param box the bounding box to check
  10867. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10868. * @returns if the box was hit
  10869. */
  10870. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10871. /**
  10872. * If the ray hits a sphere
  10873. * @param sphere the bounding sphere to check
  10874. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10875. * @returns true if it hits the sphere
  10876. */
  10877. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10878. /**
  10879. * If the ray hits a triange
  10880. * @param vertex0 triangle vertex
  10881. * @param vertex1 triangle vertex
  10882. * @param vertex2 triangle vertex
  10883. * @returns intersection information if hit
  10884. */
  10885. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10886. /**
  10887. * Checks if ray intersects a plane
  10888. * @param plane the plane to check
  10889. * @returns the distance away it was hit
  10890. */
  10891. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10892. /**
  10893. * Calculate the intercept of a ray on a given axis
  10894. * @param axis to check 'x' | 'y' | 'z'
  10895. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10896. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10897. */
  10898. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10899. /**
  10900. * Checks if ray intersects a mesh
  10901. * @param mesh the mesh to check
  10902. * @param fastCheck if only the bounding box should checked
  10903. * @returns picking info of the intersecton
  10904. */
  10905. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10906. /**
  10907. * Checks if ray intersects a mesh
  10908. * @param meshes the meshes to check
  10909. * @param fastCheck if only the bounding box should checked
  10910. * @param results array to store result in
  10911. * @returns Array of picking infos
  10912. */
  10913. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10914. private _comparePickingInfo;
  10915. private static smallnum;
  10916. private static rayl;
  10917. /**
  10918. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10919. * @param sega the first point of the segment to test the intersection against
  10920. * @param segb the second point of the segment to test the intersection against
  10921. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10922. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10923. */
  10924. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10925. /**
  10926. * Update the ray from viewport position
  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 this ray updated
  10935. */
  10936. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10937. /**
  10938. * Creates a ray with origin and direction of 0,0,0
  10939. * @returns the new ray
  10940. */
  10941. static Zero(): Ray;
  10942. /**
  10943. * Creates a new ray from screen space and viewport
  10944. * @param x position
  10945. * @param y y position
  10946. * @param viewportWidth viewport width
  10947. * @param viewportHeight viewport height
  10948. * @param world world matrix
  10949. * @param view view matrix
  10950. * @param projection projection matrix
  10951. * @returns new ray
  10952. */
  10953. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10954. /**
  10955. * 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
  10956. * transformed to the given world matrix.
  10957. * @param origin The origin point
  10958. * @param end The end point
  10959. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10960. * @returns the new ray
  10961. */
  10962. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10963. /**
  10964. * Transforms a ray by a matrix
  10965. * @param ray ray to transform
  10966. * @param matrix matrix to apply
  10967. * @returns the resulting new ray
  10968. */
  10969. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10970. /**
  10971. * Transforms a ray by a matrix
  10972. * @param ray ray to transform
  10973. * @param matrix matrix to apply
  10974. * @param result ray to store result in
  10975. */
  10976. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10977. /**
  10978. * Unproject a ray from screen space to object space
  10979. * @param sourceX defines the screen space x coordinate to use
  10980. * @param sourceY defines the screen space y coordinate to use
  10981. * @param viewportWidth defines the current width of the viewport
  10982. * @param viewportHeight defines the current height of the viewport
  10983. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10984. * @param view defines the view matrix to use
  10985. * @param projection defines the projection matrix to use
  10986. */
  10987. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10988. }
  10989. /**
  10990. * Type used to define predicate used to select faces when a mesh intersection is detected
  10991. */
  10992. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10993. interface Scene {
  10994. /** @hidden */
  10995. _tempPickingRay: Nullable<Ray>;
  10996. /** @hidden */
  10997. _cachedRayForTransform: Ray;
  10998. /** @hidden */
  10999. _pickWithRayInverseMatrix: Matrix;
  11000. /** @hidden */
  11001. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11002. /** @hidden */
  11003. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11004. }
  11005. }
  11006. declare module BABYLON {
  11007. /**
  11008. * Groups all the scene component constants in one place to ease maintenance.
  11009. * @hidden
  11010. */
  11011. export class SceneComponentConstants {
  11012. static readonly NAME_EFFECTLAYER: string;
  11013. static readonly NAME_LAYER: string;
  11014. static readonly NAME_LENSFLARESYSTEM: string;
  11015. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11016. static readonly NAME_PARTICLESYSTEM: string;
  11017. static readonly NAME_GAMEPAD: string;
  11018. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11019. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11020. static readonly NAME_DEPTHRENDERER: string;
  11021. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11022. static readonly NAME_SPRITE: string;
  11023. static readonly NAME_OUTLINERENDERER: string;
  11024. static readonly NAME_PROCEDURALTEXTURE: string;
  11025. static readonly NAME_SHADOWGENERATOR: string;
  11026. static readonly NAME_OCTREE: string;
  11027. static readonly NAME_PHYSICSENGINE: string;
  11028. static readonly NAME_AUDIO: string;
  11029. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11030. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11031. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11032. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11033. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11034. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11035. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11036. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11037. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11038. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11039. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11040. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11041. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11042. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11043. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11044. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11045. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11046. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11047. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11048. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11049. static readonly STEP_AFTERRENDER_AUDIO: number;
  11050. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11051. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11052. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11053. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11054. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11055. static readonly STEP_POINTERMOVE_SPRITE: number;
  11056. static readonly STEP_POINTERDOWN_SPRITE: number;
  11057. static readonly STEP_POINTERUP_SPRITE: number;
  11058. }
  11059. /**
  11060. * This represents a scene component.
  11061. *
  11062. * This is used to decouple the dependency the scene is having on the different workloads like
  11063. * layers, post processes...
  11064. */
  11065. export interface ISceneComponent {
  11066. /**
  11067. * The name of the component. Each component must have a unique name.
  11068. */
  11069. name: string;
  11070. /**
  11071. * The scene the component belongs to.
  11072. */
  11073. scene: Scene;
  11074. /**
  11075. * Register the component to one instance of a scene.
  11076. */
  11077. register(): void;
  11078. /**
  11079. * Rebuilds the elements related to this component in case of
  11080. * context lost for instance.
  11081. */
  11082. rebuild(): void;
  11083. /**
  11084. * Disposes the component and the associated ressources.
  11085. */
  11086. dispose(): void;
  11087. }
  11088. /**
  11089. * This represents a SERIALIZABLE scene component.
  11090. *
  11091. * This extends Scene Component to add Serialization methods on top.
  11092. */
  11093. export interface ISceneSerializableComponent extends ISceneComponent {
  11094. /**
  11095. * Adds all the elements from the container to the scene
  11096. * @param container the container holding the elements
  11097. */
  11098. addFromContainer(container: AbstractScene): void;
  11099. /**
  11100. * Removes all the elements in the container from the scene
  11101. * @param container contains the elements to remove
  11102. * @param dispose if the removed element should be disposed (default: false)
  11103. */
  11104. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11105. /**
  11106. * Serializes the component data to the specified json object
  11107. * @param serializationObject The object to serialize to
  11108. */
  11109. serialize(serializationObject: any): void;
  11110. }
  11111. /**
  11112. * Strong typing of a Mesh related stage step action
  11113. */
  11114. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11115. /**
  11116. * Strong typing of a Evaluate Sub Mesh related stage step action
  11117. */
  11118. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11119. /**
  11120. * Strong typing of a Active Mesh related stage step action
  11121. */
  11122. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11123. /**
  11124. * Strong typing of a Camera related stage step action
  11125. */
  11126. export type CameraStageAction = (camera: Camera) => void;
  11127. /**
  11128. * Strong typing of a Camera Frame buffer related stage step action
  11129. */
  11130. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11131. /**
  11132. * Strong typing of a Render Target related stage step action
  11133. */
  11134. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11135. /**
  11136. * Strong typing of a RenderingGroup related stage step action
  11137. */
  11138. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11139. /**
  11140. * Strong typing of a Mesh Render related stage step action
  11141. */
  11142. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11143. /**
  11144. * Strong typing of a simple stage step action
  11145. */
  11146. export type SimpleStageAction = () => void;
  11147. /**
  11148. * Strong typing of a render target action.
  11149. */
  11150. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11151. /**
  11152. * Strong typing of a pointer move action.
  11153. */
  11154. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11155. /**
  11156. * Strong typing of a pointer up/down action.
  11157. */
  11158. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11159. /**
  11160. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11161. * @hidden
  11162. */
  11163. export class Stage<T extends Function> extends Array<{
  11164. index: number;
  11165. component: ISceneComponent;
  11166. action: T;
  11167. }> {
  11168. /**
  11169. * Hide ctor from the rest of the world.
  11170. * @param items The items to add.
  11171. */
  11172. private constructor();
  11173. /**
  11174. * Creates a new Stage.
  11175. * @returns A new instance of a Stage
  11176. */
  11177. static Create<T extends Function>(): Stage<T>;
  11178. /**
  11179. * Registers a step in an ordered way in the targeted stage.
  11180. * @param index Defines the position to register the step in
  11181. * @param component Defines the component attached to the step
  11182. * @param action Defines the action to launch during the step
  11183. */
  11184. registerStep(index: number, component: ISceneComponent, action: T): void;
  11185. /**
  11186. * Clears all the steps from the stage.
  11187. */
  11188. clear(): void;
  11189. }
  11190. }
  11191. declare module BABYLON {
  11192. interface Scene {
  11193. /** @hidden */
  11194. _pointerOverSprite: Nullable<Sprite>;
  11195. /** @hidden */
  11196. _pickedDownSprite: Nullable<Sprite>;
  11197. /** @hidden */
  11198. _tempSpritePickingRay: Nullable<Ray>;
  11199. /**
  11200. * All of the sprite managers added to this scene
  11201. * @see http://doc.babylonjs.com/babylon101/sprites
  11202. */
  11203. spriteManagers: Array<ISpriteManager>;
  11204. /**
  11205. * An event triggered when sprites rendering is about to start
  11206. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11207. */
  11208. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11209. /**
  11210. * An event triggered when sprites rendering is done
  11211. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11212. */
  11213. onAfterSpritesRenderingObservable: Observable<Scene>;
  11214. /** @hidden */
  11215. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11216. /** Launch a ray to try to pick a sprite in the scene
  11217. * @param x position on screen
  11218. * @param y position on screen
  11219. * @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
  11220. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11221. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11222. * @returns a PickingInfo
  11223. */
  11224. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11225. /** Use the given ray to pick a sprite in the scene
  11226. * @param ray The ray (in world space) to use to pick meshes
  11227. * @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
  11228. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11229. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11230. * @returns a PickingInfo
  11231. */
  11232. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11233. /** @hidden */
  11234. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11235. /** Launch a ray to try to pick sprites in the scene
  11236. * @param x position on screen
  11237. * @param y position on screen
  11238. * @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
  11239. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11240. * @returns a PickingInfo array
  11241. */
  11242. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11243. /** Use the given ray to pick sprites in the scene
  11244. * @param ray The ray (in world space) to use to pick meshes
  11245. * @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
  11246. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11247. * @returns a PickingInfo array
  11248. */
  11249. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11250. /**
  11251. * Force the sprite under the pointer
  11252. * @param sprite defines the sprite to use
  11253. */
  11254. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11255. /**
  11256. * Gets the sprite under the pointer
  11257. * @returns a Sprite or null if no sprite is under the pointer
  11258. */
  11259. getPointerOverSprite(): Nullable<Sprite>;
  11260. }
  11261. /**
  11262. * Defines the sprite scene component responsible to manage sprites
  11263. * in a given scene.
  11264. */
  11265. export class SpriteSceneComponent implements ISceneComponent {
  11266. /**
  11267. * The component name helpfull to identify the component in the list of scene components.
  11268. */
  11269. readonly name: string;
  11270. /**
  11271. * The scene the component belongs to.
  11272. */
  11273. scene: Scene;
  11274. /** @hidden */
  11275. private _spritePredicate;
  11276. /**
  11277. * Creates a new instance of the component for the given scene
  11278. * @param scene Defines the scene to register the component in
  11279. */
  11280. constructor(scene: Scene);
  11281. /**
  11282. * Registers the component in a given scene
  11283. */
  11284. register(): void;
  11285. /**
  11286. * Rebuilds the elements related to this component in case of
  11287. * context lost for instance.
  11288. */
  11289. rebuild(): void;
  11290. /**
  11291. * Disposes the component and the associated ressources.
  11292. */
  11293. dispose(): void;
  11294. private _pickSpriteButKeepRay;
  11295. private _pointerMove;
  11296. private _pointerDown;
  11297. private _pointerUp;
  11298. }
  11299. }
  11300. declare module BABYLON {
  11301. /** @hidden */
  11302. export var fogFragmentDeclaration: {
  11303. name: string;
  11304. shader: string;
  11305. };
  11306. }
  11307. declare module BABYLON {
  11308. /** @hidden */
  11309. export var fogFragment: {
  11310. name: string;
  11311. shader: string;
  11312. };
  11313. }
  11314. declare module BABYLON {
  11315. /** @hidden */
  11316. export var spritesPixelShader: {
  11317. name: string;
  11318. shader: string;
  11319. };
  11320. }
  11321. declare module BABYLON {
  11322. /** @hidden */
  11323. export var fogVertexDeclaration: {
  11324. name: string;
  11325. shader: string;
  11326. };
  11327. }
  11328. declare module BABYLON {
  11329. /** @hidden */
  11330. export var spritesVertexShader: {
  11331. name: string;
  11332. shader: string;
  11333. };
  11334. }
  11335. declare module BABYLON {
  11336. /**
  11337. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11338. */
  11339. export interface ISpriteManager extends IDisposable {
  11340. /**
  11341. * Restricts the camera to viewing objects with the same layerMask.
  11342. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11343. */
  11344. layerMask: number;
  11345. /**
  11346. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11347. */
  11348. isPickable: boolean;
  11349. /**
  11350. * Specifies the rendering group id for this mesh (0 by default)
  11351. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11352. */
  11353. renderingGroupId: number;
  11354. /**
  11355. * Defines the list of sprites managed by the manager.
  11356. */
  11357. sprites: Array<Sprite>;
  11358. /**
  11359. * Tests the intersection of a sprite with a specific ray.
  11360. * @param ray The ray we are sending to test the collision
  11361. * @param camera The camera space we are sending rays in
  11362. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11363. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11364. * @returns picking info or null.
  11365. */
  11366. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11367. /**
  11368. * Intersects the sprites with a ray
  11369. * @param ray defines the ray to intersect with
  11370. * @param camera defines the current active camera
  11371. * @param predicate defines a predicate used to select candidate sprites
  11372. * @returns null if no hit or a PickingInfo array
  11373. */
  11374. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11375. /**
  11376. * Renders the list of sprites on screen.
  11377. */
  11378. render(): void;
  11379. }
  11380. /**
  11381. * Class used to manage multiple sprites on the same spritesheet
  11382. * @see http://doc.babylonjs.com/babylon101/sprites
  11383. */
  11384. export class SpriteManager implements ISpriteManager {
  11385. /** defines the manager's name */
  11386. name: string;
  11387. /** Gets the list of sprites */
  11388. sprites: Sprite[];
  11389. /** Gets or sets the rendering group id (0 by default) */
  11390. renderingGroupId: number;
  11391. /** Gets or sets camera layer mask */
  11392. layerMask: number;
  11393. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11394. fogEnabled: boolean;
  11395. /** Gets or sets a boolean indicating if the sprites are pickable */
  11396. isPickable: boolean;
  11397. /** Defines the default width of a cell in the spritesheet */
  11398. cellWidth: number;
  11399. /** Defines the default height of a cell in the spritesheet */
  11400. cellHeight: number;
  11401. /** Associative array from JSON sprite data file */
  11402. private _cellData;
  11403. /** Array of sprite names from JSON sprite data file */
  11404. private _spriteMap;
  11405. /** True when packed cell data from JSON file is ready*/
  11406. private _packedAndReady;
  11407. /**
  11408. * An event triggered when the manager is disposed.
  11409. */
  11410. onDisposeObservable: Observable<SpriteManager>;
  11411. private _onDisposeObserver;
  11412. /**
  11413. * Callback called when the manager is disposed
  11414. */
  11415. onDispose: () => void;
  11416. private _capacity;
  11417. private _fromPacked;
  11418. private _spriteTexture;
  11419. private _epsilon;
  11420. private _scene;
  11421. private _vertexData;
  11422. private _buffer;
  11423. private _vertexBuffers;
  11424. private _indexBuffer;
  11425. private _effectBase;
  11426. private _effectFog;
  11427. /**
  11428. * Gets or sets the spritesheet texture
  11429. */
  11430. texture: Texture;
  11431. /**
  11432. * Creates a new sprite manager
  11433. * @param name defines the manager's name
  11434. * @param imgUrl defines the sprite sheet url
  11435. * @param capacity defines the maximum allowed number of sprites
  11436. * @param cellSize defines the size of a sprite cell
  11437. * @param scene defines the hosting scene
  11438. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11439. * @param samplingMode defines the smapling mode to use with spritesheet
  11440. * @param fromPacked set to false; do not alter
  11441. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11442. */
  11443. constructor(
  11444. /** defines the manager's name */
  11445. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11446. private _makePacked;
  11447. private _appendSpriteVertex;
  11448. /**
  11449. * Intersects the sprites with a ray
  11450. * @param ray defines the ray to intersect with
  11451. * @param camera defines the current active camera
  11452. * @param predicate defines a predicate used to select candidate sprites
  11453. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11454. * @returns null if no hit or a PickingInfo
  11455. */
  11456. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11457. /**
  11458. * Intersects the sprites with a ray
  11459. * @param ray defines the ray to intersect with
  11460. * @param camera defines the current active camera
  11461. * @param predicate defines a predicate used to select candidate sprites
  11462. * @returns null if no hit or a PickingInfo array
  11463. */
  11464. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11465. /**
  11466. * Render all child sprites
  11467. */
  11468. render(): void;
  11469. /**
  11470. * Release associated resources
  11471. */
  11472. dispose(): void;
  11473. }
  11474. }
  11475. declare module BABYLON {
  11476. /**
  11477. * Class used to represent a sprite
  11478. * @see http://doc.babylonjs.com/babylon101/sprites
  11479. */
  11480. export class Sprite {
  11481. /** defines the name */
  11482. name: string;
  11483. /** Gets or sets the current world position */
  11484. position: Vector3;
  11485. /** Gets or sets the main color */
  11486. color: Color4;
  11487. /** Gets or sets the width */
  11488. width: number;
  11489. /** Gets or sets the height */
  11490. height: number;
  11491. /** Gets or sets rotation angle */
  11492. angle: number;
  11493. /** Gets or sets the cell index in the sprite sheet */
  11494. cellIndex: number;
  11495. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11496. cellRef: string;
  11497. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11498. invertU: number;
  11499. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11500. invertV: number;
  11501. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11502. disposeWhenFinishedAnimating: boolean;
  11503. /** Gets the list of attached animations */
  11504. animations: Animation[];
  11505. /** Gets or sets a boolean indicating if the sprite can be picked */
  11506. isPickable: boolean;
  11507. /**
  11508. * Gets or sets the associated action manager
  11509. */
  11510. actionManager: Nullable<ActionManager>;
  11511. private _animationStarted;
  11512. private _loopAnimation;
  11513. private _fromIndex;
  11514. private _toIndex;
  11515. private _delay;
  11516. private _direction;
  11517. private _manager;
  11518. private _time;
  11519. private _onAnimationEnd;
  11520. /**
  11521. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11522. */
  11523. isVisible: boolean;
  11524. /**
  11525. * Gets or sets the sprite size
  11526. */
  11527. size: number;
  11528. /**
  11529. * Creates a new Sprite
  11530. * @param name defines the name
  11531. * @param manager defines the manager
  11532. */
  11533. constructor(
  11534. /** defines the name */
  11535. name: string, manager: ISpriteManager);
  11536. /**
  11537. * Starts an animation
  11538. * @param from defines the initial key
  11539. * @param to defines the end key
  11540. * @param loop defines if the animation must loop
  11541. * @param delay defines the start delay (in ms)
  11542. * @param onAnimationEnd defines a callback to call when animation ends
  11543. */
  11544. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11545. /** Stops current animation (if any) */
  11546. stopAnimation(): void;
  11547. /** @hidden */
  11548. _animate(deltaTime: number): void;
  11549. /** Release associated resources */
  11550. dispose(): void;
  11551. }
  11552. }
  11553. declare module BABYLON {
  11554. /**
  11555. * Information about the result of picking within a scene
  11556. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11557. */
  11558. export class PickingInfo {
  11559. /** @hidden */
  11560. _pickingUnavailable: boolean;
  11561. /**
  11562. * If the pick collided with an object
  11563. */
  11564. hit: boolean;
  11565. /**
  11566. * Distance away where the pick collided
  11567. */
  11568. distance: number;
  11569. /**
  11570. * The location of pick collision
  11571. */
  11572. pickedPoint: Nullable<Vector3>;
  11573. /**
  11574. * The mesh corresponding the the pick collision
  11575. */
  11576. pickedMesh: Nullable<AbstractMesh>;
  11577. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11578. bu: number;
  11579. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11580. bv: number;
  11581. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11582. faceId: number;
  11583. /** Id of the the submesh that was picked */
  11584. subMeshId: number;
  11585. /** If a sprite was picked, this will be the sprite the pick collided with */
  11586. pickedSprite: Nullable<Sprite>;
  11587. /**
  11588. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11589. */
  11590. originMesh: Nullable<AbstractMesh>;
  11591. /**
  11592. * The ray that was used to perform the picking.
  11593. */
  11594. ray: Nullable<Ray>;
  11595. /**
  11596. * Gets the normal correspodning to the face the pick collided with
  11597. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11598. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11599. * @returns The normal correspodning to the face the pick collided with
  11600. */
  11601. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11602. /**
  11603. * Gets the texture coordinates of where the pick occured
  11604. * @returns the vector containing the coordnates of the texture
  11605. */
  11606. getTextureCoordinates(): Nullable<Vector2>;
  11607. }
  11608. }
  11609. declare module BABYLON {
  11610. /**
  11611. * Gather the list of pointer event types as constants.
  11612. */
  11613. export class PointerEventTypes {
  11614. /**
  11615. * 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.
  11616. */
  11617. static readonly POINTERDOWN: number;
  11618. /**
  11619. * The pointerup event is fired when a pointer is no longer active.
  11620. */
  11621. static readonly POINTERUP: number;
  11622. /**
  11623. * The pointermove event is fired when a pointer changes coordinates.
  11624. */
  11625. static readonly POINTERMOVE: number;
  11626. /**
  11627. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11628. */
  11629. static readonly POINTERWHEEL: number;
  11630. /**
  11631. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11632. */
  11633. static readonly POINTERPICK: number;
  11634. /**
  11635. * The pointertap event is fired when a the object has been touched and released without drag.
  11636. */
  11637. static readonly POINTERTAP: number;
  11638. /**
  11639. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11640. */
  11641. static readonly POINTERDOUBLETAP: number;
  11642. }
  11643. /**
  11644. * Base class of pointer info types.
  11645. */
  11646. export class PointerInfoBase {
  11647. /**
  11648. * Defines the type of event (PointerEventTypes)
  11649. */
  11650. type: number;
  11651. /**
  11652. * Defines the related dom event
  11653. */
  11654. event: PointerEvent | MouseWheelEvent;
  11655. /**
  11656. * Instantiates the base class of pointers info.
  11657. * @param type Defines the type of event (PointerEventTypes)
  11658. * @param event Defines the related dom event
  11659. */
  11660. constructor(
  11661. /**
  11662. * Defines the type of event (PointerEventTypes)
  11663. */
  11664. type: number,
  11665. /**
  11666. * Defines the related dom event
  11667. */
  11668. event: PointerEvent | MouseWheelEvent);
  11669. }
  11670. /**
  11671. * This class is used to store pointer related info for the onPrePointerObservable event.
  11672. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11673. */
  11674. export class PointerInfoPre extends PointerInfoBase {
  11675. /**
  11676. * Ray from a pointer if availible (eg. 6dof controller)
  11677. */
  11678. ray: Nullable<Ray>;
  11679. /**
  11680. * Defines the local position of the pointer on the canvas.
  11681. */
  11682. localPosition: Vector2;
  11683. /**
  11684. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11685. */
  11686. skipOnPointerObservable: boolean;
  11687. /**
  11688. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11689. * @param type Defines the type of event (PointerEventTypes)
  11690. * @param event Defines the related dom event
  11691. * @param localX Defines the local x coordinates of the pointer when the event occured
  11692. * @param localY Defines the local y coordinates of the pointer when the event occured
  11693. */
  11694. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11695. }
  11696. /**
  11697. * This type contains all the data related to a pointer event in Babylon.js.
  11698. * 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.
  11699. */
  11700. export class PointerInfo extends PointerInfoBase {
  11701. /**
  11702. * Defines the picking info associated to the info (if any)\
  11703. */
  11704. pickInfo: Nullable<PickingInfo>;
  11705. /**
  11706. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11707. * @param type Defines the type of event (PointerEventTypes)
  11708. * @param event Defines the related dom event
  11709. * @param pickInfo Defines the picking info associated to the info (if any)\
  11710. */
  11711. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11712. /**
  11713. * Defines the picking info associated to the info (if any)\
  11714. */
  11715. pickInfo: Nullable<PickingInfo>);
  11716. }
  11717. /**
  11718. * Data relating to a touch event on the screen.
  11719. */
  11720. export interface PointerTouch {
  11721. /**
  11722. * X coordinate of touch.
  11723. */
  11724. x: number;
  11725. /**
  11726. * Y coordinate of touch.
  11727. */
  11728. y: number;
  11729. /**
  11730. * Id of touch. Unique for each finger.
  11731. */
  11732. pointerId: number;
  11733. /**
  11734. * Event type passed from DOM.
  11735. */
  11736. type: any;
  11737. }
  11738. }
  11739. declare module BABYLON {
  11740. /**
  11741. * Manage the mouse inputs to control the movement of a free camera.
  11742. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11743. */
  11744. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11745. /**
  11746. * Define if touch is enabled in the mouse input
  11747. */
  11748. touchEnabled: boolean;
  11749. /**
  11750. * Defines the camera the input is attached to.
  11751. */
  11752. camera: FreeCamera;
  11753. /**
  11754. * Defines the buttons associated with the input to handle camera move.
  11755. */
  11756. buttons: number[];
  11757. /**
  11758. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11759. */
  11760. angularSensibility: number;
  11761. private _pointerInput;
  11762. private _onMouseMove;
  11763. private _observer;
  11764. private previousPosition;
  11765. /**
  11766. * Observable for when a pointer move event occurs containing the move offset
  11767. */
  11768. onPointerMovedObservable: Observable<{
  11769. offsetX: number;
  11770. offsetY: number;
  11771. }>;
  11772. /**
  11773. * @hidden
  11774. * If the camera should be rotated automatically based on pointer movement
  11775. */
  11776. _allowCameraRotation: boolean;
  11777. /**
  11778. * Manage the mouse inputs to control the movement of a free camera.
  11779. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11780. * @param touchEnabled Defines if touch is enabled or not
  11781. */
  11782. constructor(
  11783. /**
  11784. * Define if touch is enabled in the mouse input
  11785. */
  11786. touchEnabled?: boolean);
  11787. /**
  11788. * Attach the input controls to a specific dom element to get the input from.
  11789. * @param element Defines the element the controls should be listened from
  11790. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11791. */
  11792. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11793. /**
  11794. * Called on JS contextmenu event.
  11795. * Override this method to provide functionality.
  11796. */
  11797. protected onContextMenu(evt: PointerEvent): void;
  11798. /**
  11799. * Detach the current controls from the specified dom element.
  11800. * @param element Defines the element to stop listening the inputs from
  11801. */
  11802. detachControl(element: Nullable<HTMLElement>): void;
  11803. /**
  11804. * Gets the class name of the current intput.
  11805. * @returns the class name
  11806. */
  11807. getClassName(): string;
  11808. /**
  11809. * Get the friendly name associated with the input class.
  11810. * @returns the input friendly name
  11811. */
  11812. getSimpleName(): string;
  11813. }
  11814. }
  11815. declare module BABYLON {
  11816. /**
  11817. * Manage the touch inputs to control the movement of a free camera.
  11818. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11819. */
  11820. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11821. /**
  11822. * Defines the camera the input is attached to.
  11823. */
  11824. camera: FreeCamera;
  11825. /**
  11826. * Defines the touch sensibility for rotation.
  11827. * The higher the faster.
  11828. */
  11829. touchAngularSensibility: number;
  11830. /**
  11831. * Defines the touch sensibility for move.
  11832. * The higher the faster.
  11833. */
  11834. touchMoveSensibility: number;
  11835. private _offsetX;
  11836. private _offsetY;
  11837. private _pointerPressed;
  11838. private _pointerInput;
  11839. private _observer;
  11840. private _onLostFocus;
  11841. /**
  11842. * Attach the input controls to a specific dom element to get the input from.
  11843. * @param element Defines the element the controls should be listened from
  11844. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11845. */
  11846. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11847. /**
  11848. * Detach the current controls from the specified dom element.
  11849. * @param element Defines the element to stop listening the inputs from
  11850. */
  11851. detachControl(element: Nullable<HTMLElement>): void;
  11852. /**
  11853. * Update the current camera state depending on the inputs that have been used this frame.
  11854. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11855. */
  11856. checkInputs(): void;
  11857. /**
  11858. * Gets the class name of the current intput.
  11859. * @returns the class name
  11860. */
  11861. getClassName(): string;
  11862. /**
  11863. * Get the friendly name associated with the input class.
  11864. * @returns the input friendly name
  11865. */
  11866. getSimpleName(): string;
  11867. }
  11868. }
  11869. declare module BABYLON {
  11870. /**
  11871. * Default Inputs manager for the FreeCamera.
  11872. * It groups all the default supported inputs for ease of use.
  11873. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11874. */
  11875. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11876. /**
  11877. * @hidden
  11878. */
  11879. _mouseInput: Nullable<FreeCameraMouseInput>;
  11880. /**
  11881. * Instantiates a new FreeCameraInputsManager.
  11882. * @param camera Defines the camera the inputs belong to
  11883. */
  11884. constructor(camera: FreeCamera);
  11885. /**
  11886. * Add keyboard input support to the input manager.
  11887. * @returns the current input manager
  11888. */
  11889. addKeyboard(): FreeCameraInputsManager;
  11890. /**
  11891. * Add mouse input support to the input manager.
  11892. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11893. * @returns the current input manager
  11894. */
  11895. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11896. /**
  11897. * Removes the mouse input support from the manager
  11898. * @returns the current input manager
  11899. */
  11900. removeMouse(): FreeCameraInputsManager;
  11901. /**
  11902. * Add touch input support to the input manager.
  11903. * @returns the current input manager
  11904. */
  11905. addTouch(): FreeCameraInputsManager;
  11906. /**
  11907. * Remove all attached input methods from a camera
  11908. */
  11909. clear(): void;
  11910. }
  11911. }
  11912. declare module BABYLON {
  11913. /**
  11914. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11915. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  11916. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11917. */
  11918. export class FreeCamera extends TargetCamera {
  11919. /**
  11920. * Define the collision ellipsoid of the camera.
  11921. * This is helpful to simulate a camera body like the player body around the camera
  11922. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  11923. */
  11924. ellipsoid: Vector3;
  11925. /**
  11926. * Define an offset for the position of the ellipsoid around the camera.
  11927. * This can be helpful to determine the center of the body near the gravity center of the body
  11928. * instead of its head.
  11929. */
  11930. ellipsoidOffset: Vector3;
  11931. /**
  11932. * Enable or disable collisions of the camera with the rest of the scene objects.
  11933. */
  11934. checkCollisions: boolean;
  11935. /**
  11936. * Enable or disable gravity on the camera.
  11937. */
  11938. applyGravity: boolean;
  11939. /**
  11940. * Define the input manager associated to the camera.
  11941. */
  11942. inputs: FreeCameraInputsManager;
  11943. /**
  11944. * Gets the input sensibility for a mouse input. (default is 2000.0)
  11945. * Higher values reduce sensitivity.
  11946. */
  11947. /**
  11948. * Sets the input sensibility for a mouse input. (default is 2000.0)
  11949. * Higher values reduce sensitivity.
  11950. */
  11951. angularSensibility: number;
  11952. /**
  11953. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  11954. */
  11955. keysUp: number[];
  11956. /**
  11957. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  11958. */
  11959. keysDown: number[];
  11960. /**
  11961. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  11962. */
  11963. keysLeft: number[];
  11964. /**
  11965. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  11966. */
  11967. keysRight: number[];
  11968. /**
  11969. * Event raised when the camera collide with a mesh in the scene.
  11970. */
  11971. onCollide: (collidedMesh: AbstractMesh) => void;
  11972. private _collider;
  11973. private _needMoveForGravity;
  11974. private _oldPosition;
  11975. private _diffPosition;
  11976. private _newPosition;
  11977. /** @hidden */
  11978. _localDirection: Vector3;
  11979. /** @hidden */
  11980. _transformedDirection: Vector3;
  11981. /**
  11982. * Instantiates a Free Camera.
  11983. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11984. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  11985. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11986. * @param name Define the name of the camera in the scene
  11987. * @param position Define the start position of the camera in the scene
  11988. * @param scene Define the scene the camera belongs to
  11989. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  11990. */
  11991. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  11992. /**
  11993. * Attached controls to the current camera.
  11994. * @param element Defines the element the controls should be listened from
  11995. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11996. */
  11997. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11998. /**
  11999. * Detach the current controls from the camera.
  12000. * The camera will stop reacting to inputs.
  12001. * @param element Defines the element to stop listening the inputs from
  12002. */
  12003. detachControl(element: HTMLElement): void;
  12004. private _collisionMask;
  12005. /**
  12006. * Define a collision mask to limit the list of object the camera can collide with
  12007. */
  12008. collisionMask: number;
  12009. /** @hidden */
  12010. _collideWithWorld(displacement: Vector3): void;
  12011. private _onCollisionPositionChange;
  12012. /** @hidden */
  12013. _checkInputs(): void;
  12014. /** @hidden */
  12015. _decideIfNeedsToMove(): boolean;
  12016. /** @hidden */
  12017. _updatePosition(): void;
  12018. /**
  12019. * Destroy the camera and release the current resources hold by it.
  12020. */
  12021. dispose(): void;
  12022. /**
  12023. * Gets the current object class name.
  12024. * @return the class name
  12025. */
  12026. getClassName(): string;
  12027. }
  12028. }
  12029. declare module BABYLON {
  12030. /**
  12031. * Represents a gamepad control stick position
  12032. */
  12033. export class StickValues {
  12034. /**
  12035. * The x component of the control stick
  12036. */
  12037. x: number;
  12038. /**
  12039. * The y component of the control stick
  12040. */
  12041. y: number;
  12042. /**
  12043. * Initializes the gamepad x and y control stick values
  12044. * @param x The x component of the gamepad control stick value
  12045. * @param y The y component of the gamepad control stick value
  12046. */
  12047. constructor(
  12048. /**
  12049. * The x component of the control stick
  12050. */
  12051. x: number,
  12052. /**
  12053. * The y component of the control stick
  12054. */
  12055. y: number);
  12056. }
  12057. /**
  12058. * An interface which manages callbacks for gamepad button changes
  12059. */
  12060. export interface GamepadButtonChanges {
  12061. /**
  12062. * Called when a gamepad has been changed
  12063. */
  12064. changed: boolean;
  12065. /**
  12066. * Called when a gamepad press event has been triggered
  12067. */
  12068. pressChanged: boolean;
  12069. /**
  12070. * Called when a touch event has been triggered
  12071. */
  12072. touchChanged: boolean;
  12073. /**
  12074. * Called when a value has changed
  12075. */
  12076. valueChanged: boolean;
  12077. }
  12078. /**
  12079. * Represents a gamepad
  12080. */
  12081. export class Gamepad {
  12082. /**
  12083. * The id of the gamepad
  12084. */
  12085. id: string;
  12086. /**
  12087. * The index of the gamepad
  12088. */
  12089. index: number;
  12090. /**
  12091. * The browser gamepad
  12092. */
  12093. browserGamepad: any;
  12094. /**
  12095. * Specifies what type of gamepad this represents
  12096. */
  12097. type: number;
  12098. private _leftStick;
  12099. private _rightStick;
  12100. /** @hidden */
  12101. _isConnected: boolean;
  12102. private _leftStickAxisX;
  12103. private _leftStickAxisY;
  12104. private _rightStickAxisX;
  12105. private _rightStickAxisY;
  12106. /**
  12107. * Triggered when the left control stick has been changed
  12108. */
  12109. private _onleftstickchanged;
  12110. /**
  12111. * Triggered when the right control stick has been changed
  12112. */
  12113. private _onrightstickchanged;
  12114. /**
  12115. * Represents a gamepad controller
  12116. */
  12117. static GAMEPAD: number;
  12118. /**
  12119. * Represents a generic controller
  12120. */
  12121. static GENERIC: number;
  12122. /**
  12123. * Represents an XBox controller
  12124. */
  12125. static XBOX: number;
  12126. /**
  12127. * Represents a pose-enabled controller
  12128. */
  12129. static POSE_ENABLED: number;
  12130. /**
  12131. * Represents an Dual Shock controller
  12132. */
  12133. static DUALSHOCK: number;
  12134. /**
  12135. * Specifies whether the left control stick should be Y-inverted
  12136. */
  12137. protected _invertLeftStickY: boolean;
  12138. /**
  12139. * Specifies if the gamepad has been connected
  12140. */
  12141. readonly isConnected: boolean;
  12142. /**
  12143. * Initializes the gamepad
  12144. * @param id The id of the gamepad
  12145. * @param index The index of the gamepad
  12146. * @param browserGamepad The browser gamepad
  12147. * @param leftStickX The x component of the left joystick
  12148. * @param leftStickY The y component of the left joystick
  12149. * @param rightStickX The x component of the right joystick
  12150. * @param rightStickY The y component of the right joystick
  12151. */
  12152. constructor(
  12153. /**
  12154. * The id of the gamepad
  12155. */
  12156. id: string,
  12157. /**
  12158. * The index of the gamepad
  12159. */
  12160. index: number,
  12161. /**
  12162. * The browser gamepad
  12163. */
  12164. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12165. /**
  12166. * Callback triggered when the left joystick has changed
  12167. * @param callback
  12168. */
  12169. onleftstickchanged(callback: (values: StickValues) => void): void;
  12170. /**
  12171. * Callback triggered when the right joystick has changed
  12172. * @param callback
  12173. */
  12174. onrightstickchanged(callback: (values: StickValues) => void): void;
  12175. /**
  12176. * Gets the left joystick
  12177. */
  12178. /**
  12179. * Sets the left joystick values
  12180. */
  12181. leftStick: StickValues;
  12182. /**
  12183. * Gets the right joystick
  12184. */
  12185. /**
  12186. * Sets the right joystick value
  12187. */
  12188. rightStick: StickValues;
  12189. /**
  12190. * Updates the gamepad joystick positions
  12191. */
  12192. update(): void;
  12193. /**
  12194. * Disposes the gamepad
  12195. */
  12196. dispose(): void;
  12197. }
  12198. /**
  12199. * Represents a generic gamepad
  12200. */
  12201. export class GenericPad extends Gamepad {
  12202. private _buttons;
  12203. private _onbuttondown;
  12204. private _onbuttonup;
  12205. /**
  12206. * Observable triggered when a button has been pressed
  12207. */
  12208. onButtonDownObservable: Observable<number>;
  12209. /**
  12210. * Observable triggered when a button has been released
  12211. */
  12212. onButtonUpObservable: Observable<number>;
  12213. /**
  12214. * Callback triggered when a button has been pressed
  12215. * @param callback Called when a button has been pressed
  12216. */
  12217. onbuttondown(callback: (buttonPressed: number) => void): void;
  12218. /**
  12219. * Callback triggered when a button has been released
  12220. * @param callback Called when a button has been released
  12221. */
  12222. onbuttonup(callback: (buttonReleased: number) => void): void;
  12223. /**
  12224. * Initializes the generic gamepad
  12225. * @param id The id of the generic gamepad
  12226. * @param index The index of the generic gamepad
  12227. * @param browserGamepad The browser gamepad
  12228. */
  12229. constructor(id: string, index: number, browserGamepad: any);
  12230. private _setButtonValue;
  12231. /**
  12232. * Updates the generic gamepad
  12233. */
  12234. update(): void;
  12235. /**
  12236. * Disposes the generic gamepad
  12237. */
  12238. dispose(): void;
  12239. }
  12240. }
  12241. declare module BABYLON {
  12242. interface Engine {
  12243. /**
  12244. * Creates a raw texture
  12245. * @param data defines the data to store in the texture
  12246. * @param width defines the width of the texture
  12247. * @param height defines the height of the texture
  12248. * @param format defines the format of the data
  12249. * @param generateMipMaps defines if the engine should generate the mip levels
  12250. * @param invertY defines if data must be stored with Y axis inverted
  12251. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12252. * @param compression defines the compression used (null by default)
  12253. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12254. * @returns the raw texture inside an InternalTexture
  12255. */
  12256. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12257. /**
  12258. * Update a raw texture
  12259. * @param texture defines the texture to update
  12260. * @param data defines the data to store in the texture
  12261. * @param format defines the format of the data
  12262. * @param invertY defines if data must be stored with Y axis inverted
  12263. */
  12264. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12265. /**
  12266. * Update a raw texture
  12267. * @param texture defines the texture to update
  12268. * @param data defines the data to store in the texture
  12269. * @param format defines the format of the data
  12270. * @param invertY defines if data must be stored with Y axis inverted
  12271. * @param compression defines the compression used (null by default)
  12272. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12273. */
  12274. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12275. /**
  12276. * Creates a new raw cube texture
  12277. * @param data defines the array of data to use to create each face
  12278. * @param size defines the size of the textures
  12279. * @param format defines the format of the data
  12280. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12281. * @param generateMipMaps defines if the engine should generate the mip levels
  12282. * @param invertY defines if data must be stored with Y axis inverted
  12283. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12284. * @param compression defines the compression used (null by default)
  12285. * @returns the cube texture as an InternalTexture
  12286. */
  12287. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12288. /**
  12289. * Update a raw cube texture
  12290. * @param texture defines the texture to udpdate
  12291. * @param data defines the data to store
  12292. * @param format defines the data format
  12293. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12294. * @param invertY defines if data must be stored with Y axis inverted
  12295. */
  12296. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12297. /**
  12298. * Update a raw cube texture
  12299. * @param texture defines the texture to udpdate
  12300. * @param data defines the data to store
  12301. * @param format defines the data format
  12302. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12303. * @param invertY defines if data must be stored with Y axis inverted
  12304. * @param compression defines the compression used (null by default)
  12305. */
  12306. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12307. /**
  12308. * Update a raw cube texture
  12309. * @param texture defines the texture to udpdate
  12310. * @param data defines the data to store
  12311. * @param format defines the data format
  12312. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12313. * @param invertY defines if data must be stored with Y axis inverted
  12314. * @param compression defines the compression used (null by default)
  12315. * @param level defines which level of the texture to update
  12316. */
  12317. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12318. /**
  12319. * Creates a new raw cube texture from a specified url
  12320. * @param url defines the url where the data is located
  12321. * @param scene defines the current scene
  12322. * @param size defines the size of the textures
  12323. * @param format defines the format of the data
  12324. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12325. * @param noMipmap defines if the engine should avoid generating the mip levels
  12326. * @param callback defines a callback used to extract texture data from loaded data
  12327. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12328. * @param onLoad defines a callback called when texture is loaded
  12329. * @param onError defines a callback called if there is an error
  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>): InternalTexture;
  12333. /**
  12334. * Creates a new raw cube texture from a specified url
  12335. * @param url defines the url where the data is located
  12336. * @param scene defines the current scene
  12337. * @param size defines the size of the textures
  12338. * @param format defines the format of the data
  12339. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12340. * @param noMipmap defines if the engine should avoid generating the mip levels
  12341. * @param callback defines a callback used to extract texture data from loaded data
  12342. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12343. * @param onLoad defines a callback called when texture is loaded
  12344. * @param onError defines a callback called if there is an error
  12345. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12346. * @param invertY defines if data must be stored with Y axis inverted
  12347. * @returns the cube texture as an InternalTexture
  12348. */
  12349. 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;
  12350. /**
  12351. * Creates a new raw 3D texture
  12352. * @param data defines the data used to create the texture
  12353. * @param width defines the width of the texture
  12354. * @param height defines the height of the texture
  12355. * @param depth defines the depth of the texture
  12356. * @param format defines the format of the texture
  12357. * @param generateMipMaps defines if the engine must generate mip levels
  12358. * @param invertY defines if data must be stored with Y axis inverted
  12359. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12360. * @param compression defines the compressed used (can be null)
  12361. * @param textureType defines the compressed used (can be null)
  12362. * @returns a new raw 3D texture (stored in an InternalTexture)
  12363. */
  12364. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12365. /**
  12366. * Update a raw 3D texture
  12367. * @param texture defines the texture to update
  12368. * @param data defines the data to store
  12369. * @param format defines the data format
  12370. * @param invertY defines if data must be stored with Y axis inverted
  12371. */
  12372. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12373. /**
  12374. * Update a raw 3D texture
  12375. * @param texture defines the texture to update
  12376. * @param data defines the data to store
  12377. * @param format defines the data format
  12378. * @param invertY defines if data must be stored with Y axis inverted
  12379. * @param compression defines the used compression (can be null)
  12380. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12381. */
  12382. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12383. }
  12384. }
  12385. declare module BABYLON {
  12386. /**
  12387. * Raw texture can help creating a texture directly from an array of data.
  12388. * This can be super useful if you either get the data from an uncompressed source or
  12389. * if you wish to create your texture pixel by pixel.
  12390. */
  12391. export class RawTexture extends Texture {
  12392. /**
  12393. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12394. */
  12395. format: number;
  12396. private _engine;
  12397. /**
  12398. * Instantiates a new RawTexture.
  12399. * Raw texture can help creating a texture directly from an array of data.
  12400. * This can be super useful if you either get the data from an uncompressed source or
  12401. * if you wish to create your texture pixel by pixel.
  12402. * @param data define the array of data to use to create the texture
  12403. * @param width define the width of the texture
  12404. * @param height define the height of the texture
  12405. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12406. * @param scene define the scene the texture belongs to
  12407. * @param generateMipMaps define whether mip maps should be generated or not
  12408. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12409. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12410. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12411. */
  12412. constructor(data: ArrayBufferView, width: number, height: number,
  12413. /**
  12414. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12415. */
  12416. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12417. /**
  12418. * Updates the texture underlying data.
  12419. * @param data Define the new data of the texture
  12420. */
  12421. update(data: ArrayBufferView): void;
  12422. /**
  12423. * Creates a luminance texture from some data.
  12424. * @param data Define the texture data
  12425. * @param width Define the width of the texture
  12426. * @param height Define the height of the texture
  12427. * @param scene Define the scene the texture belongs to
  12428. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12429. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12430. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12431. * @returns the luminance texture
  12432. */
  12433. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12434. /**
  12435. * Creates a luminance alpha texture from some data.
  12436. * @param data Define the texture data
  12437. * @param width Define the width of the texture
  12438. * @param height Define the height of the texture
  12439. * @param scene Define the scene the texture belongs to
  12440. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12441. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12442. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12443. * @returns the luminance alpha texture
  12444. */
  12445. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12446. /**
  12447. * Creates an alpha texture from some data.
  12448. * @param data Define the texture data
  12449. * @param width Define the width of the texture
  12450. * @param height Define the height of the texture
  12451. * @param scene Define the scene the texture belongs to
  12452. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12453. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12454. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12455. * @returns the alpha texture
  12456. */
  12457. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12458. /**
  12459. * Creates a RGB texture from some data.
  12460. * @param data Define the texture data
  12461. * @param width Define the width of the texture
  12462. * @param height Define the height of the texture
  12463. * @param scene Define the scene the texture belongs to
  12464. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12465. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12466. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12467. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12468. * @returns the RGB alpha texture
  12469. */
  12470. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12471. /**
  12472. * Creates a RGBA texture from some data.
  12473. * @param data Define the texture data
  12474. * @param width Define the width of the texture
  12475. * @param height Define the height of the texture
  12476. * @param scene Define the scene the texture belongs to
  12477. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12478. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12479. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12480. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12481. * @returns the RGBA texture
  12482. */
  12483. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12484. /**
  12485. * Creates a R texture from some data.
  12486. * @param data Define the texture data
  12487. * @param width Define the width of the texture
  12488. * @param height Define the height of the texture
  12489. * @param scene Define the scene the texture belongs to
  12490. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12491. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12492. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12493. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12494. * @returns the R texture
  12495. */
  12496. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12497. }
  12498. }
  12499. declare module BABYLON {
  12500. /**
  12501. * Interface for the size containing width and height
  12502. */
  12503. export interface ISize {
  12504. /**
  12505. * Width
  12506. */
  12507. width: number;
  12508. /**
  12509. * Heighht
  12510. */
  12511. height: number;
  12512. }
  12513. /**
  12514. * Size containing widht and height
  12515. */
  12516. export class Size implements ISize {
  12517. /**
  12518. * Width
  12519. */
  12520. width: number;
  12521. /**
  12522. * Height
  12523. */
  12524. height: number;
  12525. /**
  12526. * Creates a Size object from the given width and height (floats).
  12527. * @param width width of the new size
  12528. * @param height height of the new size
  12529. */
  12530. constructor(width: number, height: number);
  12531. /**
  12532. * Returns a string with the Size width and height
  12533. * @returns a string with the Size width and height
  12534. */
  12535. toString(): string;
  12536. /**
  12537. * "Size"
  12538. * @returns the string "Size"
  12539. */
  12540. getClassName(): string;
  12541. /**
  12542. * Returns the Size hash code.
  12543. * @returns a hash code for a unique width and height
  12544. */
  12545. getHashCode(): number;
  12546. /**
  12547. * Updates the current size from the given one.
  12548. * @param src the given size
  12549. */
  12550. copyFrom(src: Size): void;
  12551. /**
  12552. * Updates in place the current Size from the given floats.
  12553. * @param width width of the new size
  12554. * @param height height of the new size
  12555. * @returns the updated Size.
  12556. */
  12557. copyFromFloats(width: number, height: number): Size;
  12558. /**
  12559. * Updates in place the current Size from the given floats.
  12560. * @param width width to set
  12561. * @param height height to set
  12562. * @returns the updated Size.
  12563. */
  12564. set(width: number, height: number): Size;
  12565. /**
  12566. * Multiplies the width and height by numbers
  12567. * @param w factor to multiple the width by
  12568. * @param h factor to multiple the height by
  12569. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12570. */
  12571. multiplyByFloats(w: number, h: number): Size;
  12572. /**
  12573. * Clones the size
  12574. * @returns a new Size copied from the given one.
  12575. */
  12576. clone(): Size;
  12577. /**
  12578. * True if the current Size and the given one width and height are strictly equal.
  12579. * @param other the other size to compare against
  12580. * @returns True if the current Size and the given one width and height are strictly equal.
  12581. */
  12582. equals(other: Size): boolean;
  12583. /**
  12584. * The surface of the Size : width * height (float).
  12585. */
  12586. readonly surface: number;
  12587. /**
  12588. * Create a new size of zero
  12589. * @returns a new Size set to (0.0, 0.0)
  12590. */
  12591. static Zero(): Size;
  12592. /**
  12593. * Sums the width and height of two sizes
  12594. * @param otherSize size to add to this size
  12595. * @returns a new Size set as the addition result of the current Size and the given one.
  12596. */
  12597. add(otherSize: Size): Size;
  12598. /**
  12599. * Subtracts the width and height of two
  12600. * @param otherSize size to subtract to this size
  12601. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12602. */
  12603. subtract(otherSize: Size): Size;
  12604. /**
  12605. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12606. * @param start starting size to lerp between
  12607. * @param end end size to lerp between
  12608. * @param amount amount to lerp between the start and end values
  12609. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12610. */
  12611. static Lerp(start: Size, end: Size, amount: number): Size;
  12612. }
  12613. }
  12614. declare module BABYLON {
  12615. /**
  12616. * Defines a runtime animation
  12617. */
  12618. export class RuntimeAnimation {
  12619. private _events;
  12620. /**
  12621. * The current frame of the runtime animation
  12622. */
  12623. private _currentFrame;
  12624. /**
  12625. * The animation used by the runtime animation
  12626. */
  12627. private _animation;
  12628. /**
  12629. * The target of the runtime animation
  12630. */
  12631. private _target;
  12632. /**
  12633. * The initiating animatable
  12634. */
  12635. private _host;
  12636. /**
  12637. * The original value of the runtime animation
  12638. */
  12639. private _originalValue;
  12640. /**
  12641. * The original blend value of the runtime animation
  12642. */
  12643. private _originalBlendValue;
  12644. /**
  12645. * The offsets cache of the runtime animation
  12646. */
  12647. private _offsetsCache;
  12648. /**
  12649. * The high limits cache of the runtime animation
  12650. */
  12651. private _highLimitsCache;
  12652. /**
  12653. * Specifies if the runtime animation has been stopped
  12654. */
  12655. private _stopped;
  12656. /**
  12657. * The blending factor of the runtime animation
  12658. */
  12659. private _blendingFactor;
  12660. /**
  12661. * The BabylonJS scene
  12662. */
  12663. private _scene;
  12664. /**
  12665. * The current value of the runtime animation
  12666. */
  12667. private _currentValue;
  12668. /** @hidden */
  12669. _animationState: _IAnimationState;
  12670. /**
  12671. * The active target of the runtime animation
  12672. */
  12673. private _activeTargets;
  12674. private _currentActiveTarget;
  12675. private _directTarget;
  12676. /**
  12677. * The target path of the runtime animation
  12678. */
  12679. private _targetPath;
  12680. /**
  12681. * The weight of the runtime animation
  12682. */
  12683. private _weight;
  12684. /**
  12685. * The ratio offset of the runtime animation
  12686. */
  12687. private _ratioOffset;
  12688. /**
  12689. * The previous delay of the runtime animation
  12690. */
  12691. private _previousDelay;
  12692. /**
  12693. * The previous ratio of the runtime animation
  12694. */
  12695. private _previousRatio;
  12696. private _enableBlending;
  12697. private _keys;
  12698. private _minFrame;
  12699. private _maxFrame;
  12700. private _minValue;
  12701. private _maxValue;
  12702. private _targetIsArray;
  12703. /**
  12704. * Gets the current frame of the runtime animation
  12705. */
  12706. readonly currentFrame: number;
  12707. /**
  12708. * Gets the weight of the runtime animation
  12709. */
  12710. readonly weight: number;
  12711. /**
  12712. * Gets the current value of the runtime animation
  12713. */
  12714. readonly currentValue: any;
  12715. /**
  12716. * Gets the target path of the runtime animation
  12717. */
  12718. readonly targetPath: string;
  12719. /**
  12720. * Gets the actual target of the runtime animation
  12721. */
  12722. readonly target: any;
  12723. /** @hidden */
  12724. _onLoop: () => void;
  12725. /**
  12726. * Create a new RuntimeAnimation object
  12727. * @param target defines the target of the animation
  12728. * @param animation defines the source animation object
  12729. * @param scene defines the hosting scene
  12730. * @param host defines the initiating Animatable
  12731. */
  12732. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12733. private _preparePath;
  12734. /**
  12735. * Gets the animation from the runtime animation
  12736. */
  12737. readonly animation: Animation;
  12738. /**
  12739. * Resets the runtime animation to the beginning
  12740. * @param restoreOriginal defines whether to restore the target property to the original value
  12741. */
  12742. reset(restoreOriginal?: boolean): void;
  12743. /**
  12744. * Specifies if the runtime animation is stopped
  12745. * @returns Boolean specifying if the runtime animation is stopped
  12746. */
  12747. isStopped(): boolean;
  12748. /**
  12749. * Disposes of the runtime animation
  12750. */
  12751. dispose(): void;
  12752. /**
  12753. * Apply the interpolated value to the target
  12754. * @param currentValue defines the value computed by the animation
  12755. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12756. */
  12757. setValue(currentValue: any, weight: number): void;
  12758. private _getOriginalValues;
  12759. private _setValue;
  12760. /**
  12761. * Gets the loop pmode of the runtime animation
  12762. * @returns Loop Mode
  12763. */
  12764. private _getCorrectLoopMode;
  12765. /**
  12766. * Move the current animation to a given frame
  12767. * @param frame defines the frame to move to
  12768. */
  12769. goToFrame(frame: number): void;
  12770. /**
  12771. * @hidden Internal use only
  12772. */
  12773. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12774. /**
  12775. * Execute the current animation
  12776. * @param delay defines the delay to add to the current frame
  12777. * @param from defines the lower bound of the animation range
  12778. * @param to defines the upper bound of the animation range
  12779. * @param loop defines if the current animation must loop
  12780. * @param speedRatio defines the current speed ratio
  12781. * @param weight defines the weight of the animation (default is -1 so no weight)
  12782. * @param onLoop optional callback called when animation loops
  12783. * @returns a boolean indicating if the animation is running
  12784. */
  12785. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12786. }
  12787. }
  12788. declare module BABYLON {
  12789. /**
  12790. * Class used to store an actual running animation
  12791. */
  12792. export class Animatable {
  12793. /** defines the target object */
  12794. target: any;
  12795. /** defines the starting frame number (default is 0) */
  12796. fromFrame: number;
  12797. /** defines the ending frame number (default is 100) */
  12798. toFrame: number;
  12799. /** defines if the animation must loop (default is false) */
  12800. loopAnimation: boolean;
  12801. /** defines a callback to call when animation ends if it is not looping */
  12802. onAnimationEnd?: (() => void) | null | undefined;
  12803. /** defines a callback to call when animation loops */
  12804. onAnimationLoop?: (() => void) | null | undefined;
  12805. private _localDelayOffset;
  12806. private _pausedDelay;
  12807. private _runtimeAnimations;
  12808. private _paused;
  12809. private _scene;
  12810. private _speedRatio;
  12811. private _weight;
  12812. private _syncRoot;
  12813. /**
  12814. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12815. * This will only apply for non looping animation (default is true)
  12816. */
  12817. disposeOnEnd: boolean;
  12818. /**
  12819. * Gets a boolean indicating if the animation has started
  12820. */
  12821. animationStarted: boolean;
  12822. /**
  12823. * Observer raised when the animation ends
  12824. */
  12825. onAnimationEndObservable: Observable<Animatable>;
  12826. /**
  12827. * Observer raised when the animation loops
  12828. */
  12829. onAnimationLoopObservable: Observable<Animatable>;
  12830. /**
  12831. * Gets the root Animatable used to synchronize and normalize animations
  12832. */
  12833. readonly syncRoot: Nullable<Animatable>;
  12834. /**
  12835. * Gets the current frame of the first RuntimeAnimation
  12836. * Used to synchronize Animatables
  12837. */
  12838. readonly masterFrame: number;
  12839. /**
  12840. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  12841. */
  12842. weight: number;
  12843. /**
  12844. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  12845. */
  12846. speedRatio: number;
  12847. /**
  12848. * Creates a new Animatable
  12849. * @param scene defines the hosting scene
  12850. * @param target defines the target object
  12851. * @param fromFrame defines the starting frame number (default is 0)
  12852. * @param toFrame defines the ending frame number (default is 100)
  12853. * @param loopAnimation defines if the animation must loop (default is false)
  12854. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  12855. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  12856. * @param animations defines a group of animation to add to the new Animatable
  12857. * @param onAnimationLoop defines a callback to call when animation loops
  12858. */
  12859. constructor(scene: Scene,
  12860. /** defines the target object */
  12861. target: any,
  12862. /** defines the starting frame number (default is 0) */
  12863. fromFrame?: number,
  12864. /** defines the ending frame number (default is 100) */
  12865. toFrame?: number,
  12866. /** defines if the animation must loop (default is false) */
  12867. loopAnimation?: boolean, speedRatio?: number,
  12868. /** defines a callback to call when animation ends if it is not looping */
  12869. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  12870. /** defines a callback to call when animation loops */
  12871. onAnimationLoop?: (() => void) | null | undefined);
  12872. /**
  12873. * Synchronize and normalize current Animatable with a source Animatable
  12874. * This is useful when using animation weights and when animations are not of the same length
  12875. * @param root defines the root Animatable to synchronize with
  12876. * @returns the current Animatable
  12877. */
  12878. syncWith(root: Animatable): Animatable;
  12879. /**
  12880. * Gets the list of runtime animations
  12881. * @returns an array of RuntimeAnimation
  12882. */
  12883. getAnimations(): RuntimeAnimation[];
  12884. /**
  12885. * Adds more animations to the current animatable
  12886. * @param target defines the target of the animations
  12887. * @param animations defines the new animations to add
  12888. */
  12889. appendAnimations(target: any, animations: Animation[]): void;
  12890. /**
  12891. * Gets the source animation for a specific property
  12892. * @param property defines the propertyu to look for
  12893. * @returns null or the source animation for the given property
  12894. */
  12895. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  12896. /**
  12897. * Gets the runtime animation for a specific property
  12898. * @param property defines the propertyu to look for
  12899. * @returns null or the runtime animation for the given property
  12900. */
  12901. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  12902. /**
  12903. * Resets the animatable to its original state
  12904. */
  12905. reset(): void;
  12906. /**
  12907. * Allows the animatable to blend with current running animations
  12908. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12909. * @param blendingSpeed defines the blending speed to use
  12910. */
  12911. enableBlending(blendingSpeed: number): void;
  12912. /**
  12913. * Disable animation blending
  12914. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12915. */
  12916. disableBlending(): void;
  12917. /**
  12918. * Jump directly to a given frame
  12919. * @param frame defines the frame to jump to
  12920. */
  12921. goToFrame(frame: number): void;
  12922. /**
  12923. * Pause the animation
  12924. */
  12925. pause(): void;
  12926. /**
  12927. * Restart the animation
  12928. */
  12929. restart(): void;
  12930. private _raiseOnAnimationEnd;
  12931. /**
  12932. * Stop and delete the current animation
  12933. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  12934. * @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)
  12935. */
  12936. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  12937. /**
  12938. * Wait asynchronously for the animation to end
  12939. * @returns a promise which will be fullfilled when the animation ends
  12940. */
  12941. waitAsync(): Promise<Animatable>;
  12942. /** @hidden */
  12943. _animate(delay: number): boolean;
  12944. }
  12945. interface Scene {
  12946. /** @hidden */
  12947. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  12948. /** @hidden */
  12949. _processLateAnimationBindingsForMatrices(holder: {
  12950. totalWeight: number;
  12951. animations: RuntimeAnimation[];
  12952. originalValue: Matrix;
  12953. }): any;
  12954. /** @hidden */
  12955. _processLateAnimationBindingsForQuaternions(holder: {
  12956. totalWeight: number;
  12957. animations: RuntimeAnimation[];
  12958. originalValue: Quaternion;
  12959. }, refQuaternion: Quaternion): Quaternion;
  12960. /** @hidden */
  12961. _processLateAnimationBindings(): void;
  12962. /**
  12963. * Will start the animation sequence of a given target
  12964. * @param target defines the target
  12965. * @param from defines from which frame should animation start
  12966. * @param to defines until which frame should animation run.
  12967. * @param weight defines the weight to apply to the animation (1.0 by default)
  12968. * @param loop defines if the animation loops
  12969. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12970. * @param onAnimationEnd defines the function to be executed when the animation ends
  12971. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12972. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12973. * @param onAnimationLoop defines the callback to call when an animation loops
  12974. * @returns the animatable object created for this animation
  12975. */
  12976. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12977. /**
  12978. * Will start the animation sequence of a given target
  12979. * @param target defines the target
  12980. * @param from defines from which frame should animation start
  12981. * @param to defines until which frame should animation run.
  12982. * @param loop defines if the animation loops
  12983. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12984. * @param onAnimationEnd defines the function to be executed when the animation ends
  12985. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12986. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  12987. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  12988. * @param onAnimationLoop defines the callback to call when an animation loops
  12989. * @returns the animatable object created for this animation
  12990. */
  12991. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12992. /**
  12993. * Will start the animation sequence of a given target and its hierarchy
  12994. * @param target defines the target
  12995. * @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.
  12996. * @param from defines from which frame should animation start
  12997. * @param to defines until which frame should animation run.
  12998. * @param loop defines if the animation loops
  12999. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13000. * @param onAnimationEnd defines the function to be executed when the animation ends
  13001. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13002. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13003. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13004. * @param onAnimationLoop defines the callback to call when an animation loops
  13005. * @returns the list of created animatables
  13006. */
  13007. 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[];
  13008. /**
  13009. * Begin a new animation on a given node
  13010. * @param target defines the target where the animation will take place
  13011. * @param animations defines the list of animations to start
  13012. * @param from defines the initial value
  13013. * @param to defines the final value
  13014. * @param loop defines if you want animation to loop (off by default)
  13015. * @param speedRatio defines the speed ratio to apply to all animations
  13016. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13017. * @param onAnimationLoop defines the callback to call when an animation loops
  13018. * @returns the list of created animatables
  13019. */
  13020. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13021. /**
  13022. * Begin a new animation on a given node and its hierarchy
  13023. * @param target defines the root node where the animation will take place
  13024. * @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.
  13025. * @param animations defines the list of animations to start
  13026. * @param from defines the initial value
  13027. * @param to defines the final value
  13028. * @param loop defines if you want animation to loop (off by default)
  13029. * @param speedRatio defines the speed ratio to apply to all animations
  13030. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13031. * @param onAnimationLoop defines the callback to call when an animation loops
  13032. * @returns the list of animatables created for all nodes
  13033. */
  13034. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13035. /**
  13036. * Gets the animatable associated with a specific target
  13037. * @param target defines the target of the animatable
  13038. * @returns the required animatable if found
  13039. */
  13040. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13041. /**
  13042. * Gets all animatables associated with a given target
  13043. * @param target defines the target to look animatables for
  13044. * @returns an array of Animatables
  13045. */
  13046. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13047. /**
  13048. * Stops and removes all animations that have been applied to the scene
  13049. */
  13050. stopAllAnimations(): void;
  13051. }
  13052. interface Bone {
  13053. /**
  13054. * Copy an animation range from another bone
  13055. * @param source defines the source bone
  13056. * @param rangeName defines the range name to copy
  13057. * @param frameOffset defines the frame offset
  13058. * @param rescaleAsRequired defines if rescaling must be applied if required
  13059. * @param skelDimensionsRatio defines the scaling ratio
  13060. * @returns true if operation was successful
  13061. */
  13062. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13063. }
  13064. }
  13065. declare module BABYLON {
  13066. /**
  13067. * Class used to override all child animations of a given target
  13068. */
  13069. export class AnimationPropertiesOverride {
  13070. /**
  13071. * Gets or sets a value indicating if animation blending must be used
  13072. */
  13073. enableBlending: boolean;
  13074. /**
  13075. * Gets or sets the blending speed to use when enableBlending is true
  13076. */
  13077. blendingSpeed: number;
  13078. /**
  13079. * Gets or sets the default loop mode to use
  13080. */
  13081. loopMode: number;
  13082. }
  13083. }
  13084. declare module BABYLON {
  13085. /**
  13086. * Class used to handle skinning animations
  13087. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13088. */
  13089. export class Skeleton implements IAnimatable {
  13090. /** defines the skeleton name */
  13091. name: string;
  13092. /** defines the skeleton Id */
  13093. id: string;
  13094. /**
  13095. * Defines the list of child bones
  13096. */
  13097. bones: Bone[];
  13098. /**
  13099. * Defines an estimate of the dimension of the skeleton at rest
  13100. */
  13101. dimensionsAtRest: Vector3;
  13102. /**
  13103. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13104. */
  13105. needInitialSkinMatrix: boolean;
  13106. /**
  13107. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13108. */
  13109. overrideMesh: Nullable<AbstractMesh>;
  13110. /**
  13111. * Gets the list of animations attached to this skeleton
  13112. */
  13113. animations: Array<Animation>;
  13114. private _scene;
  13115. private _isDirty;
  13116. private _transformMatrices;
  13117. private _transformMatrixTexture;
  13118. private _meshesWithPoseMatrix;
  13119. private _animatables;
  13120. private _identity;
  13121. private _synchronizedWithMesh;
  13122. private _ranges;
  13123. private _lastAbsoluteTransformsUpdateId;
  13124. private _canUseTextureForBones;
  13125. private _uniqueId;
  13126. /** @hidden */
  13127. _numBonesWithLinkedTransformNode: number;
  13128. /** @hidden */
  13129. _hasWaitingData: Nullable<boolean>;
  13130. /**
  13131. * Specifies if the skeleton should be serialized
  13132. */
  13133. doNotSerialize: boolean;
  13134. private _useTextureToStoreBoneMatrices;
  13135. /**
  13136. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13137. * Please note that this option is not available if the hardware does not support it
  13138. */
  13139. useTextureToStoreBoneMatrices: boolean;
  13140. private _animationPropertiesOverride;
  13141. /**
  13142. * Gets or sets the animation properties override
  13143. */
  13144. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13145. /**
  13146. * List of inspectable custom properties (used by the Inspector)
  13147. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13148. */
  13149. inspectableCustomProperties: IInspectable[];
  13150. /**
  13151. * An observable triggered before computing the skeleton's matrices
  13152. */
  13153. onBeforeComputeObservable: Observable<Skeleton>;
  13154. /**
  13155. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13156. */
  13157. readonly isUsingTextureForMatrices: boolean;
  13158. /**
  13159. * Gets the unique ID of this skeleton
  13160. */
  13161. readonly uniqueId: number;
  13162. /**
  13163. * Creates a new skeleton
  13164. * @param name defines the skeleton name
  13165. * @param id defines the skeleton Id
  13166. * @param scene defines the hosting scene
  13167. */
  13168. constructor(
  13169. /** defines the skeleton name */
  13170. name: string,
  13171. /** defines the skeleton Id */
  13172. id: string, scene: Scene);
  13173. /**
  13174. * Gets the current object class name.
  13175. * @return the class name
  13176. */
  13177. getClassName(): string;
  13178. /**
  13179. * Returns an array containing the root bones
  13180. * @returns an array containing the root bones
  13181. */
  13182. getChildren(): Array<Bone>;
  13183. /**
  13184. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13185. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13186. * @returns a Float32Array containing matrices data
  13187. */
  13188. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13189. /**
  13190. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13191. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13192. * @returns a raw texture containing the data
  13193. */
  13194. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13195. /**
  13196. * Gets the current hosting scene
  13197. * @returns a scene object
  13198. */
  13199. getScene(): Scene;
  13200. /**
  13201. * Gets a string representing the current skeleton data
  13202. * @param fullDetails defines a boolean indicating if we want a verbose version
  13203. * @returns a string representing the current skeleton data
  13204. */
  13205. toString(fullDetails?: boolean): string;
  13206. /**
  13207. * Get bone's index searching by name
  13208. * @param name defines bone's name to search for
  13209. * @return the indice of the bone. Returns -1 if not found
  13210. */
  13211. getBoneIndexByName(name: string): number;
  13212. /**
  13213. * Creater a new animation range
  13214. * @param name defines the name of the range
  13215. * @param from defines the start key
  13216. * @param to defines the end key
  13217. */
  13218. createAnimationRange(name: string, from: number, to: number): void;
  13219. /**
  13220. * Delete a specific animation range
  13221. * @param name defines the name of the range
  13222. * @param deleteFrames defines if frames must be removed as well
  13223. */
  13224. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13225. /**
  13226. * Gets a specific animation range
  13227. * @param name defines the name of the range to look for
  13228. * @returns the requested animation range or null if not found
  13229. */
  13230. getAnimationRange(name: string): Nullable<AnimationRange>;
  13231. /**
  13232. * Gets the list of all animation ranges defined on this skeleton
  13233. * @returns an array
  13234. */
  13235. getAnimationRanges(): Nullable<AnimationRange>[];
  13236. /**
  13237. * Copy animation range from a source skeleton.
  13238. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13239. * @param source defines the source skeleton
  13240. * @param name defines the name of the range to copy
  13241. * @param rescaleAsRequired defines if rescaling must be applied if required
  13242. * @returns true if operation was successful
  13243. */
  13244. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13245. /**
  13246. * Forces the skeleton to go to rest pose
  13247. */
  13248. returnToRest(): void;
  13249. private _getHighestAnimationFrame;
  13250. /**
  13251. * Begin a specific animation range
  13252. * @param name defines the name of the range to start
  13253. * @param loop defines if looping must be turned on (false by default)
  13254. * @param speedRatio defines the speed ratio to apply (1 by default)
  13255. * @param onAnimationEnd defines a callback which will be called when animation will end
  13256. * @returns a new animatable
  13257. */
  13258. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13259. /** @hidden */
  13260. _markAsDirty(): void;
  13261. /** @hidden */
  13262. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13263. /** @hidden */
  13264. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13265. private _computeTransformMatrices;
  13266. /**
  13267. * Build all resources required to render a skeleton
  13268. */
  13269. prepare(): void;
  13270. /**
  13271. * Gets the list of animatables currently running for this skeleton
  13272. * @returns an array of animatables
  13273. */
  13274. getAnimatables(): IAnimatable[];
  13275. /**
  13276. * Clone the current skeleton
  13277. * @param name defines the name of the new skeleton
  13278. * @param id defines the id of the new skeleton
  13279. * @returns the new skeleton
  13280. */
  13281. clone(name: string, id: string): Skeleton;
  13282. /**
  13283. * Enable animation blending for this skeleton
  13284. * @param blendingSpeed defines the blending speed to apply
  13285. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13286. */
  13287. enableBlending(blendingSpeed?: number): void;
  13288. /**
  13289. * Releases all resources associated with the current skeleton
  13290. */
  13291. dispose(): void;
  13292. /**
  13293. * Serialize the skeleton in a JSON object
  13294. * @returns a JSON object
  13295. */
  13296. serialize(): any;
  13297. /**
  13298. * Creates a new skeleton from serialized data
  13299. * @param parsedSkeleton defines the serialized data
  13300. * @param scene defines the hosting scene
  13301. * @returns a new skeleton
  13302. */
  13303. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13304. /**
  13305. * Compute all node absolute transforms
  13306. * @param forceUpdate defines if computation must be done even if cache is up to date
  13307. */
  13308. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13309. /**
  13310. * Gets the root pose matrix
  13311. * @returns a matrix
  13312. */
  13313. getPoseMatrix(): Nullable<Matrix>;
  13314. /**
  13315. * Sorts bones per internal index
  13316. */
  13317. sortBones(): void;
  13318. private _sortBones;
  13319. }
  13320. }
  13321. declare module BABYLON {
  13322. /**
  13323. * Class used to store bone information
  13324. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13325. */
  13326. export class Bone extends Node {
  13327. /**
  13328. * defines the bone name
  13329. */
  13330. name: string;
  13331. private static _tmpVecs;
  13332. private static _tmpQuat;
  13333. private static _tmpMats;
  13334. /**
  13335. * Gets the list of child bones
  13336. */
  13337. children: Bone[];
  13338. /** Gets the animations associated with this bone */
  13339. animations: Animation[];
  13340. /**
  13341. * Gets or sets bone length
  13342. */
  13343. length: number;
  13344. /**
  13345. * @hidden Internal only
  13346. * Set this value to map this bone to a different index in the transform matrices
  13347. * Set this value to -1 to exclude the bone from the transform matrices
  13348. */
  13349. _index: Nullable<number>;
  13350. private _skeleton;
  13351. private _localMatrix;
  13352. private _restPose;
  13353. private _baseMatrix;
  13354. private _absoluteTransform;
  13355. private _invertedAbsoluteTransform;
  13356. private _parent;
  13357. private _scalingDeterminant;
  13358. private _worldTransform;
  13359. private _localScaling;
  13360. private _localRotation;
  13361. private _localPosition;
  13362. private _needToDecompose;
  13363. private _needToCompose;
  13364. /** @hidden */
  13365. _linkedTransformNode: Nullable<TransformNode>;
  13366. /** @hidden */
  13367. _waitingTransformNodeId: Nullable<string>;
  13368. /** @hidden */
  13369. /** @hidden */
  13370. _matrix: Matrix;
  13371. /**
  13372. * Create a new bone
  13373. * @param name defines the bone name
  13374. * @param skeleton defines the parent skeleton
  13375. * @param parentBone defines the parent (can be null if the bone is the root)
  13376. * @param localMatrix defines the local matrix
  13377. * @param restPose defines the rest pose matrix
  13378. * @param baseMatrix defines the base matrix
  13379. * @param index defines index of the bone in the hiearchy
  13380. */
  13381. constructor(
  13382. /**
  13383. * defines the bone name
  13384. */
  13385. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13386. /**
  13387. * Gets the current object class name.
  13388. * @return the class name
  13389. */
  13390. getClassName(): string;
  13391. /**
  13392. * Gets the parent skeleton
  13393. * @returns a skeleton
  13394. */
  13395. getSkeleton(): Skeleton;
  13396. /**
  13397. * Gets parent bone
  13398. * @returns a bone or null if the bone is the root of the bone hierarchy
  13399. */
  13400. getParent(): Nullable<Bone>;
  13401. /**
  13402. * Returns an array containing the root bones
  13403. * @returns an array containing the root bones
  13404. */
  13405. getChildren(): Array<Bone>;
  13406. /**
  13407. * Sets the parent bone
  13408. * @param parent defines the parent (can be null if the bone is the root)
  13409. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13410. */
  13411. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13412. /**
  13413. * Gets the local matrix
  13414. * @returns a matrix
  13415. */
  13416. getLocalMatrix(): Matrix;
  13417. /**
  13418. * Gets the base matrix (initial matrix which remains unchanged)
  13419. * @returns a matrix
  13420. */
  13421. getBaseMatrix(): Matrix;
  13422. /**
  13423. * Gets the rest pose matrix
  13424. * @returns a matrix
  13425. */
  13426. getRestPose(): Matrix;
  13427. /**
  13428. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13429. */
  13430. getWorldMatrix(): Matrix;
  13431. /**
  13432. * Sets the local matrix to rest pose matrix
  13433. */
  13434. returnToRest(): void;
  13435. /**
  13436. * Gets the inverse of the absolute transform matrix.
  13437. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13438. * @returns a matrix
  13439. */
  13440. getInvertedAbsoluteTransform(): Matrix;
  13441. /**
  13442. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13443. * @returns a matrix
  13444. */
  13445. getAbsoluteTransform(): Matrix;
  13446. /**
  13447. * Links with the given transform node.
  13448. * The local matrix of this bone is copied from the transform node every frame.
  13449. * @param transformNode defines the transform node to link to
  13450. */
  13451. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13452. /**
  13453. * Gets the node used to drive the bone's transformation
  13454. * @returns a transform node or null
  13455. */
  13456. getTransformNode(): Nullable<TransformNode>;
  13457. /** Gets or sets current position (in local space) */
  13458. position: Vector3;
  13459. /** Gets or sets current rotation (in local space) */
  13460. rotation: Vector3;
  13461. /** Gets or sets current rotation quaternion (in local space) */
  13462. rotationQuaternion: Quaternion;
  13463. /** Gets or sets current scaling (in local space) */
  13464. scaling: Vector3;
  13465. /**
  13466. * Gets the animation properties override
  13467. */
  13468. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13469. private _decompose;
  13470. private _compose;
  13471. /**
  13472. * Update the base and local matrices
  13473. * @param matrix defines the new base or local matrix
  13474. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13475. * @param updateLocalMatrix defines if the local matrix should be updated
  13476. */
  13477. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13478. /** @hidden */
  13479. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13480. /**
  13481. * Flag the bone as dirty (Forcing it to update everything)
  13482. */
  13483. markAsDirty(): void;
  13484. /** @hidden */
  13485. _markAsDirtyAndCompose(): void;
  13486. private _markAsDirtyAndDecompose;
  13487. /**
  13488. * Translate the bone in local or world space
  13489. * @param vec The amount to translate the bone
  13490. * @param space The space that the translation is in
  13491. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13492. */
  13493. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13494. /**
  13495. * Set the postion of the bone in local or world space
  13496. * @param position The position to set the bone
  13497. * @param space The space that the position is in
  13498. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13499. */
  13500. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13501. /**
  13502. * Set the absolute position of the bone (world space)
  13503. * @param position The position to set the bone
  13504. * @param mesh The mesh that this bone is attached to
  13505. */
  13506. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13507. /**
  13508. * Scale the bone on the x, y and z axes (in local space)
  13509. * @param x The amount to scale the bone on the x axis
  13510. * @param y The amount to scale the bone on the y axis
  13511. * @param z The amount to scale the bone on the z axis
  13512. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13513. */
  13514. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13515. /**
  13516. * Set the bone scaling in local space
  13517. * @param scale defines the scaling vector
  13518. */
  13519. setScale(scale: Vector3): void;
  13520. /**
  13521. * Gets the current scaling in local space
  13522. * @returns the current scaling vector
  13523. */
  13524. getScale(): Vector3;
  13525. /**
  13526. * Gets the current scaling in local space and stores it in a target vector
  13527. * @param result defines the target vector
  13528. */
  13529. getScaleToRef(result: Vector3): void;
  13530. /**
  13531. * Set the yaw, pitch, and roll of the bone in local or world space
  13532. * @param yaw The rotation of the bone on the y axis
  13533. * @param pitch The rotation of the bone on the x axis
  13534. * @param roll The rotation of the bone on the z axis
  13535. * @param space The space that the axes of rotation are in
  13536. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13537. */
  13538. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13539. /**
  13540. * Add a rotation to the bone on an axis in local or world space
  13541. * @param axis The axis to rotate the bone on
  13542. * @param amount The amount to rotate the bone
  13543. * @param space The space that the axis is in
  13544. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13545. */
  13546. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13547. /**
  13548. * Set the rotation of the bone to a particular axis angle in local or world space
  13549. * @param axis The axis to rotate the bone on
  13550. * @param angle The angle that the bone should be rotated to
  13551. * @param space The space that the axis is in
  13552. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13553. */
  13554. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13555. /**
  13556. * Set the euler rotation of the bone in local of world space
  13557. * @param rotation The euler rotation that the bone should be set to
  13558. * @param space The space that the rotation is in
  13559. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13560. */
  13561. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13562. /**
  13563. * Set the quaternion rotation of the bone in local of world space
  13564. * @param quat The quaternion rotation that the bone should be set to
  13565. * @param space The space that the rotation is in
  13566. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13567. */
  13568. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13569. /**
  13570. * Set the rotation matrix of the bone in local of world space
  13571. * @param rotMat The rotation matrix that the bone should be set to
  13572. * @param space The space that the rotation is in
  13573. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13574. */
  13575. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13576. private _rotateWithMatrix;
  13577. private _getNegativeRotationToRef;
  13578. /**
  13579. * Get the position of the bone in local or world space
  13580. * @param space The space that the returned position is in
  13581. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13582. * @returns The position of the bone
  13583. */
  13584. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13585. /**
  13586. * Copy the position of the bone to a vector3 in local or world space
  13587. * @param space The space that the returned position is in
  13588. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13589. * @param result The vector3 to copy the position to
  13590. */
  13591. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13592. /**
  13593. * Get the absolute position of the bone (world space)
  13594. * @param mesh The mesh that this bone is attached to
  13595. * @returns The absolute position of the bone
  13596. */
  13597. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13598. /**
  13599. * Copy the absolute position of the bone (world space) to the result param
  13600. * @param mesh The mesh that this bone is attached to
  13601. * @param result The vector3 to copy the absolute position to
  13602. */
  13603. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13604. /**
  13605. * Compute the absolute transforms of this bone and its children
  13606. */
  13607. computeAbsoluteTransforms(): void;
  13608. /**
  13609. * Get the world direction from an axis that is in the local space of the bone
  13610. * @param localAxis The local direction that is used to compute the world direction
  13611. * @param mesh The mesh that this bone is attached to
  13612. * @returns The world direction
  13613. */
  13614. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13615. /**
  13616. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13617. * @param localAxis The local direction that is used to compute the world direction
  13618. * @param mesh The mesh that this bone is attached to
  13619. * @param result The vector3 that the world direction will be copied to
  13620. */
  13621. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13622. /**
  13623. * Get the euler rotation of the bone in local or world space
  13624. * @param space The space that the rotation should be in
  13625. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13626. * @returns The euler rotation
  13627. */
  13628. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13629. /**
  13630. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13631. * @param space The space that the rotation should be in
  13632. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13633. * @param result The vector3 that the rotation should be copied to
  13634. */
  13635. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13636. /**
  13637. * Get the quaternion rotation of the bone in either local or world space
  13638. * @param space The space that the rotation should be in
  13639. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13640. * @returns The quaternion rotation
  13641. */
  13642. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13643. /**
  13644. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13645. * @param space The space that the rotation should be in
  13646. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13647. * @param result The quaternion that the rotation should be copied to
  13648. */
  13649. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13650. /**
  13651. * Get the rotation matrix of the bone in local or world space
  13652. * @param space The space that the rotation should be in
  13653. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13654. * @returns The rotation matrix
  13655. */
  13656. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13657. /**
  13658. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13659. * @param space The space that the rotation should be in
  13660. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13661. * @param result The quaternion that the rotation should be copied to
  13662. */
  13663. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13664. /**
  13665. * Get the world position of a point that is in the local space of the bone
  13666. * @param position The local position
  13667. * @param mesh The mesh that this bone is attached to
  13668. * @returns The world position
  13669. */
  13670. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13671. /**
  13672. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13673. * @param position The local position
  13674. * @param mesh The mesh that this bone is attached to
  13675. * @param result The vector3 that the world position should be copied to
  13676. */
  13677. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13678. /**
  13679. * Get the local position of a point that is in world space
  13680. * @param position The world position
  13681. * @param mesh The mesh that this bone is attached to
  13682. * @returns The local position
  13683. */
  13684. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13685. /**
  13686. * Get the local position of a point that is in world space and copy it to the result param
  13687. * @param position The world position
  13688. * @param mesh The mesh that this bone is attached to
  13689. * @param result The vector3 that the local position should be copied to
  13690. */
  13691. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13692. }
  13693. }
  13694. declare module BABYLON {
  13695. /**
  13696. * 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.
  13697. * @see https://doc.babylonjs.com/how_to/transformnode
  13698. */
  13699. export class TransformNode extends Node {
  13700. /**
  13701. * Object will not rotate to face the camera
  13702. */
  13703. static BILLBOARDMODE_NONE: number;
  13704. /**
  13705. * Object will rotate to face the camera but only on the x axis
  13706. */
  13707. static BILLBOARDMODE_X: number;
  13708. /**
  13709. * Object will rotate to face the camera but only on the y axis
  13710. */
  13711. static BILLBOARDMODE_Y: number;
  13712. /**
  13713. * Object will rotate to face the camera but only on the z axis
  13714. */
  13715. static BILLBOARDMODE_Z: number;
  13716. /**
  13717. * Object will rotate to face the camera
  13718. */
  13719. static BILLBOARDMODE_ALL: number;
  13720. /**
  13721. * Object will rotate to face the camera's position instead of orientation
  13722. */
  13723. static BILLBOARDMODE_USE_POSITION: number;
  13724. private _forward;
  13725. private _forwardInverted;
  13726. private _up;
  13727. private _right;
  13728. private _rightInverted;
  13729. private _position;
  13730. private _rotation;
  13731. private _rotationQuaternion;
  13732. protected _scaling: Vector3;
  13733. protected _isDirty: boolean;
  13734. private _transformToBoneReferal;
  13735. private _isAbsoluteSynced;
  13736. private _billboardMode;
  13737. /**
  13738. * Gets or sets the billboard mode. Default is 0.
  13739. *
  13740. * | Value | Type | Description |
  13741. * | --- | --- | --- |
  13742. * | 0 | BILLBOARDMODE_NONE | |
  13743. * | 1 | BILLBOARDMODE_X | |
  13744. * | 2 | BILLBOARDMODE_Y | |
  13745. * | 4 | BILLBOARDMODE_Z | |
  13746. * | 7 | BILLBOARDMODE_ALL | |
  13747. *
  13748. */
  13749. billboardMode: number;
  13750. private _preserveParentRotationForBillboard;
  13751. /**
  13752. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13753. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13754. */
  13755. preserveParentRotationForBillboard: boolean;
  13756. /**
  13757. * 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
  13758. */
  13759. scalingDeterminant: number;
  13760. private _infiniteDistance;
  13761. /**
  13762. * Gets or sets the distance of the object to max, often used by skybox
  13763. */
  13764. infiniteDistance: boolean;
  13765. /**
  13766. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13767. * By default the system will update normals to compensate
  13768. */
  13769. ignoreNonUniformScaling: boolean;
  13770. /**
  13771. * 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
  13772. */
  13773. reIntegrateRotationIntoRotationQuaternion: boolean;
  13774. /** @hidden */
  13775. _poseMatrix: Nullable<Matrix>;
  13776. /** @hidden */
  13777. _localMatrix: Matrix;
  13778. private _usePivotMatrix;
  13779. private _absolutePosition;
  13780. private _absoluteScaling;
  13781. private _absoluteRotationQuaternion;
  13782. private _pivotMatrix;
  13783. private _pivotMatrixInverse;
  13784. protected _postMultiplyPivotMatrix: boolean;
  13785. protected _isWorldMatrixFrozen: boolean;
  13786. /** @hidden */
  13787. _indexInSceneTransformNodesArray: number;
  13788. /**
  13789. * An event triggered after the world matrix is updated
  13790. */
  13791. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13792. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13793. /**
  13794. * Gets a string identifying the name of the class
  13795. * @returns "TransformNode" string
  13796. */
  13797. getClassName(): string;
  13798. /**
  13799. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13800. */
  13801. position: Vector3;
  13802. /**
  13803. * 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)).
  13804. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13805. */
  13806. rotation: Vector3;
  13807. /**
  13808. * 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)).
  13809. */
  13810. scaling: Vector3;
  13811. /**
  13812. * 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).
  13813. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13814. */
  13815. rotationQuaternion: Nullable<Quaternion>;
  13816. /**
  13817. * The forward direction of that transform in world space.
  13818. */
  13819. readonly forward: Vector3;
  13820. /**
  13821. * The up direction of that transform in world space.
  13822. */
  13823. readonly up: Vector3;
  13824. /**
  13825. * The right direction of that transform in world space.
  13826. */
  13827. readonly right: Vector3;
  13828. /**
  13829. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13830. * @param matrix the matrix to copy the pose from
  13831. * @returns this TransformNode.
  13832. */
  13833. updatePoseMatrix(matrix: Matrix): TransformNode;
  13834. /**
  13835. * Returns the mesh Pose matrix.
  13836. * @returns the pose matrix
  13837. */
  13838. getPoseMatrix(): Matrix;
  13839. /** @hidden */
  13840. _isSynchronized(): boolean;
  13841. /** @hidden */
  13842. _initCache(): void;
  13843. /**
  13844. * Flag the transform node as dirty (Forcing it to update everything)
  13845. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13846. * @returns this transform node
  13847. */
  13848. markAsDirty(property: string): TransformNode;
  13849. /**
  13850. * Returns the current mesh absolute position.
  13851. * Returns a Vector3.
  13852. */
  13853. readonly absolutePosition: Vector3;
  13854. /**
  13855. * Returns the current mesh absolute scaling.
  13856. * Returns a Vector3.
  13857. */
  13858. readonly absoluteScaling: Vector3;
  13859. /**
  13860. * Returns the current mesh absolute rotation.
  13861. * Returns a Quaternion.
  13862. */
  13863. readonly absoluteRotationQuaternion: Quaternion;
  13864. /**
  13865. * Sets a new matrix to apply before all other transformation
  13866. * @param matrix defines the transform matrix
  13867. * @returns the current TransformNode
  13868. */
  13869. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13870. /**
  13871. * Sets a new pivot matrix to the current node
  13872. * @param matrix defines the new pivot matrix to use
  13873. * @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
  13874. * @returns the current TransformNode
  13875. */
  13876. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13877. /**
  13878. * Returns the mesh pivot matrix.
  13879. * Default : Identity.
  13880. * @returns the matrix
  13881. */
  13882. getPivotMatrix(): Matrix;
  13883. /**
  13884. * Instantiate (when possible) or clone that node with its hierarchy
  13885. * @param newParent defines the new parent to use for the instance (or clone)
  13886. * @returns an instance (or a clone) of the current node with its hiearchy
  13887. */
  13888. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  13889. /**
  13890. * Prevents the World matrix to be computed any longer
  13891. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13892. * @returns the TransformNode.
  13893. */
  13894. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13895. /**
  13896. * Allows back the World matrix computation.
  13897. * @returns the TransformNode.
  13898. */
  13899. unfreezeWorldMatrix(): this;
  13900. /**
  13901. * True if the World matrix has been frozen.
  13902. */
  13903. readonly isWorldMatrixFrozen: boolean;
  13904. /**
  13905. * Retuns the mesh absolute position in the World.
  13906. * @returns a Vector3.
  13907. */
  13908. getAbsolutePosition(): Vector3;
  13909. /**
  13910. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13911. * @param absolutePosition the absolute position to set
  13912. * @returns the TransformNode.
  13913. */
  13914. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13915. /**
  13916. * Sets the mesh position in its local space.
  13917. * @param vector3 the position to set in localspace
  13918. * @returns the TransformNode.
  13919. */
  13920. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13921. /**
  13922. * Returns the mesh position in the local space from the current World matrix values.
  13923. * @returns a new Vector3.
  13924. */
  13925. getPositionExpressedInLocalSpace(): Vector3;
  13926. /**
  13927. * Translates the mesh along the passed Vector3 in its local space.
  13928. * @param vector3 the distance to translate in localspace
  13929. * @returns the TransformNode.
  13930. */
  13931. locallyTranslate(vector3: Vector3): TransformNode;
  13932. private static _lookAtVectorCache;
  13933. /**
  13934. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13935. * @param targetPoint the position (must be in same space as current mesh) to look at
  13936. * @param yawCor optional yaw (y-axis) correction in radians
  13937. * @param pitchCor optional pitch (x-axis) correction in radians
  13938. * @param rollCor optional roll (z-axis) correction in radians
  13939. * @param space the choosen space of the target
  13940. * @returns the TransformNode.
  13941. */
  13942. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13943. /**
  13944. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13945. * This Vector3 is expressed in the World space.
  13946. * @param localAxis axis to rotate
  13947. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13948. */
  13949. getDirection(localAxis: Vector3): Vector3;
  13950. /**
  13951. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13952. * localAxis is expressed in the mesh local space.
  13953. * result is computed in the Wordl space from the mesh World matrix.
  13954. * @param localAxis axis to rotate
  13955. * @param result the resulting transformnode
  13956. * @returns this TransformNode.
  13957. */
  13958. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13959. /**
  13960. * Sets this transform node rotation to the given local axis.
  13961. * @param localAxis the axis in local space
  13962. * @param yawCor optional yaw (y-axis) correction in radians
  13963. * @param pitchCor optional pitch (x-axis) correction in radians
  13964. * @param rollCor optional roll (z-axis) correction in radians
  13965. * @returns this TransformNode
  13966. */
  13967. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13968. /**
  13969. * Sets a new pivot point to the current node
  13970. * @param point defines the new pivot point to use
  13971. * @param space defines if the point is in world or local space (local by default)
  13972. * @returns the current TransformNode
  13973. */
  13974. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13975. /**
  13976. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13977. * @returns the pivot point
  13978. */
  13979. getPivotPoint(): Vector3;
  13980. /**
  13981. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13982. * @param result the vector3 to store the result
  13983. * @returns this TransformNode.
  13984. */
  13985. getPivotPointToRef(result: Vector3): TransformNode;
  13986. /**
  13987. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13988. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13989. */
  13990. getAbsolutePivotPoint(): Vector3;
  13991. /**
  13992. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13993. * @param result vector3 to store the result
  13994. * @returns this TransformNode.
  13995. */
  13996. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13997. /**
  13998. * Defines the passed node as the parent of the current node.
  13999. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14000. * @see https://doc.babylonjs.com/how_to/parenting
  14001. * @param node the node ot set as the parent
  14002. * @returns this TransformNode.
  14003. */
  14004. setParent(node: Nullable<Node>): TransformNode;
  14005. private _nonUniformScaling;
  14006. /**
  14007. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14008. */
  14009. readonly nonUniformScaling: boolean;
  14010. /** @hidden */
  14011. _updateNonUniformScalingState(value: boolean): boolean;
  14012. /**
  14013. * Attach the current TransformNode to another TransformNode associated with a bone
  14014. * @param bone Bone affecting the TransformNode
  14015. * @param affectedTransformNode TransformNode associated with the bone
  14016. * @returns this object
  14017. */
  14018. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14019. /**
  14020. * Detach the transform node if its associated with a bone
  14021. * @returns this object
  14022. */
  14023. detachFromBone(): TransformNode;
  14024. private static _rotationAxisCache;
  14025. /**
  14026. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14027. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14028. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14029. * The passed axis is also normalized.
  14030. * @param axis the axis to rotate around
  14031. * @param amount the amount to rotate in radians
  14032. * @param space Space to rotate in (Default: local)
  14033. * @returns the TransformNode.
  14034. */
  14035. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14036. /**
  14037. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14038. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14039. * The passed axis is also normalized. .
  14040. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14041. * @param point the point to rotate around
  14042. * @param axis the axis to rotate around
  14043. * @param amount the amount to rotate in radians
  14044. * @returns the TransformNode
  14045. */
  14046. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14047. /**
  14048. * Translates the mesh along the axis vector for the passed distance in the given space.
  14049. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14050. * @param axis the axis to translate in
  14051. * @param distance the distance to translate
  14052. * @param space Space to rotate in (Default: local)
  14053. * @returns the TransformNode.
  14054. */
  14055. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14056. /**
  14057. * Adds a rotation step to the mesh current rotation.
  14058. * x, y, z are Euler angles expressed in radians.
  14059. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14060. * This means this rotation is made in the mesh local space only.
  14061. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14062. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14063. * ```javascript
  14064. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14065. * ```
  14066. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14067. * 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.
  14068. * @param x Rotation to add
  14069. * @param y Rotation to add
  14070. * @param z Rotation to add
  14071. * @returns the TransformNode.
  14072. */
  14073. addRotation(x: number, y: number, z: number): TransformNode;
  14074. /**
  14075. * @hidden
  14076. */
  14077. protected _getEffectiveParent(): Nullable<Node>;
  14078. /**
  14079. * Computes the world matrix of the node
  14080. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14081. * @returns the world matrix
  14082. */
  14083. computeWorldMatrix(force?: boolean): Matrix;
  14084. protected _afterComputeWorldMatrix(): void;
  14085. /**
  14086. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14087. * @param func callback function to add
  14088. *
  14089. * @returns the TransformNode.
  14090. */
  14091. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14092. /**
  14093. * Removes a registered callback function.
  14094. * @param func callback function to remove
  14095. * @returns the TransformNode.
  14096. */
  14097. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14098. /**
  14099. * Gets the position of the current mesh in camera space
  14100. * @param camera defines the camera to use
  14101. * @returns a position
  14102. */
  14103. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14104. /**
  14105. * Returns the distance from the mesh to the active camera
  14106. * @param camera defines the camera to use
  14107. * @returns the distance
  14108. */
  14109. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14110. /**
  14111. * Clone the current transform node
  14112. * @param name Name of the new clone
  14113. * @param newParent New parent for the clone
  14114. * @param doNotCloneChildren Do not clone children hierarchy
  14115. * @returns the new transform node
  14116. */
  14117. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14118. /**
  14119. * Serializes the objects information.
  14120. * @param currentSerializationObject defines the object to serialize in
  14121. * @returns the serialized object
  14122. */
  14123. serialize(currentSerializationObject?: any): any;
  14124. /**
  14125. * Returns a new TransformNode object parsed from the source provided.
  14126. * @param parsedTransformNode is the source.
  14127. * @param scene the scne the object belongs to
  14128. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14129. * @returns a new TransformNode object parsed from the source provided.
  14130. */
  14131. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14132. /**
  14133. * Get all child-transformNodes of this node
  14134. * @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
  14135. * @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
  14136. * @returns an array of TransformNode
  14137. */
  14138. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14139. /**
  14140. * Releases resources associated with this transform node.
  14141. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14142. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14143. */
  14144. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14145. /**
  14146. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14147. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14148. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14149. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14150. * @returns the current mesh
  14151. */
  14152. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14153. private _syncAbsoluteScalingAndRotation;
  14154. }
  14155. }
  14156. declare module BABYLON {
  14157. /**
  14158. * Defines the types of pose enabled controllers that are supported
  14159. */
  14160. export enum PoseEnabledControllerType {
  14161. /**
  14162. * HTC Vive
  14163. */
  14164. VIVE = 0,
  14165. /**
  14166. * Oculus Rift
  14167. */
  14168. OCULUS = 1,
  14169. /**
  14170. * Windows mixed reality
  14171. */
  14172. WINDOWS = 2,
  14173. /**
  14174. * Samsung gear VR
  14175. */
  14176. GEAR_VR = 3,
  14177. /**
  14178. * Google Daydream
  14179. */
  14180. DAYDREAM = 4,
  14181. /**
  14182. * Generic
  14183. */
  14184. GENERIC = 5
  14185. }
  14186. /**
  14187. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14188. */
  14189. export interface MutableGamepadButton {
  14190. /**
  14191. * Value of the button/trigger
  14192. */
  14193. value: number;
  14194. /**
  14195. * If the button/trigger is currently touched
  14196. */
  14197. touched: boolean;
  14198. /**
  14199. * If the button/trigger is currently pressed
  14200. */
  14201. pressed: boolean;
  14202. }
  14203. /**
  14204. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14205. * @hidden
  14206. */
  14207. export interface ExtendedGamepadButton extends GamepadButton {
  14208. /**
  14209. * If the button/trigger is currently pressed
  14210. */
  14211. readonly pressed: boolean;
  14212. /**
  14213. * If the button/trigger is currently touched
  14214. */
  14215. readonly touched: boolean;
  14216. /**
  14217. * Value of the button/trigger
  14218. */
  14219. readonly value: number;
  14220. }
  14221. /** @hidden */
  14222. export interface _GamePadFactory {
  14223. /**
  14224. * Returns wether or not the current gamepad can be created for this type of controller.
  14225. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14226. * @returns true if it can be created, otherwise false
  14227. */
  14228. canCreate(gamepadInfo: any): boolean;
  14229. /**
  14230. * Creates a new instance of the Gamepad.
  14231. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14232. * @returns the new gamepad instance
  14233. */
  14234. create(gamepadInfo: any): Gamepad;
  14235. }
  14236. /**
  14237. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14238. */
  14239. export class PoseEnabledControllerHelper {
  14240. /** @hidden */
  14241. static _ControllerFactories: _GamePadFactory[];
  14242. /** @hidden */
  14243. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14244. /**
  14245. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14246. * @param vrGamepad the gamepad to initialized
  14247. * @returns a vr controller of the type the gamepad identified as
  14248. */
  14249. static InitiateController(vrGamepad: any): Gamepad;
  14250. }
  14251. /**
  14252. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14253. */
  14254. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14255. /**
  14256. * If the controller is used in a webXR session
  14257. */
  14258. isXR: boolean;
  14259. private _deviceRoomPosition;
  14260. private _deviceRoomRotationQuaternion;
  14261. /**
  14262. * The device position in babylon space
  14263. */
  14264. devicePosition: Vector3;
  14265. /**
  14266. * The device rotation in babylon space
  14267. */
  14268. deviceRotationQuaternion: Quaternion;
  14269. /**
  14270. * The scale factor of the device in babylon space
  14271. */
  14272. deviceScaleFactor: number;
  14273. /**
  14274. * (Likely devicePosition should be used instead) The device position in its room space
  14275. */
  14276. position: Vector3;
  14277. /**
  14278. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14279. */
  14280. rotationQuaternion: Quaternion;
  14281. /**
  14282. * The type of controller (Eg. Windows mixed reality)
  14283. */
  14284. controllerType: PoseEnabledControllerType;
  14285. protected _calculatedPosition: Vector3;
  14286. private _calculatedRotation;
  14287. /**
  14288. * The raw pose from the device
  14289. */
  14290. rawPose: DevicePose;
  14291. private _trackPosition;
  14292. private _maxRotationDistFromHeadset;
  14293. private _draggedRoomRotation;
  14294. /**
  14295. * @hidden
  14296. */
  14297. _disableTrackPosition(fixedPosition: Vector3): void;
  14298. /**
  14299. * Internal, the mesh attached to the controller
  14300. * @hidden
  14301. */
  14302. _mesh: Nullable<AbstractMesh>;
  14303. private _poseControlledCamera;
  14304. private _leftHandSystemQuaternion;
  14305. /**
  14306. * Internal, matrix used to convert room space to babylon space
  14307. * @hidden
  14308. */
  14309. _deviceToWorld: Matrix;
  14310. /**
  14311. * Node to be used when casting a ray from the controller
  14312. * @hidden
  14313. */
  14314. _pointingPoseNode: Nullable<TransformNode>;
  14315. /**
  14316. * Name of the child mesh that can be used to cast a ray from the controller
  14317. */
  14318. static readonly POINTING_POSE: string;
  14319. /**
  14320. * Creates a new PoseEnabledController from a gamepad
  14321. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14322. */
  14323. constructor(browserGamepad: any);
  14324. private _workingMatrix;
  14325. /**
  14326. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14327. */
  14328. update(): void;
  14329. /**
  14330. * Updates only the pose device and mesh without doing any button event checking
  14331. */
  14332. protected _updatePoseAndMesh(): void;
  14333. /**
  14334. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14335. * @param poseData raw pose fromthe device
  14336. */
  14337. updateFromDevice(poseData: DevicePose): void;
  14338. /**
  14339. * @hidden
  14340. */
  14341. _meshAttachedObservable: Observable<AbstractMesh>;
  14342. /**
  14343. * Attaches a mesh to the controller
  14344. * @param mesh the mesh to be attached
  14345. */
  14346. attachToMesh(mesh: AbstractMesh): void;
  14347. /**
  14348. * Attaches the controllers mesh to a camera
  14349. * @param camera the camera the mesh should be attached to
  14350. */
  14351. attachToPoseControlledCamera(camera: TargetCamera): void;
  14352. /**
  14353. * Disposes of the controller
  14354. */
  14355. dispose(): void;
  14356. /**
  14357. * The mesh that is attached to the controller
  14358. */
  14359. readonly mesh: Nullable<AbstractMesh>;
  14360. /**
  14361. * Gets the ray of the controller in the direction the controller is pointing
  14362. * @param length the length the resulting ray should be
  14363. * @returns a ray in the direction the controller is pointing
  14364. */
  14365. getForwardRay(length?: number): Ray;
  14366. }
  14367. }
  14368. declare module BABYLON {
  14369. /**
  14370. * Defines the WebVRController object that represents controllers tracked in 3D space
  14371. */
  14372. export abstract class WebVRController extends PoseEnabledController {
  14373. /**
  14374. * Internal, the default controller model for the controller
  14375. */
  14376. protected _defaultModel: AbstractMesh;
  14377. /**
  14378. * Fired when the trigger state has changed
  14379. */
  14380. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14381. /**
  14382. * Fired when the main button state has changed
  14383. */
  14384. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14385. /**
  14386. * Fired when the secondary button state has changed
  14387. */
  14388. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14389. /**
  14390. * Fired when the pad state has changed
  14391. */
  14392. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14393. /**
  14394. * Fired when controllers stick values have changed
  14395. */
  14396. onPadValuesChangedObservable: Observable<StickValues>;
  14397. /**
  14398. * Array of button availible on the controller
  14399. */
  14400. protected _buttons: Array<MutableGamepadButton>;
  14401. private _onButtonStateChange;
  14402. /**
  14403. * Fired when a controller button's state has changed
  14404. * @param callback the callback containing the button that was modified
  14405. */
  14406. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14407. /**
  14408. * X and Y axis corresponding to the controllers joystick
  14409. */
  14410. pad: StickValues;
  14411. /**
  14412. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14413. */
  14414. hand: string;
  14415. /**
  14416. * The default controller model for the controller
  14417. */
  14418. readonly defaultModel: AbstractMesh;
  14419. /**
  14420. * Creates a new WebVRController from a gamepad
  14421. * @param vrGamepad the gamepad that the WebVRController should be created from
  14422. */
  14423. constructor(vrGamepad: any);
  14424. /**
  14425. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14426. */
  14427. update(): void;
  14428. /**
  14429. * Function to be called when a button is modified
  14430. */
  14431. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14432. /**
  14433. * Loads a mesh and attaches it to the controller
  14434. * @param scene the scene the mesh should be added to
  14435. * @param meshLoaded callback for when the mesh has been loaded
  14436. */
  14437. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14438. private _setButtonValue;
  14439. private _changes;
  14440. private _checkChanges;
  14441. /**
  14442. * Disposes of th webVRCOntroller
  14443. */
  14444. dispose(): void;
  14445. }
  14446. }
  14447. declare module BABYLON {
  14448. /**
  14449. * The HemisphericLight simulates the ambient environment light,
  14450. * so the passed direction is the light reflection direction, not the incoming direction.
  14451. */
  14452. export class HemisphericLight extends Light {
  14453. /**
  14454. * The groundColor is the light in the opposite direction to the one specified during creation.
  14455. * 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.
  14456. */
  14457. groundColor: Color3;
  14458. /**
  14459. * The light reflection direction, not the incoming direction.
  14460. */
  14461. direction: Vector3;
  14462. /**
  14463. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14464. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14465. * The HemisphericLight can't cast shadows.
  14466. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14467. * @param name The friendly name of the light
  14468. * @param direction The direction of the light reflection
  14469. * @param scene The scene the light belongs to
  14470. */
  14471. constructor(name: string, direction: Vector3, scene: Scene);
  14472. protected _buildUniformLayout(): void;
  14473. /**
  14474. * Returns the string "HemisphericLight".
  14475. * @return The class name
  14476. */
  14477. getClassName(): string;
  14478. /**
  14479. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14480. * Returns the updated direction.
  14481. * @param target The target the direction should point to
  14482. * @return The computed direction
  14483. */
  14484. setDirectionToTarget(target: Vector3): Vector3;
  14485. /**
  14486. * Returns the shadow generator associated to the light.
  14487. * @returns Always null for hemispheric lights because it does not support shadows.
  14488. */
  14489. getShadowGenerator(): Nullable<IShadowGenerator>;
  14490. /**
  14491. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14492. * @param effect The effect to update
  14493. * @param lightIndex The index of the light in the effect to update
  14494. * @returns The hemispheric light
  14495. */
  14496. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14497. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14498. /**
  14499. * Computes the world matrix of the node
  14500. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14501. * @param useWasUpdatedFlag defines a reserved property
  14502. * @returns the world matrix
  14503. */
  14504. computeWorldMatrix(): Matrix;
  14505. /**
  14506. * Returns the integer 3.
  14507. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14508. */
  14509. getTypeID(): number;
  14510. /**
  14511. * Prepares the list of defines specific to the light type.
  14512. * @param defines the list of defines
  14513. * @param lightIndex defines the index of the light for the effect
  14514. */
  14515. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14516. }
  14517. }
  14518. declare module BABYLON {
  14519. /** @hidden */
  14520. export var vrMultiviewToSingleviewPixelShader: {
  14521. name: string;
  14522. shader: string;
  14523. };
  14524. }
  14525. declare module BABYLON {
  14526. /**
  14527. * Renders to multiple views with a single draw call
  14528. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14529. */
  14530. export class MultiviewRenderTarget extends RenderTargetTexture {
  14531. /**
  14532. * Creates a multiview render target
  14533. * @param scene scene used with the render target
  14534. * @param size the size of the render target (used for each view)
  14535. */
  14536. constructor(scene: Scene, size?: number | {
  14537. width: number;
  14538. height: number;
  14539. } | {
  14540. ratio: number;
  14541. });
  14542. /**
  14543. * @hidden
  14544. * @param faceIndex the face index, if its a cube texture
  14545. */
  14546. _bindFrameBuffer(faceIndex?: number): void;
  14547. /**
  14548. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14549. * @returns the view count
  14550. */
  14551. getViewCount(): number;
  14552. }
  14553. }
  14554. declare module BABYLON {
  14555. /**
  14556. * Reprasents a camera frustum
  14557. */
  14558. export class Frustum {
  14559. /**
  14560. * Gets the planes representing the frustum
  14561. * @param transform matrix to be applied to the returned planes
  14562. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14563. */
  14564. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14565. /**
  14566. * Gets the near 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 GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14571. /**
  14572. * Gets the far 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 GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14577. /**
  14578. * Gets the left 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 GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14583. /**
  14584. * Gets the right frustum plane transformed by the transform matrix
  14585. * @param transform transformation matrix to be applied to the resulting frustum plane
  14586. * @param frustumPlane the resuling frustum plane
  14587. */
  14588. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14589. /**
  14590. * Gets the top frustum plane transformed by the transform matrix
  14591. * @param transform transformation matrix to be applied to the resulting frustum plane
  14592. * @param frustumPlane the resuling frustum plane
  14593. */
  14594. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14595. /**
  14596. * Gets the bottom frustum plane transformed by the transform matrix
  14597. * @param transform transformation matrix to be applied to the resulting frustum plane
  14598. * @param frustumPlane the resuling frustum plane
  14599. */
  14600. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14601. /**
  14602. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14603. * @param transform transformation matrix to be applied to the resulting frustum planes
  14604. * @param frustumPlanes the resuling frustum planes
  14605. */
  14606. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14607. }
  14608. }
  14609. declare module BABYLON {
  14610. interface Engine {
  14611. /**
  14612. * Creates a new multiview render target
  14613. * @param width defines the width of the texture
  14614. * @param height defines the height of the texture
  14615. * @returns the created multiview texture
  14616. */
  14617. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14618. /**
  14619. * Binds a multiview framebuffer to be drawn to
  14620. * @param multiviewTexture texture to bind
  14621. */
  14622. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14623. }
  14624. interface Camera {
  14625. /**
  14626. * @hidden
  14627. * 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)
  14628. */
  14629. _useMultiviewToSingleView: boolean;
  14630. /**
  14631. * @hidden
  14632. * 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)
  14633. */
  14634. _multiviewTexture: Nullable<RenderTargetTexture>;
  14635. /**
  14636. * @hidden
  14637. * ensures the multiview texture of the camera exists and has the specified width/height
  14638. * @param width height to set on the multiview texture
  14639. * @param height width to set on the multiview texture
  14640. */
  14641. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14642. }
  14643. interface Scene {
  14644. /** @hidden */
  14645. _transformMatrixR: Matrix;
  14646. /** @hidden */
  14647. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14648. /** @hidden */
  14649. _createMultiviewUbo(): void;
  14650. /** @hidden */
  14651. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14652. /** @hidden */
  14653. _renderMultiviewToSingleView(camera: Camera): void;
  14654. }
  14655. }
  14656. declare module BABYLON {
  14657. /**
  14658. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14659. * This will not be used for webXR as it supports displaying texture arrays directly
  14660. */
  14661. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14662. /**
  14663. * Initializes a VRMultiviewToSingleview
  14664. * @param name name of the post process
  14665. * @param camera camera to be applied to
  14666. * @param scaleFactor scaling factor to the size of the output texture
  14667. */
  14668. constructor(name: string, camera: Camera, scaleFactor: number);
  14669. }
  14670. }
  14671. declare module BABYLON {
  14672. interface Engine {
  14673. /** @hidden */
  14674. _vrDisplay: any;
  14675. /** @hidden */
  14676. _vrSupported: boolean;
  14677. /** @hidden */
  14678. _oldSize: Size;
  14679. /** @hidden */
  14680. _oldHardwareScaleFactor: number;
  14681. /** @hidden */
  14682. _vrExclusivePointerMode: boolean;
  14683. /** @hidden */
  14684. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14685. /** @hidden */
  14686. _onVRDisplayPointerRestricted: () => void;
  14687. /** @hidden */
  14688. _onVRDisplayPointerUnrestricted: () => void;
  14689. /** @hidden */
  14690. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14691. /** @hidden */
  14692. _onVrDisplayDisconnect: Nullable<() => void>;
  14693. /** @hidden */
  14694. _onVrDisplayPresentChange: Nullable<() => void>;
  14695. /**
  14696. * Observable signaled when VR display mode changes
  14697. */
  14698. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14699. /**
  14700. * Observable signaled when VR request present is complete
  14701. */
  14702. onVRRequestPresentComplete: Observable<boolean>;
  14703. /**
  14704. * Observable signaled when VR request present starts
  14705. */
  14706. onVRRequestPresentStart: Observable<Engine>;
  14707. /**
  14708. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14709. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14710. */
  14711. isInVRExclusivePointerMode: boolean;
  14712. /**
  14713. * Gets a boolean indicating if a webVR device was detected
  14714. * @returns true if a webVR device was detected
  14715. */
  14716. isVRDevicePresent(): boolean;
  14717. /**
  14718. * Gets the current webVR device
  14719. * @returns the current webVR device (or null)
  14720. */
  14721. getVRDevice(): any;
  14722. /**
  14723. * Initializes a webVR display and starts listening to display change events
  14724. * The onVRDisplayChangedObservable will be notified upon these changes
  14725. * @returns A promise containing a VRDisplay and if vr is supported
  14726. */
  14727. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14728. /** @hidden */
  14729. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14730. /**
  14731. * Call this function to switch to webVR mode
  14732. * Will do nothing if webVR is not supported or if there is no webVR device
  14733. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14734. */
  14735. enableVR(): void;
  14736. /** @hidden */
  14737. _onVRFullScreenTriggered(): void;
  14738. }
  14739. }
  14740. declare module BABYLON {
  14741. /**
  14742. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14743. * IMPORTANT!! The data is right-hand data.
  14744. * @export
  14745. * @interface DevicePose
  14746. */
  14747. export interface DevicePose {
  14748. /**
  14749. * The position of the device, values in array are [x,y,z].
  14750. */
  14751. readonly position: Nullable<Float32Array>;
  14752. /**
  14753. * The linearVelocity of the device, values in array are [x,y,z].
  14754. */
  14755. readonly linearVelocity: Nullable<Float32Array>;
  14756. /**
  14757. * The linearAcceleration of the device, values in array are [x,y,z].
  14758. */
  14759. readonly linearAcceleration: Nullable<Float32Array>;
  14760. /**
  14761. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14762. */
  14763. readonly orientation: Nullable<Float32Array>;
  14764. /**
  14765. * The angularVelocity of the device, values in array are [x,y,z].
  14766. */
  14767. readonly angularVelocity: Nullable<Float32Array>;
  14768. /**
  14769. * The angularAcceleration of the device, values in array are [x,y,z].
  14770. */
  14771. readonly angularAcceleration: Nullable<Float32Array>;
  14772. }
  14773. /**
  14774. * Interface representing a pose controlled object in Babylon.
  14775. * A pose controlled object has both regular pose values as well as pose values
  14776. * from an external device such as a VR head mounted display
  14777. */
  14778. export interface PoseControlled {
  14779. /**
  14780. * The position of the object in babylon space.
  14781. */
  14782. position: Vector3;
  14783. /**
  14784. * The rotation quaternion of the object in babylon space.
  14785. */
  14786. rotationQuaternion: Quaternion;
  14787. /**
  14788. * The position of the device in babylon space.
  14789. */
  14790. devicePosition?: Vector3;
  14791. /**
  14792. * The rotation quaternion of the device in babylon space.
  14793. */
  14794. deviceRotationQuaternion: Quaternion;
  14795. /**
  14796. * The raw pose coming from the device.
  14797. */
  14798. rawPose: Nullable<DevicePose>;
  14799. /**
  14800. * The scale of the device to be used when translating from device space to babylon space.
  14801. */
  14802. deviceScaleFactor: number;
  14803. /**
  14804. * Updates the poseControlled values based on the input device pose.
  14805. * @param poseData the pose data to update the object with
  14806. */
  14807. updateFromDevice(poseData: DevicePose): void;
  14808. }
  14809. /**
  14810. * Set of options to customize the webVRCamera
  14811. */
  14812. export interface WebVROptions {
  14813. /**
  14814. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14815. */
  14816. trackPosition?: boolean;
  14817. /**
  14818. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14819. */
  14820. positionScale?: number;
  14821. /**
  14822. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  14823. */
  14824. displayName?: string;
  14825. /**
  14826. * Should the native controller meshes be initialized. (default: true)
  14827. */
  14828. controllerMeshes?: boolean;
  14829. /**
  14830. * Creating a default HemiLight only on controllers. (default: true)
  14831. */
  14832. defaultLightingOnControllers?: boolean;
  14833. /**
  14834. * If you don't want to use the default VR button of the helper. (default: false)
  14835. */
  14836. useCustomVRButton?: boolean;
  14837. /**
  14838. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  14839. */
  14840. customVRButton?: HTMLButtonElement;
  14841. /**
  14842. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  14843. */
  14844. rayLength?: number;
  14845. /**
  14846. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  14847. */
  14848. defaultHeight?: number;
  14849. /**
  14850. * If multiview should be used if availible (default: false)
  14851. */
  14852. useMultiview?: boolean;
  14853. }
  14854. /**
  14855. * This represents a WebVR camera.
  14856. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  14857. * @example http://doc.babylonjs.com/how_to/webvr_camera
  14858. */
  14859. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  14860. private webVROptions;
  14861. /**
  14862. * @hidden
  14863. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  14864. */
  14865. _vrDevice: any;
  14866. /**
  14867. * The rawPose of the vrDevice.
  14868. */
  14869. rawPose: Nullable<DevicePose>;
  14870. private _onVREnabled;
  14871. private _specsVersion;
  14872. private _attached;
  14873. private _frameData;
  14874. protected _descendants: Array<Node>;
  14875. private _deviceRoomPosition;
  14876. /** @hidden */
  14877. _deviceRoomRotationQuaternion: Quaternion;
  14878. private _standingMatrix;
  14879. /**
  14880. * Represents device position in babylon space.
  14881. */
  14882. devicePosition: Vector3;
  14883. /**
  14884. * Represents device rotation in babylon space.
  14885. */
  14886. deviceRotationQuaternion: Quaternion;
  14887. /**
  14888. * The scale of the device to be used when translating from device space to babylon space.
  14889. */
  14890. deviceScaleFactor: number;
  14891. private _deviceToWorld;
  14892. private _worldToDevice;
  14893. /**
  14894. * References to the webVR controllers for the vrDevice.
  14895. */
  14896. controllers: Array<WebVRController>;
  14897. /**
  14898. * Emits an event when a controller is attached.
  14899. */
  14900. onControllersAttachedObservable: Observable<WebVRController[]>;
  14901. /**
  14902. * Emits an event when a controller's mesh has been loaded;
  14903. */
  14904. onControllerMeshLoadedObservable: Observable<WebVRController>;
  14905. /**
  14906. * Emits an event when the HMD's pose has been updated.
  14907. */
  14908. onPoseUpdatedFromDeviceObservable: Observable<any>;
  14909. private _poseSet;
  14910. /**
  14911. * If the rig cameras be used as parent instead of this camera.
  14912. */
  14913. rigParenting: boolean;
  14914. private _lightOnControllers;
  14915. private _defaultHeight?;
  14916. /**
  14917. * Instantiates a WebVRFreeCamera.
  14918. * @param name The name of the WebVRFreeCamera
  14919. * @param position The starting anchor position for the camera
  14920. * @param scene The scene the camera belongs to
  14921. * @param webVROptions a set of customizable options for the webVRCamera
  14922. */
  14923. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  14924. /**
  14925. * Gets the device distance from the ground in meters.
  14926. * @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.
  14927. */
  14928. deviceDistanceToRoomGround(): number;
  14929. /**
  14930. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14931. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  14932. */
  14933. useStandingMatrix(callback?: (bool: boolean) => void): void;
  14934. /**
  14935. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14936. * @returns A promise with a boolean set to if the standing matrix is supported.
  14937. */
  14938. useStandingMatrixAsync(): Promise<boolean>;
  14939. /**
  14940. * Disposes the camera
  14941. */
  14942. dispose(): void;
  14943. /**
  14944. * Gets a vrController by name.
  14945. * @param name The name of the controller to retreive
  14946. * @returns the controller matching the name specified or null if not found
  14947. */
  14948. getControllerByName(name: string): Nullable<WebVRController>;
  14949. private _leftController;
  14950. /**
  14951. * The controller corresponding to the users left hand.
  14952. */
  14953. readonly leftController: Nullable<WebVRController>;
  14954. private _rightController;
  14955. /**
  14956. * The controller corresponding to the users right hand.
  14957. */
  14958. readonly rightController: Nullable<WebVRController>;
  14959. /**
  14960. * Casts a ray forward from the vrCamera's gaze.
  14961. * @param length Length of the ray (default: 100)
  14962. * @returns the ray corresponding to the gaze
  14963. */
  14964. getForwardRay(length?: number): Ray;
  14965. /**
  14966. * @hidden
  14967. * Updates the camera based on device's frame data
  14968. */
  14969. _checkInputs(): void;
  14970. /**
  14971. * Updates the poseControlled values based on the input device pose.
  14972. * @param poseData Pose coming from the device
  14973. */
  14974. updateFromDevice(poseData: DevicePose): void;
  14975. private _htmlElementAttached;
  14976. private _detachIfAttached;
  14977. /**
  14978. * WebVR's attach control will start broadcasting frames to the device.
  14979. * Note that in certain browsers (chrome for example) this function must be called
  14980. * within a user-interaction callback. Example:
  14981. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  14982. *
  14983. * @param element html element to attach the vrDevice to
  14984. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  14985. */
  14986. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  14987. /**
  14988. * Detaches the camera from the html element and disables VR
  14989. *
  14990. * @param element html element to detach from
  14991. */
  14992. detachControl(element: HTMLElement): void;
  14993. /**
  14994. * @returns the name of this class
  14995. */
  14996. getClassName(): string;
  14997. /**
  14998. * Calls resetPose on the vrDisplay
  14999. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15000. */
  15001. resetToCurrentRotation(): void;
  15002. /**
  15003. * @hidden
  15004. * Updates the rig cameras (left and right eye)
  15005. */
  15006. _updateRigCameras(): void;
  15007. private _workingVector;
  15008. private _oneVector;
  15009. private _workingMatrix;
  15010. private updateCacheCalled;
  15011. private _correctPositionIfNotTrackPosition;
  15012. /**
  15013. * @hidden
  15014. * Updates the cached values of the camera
  15015. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15016. */
  15017. _updateCache(ignoreParentClass?: boolean): void;
  15018. /**
  15019. * @hidden
  15020. * Get current device position in babylon world
  15021. */
  15022. _computeDevicePosition(): void;
  15023. /**
  15024. * Updates the current device position and rotation in the babylon world
  15025. */
  15026. update(): void;
  15027. /**
  15028. * @hidden
  15029. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15030. * @returns an identity matrix
  15031. */
  15032. _getViewMatrix(): Matrix;
  15033. private _tmpMatrix;
  15034. /**
  15035. * This function is called by the two RIG cameras.
  15036. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15037. * @hidden
  15038. */
  15039. _getWebVRViewMatrix(): Matrix;
  15040. /** @hidden */
  15041. _getWebVRProjectionMatrix(): Matrix;
  15042. private _onGamepadConnectedObserver;
  15043. private _onGamepadDisconnectedObserver;
  15044. private _updateCacheWhenTrackingDisabledObserver;
  15045. /**
  15046. * Initializes the controllers and their meshes
  15047. */
  15048. initControllers(): void;
  15049. }
  15050. }
  15051. declare module BABYLON {
  15052. /**
  15053. * Size options for a post process
  15054. */
  15055. export type PostProcessOptions = {
  15056. width: number;
  15057. height: number;
  15058. };
  15059. /**
  15060. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15061. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15062. */
  15063. export class PostProcess {
  15064. /** Name of the PostProcess. */
  15065. name: string;
  15066. /**
  15067. * Gets or sets the unique id of the post process
  15068. */
  15069. uniqueId: number;
  15070. /**
  15071. * Width of the texture to apply the post process on
  15072. */
  15073. width: number;
  15074. /**
  15075. * Height of the texture to apply the post process on
  15076. */
  15077. height: number;
  15078. /**
  15079. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15080. * @hidden
  15081. */
  15082. _outputTexture: Nullable<InternalTexture>;
  15083. /**
  15084. * Sampling mode used by the shader
  15085. * See https://doc.babylonjs.com/classes/3.1/texture
  15086. */
  15087. renderTargetSamplingMode: number;
  15088. /**
  15089. * Clear color to use when screen clearing
  15090. */
  15091. clearColor: Color4;
  15092. /**
  15093. * If the buffer needs to be cleared before applying the post process. (default: true)
  15094. * Should be set to false if shader will overwrite all previous pixels.
  15095. */
  15096. autoClear: boolean;
  15097. /**
  15098. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15099. */
  15100. alphaMode: number;
  15101. /**
  15102. * Sets the setAlphaBlendConstants of the babylon engine
  15103. */
  15104. alphaConstants: Color4;
  15105. /**
  15106. * Animations to be used for the post processing
  15107. */
  15108. animations: Animation[];
  15109. /**
  15110. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15111. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15112. */
  15113. enablePixelPerfectMode: boolean;
  15114. /**
  15115. * Force the postprocess to be applied without taking in account viewport
  15116. */
  15117. forceFullscreenViewport: boolean;
  15118. /**
  15119. * List of inspectable custom properties (used by the Inspector)
  15120. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15121. */
  15122. inspectableCustomProperties: IInspectable[];
  15123. /**
  15124. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15125. *
  15126. * | Value | Type | Description |
  15127. * | ----- | ----------------------------------- | ----------- |
  15128. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15129. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15130. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15131. *
  15132. */
  15133. scaleMode: number;
  15134. /**
  15135. * Force textures to be a power of two (default: false)
  15136. */
  15137. alwaysForcePOT: boolean;
  15138. private _samples;
  15139. /**
  15140. * Number of sample textures (default: 1)
  15141. */
  15142. samples: number;
  15143. /**
  15144. * Modify the scale of the post process to be the same as the viewport (default: false)
  15145. */
  15146. adaptScaleToCurrentViewport: boolean;
  15147. private _camera;
  15148. private _scene;
  15149. private _engine;
  15150. private _options;
  15151. private _reusable;
  15152. private _textureType;
  15153. /**
  15154. * Smart array of input and output textures for the post process.
  15155. * @hidden
  15156. */
  15157. _textures: SmartArray<InternalTexture>;
  15158. /**
  15159. * The index in _textures that corresponds to the output texture.
  15160. * @hidden
  15161. */
  15162. _currentRenderTextureInd: number;
  15163. private _effect;
  15164. private _samplers;
  15165. private _fragmentUrl;
  15166. private _vertexUrl;
  15167. private _parameters;
  15168. private _scaleRatio;
  15169. protected _indexParameters: any;
  15170. private _shareOutputWithPostProcess;
  15171. private _texelSize;
  15172. private _forcedOutputTexture;
  15173. /**
  15174. * Returns the fragment url or shader name used in the post process.
  15175. * @returns the fragment url or name in the shader store.
  15176. */
  15177. getEffectName(): string;
  15178. /**
  15179. * An event triggered when the postprocess is activated.
  15180. */
  15181. onActivateObservable: Observable<Camera>;
  15182. private _onActivateObserver;
  15183. /**
  15184. * A function that is added to the onActivateObservable
  15185. */
  15186. onActivate: Nullable<(camera: Camera) => void>;
  15187. /**
  15188. * An event triggered when the postprocess changes its size.
  15189. */
  15190. onSizeChangedObservable: Observable<PostProcess>;
  15191. private _onSizeChangedObserver;
  15192. /**
  15193. * A function that is added to the onSizeChangedObservable
  15194. */
  15195. onSizeChanged: (postProcess: PostProcess) => void;
  15196. /**
  15197. * An event triggered when the postprocess applies its effect.
  15198. */
  15199. onApplyObservable: Observable<Effect>;
  15200. private _onApplyObserver;
  15201. /**
  15202. * A function that is added to the onApplyObservable
  15203. */
  15204. onApply: (effect: Effect) => void;
  15205. /**
  15206. * An event triggered before rendering the postprocess
  15207. */
  15208. onBeforeRenderObservable: Observable<Effect>;
  15209. private _onBeforeRenderObserver;
  15210. /**
  15211. * A function that is added to the onBeforeRenderObservable
  15212. */
  15213. onBeforeRender: (effect: Effect) => void;
  15214. /**
  15215. * An event triggered after rendering the postprocess
  15216. */
  15217. onAfterRenderObservable: Observable<Effect>;
  15218. private _onAfterRenderObserver;
  15219. /**
  15220. * A function that is added to the onAfterRenderObservable
  15221. */
  15222. onAfterRender: (efect: Effect) => void;
  15223. /**
  15224. * 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
  15225. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15226. */
  15227. inputTexture: InternalTexture;
  15228. /**
  15229. * Gets the camera which post process is applied to.
  15230. * @returns The camera the post process is applied to.
  15231. */
  15232. getCamera(): Camera;
  15233. /**
  15234. * Gets the texel size of the postprocess.
  15235. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15236. */
  15237. readonly texelSize: Vector2;
  15238. /**
  15239. * Creates a new instance PostProcess
  15240. * @param name The name of the PostProcess.
  15241. * @param fragmentUrl The url of the fragment shader to be used.
  15242. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15243. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15244. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15245. * @param camera The camera to apply the render pass to.
  15246. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15247. * @param engine The engine which the post process will be applied. (default: current engine)
  15248. * @param reusable If the post process can be reused on the same frame. (default: false)
  15249. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15250. * @param textureType Type of textures used when performing the post process. (default: 0)
  15251. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15252. * @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
  15253. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15254. */
  15255. constructor(
  15256. /** Name of the PostProcess. */
  15257. 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);
  15258. /**
  15259. * Gets a string idenfifying the name of the class
  15260. * @returns "PostProcess" string
  15261. */
  15262. getClassName(): string;
  15263. /**
  15264. * Gets the engine which this post process belongs to.
  15265. * @returns The engine the post process was enabled with.
  15266. */
  15267. getEngine(): Engine;
  15268. /**
  15269. * The effect that is created when initializing the post process.
  15270. * @returns The created effect corresponding the the postprocess.
  15271. */
  15272. getEffect(): Effect;
  15273. /**
  15274. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15275. * @param postProcess The post process to share the output with.
  15276. * @returns This post process.
  15277. */
  15278. shareOutputWith(postProcess: PostProcess): PostProcess;
  15279. /**
  15280. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15281. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15282. */
  15283. useOwnOutput(): void;
  15284. /**
  15285. * Updates the effect with the current post process compile time values and recompiles the shader.
  15286. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15287. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15288. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15289. * @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
  15290. * @param onCompiled Called when the shader has been compiled.
  15291. * @param onError Called if there is an error when compiling a shader.
  15292. */
  15293. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15294. /**
  15295. * The post process is reusable if it can be used multiple times within one frame.
  15296. * @returns If the post process is reusable
  15297. */
  15298. isReusable(): boolean;
  15299. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15300. markTextureDirty(): void;
  15301. /**
  15302. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15303. * 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.
  15304. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15305. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15306. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15307. * @returns The target texture that was bound to be written to.
  15308. */
  15309. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15310. /**
  15311. * If the post process is supported.
  15312. */
  15313. readonly isSupported: boolean;
  15314. /**
  15315. * The aspect ratio of the output texture.
  15316. */
  15317. readonly aspectRatio: number;
  15318. /**
  15319. * Get a value indicating if the post-process is ready to be used
  15320. * @returns true if the post-process is ready (shader is compiled)
  15321. */
  15322. isReady(): boolean;
  15323. /**
  15324. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15325. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15326. */
  15327. apply(): Nullable<Effect>;
  15328. private _disposeTextures;
  15329. /**
  15330. * Disposes the post process.
  15331. * @param camera The camera to dispose the post process on.
  15332. */
  15333. dispose(camera?: Camera): void;
  15334. }
  15335. }
  15336. declare module BABYLON {
  15337. /** @hidden */
  15338. export var kernelBlurVaryingDeclaration: {
  15339. name: string;
  15340. shader: string;
  15341. };
  15342. }
  15343. declare module BABYLON {
  15344. /** @hidden */
  15345. export var kernelBlurFragment: {
  15346. name: string;
  15347. shader: string;
  15348. };
  15349. }
  15350. declare module BABYLON {
  15351. /** @hidden */
  15352. export var kernelBlurFragment2: {
  15353. name: string;
  15354. shader: string;
  15355. };
  15356. }
  15357. declare module BABYLON {
  15358. /** @hidden */
  15359. export var kernelBlurPixelShader: {
  15360. name: string;
  15361. shader: string;
  15362. };
  15363. }
  15364. declare module BABYLON {
  15365. /** @hidden */
  15366. export var kernelBlurVertex: {
  15367. name: string;
  15368. shader: string;
  15369. };
  15370. }
  15371. declare module BABYLON {
  15372. /** @hidden */
  15373. export var kernelBlurVertexShader: {
  15374. name: string;
  15375. shader: string;
  15376. };
  15377. }
  15378. declare module BABYLON {
  15379. /**
  15380. * The Blur Post Process which blurs an image based on a kernel and direction.
  15381. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15382. */
  15383. export class BlurPostProcess extends PostProcess {
  15384. /** The direction in which to blur the image. */
  15385. direction: Vector2;
  15386. private blockCompilation;
  15387. protected _kernel: number;
  15388. protected _idealKernel: number;
  15389. protected _packedFloat: boolean;
  15390. private _staticDefines;
  15391. /**
  15392. * Sets the length in pixels of the blur sample region
  15393. */
  15394. /**
  15395. * Gets the length in pixels of the blur sample region
  15396. */
  15397. kernel: number;
  15398. /**
  15399. * Sets wether or not the blur needs to unpack/repack floats
  15400. */
  15401. /**
  15402. * Gets wether or not the blur is unpacking/repacking floats
  15403. */
  15404. packedFloat: boolean;
  15405. /**
  15406. * Creates a new instance BlurPostProcess
  15407. * @param name The name of the effect.
  15408. * @param direction The direction in which to blur the image.
  15409. * @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.
  15410. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15411. * @param camera The camera to apply the render pass to.
  15412. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15413. * @param engine The engine which the post process will be applied. (default: current engine)
  15414. * @param reusable If the post process can be reused on the same frame. (default: false)
  15415. * @param textureType Type of textures used when performing the post process. (default: 0)
  15416. * @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)
  15417. */
  15418. constructor(name: string,
  15419. /** The direction in which to blur the image. */
  15420. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15421. /**
  15422. * Updates the effect with the current post process compile time values and recompiles the shader.
  15423. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15424. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15425. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15426. * @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
  15427. * @param onCompiled Called when the shader has been compiled.
  15428. * @param onError Called if there is an error when compiling a shader.
  15429. */
  15430. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15431. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15432. /**
  15433. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15434. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15435. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15436. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15437. * The gaps between physical kernels are compensated for in the weighting of the samples
  15438. * @param idealKernel Ideal blur kernel.
  15439. * @return Nearest best kernel.
  15440. */
  15441. protected _nearestBestKernel(idealKernel: number): number;
  15442. /**
  15443. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15444. * @param x The point on the Gaussian distribution to sample.
  15445. * @return the value of the Gaussian function at x.
  15446. */
  15447. protected _gaussianWeight(x: number): number;
  15448. /**
  15449. * Generates a string that can be used as a floating point number in GLSL.
  15450. * @param x Value to print.
  15451. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15452. * @return GLSL float string.
  15453. */
  15454. protected _glslFloat(x: number, decimalFigures?: number): string;
  15455. }
  15456. }
  15457. declare module BABYLON {
  15458. /**
  15459. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15460. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15461. * You can then easily use it as a reflectionTexture on a flat surface.
  15462. * In case the surface is not a plane, please consider relying on reflection probes.
  15463. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15464. */
  15465. export class MirrorTexture extends RenderTargetTexture {
  15466. private scene;
  15467. /**
  15468. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15469. * 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.
  15470. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15471. */
  15472. mirrorPlane: Plane;
  15473. /**
  15474. * Define the blur ratio used to blur the reflection if needed.
  15475. */
  15476. blurRatio: number;
  15477. /**
  15478. * Define the adaptive blur kernel used to blur the reflection if needed.
  15479. * This will autocompute the closest best match for the `blurKernel`
  15480. */
  15481. adaptiveBlurKernel: number;
  15482. /**
  15483. * Define the blur kernel used to blur the reflection if needed.
  15484. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15485. */
  15486. blurKernel: number;
  15487. /**
  15488. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15489. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15490. */
  15491. blurKernelX: number;
  15492. /**
  15493. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15494. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15495. */
  15496. blurKernelY: number;
  15497. private _autoComputeBlurKernel;
  15498. protected _onRatioRescale(): void;
  15499. private _updateGammaSpace;
  15500. private _imageProcessingConfigChangeObserver;
  15501. private _transformMatrix;
  15502. private _mirrorMatrix;
  15503. private _savedViewMatrix;
  15504. private _blurX;
  15505. private _blurY;
  15506. private _adaptiveBlurKernel;
  15507. private _blurKernelX;
  15508. private _blurKernelY;
  15509. private _blurRatio;
  15510. /**
  15511. * Instantiates a Mirror Texture.
  15512. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15513. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15514. * You can then easily use it as a reflectionTexture on a flat surface.
  15515. * In case the surface is not a plane, please consider relying on reflection probes.
  15516. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15517. * @param name
  15518. * @param size
  15519. * @param scene
  15520. * @param generateMipMaps
  15521. * @param type
  15522. * @param samplingMode
  15523. * @param generateDepthBuffer
  15524. */
  15525. constructor(name: string, size: number | {
  15526. width: number;
  15527. height: number;
  15528. } | {
  15529. ratio: number;
  15530. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15531. private _preparePostProcesses;
  15532. /**
  15533. * Clone the mirror texture.
  15534. * @returns the cloned texture
  15535. */
  15536. clone(): MirrorTexture;
  15537. /**
  15538. * Serialize the texture to a JSON representation you could use in Parse later on
  15539. * @returns the serialized JSON representation
  15540. */
  15541. serialize(): any;
  15542. /**
  15543. * Dispose the texture and release its associated resources.
  15544. */
  15545. dispose(): void;
  15546. }
  15547. }
  15548. declare module BABYLON {
  15549. /**
  15550. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15551. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15552. */
  15553. export class Texture extends BaseTexture {
  15554. /** @hidden */
  15555. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15556. /** @hidden */
  15557. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15558. /** @hidden */
  15559. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15560. /** nearest is mag = nearest and min = nearest and mip = linear */
  15561. static readonly NEAREST_SAMPLINGMODE: number;
  15562. /** nearest is mag = nearest and min = nearest and mip = linear */
  15563. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15564. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15565. static readonly BILINEAR_SAMPLINGMODE: number;
  15566. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15567. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15568. /** Trilinear is mag = linear and min = linear and mip = linear */
  15569. static readonly TRILINEAR_SAMPLINGMODE: number;
  15570. /** Trilinear is mag = linear and min = linear and mip = linear */
  15571. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15572. /** mag = nearest and min = nearest and mip = nearest */
  15573. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15574. /** mag = nearest and min = linear and mip = nearest */
  15575. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15576. /** mag = nearest and min = linear and mip = linear */
  15577. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15578. /** mag = nearest and min = linear and mip = none */
  15579. static readonly NEAREST_LINEAR: number;
  15580. /** mag = nearest and min = nearest and mip = none */
  15581. static readonly NEAREST_NEAREST: number;
  15582. /** mag = linear and min = nearest and mip = nearest */
  15583. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15584. /** mag = linear and min = nearest and mip = linear */
  15585. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15586. /** mag = linear and min = linear and mip = none */
  15587. static readonly LINEAR_LINEAR: number;
  15588. /** mag = linear and min = nearest and mip = none */
  15589. static readonly LINEAR_NEAREST: number;
  15590. /** Explicit coordinates mode */
  15591. static readonly EXPLICIT_MODE: number;
  15592. /** Spherical coordinates mode */
  15593. static readonly SPHERICAL_MODE: number;
  15594. /** Planar coordinates mode */
  15595. static readonly PLANAR_MODE: number;
  15596. /** Cubic coordinates mode */
  15597. static readonly CUBIC_MODE: number;
  15598. /** Projection coordinates mode */
  15599. static readonly PROJECTION_MODE: number;
  15600. /** Inverse Cubic coordinates mode */
  15601. static readonly SKYBOX_MODE: number;
  15602. /** Inverse Cubic coordinates mode */
  15603. static readonly INVCUBIC_MODE: number;
  15604. /** Equirectangular coordinates mode */
  15605. static readonly EQUIRECTANGULAR_MODE: number;
  15606. /** Equirectangular Fixed coordinates mode */
  15607. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15608. /** Equirectangular Fixed Mirrored coordinates mode */
  15609. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15610. /** Texture is not repeating outside of 0..1 UVs */
  15611. static readonly CLAMP_ADDRESSMODE: number;
  15612. /** Texture is repeating outside of 0..1 UVs */
  15613. static readonly WRAP_ADDRESSMODE: number;
  15614. /** Texture is repeating and mirrored */
  15615. static readonly MIRROR_ADDRESSMODE: number;
  15616. /**
  15617. * 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
  15618. */
  15619. static UseSerializedUrlIfAny: boolean;
  15620. /**
  15621. * Define the url of the texture.
  15622. */
  15623. url: Nullable<string>;
  15624. /**
  15625. * Define an offset on the texture to offset the u coordinates of the UVs
  15626. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15627. */
  15628. uOffset: number;
  15629. /**
  15630. * Define an offset on the texture to offset the v coordinates of the UVs
  15631. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15632. */
  15633. vOffset: number;
  15634. /**
  15635. * Define an offset on the texture to scale the u coordinates of the UVs
  15636. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15637. */
  15638. uScale: number;
  15639. /**
  15640. * Define an offset on the texture to scale the v coordinates of the UVs
  15641. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15642. */
  15643. vScale: number;
  15644. /**
  15645. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15646. * @see http://doc.babylonjs.com/how_to/more_materials
  15647. */
  15648. uAng: number;
  15649. /**
  15650. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15651. * @see http://doc.babylonjs.com/how_to/more_materials
  15652. */
  15653. vAng: number;
  15654. /**
  15655. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15656. * @see http://doc.babylonjs.com/how_to/more_materials
  15657. */
  15658. wAng: number;
  15659. /**
  15660. * Defines the center of rotation (U)
  15661. */
  15662. uRotationCenter: number;
  15663. /**
  15664. * Defines the center of rotation (V)
  15665. */
  15666. vRotationCenter: number;
  15667. /**
  15668. * Defines the center of rotation (W)
  15669. */
  15670. wRotationCenter: number;
  15671. /**
  15672. * Are mip maps generated for this texture or not.
  15673. */
  15674. readonly noMipmap: boolean;
  15675. /**
  15676. * List of inspectable custom properties (used by the Inspector)
  15677. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15678. */
  15679. inspectableCustomProperties: Nullable<IInspectable[]>;
  15680. private _noMipmap;
  15681. /** @hidden */
  15682. _invertY: boolean;
  15683. private _rowGenerationMatrix;
  15684. private _cachedTextureMatrix;
  15685. private _projectionModeMatrix;
  15686. private _t0;
  15687. private _t1;
  15688. private _t2;
  15689. private _cachedUOffset;
  15690. private _cachedVOffset;
  15691. private _cachedUScale;
  15692. private _cachedVScale;
  15693. private _cachedUAng;
  15694. private _cachedVAng;
  15695. private _cachedWAng;
  15696. private _cachedProjectionMatrixId;
  15697. private _cachedCoordinatesMode;
  15698. /** @hidden */
  15699. protected _initialSamplingMode: number;
  15700. /** @hidden */
  15701. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  15702. private _deleteBuffer;
  15703. protected _format: Nullable<number>;
  15704. private _delayedOnLoad;
  15705. private _delayedOnError;
  15706. /**
  15707. * Observable triggered once the texture has been loaded.
  15708. */
  15709. onLoadObservable: Observable<Texture>;
  15710. protected _isBlocking: boolean;
  15711. /**
  15712. * Is the texture preventing material to render while loading.
  15713. * If false, a default texture will be used instead of the loading one during the preparation step.
  15714. */
  15715. isBlocking: boolean;
  15716. /**
  15717. * Get the current sampling mode associated with the texture.
  15718. */
  15719. readonly samplingMode: number;
  15720. /**
  15721. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15722. */
  15723. readonly invertY: boolean;
  15724. /**
  15725. * Instantiates a new texture.
  15726. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15727. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15728. * @param url define the url of the picture to load as a texture
  15729. * @param scene define the scene or engine the texture will belong to
  15730. * @param noMipmap define if the texture will require mip maps or not
  15731. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15732. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15733. * @param onLoad define a callback triggered when the texture has been loaded
  15734. * @param onError define a callback triggered when an error occurred during the loading session
  15735. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15736. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15737. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15738. */
  15739. 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 | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  15740. /**
  15741. * Update the url (and optional buffer) of this texture if url was null during construction.
  15742. * @param url the url of the texture
  15743. * @param buffer the buffer of the texture (defaults to null)
  15744. * @param onLoad callback called when the texture is loaded (defaults to null)
  15745. */
  15746. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15747. /**
  15748. * Finish the loading sequence of a texture flagged as delayed load.
  15749. * @hidden
  15750. */
  15751. delayLoad(): void;
  15752. private _prepareRowForTextureGeneration;
  15753. /**
  15754. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15755. * @returns the transform matrix of the texture.
  15756. */
  15757. getTextureMatrix(): Matrix;
  15758. /**
  15759. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15760. * @returns The reflection texture transform
  15761. */
  15762. getReflectionTextureMatrix(): Matrix;
  15763. /**
  15764. * Clones the texture.
  15765. * @returns the cloned texture
  15766. */
  15767. clone(): Texture;
  15768. /**
  15769. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15770. * @returns The JSON representation of the texture
  15771. */
  15772. serialize(): any;
  15773. /**
  15774. * Get the current class name of the texture useful for serialization or dynamic coding.
  15775. * @returns "Texture"
  15776. */
  15777. getClassName(): string;
  15778. /**
  15779. * Dispose the texture and release its associated resources.
  15780. */
  15781. dispose(): void;
  15782. /**
  15783. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15784. * @param parsedTexture Define the JSON representation of the texture
  15785. * @param scene Define the scene the parsed texture should be instantiated in
  15786. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15787. * @returns The parsed texture if successful
  15788. */
  15789. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15790. /**
  15791. * Creates a texture from its base 64 representation.
  15792. * @param data Define the base64 payload without the data: prefix
  15793. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15794. * @param scene Define the scene the texture should belong to
  15795. * @param noMipmap Forces the texture to not create mip map information if true
  15796. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15797. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15798. * @param onLoad define a callback triggered when the texture has been loaded
  15799. * @param onError define a callback triggered when an error occurred during the loading session
  15800. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15801. * @returns the created texture
  15802. */
  15803. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15804. /**
  15805. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15806. * @param data Define the base64 payload without the data: prefix
  15807. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15808. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15809. * @param scene Define the scene the texture should belong to
  15810. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15811. * @param noMipmap Forces the texture to not create mip map information if true
  15812. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15813. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15814. * @param onLoad define a callback triggered when the texture has been loaded
  15815. * @param onError define a callback triggered when an error occurred during the loading session
  15816. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15817. * @returns the created texture
  15818. */
  15819. 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;
  15820. }
  15821. }
  15822. declare module BABYLON {
  15823. /**
  15824. * PostProcessManager is used to manage one or more post processes or post process pipelines
  15825. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15826. */
  15827. export class PostProcessManager {
  15828. private _scene;
  15829. private _indexBuffer;
  15830. private _vertexBuffers;
  15831. /**
  15832. * Creates a new instance PostProcess
  15833. * @param scene The scene that the post process is associated with.
  15834. */
  15835. constructor(scene: Scene);
  15836. private _prepareBuffers;
  15837. private _buildIndexBuffer;
  15838. /**
  15839. * Rebuilds the vertex buffers of the manager.
  15840. * @hidden
  15841. */
  15842. _rebuild(): void;
  15843. /**
  15844. * Prepares a frame to be run through a post process.
  15845. * @param sourceTexture The input texture to the post procesess. (default: null)
  15846. * @param postProcesses An array of post processes to be run. (default: null)
  15847. * @returns True if the post processes were able to be run.
  15848. * @hidden
  15849. */
  15850. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  15851. /**
  15852. * Manually render a set of post processes to a texture.
  15853. * @param postProcesses An array of post processes to be run.
  15854. * @param targetTexture The target texture to render to.
  15855. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  15856. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  15857. * @param lodLevel defines which lod of the texture to render to
  15858. */
  15859. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  15860. /**
  15861. * Finalize the result of the output of the postprocesses.
  15862. * @param doNotPresent If true the result will not be displayed to the screen.
  15863. * @param targetTexture The target texture to render to.
  15864. * @param faceIndex The index of the face to bind the target texture to.
  15865. * @param postProcesses The array of post processes to render.
  15866. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  15867. * @hidden
  15868. */
  15869. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  15870. /**
  15871. * Disposes of the post process manager.
  15872. */
  15873. dispose(): void;
  15874. }
  15875. }
  15876. declare module BABYLON {
  15877. /** Interface used by value gradients (color, factor, ...) */
  15878. export interface IValueGradient {
  15879. /**
  15880. * Gets or sets the gradient value (between 0 and 1)
  15881. */
  15882. gradient: number;
  15883. }
  15884. /** Class used to store color4 gradient */
  15885. export class ColorGradient implements IValueGradient {
  15886. /**
  15887. * Gets or sets the gradient value (between 0 and 1)
  15888. */
  15889. gradient: number;
  15890. /**
  15891. * Gets or sets first associated color
  15892. */
  15893. color1: Color4;
  15894. /**
  15895. * Gets or sets second associated color
  15896. */
  15897. color2?: Color4;
  15898. /**
  15899. * Will get a color picked randomly between color1 and color2.
  15900. * If color2 is undefined then color1 will be used
  15901. * @param result defines the target Color4 to store the result in
  15902. */
  15903. getColorToRef(result: Color4): void;
  15904. }
  15905. /** Class used to store color 3 gradient */
  15906. export class Color3Gradient implements IValueGradient {
  15907. /**
  15908. * Gets or sets the gradient value (between 0 and 1)
  15909. */
  15910. gradient: number;
  15911. /**
  15912. * Gets or sets the associated color
  15913. */
  15914. color: Color3;
  15915. }
  15916. /** Class used to store factor gradient */
  15917. export class FactorGradient implements IValueGradient {
  15918. /**
  15919. * Gets or sets the gradient value (between 0 and 1)
  15920. */
  15921. gradient: number;
  15922. /**
  15923. * Gets or sets first associated factor
  15924. */
  15925. factor1: number;
  15926. /**
  15927. * Gets or sets second associated factor
  15928. */
  15929. factor2?: number;
  15930. /**
  15931. * Will get a number picked randomly between factor1 and factor2.
  15932. * If factor2 is undefined then factor1 will be used
  15933. * @returns the picked number
  15934. */
  15935. getFactor(): number;
  15936. }
  15937. /**
  15938. * Helper used to simplify some generic gradient tasks
  15939. */
  15940. export class GradientHelper {
  15941. /**
  15942. * Gets the current gradient from an array of IValueGradient
  15943. * @param ratio defines the current ratio to get
  15944. * @param gradients defines the array of IValueGradient
  15945. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  15946. */
  15947. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  15948. }
  15949. }
  15950. declare module BABYLON {
  15951. interface AbstractScene {
  15952. /**
  15953. * The list of procedural textures added to the scene
  15954. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15955. */
  15956. proceduralTextures: Array<ProceduralTexture>;
  15957. }
  15958. /**
  15959. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  15960. * in a given scene.
  15961. */
  15962. export class ProceduralTextureSceneComponent implements ISceneComponent {
  15963. /**
  15964. * The component name helpfull to identify the component in the list of scene components.
  15965. */
  15966. readonly name: string;
  15967. /**
  15968. * The scene the component belongs to.
  15969. */
  15970. scene: Scene;
  15971. /**
  15972. * Creates a new instance of the component for the given scene
  15973. * @param scene Defines the scene to register the component in
  15974. */
  15975. constructor(scene: Scene);
  15976. /**
  15977. * Registers the component in a given scene
  15978. */
  15979. register(): void;
  15980. /**
  15981. * Rebuilds the elements related to this component in case of
  15982. * context lost for instance.
  15983. */
  15984. rebuild(): void;
  15985. /**
  15986. * Disposes the component and the associated ressources.
  15987. */
  15988. dispose(): void;
  15989. private _beforeClear;
  15990. }
  15991. }
  15992. declare module BABYLON {
  15993. interface Engine {
  15994. /**
  15995. * Creates a new render target cube texture
  15996. * @param size defines the size of the texture
  15997. * @param options defines the options used to create the texture
  15998. * @returns a new render target cube texture stored in an InternalTexture
  15999. */
  16000. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16001. }
  16002. }
  16003. declare module BABYLON {
  16004. /** @hidden */
  16005. export var proceduralVertexShader: {
  16006. name: string;
  16007. shader: string;
  16008. };
  16009. }
  16010. declare module BABYLON {
  16011. /**
  16012. * 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.
  16013. * This is the base class of any Procedural texture and contains most of the shareable code.
  16014. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16015. */
  16016. export class ProceduralTexture extends Texture {
  16017. isCube: boolean;
  16018. /**
  16019. * Define if the texture is enabled or not (disabled texture will not render)
  16020. */
  16021. isEnabled: boolean;
  16022. /**
  16023. * Define if the texture must be cleared before rendering (default is true)
  16024. */
  16025. autoClear: boolean;
  16026. /**
  16027. * Callback called when the texture is generated
  16028. */
  16029. onGenerated: () => void;
  16030. /**
  16031. * Event raised when the texture is generated
  16032. */
  16033. onGeneratedObservable: Observable<ProceduralTexture>;
  16034. /** @hidden */
  16035. _generateMipMaps: boolean;
  16036. /** @hidden **/
  16037. _effect: Effect;
  16038. /** @hidden */
  16039. _textures: {
  16040. [key: string]: Texture;
  16041. };
  16042. private _size;
  16043. private _currentRefreshId;
  16044. private _refreshRate;
  16045. private _vertexBuffers;
  16046. private _indexBuffer;
  16047. private _uniforms;
  16048. private _samplers;
  16049. private _fragment;
  16050. private _floats;
  16051. private _ints;
  16052. private _floatsArrays;
  16053. private _colors3;
  16054. private _colors4;
  16055. private _vectors2;
  16056. private _vectors3;
  16057. private _matrices;
  16058. private _fallbackTexture;
  16059. private _fallbackTextureUsed;
  16060. private _engine;
  16061. private _cachedDefines;
  16062. private _contentUpdateId;
  16063. private _contentData;
  16064. /**
  16065. * Instantiates a new procedural texture.
  16066. * 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.
  16067. * This is the base class of any Procedural texture and contains most of the shareable code.
  16068. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16069. * @param name Define the name of the texture
  16070. * @param size Define the size of the texture to create
  16071. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16072. * @param scene Define the scene the texture belongs to
  16073. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16074. * @param generateMipMaps Define if the texture should creates mip maps or not
  16075. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16076. */
  16077. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16078. /**
  16079. * The effect that is created when initializing the post process.
  16080. * @returns The created effect corresponding the the postprocess.
  16081. */
  16082. getEffect(): Effect;
  16083. /**
  16084. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16085. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16086. */
  16087. getContent(): Nullable<ArrayBufferView>;
  16088. private _createIndexBuffer;
  16089. /** @hidden */
  16090. _rebuild(): void;
  16091. /**
  16092. * Resets the texture in order to recreate its associated resources.
  16093. * This can be called in case of context loss
  16094. */
  16095. reset(): void;
  16096. protected _getDefines(): string;
  16097. /**
  16098. * Is the texture ready to be used ? (rendered at least once)
  16099. * @returns true if ready, otherwise, false.
  16100. */
  16101. isReady(): boolean;
  16102. /**
  16103. * Resets the refresh counter of the texture and start bak from scratch.
  16104. * Could be useful to regenerate the texture if it is setup to render only once.
  16105. */
  16106. resetRefreshCounter(): void;
  16107. /**
  16108. * Set the fragment shader to use in order to render the texture.
  16109. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16110. */
  16111. setFragment(fragment: any): void;
  16112. /**
  16113. * Define the refresh rate of the texture or the rendering frequency.
  16114. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16115. */
  16116. refreshRate: number;
  16117. /** @hidden */
  16118. _shouldRender(): boolean;
  16119. /**
  16120. * Get the size the texture is rendering at.
  16121. * @returns the size (texture is always squared)
  16122. */
  16123. getRenderSize(): number;
  16124. /**
  16125. * Resize the texture to new value.
  16126. * @param size Define the new size the texture should have
  16127. * @param generateMipMaps Define whether the new texture should create mip maps
  16128. */
  16129. resize(size: number, generateMipMaps: boolean): void;
  16130. private _checkUniform;
  16131. /**
  16132. * Set a texture in the shader program used to render.
  16133. * @param name Define the name of the uniform samplers as defined in the shader
  16134. * @param texture Define the texture to bind to this sampler
  16135. * @return the texture itself allowing "fluent" like uniform updates
  16136. */
  16137. setTexture(name: string, texture: Texture): ProceduralTexture;
  16138. /**
  16139. * Set a float in the shader.
  16140. * @param name Define the name of the uniform as defined in the shader
  16141. * @param value Define the value to give to the uniform
  16142. * @return the texture itself allowing "fluent" like uniform updates
  16143. */
  16144. setFloat(name: string, value: number): ProceduralTexture;
  16145. /**
  16146. * Set a int in the shader.
  16147. * @param name Define the name of the uniform as defined in the shader
  16148. * @param value Define the value to give to the uniform
  16149. * @return the texture itself allowing "fluent" like uniform updates
  16150. */
  16151. setInt(name: string, value: number): ProceduralTexture;
  16152. /**
  16153. * Set an array of floats in the shader.
  16154. * @param name Define the name of the uniform as defined in the shader
  16155. * @param value Define the value to give to the uniform
  16156. * @return the texture itself allowing "fluent" like uniform updates
  16157. */
  16158. setFloats(name: string, value: number[]): ProceduralTexture;
  16159. /**
  16160. * Set a vec3 in the shader from a Color3.
  16161. * @param name Define the name of the uniform as defined in the shader
  16162. * @param value Define the value to give to the uniform
  16163. * @return the texture itself allowing "fluent" like uniform updates
  16164. */
  16165. setColor3(name: string, value: Color3): ProceduralTexture;
  16166. /**
  16167. * Set a vec4 in the shader from a Color4.
  16168. * @param name Define the name of the uniform as defined in the shader
  16169. * @param value Define the value to give to the uniform
  16170. * @return the texture itself allowing "fluent" like uniform updates
  16171. */
  16172. setColor4(name: string, value: Color4): ProceduralTexture;
  16173. /**
  16174. * Set a vec2 in the shader from a Vector2.
  16175. * @param name Define the name of the uniform as defined in the shader
  16176. * @param value Define the value to give to the uniform
  16177. * @return the texture itself allowing "fluent" like uniform updates
  16178. */
  16179. setVector2(name: string, value: Vector2): ProceduralTexture;
  16180. /**
  16181. * Set a vec3 in the shader from a Vector3.
  16182. * @param name Define the name of the uniform as defined in the shader
  16183. * @param value Define the value to give to the uniform
  16184. * @return the texture itself allowing "fluent" like uniform updates
  16185. */
  16186. setVector3(name: string, value: Vector3): ProceduralTexture;
  16187. /**
  16188. * Set a mat4 in the shader from a MAtrix.
  16189. * @param name Define the name of the uniform as defined in the shader
  16190. * @param value Define the value to give to the uniform
  16191. * @return the texture itself allowing "fluent" like uniform updates
  16192. */
  16193. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16194. /**
  16195. * Render the texture to its associated render target.
  16196. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16197. */
  16198. render(useCameraPostProcess?: boolean): void;
  16199. /**
  16200. * Clone the texture.
  16201. * @returns the cloned texture
  16202. */
  16203. clone(): ProceduralTexture;
  16204. /**
  16205. * Dispose the texture and release its asoociated resources.
  16206. */
  16207. dispose(): void;
  16208. }
  16209. }
  16210. declare module BABYLON {
  16211. /**
  16212. * This represents the base class for particle system in Babylon.
  16213. * 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.
  16214. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16215. * @example https://doc.babylonjs.com/babylon101/particles
  16216. */
  16217. export class BaseParticleSystem {
  16218. /**
  16219. * Source color is added to the destination color without alpha affecting the result
  16220. */
  16221. static BLENDMODE_ONEONE: number;
  16222. /**
  16223. * Blend current color and particle color using particle’s alpha
  16224. */
  16225. static BLENDMODE_STANDARD: number;
  16226. /**
  16227. * Add current color and particle color multiplied by particle’s alpha
  16228. */
  16229. static BLENDMODE_ADD: number;
  16230. /**
  16231. * Multiply current color with particle color
  16232. */
  16233. static BLENDMODE_MULTIPLY: number;
  16234. /**
  16235. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16236. */
  16237. static BLENDMODE_MULTIPLYADD: number;
  16238. /**
  16239. * List of animations used by the particle system.
  16240. */
  16241. animations: Animation[];
  16242. /**
  16243. * The id of the Particle system.
  16244. */
  16245. id: string;
  16246. /**
  16247. * The friendly name of the Particle system.
  16248. */
  16249. name: string;
  16250. /**
  16251. * The rendering group used by the Particle system to chose when to render.
  16252. */
  16253. renderingGroupId: number;
  16254. /**
  16255. * The emitter represents the Mesh or position we are attaching the particle system to.
  16256. */
  16257. emitter: Nullable<AbstractMesh | Vector3>;
  16258. /**
  16259. * The maximum number of particles to emit per frame
  16260. */
  16261. emitRate: number;
  16262. /**
  16263. * If you want to launch only a few particles at once, that can be done, as well.
  16264. */
  16265. manualEmitCount: number;
  16266. /**
  16267. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16268. */
  16269. updateSpeed: number;
  16270. /**
  16271. * The amount of time the particle system is running (depends of the overall update speed).
  16272. */
  16273. targetStopDuration: number;
  16274. /**
  16275. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16276. */
  16277. disposeOnStop: boolean;
  16278. /**
  16279. * Minimum power of emitting particles.
  16280. */
  16281. minEmitPower: number;
  16282. /**
  16283. * Maximum power of emitting particles.
  16284. */
  16285. maxEmitPower: number;
  16286. /**
  16287. * Minimum life time of emitting particles.
  16288. */
  16289. minLifeTime: number;
  16290. /**
  16291. * Maximum life time of emitting particles.
  16292. */
  16293. maxLifeTime: number;
  16294. /**
  16295. * Minimum Size of emitting particles.
  16296. */
  16297. minSize: number;
  16298. /**
  16299. * Maximum Size of emitting particles.
  16300. */
  16301. maxSize: number;
  16302. /**
  16303. * Minimum scale of emitting particles on X axis.
  16304. */
  16305. minScaleX: number;
  16306. /**
  16307. * Maximum scale of emitting particles on X axis.
  16308. */
  16309. maxScaleX: number;
  16310. /**
  16311. * Minimum scale of emitting particles on Y axis.
  16312. */
  16313. minScaleY: number;
  16314. /**
  16315. * Maximum scale of emitting particles on Y axis.
  16316. */
  16317. maxScaleY: number;
  16318. /**
  16319. * Gets or sets the minimal initial rotation in radians.
  16320. */
  16321. minInitialRotation: number;
  16322. /**
  16323. * Gets or sets the maximal initial rotation in radians.
  16324. */
  16325. maxInitialRotation: number;
  16326. /**
  16327. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16328. */
  16329. minAngularSpeed: number;
  16330. /**
  16331. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16332. */
  16333. maxAngularSpeed: number;
  16334. /**
  16335. * The texture used to render each particle. (this can be a spritesheet)
  16336. */
  16337. particleTexture: Nullable<Texture>;
  16338. /**
  16339. * The layer mask we are rendering the particles through.
  16340. */
  16341. layerMask: number;
  16342. /**
  16343. * This can help using your own shader to render the particle system.
  16344. * The according effect will be created
  16345. */
  16346. customShader: any;
  16347. /**
  16348. * By default particle system starts as soon as they are created. This prevents the
  16349. * automatic start to happen and let you decide when to start emitting particles.
  16350. */
  16351. preventAutoStart: boolean;
  16352. private _noiseTexture;
  16353. /**
  16354. * Gets or sets a texture used to add random noise to particle positions
  16355. */
  16356. noiseTexture: Nullable<ProceduralTexture>;
  16357. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16358. noiseStrength: Vector3;
  16359. /**
  16360. * Callback triggered when the particle animation is ending.
  16361. */
  16362. onAnimationEnd: Nullable<() => void>;
  16363. /**
  16364. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16365. */
  16366. blendMode: number;
  16367. /**
  16368. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16369. * to override the particles.
  16370. */
  16371. forceDepthWrite: boolean;
  16372. /** 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 */
  16373. preWarmCycles: number;
  16374. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16375. preWarmStepOffset: number;
  16376. /**
  16377. * 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)
  16378. */
  16379. spriteCellChangeSpeed: number;
  16380. /**
  16381. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16382. */
  16383. startSpriteCellID: number;
  16384. /**
  16385. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16386. */
  16387. endSpriteCellID: number;
  16388. /**
  16389. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16390. */
  16391. spriteCellWidth: number;
  16392. /**
  16393. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16394. */
  16395. spriteCellHeight: number;
  16396. /**
  16397. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16398. */
  16399. spriteRandomStartCell: boolean;
  16400. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16401. translationPivot: Vector2;
  16402. /** @hidden */
  16403. protected _isAnimationSheetEnabled: boolean;
  16404. /**
  16405. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16406. */
  16407. beginAnimationOnStart: boolean;
  16408. /**
  16409. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16410. */
  16411. beginAnimationFrom: number;
  16412. /**
  16413. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16414. */
  16415. beginAnimationTo: number;
  16416. /**
  16417. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16418. */
  16419. beginAnimationLoop: boolean;
  16420. /**
  16421. * Gets or sets a world offset applied to all particles
  16422. */
  16423. worldOffset: Vector3;
  16424. /**
  16425. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16426. */
  16427. isAnimationSheetEnabled: boolean;
  16428. /**
  16429. * Get hosting scene
  16430. * @returns the scene
  16431. */
  16432. getScene(): Scene;
  16433. /**
  16434. * You can use gravity if you want to give an orientation to your particles.
  16435. */
  16436. gravity: Vector3;
  16437. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16438. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16439. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16440. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16441. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16442. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16443. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16444. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16445. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16446. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16447. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16448. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16449. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16450. /**
  16451. * Defines the delay in milliseconds before starting the system (0 by default)
  16452. */
  16453. startDelay: number;
  16454. /**
  16455. * Gets the current list of drag gradients.
  16456. * You must use addDragGradient and removeDragGradient to udpate this list
  16457. * @returns the list of drag gradients
  16458. */
  16459. getDragGradients(): Nullable<Array<FactorGradient>>;
  16460. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16461. limitVelocityDamping: number;
  16462. /**
  16463. * Gets the current list of limit velocity gradients.
  16464. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16465. * @returns the list of limit velocity gradients
  16466. */
  16467. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16468. /**
  16469. * Gets the current list of color gradients.
  16470. * You must use addColorGradient and removeColorGradient to udpate this list
  16471. * @returns the list of color gradients
  16472. */
  16473. getColorGradients(): Nullable<Array<ColorGradient>>;
  16474. /**
  16475. * Gets the current list of size gradients.
  16476. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16477. * @returns the list of size gradients
  16478. */
  16479. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16480. /**
  16481. * Gets the current list of color remap gradients.
  16482. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16483. * @returns the list of color remap gradients
  16484. */
  16485. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16486. /**
  16487. * Gets the current list of alpha remap gradients.
  16488. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16489. * @returns the list of alpha remap gradients
  16490. */
  16491. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16492. /**
  16493. * Gets the current list of life time gradients.
  16494. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16495. * @returns the list of life time gradients
  16496. */
  16497. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16498. /**
  16499. * Gets the current list of angular speed gradients.
  16500. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16501. * @returns the list of angular speed gradients
  16502. */
  16503. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16504. /**
  16505. * Gets the current list of velocity gradients.
  16506. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16507. * @returns the list of velocity gradients
  16508. */
  16509. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16510. /**
  16511. * Gets the current list of start size gradients.
  16512. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16513. * @returns the list of start size gradients
  16514. */
  16515. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16516. /**
  16517. * Gets the current list of emit rate gradients.
  16518. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16519. * @returns the list of emit rate gradients
  16520. */
  16521. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16522. /**
  16523. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16524. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16525. */
  16526. direction1: Vector3;
  16527. /**
  16528. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16529. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16530. */
  16531. direction2: Vector3;
  16532. /**
  16533. * 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.
  16534. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16535. */
  16536. minEmitBox: Vector3;
  16537. /**
  16538. * 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.
  16539. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16540. */
  16541. maxEmitBox: Vector3;
  16542. /**
  16543. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16544. */
  16545. color1: Color4;
  16546. /**
  16547. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16548. */
  16549. color2: Color4;
  16550. /**
  16551. * Color the particle will have at the end of its lifetime
  16552. */
  16553. colorDead: Color4;
  16554. /**
  16555. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16556. */
  16557. textureMask: Color4;
  16558. /**
  16559. * The particle emitter type defines the emitter used by the particle system.
  16560. * It can be for example box, sphere, or cone...
  16561. */
  16562. particleEmitterType: IParticleEmitterType;
  16563. /** @hidden */
  16564. _isSubEmitter: boolean;
  16565. /**
  16566. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16567. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16568. */
  16569. billboardMode: number;
  16570. protected _isBillboardBased: boolean;
  16571. /**
  16572. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16573. */
  16574. isBillboardBased: boolean;
  16575. /**
  16576. * The scene the particle system belongs to.
  16577. */
  16578. protected _scene: Scene;
  16579. /**
  16580. * Local cache of defines for image processing.
  16581. */
  16582. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16583. /**
  16584. * Default configuration related to image processing available in the standard Material.
  16585. */
  16586. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16587. /**
  16588. * Gets the image processing configuration used either in this material.
  16589. */
  16590. /**
  16591. * Sets the Default image processing configuration used either in the this material.
  16592. *
  16593. * If sets to null, the scene one is in use.
  16594. */
  16595. imageProcessingConfiguration: ImageProcessingConfiguration;
  16596. /**
  16597. * Attaches a new image processing configuration to the Standard Material.
  16598. * @param configuration
  16599. */
  16600. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16601. /** @hidden */
  16602. protected _reset(): void;
  16603. /** @hidden */
  16604. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16605. /**
  16606. * Instantiates a particle system.
  16607. * 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.
  16608. * @param name The name of the particle system
  16609. */
  16610. constructor(name: string);
  16611. /**
  16612. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16613. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16614. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16615. * @returns the emitter
  16616. */
  16617. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16618. /**
  16619. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16620. * @param radius The radius of the hemisphere to emit from
  16621. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16622. * @returns the emitter
  16623. */
  16624. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16625. /**
  16626. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16627. * @param radius The radius of the sphere to emit from
  16628. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16629. * @returns the emitter
  16630. */
  16631. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16632. /**
  16633. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16634. * @param radius The radius of the sphere to emit from
  16635. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16636. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16637. * @returns the emitter
  16638. */
  16639. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16640. /**
  16641. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16642. * @param radius The radius of the emission cylinder
  16643. * @param height The height of the emission cylinder
  16644. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16645. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16646. * @returns the emitter
  16647. */
  16648. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16649. /**
  16650. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16651. * @param radius The radius of the cylinder to emit from
  16652. * @param height The height of the emission cylinder
  16653. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16654. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16655. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16656. * @returns the emitter
  16657. */
  16658. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16659. /**
  16660. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16661. * @param radius The radius of the cone to emit from
  16662. * @param angle The base angle of the cone
  16663. * @returns the emitter
  16664. */
  16665. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16666. /**
  16667. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16668. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16669. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16670. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16671. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16672. * @returns the emitter
  16673. */
  16674. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16675. }
  16676. }
  16677. declare module BABYLON {
  16678. /**
  16679. * Type of sub emitter
  16680. */
  16681. export enum SubEmitterType {
  16682. /**
  16683. * Attached to the particle over it's lifetime
  16684. */
  16685. ATTACHED = 0,
  16686. /**
  16687. * Created when the particle dies
  16688. */
  16689. END = 1
  16690. }
  16691. /**
  16692. * Sub emitter class used to emit particles from an existing particle
  16693. */
  16694. export class SubEmitter {
  16695. /**
  16696. * the particle system to be used by the sub emitter
  16697. */
  16698. particleSystem: ParticleSystem;
  16699. /**
  16700. * Type of the submitter (Default: END)
  16701. */
  16702. type: SubEmitterType;
  16703. /**
  16704. * 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)
  16705. * Note: This only is supported when using an emitter of type Mesh
  16706. */
  16707. inheritDirection: boolean;
  16708. /**
  16709. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16710. */
  16711. inheritedVelocityAmount: number;
  16712. /**
  16713. * Creates a sub emitter
  16714. * @param particleSystem the particle system to be used by the sub emitter
  16715. */
  16716. constructor(
  16717. /**
  16718. * the particle system to be used by the sub emitter
  16719. */
  16720. particleSystem: ParticleSystem);
  16721. /**
  16722. * Clones the sub emitter
  16723. * @returns the cloned sub emitter
  16724. */
  16725. clone(): SubEmitter;
  16726. /**
  16727. * Serialize current object to a JSON object
  16728. * @returns the serialized object
  16729. */
  16730. serialize(): any;
  16731. /** @hidden */
  16732. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  16733. /**
  16734. * Creates a new SubEmitter from a serialized JSON version
  16735. * @param serializationObject defines the JSON object to read from
  16736. * @param scene defines the hosting scene
  16737. * @param rootUrl defines the rootUrl for data loading
  16738. * @returns a new SubEmitter
  16739. */
  16740. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  16741. /** Release associated resources */
  16742. dispose(): void;
  16743. }
  16744. }
  16745. declare module BABYLON {
  16746. /** @hidden */
  16747. export var clipPlaneFragmentDeclaration: {
  16748. name: string;
  16749. shader: string;
  16750. };
  16751. }
  16752. declare module BABYLON {
  16753. /** @hidden */
  16754. export var imageProcessingDeclaration: {
  16755. name: string;
  16756. shader: string;
  16757. };
  16758. }
  16759. declare module BABYLON {
  16760. /** @hidden */
  16761. export var imageProcessingFunctions: {
  16762. name: string;
  16763. shader: string;
  16764. };
  16765. }
  16766. declare module BABYLON {
  16767. /** @hidden */
  16768. export var clipPlaneFragment: {
  16769. name: string;
  16770. shader: string;
  16771. };
  16772. }
  16773. declare module BABYLON {
  16774. /** @hidden */
  16775. export var particlesPixelShader: {
  16776. name: string;
  16777. shader: string;
  16778. };
  16779. }
  16780. declare module BABYLON {
  16781. /** @hidden */
  16782. export var clipPlaneVertexDeclaration: {
  16783. name: string;
  16784. shader: string;
  16785. };
  16786. }
  16787. declare module BABYLON {
  16788. /** @hidden */
  16789. export var clipPlaneVertex: {
  16790. name: string;
  16791. shader: string;
  16792. };
  16793. }
  16794. declare module BABYLON {
  16795. /** @hidden */
  16796. export var particlesVertexShader: {
  16797. name: string;
  16798. shader: string;
  16799. };
  16800. }
  16801. declare module BABYLON {
  16802. /**
  16803. * This represents a particle system in Babylon.
  16804. * 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.
  16805. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16806. * @example https://doc.babylonjs.com/babylon101/particles
  16807. */
  16808. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  16809. /**
  16810. * Billboard mode will only apply to Y axis
  16811. */
  16812. static readonly BILLBOARDMODE_Y: number;
  16813. /**
  16814. * Billboard mode will apply to all axes
  16815. */
  16816. static readonly BILLBOARDMODE_ALL: number;
  16817. /**
  16818. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  16819. */
  16820. static readonly BILLBOARDMODE_STRETCHED: number;
  16821. /**
  16822. * This function can be defined to provide custom update for active particles.
  16823. * This function will be called instead of regular update (age, position, color, etc.).
  16824. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  16825. */
  16826. updateFunction: (particles: Particle[]) => void;
  16827. private _emitterWorldMatrix;
  16828. /**
  16829. * This function can be defined to specify initial direction for every new particle.
  16830. * It by default use the emitterType defined function
  16831. */
  16832. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  16833. /**
  16834. * This function can be defined to specify initial position for every new particle.
  16835. * It by default use the emitterType defined function
  16836. */
  16837. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  16838. /**
  16839. * @hidden
  16840. */
  16841. _inheritedVelocityOffset: Vector3;
  16842. /**
  16843. * An event triggered when the system is disposed
  16844. */
  16845. onDisposeObservable: Observable<ParticleSystem>;
  16846. private _onDisposeObserver;
  16847. /**
  16848. * Sets a callback that will be triggered when the system is disposed
  16849. */
  16850. onDispose: () => void;
  16851. private _particles;
  16852. private _epsilon;
  16853. private _capacity;
  16854. private _stockParticles;
  16855. private _newPartsExcess;
  16856. private _vertexData;
  16857. private _vertexBuffer;
  16858. private _vertexBuffers;
  16859. private _spriteBuffer;
  16860. private _indexBuffer;
  16861. private _effect;
  16862. private _customEffect;
  16863. private _cachedDefines;
  16864. private _scaledColorStep;
  16865. private _colorDiff;
  16866. private _scaledDirection;
  16867. private _scaledGravity;
  16868. private _currentRenderId;
  16869. private _alive;
  16870. private _useInstancing;
  16871. private _started;
  16872. private _stopped;
  16873. private _actualFrame;
  16874. private _scaledUpdateSpeed;
  16875. private _vertexBufferSize;
  16876. /** @hidden */
  16877. _currentEmitRateGradient: Nullable<FactorGradient>;
  16878. /** @hidden */
  16879. _currentEmitRate1: number;
  16880. /** @hidden */
  16881. _currentEmitRate2: number;
  16882. /** @hidden */
  16883. _currentStartSizeGradient: Nullable<FactorGradient>;
  16884. /** @hidden */
  16885. _currentStartSize1: number;
  16886. /** @hidden */
  16887. _currentStartSize2: number;
  16888. private readonly _rawTextureWidth;
  16889. private _rampGradientsTexture;
  16890. private _useRampGradients;
  16891. /** Gets or sets a boolean indicating that ramp gradients must be used
  16892. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16893. */
  16894. useRampGradients: boolean;
  16895. /**
  16896. * 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.
  16897. * 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: [])
  16898. */
  16899. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  16900. private _subEmitters;
  16901. /**
  16902. * @hidden
  16903. * If the particle systems emitter should be disposed when the particle system is disposed
  16904. */
  16905. _disposeEmitterOnDispose: boolean;
  16906. /**
  16907. * The current active Sub-systems, this property is used by the root particle system only.
  16908. */
  16909. activeSubSystems: Array<ParticleSystem>;
  16910. private _rootParticleSystem;
  16911. /**
  16912. * Gets the current list of active particles
  16913. */
  16914. readonly particles: Particle[];
  16915. /**
  16916. * Returns the string "ParticleSystem"
  16917. * @returns a string containing the class name
  16918. */
  16919. getClassName(): string;
  16920. /**
  16921. * Instantiates a particle system.
  16922. * 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.
  16923. * @param name The name of the particle system
  16924. * @param capacity The max number of particles alive at the same time
  16925. * @param scene The scene the particle system belongs to
  16926. * @param customEffect a custom effect used to change the way particles are rendered by default
  16927. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  16928. * @param epsilon Offset used to render the particles
  16929. */
  16930. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  16931. private _addFactorGradient;
  16932. private _removeFactorGradient;
  16933. /**
  16934. * Adds a new life time gradient
  16935. * @param gradient defines the gradient to use (between 0 and 1)
  16936. * @param factor defines the life time factor to affect to the specified gradient
  16937. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16938. * @returns the current particle system
  16939. */
  16940. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16941. /**
  16942. * Remove a specific life time gradient
  16943. * @param gradient defines the gradient to remove
  16944. * @returns the current particle system
  16945. */
  16946. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16947. /**
  16948. * Adds a new size gradient
  16949. * @param gradient defines the gradient to use (between 0 and 1)
  16950. * @param factor defines the size factor to affect to the specified gradient
  16951. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16952. * @returns the current particle system
  16953. */
  16954. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16955. /**
  16956. * Remove a specific size gradient
  16957. * @param gradient defines the gradient to remove
  16958. * @returns the current particle system
  16959. */
  16960. removeSizeGradient(gradient: number): IParticleSystem;
  16961. /**
  16962. * Adds a new color remap gradient
  16963. * @param gradient defines the gradient to use (between 0 and 1)
  16964. * @param min defines the color remap minimal range
  16965. * @param max defines the color remap maximal range
  16966. * @returns the current particle system
  16967. */
  16968. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16969. /**
  16970. * Remove a specific color remap gradient
  16971. * @param gradient defines the gradient to remove
  16972. * @returns the current particle system
  16973. */
  16974. removeColorRemapGradient(gradient: number): IParticleSystem;
  16975. /**
  16976. * Adds a new alpha remap gradient
  16977. * @param gradient defines the gradient to use (between 0 and 1)
  16978. * @param min defines the alpha remap minimal range
  16979. * @param max defines the alpha remap maximal range
  16980. * @returns the current particle system
  16981. */
  16982. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16983. /**
  16984. * Remove a specific alpha remap gradient
  16985. * @param gradient defines the gradient to remove
  16986. * @returns the current particle system
  16987. */
  16988. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  16989. /**
  16990. * Adds a new angular speed gradient
  16991. * @param gradient defines the gradient to use (between 0 and 1)
  16992. * @param factor defines the angular speed to affect to the specified gradient
  16993. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16994. * @returns the current particle system
  16995. */
  16996. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16997. /**
  16998. * Remove a specific angular speed gradient
  16999. * @param gradient defines the gradient to remove
  17000. * @returns the current particle system
  17001. */
  17002. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17003. /**
  17004. * Adds a new velocity gradient
  17005. * @param gradient defines the gradient to use (between 0 and 1)
  17006. * @param factor defines the velocity to affect to the specified gradient
  17007. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17008. * @returns the current particle system
  17009. */
  17010. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17011. /**
  17012. * Remove a specific velocity gradient
  17013. * @param gradient defines the gradient to remove
  17014. * @returns the current particle system
  17015. */
  17016. removeVelocityGradient(gradient: number): IParticleSystem;
  17017. /**
  17018. * Adds a new limit velocity gradient
  17019. * @param gradient defines the gradient to use (between 0 and 1)
  17020. * @param factor defines the limit velocity value to affect to the specified gradient
  17021. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17022. * @returns the current particle system
  17023. */
  17024. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17025. /**
  17026. * Remove a specific limit velocity gradient
  17027. * @param gradient defines the gradient to remove
  17028. * @returns the current particle system
  17029. */
  17030. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17031. /**
  17032. * Adds a new drag gradient
  17033. * @param gradient defines the gradient to use (between 0 and 1)
  17034. * @param factor defines the drag value to affect to the specified gradient
  17035. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17036. * @returns the current particle system
  17037. */
  17038. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17039. /**
  17040. * Remove a specific drag gradient
  17041. * @param gradient defines the gradient to remove
  17042. * @returns the current particle system
  17043. */
  17044. removeDragGradient(gradient: number): IParticleSystem;
  17045. /**
  17046. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17047. * @param gradient defines the gradient to use (between 0 and 1)
  17048. * @param factor defines the emit rate value to affect to the specified gradient
  17049. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17050. * @returns the current particle system
  17051. */
  17052. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17053. /**
  17054. * Remove a specific emit rate gradient
  17055. * @param gradient defines the gradient to remove
  17056. * @returns the current particle system
  17057. */
  17058. removeEmitRateGradient(gradient: number): IParticleSystem;
  17059. /**
  17060. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17061. * @param gradient defines the gradient to use (between 0 and 1)
  17062. * @param factor defines the start size value to affect to the specified gradient
  17063. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17064. * @returns the current particle system
  17065. */
  17066. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17067. /**
  17068. * Remove a specific start size gradient
  17069. * @param gradient defines the gradient to remove
  17070. * @returns the current particle system
  17071. */
  17072. removeStartSizeGradient(gradient: number): IParticleSystem;
  17073. private _createRampGradientTexture;
  17074. /**
  17075. * Gets the current list of ramp gradients.
  17076. * You must use addRampGradient and removeRampGradient to udpate this list
  17077. * @returns the list of ramp gradients
  17078. */
  17079. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17080. /**
  17081. * Adds a new ramp gradient used to remap particle colors
  17082. * @param gradient defines the gradient to use (between 0 and 1)
  17083. * @param color defines the color to affect to the specified gradient
  17084. * @returns the current particle system
  17085. */
  17086. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17087. /**
  17088. * Remove a specific ramp gradient
  17089. * @param gradient defines the gradient to remove
  17090. * @returns the current particle system
  17091. */
  17092. removeRampGradient(gradient: number): ParticleSystem;
  17093. /**
  17094. * Adds a new color gradient
  17095. * @param gradient defines the gradient to use (between 0 and 1)
  17096. * @param color1 defines the color to affect to the specified gradient
  17097. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17098. * @returns this particle system
  17099. */
  17100. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17101. /**
  17102. * Remove a specific color gradient
  17103. * @param gradient defines the gradient to remove
  17104. * @returns this particle system
  17105. */
  17106. removeColorGradient(gradient: number): IParticleSystem;
  17107. private _fetchR;
  17108. protected _reset(): void;
  17109. private _resetEffect;
  17110. private _createVertexBuffers;
  17111. private _createIndexBuffer;
  17112. /**
  17113. * Gets the maximum number of particles active at the same time.
  17114. * @returns The max number of active particles.
  17115. */
  17116. getCapacity(): number;
  17117. /**
  17118. * Gets whether there are still active particles in the system.
  17119. * @returns True if it is alive, otherwise false.
  17120. */
  17121. isAlive(): boolean;
  17122. /**
  17123. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17124. * @returns True if it has been started, otherwise false.
  17125. */
  17126. isStarted(): boolean;
  17127. private _prepareSubEmitterInternalArray;
  17128. /**
  17129. * Starts the particle system and begins to emit
  17130. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17131. */
  17132. start(delay?: number): void;
  17133. /**
  17134. * Stops the particle system.
  17135. * @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.
  17136. */
  17137. stop(stopSubEmitters?: boolean): void;
  17138. /**
  17139. * Remove all active particles
  17140. */
  17141. reset(): void;
  17142. /**
  17143. * @hidden (for internal use only)
  17144. */
  17145. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17146. /**
  17147. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17148. * Its lifetime will start back at 0.
  17149. */
  17150. recycleParticle: (particle: Particle) => void;
  17151. private _stopSubEmitters;
  17152. private _createParticle;
  17153. private _removeFromRoot;
  17154. private _emitFromParticle;
  17155. private _update;
  17156. /** @hidden */
  17157. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17158. /** @hidden */
  17159. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17160. /** @hidden */
  17161. private _getEffect;
  17162. /**
  17163. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17164. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17165. */
  17166. animate(preWarmOnly?: boolean): void;
  17167. private _appendParticleVertices;
  17168. /**
  17169. * Rebuilds the particle system.
  17170. */
  17171. rebuild(): void;
  17172. /**
  17173. * Is this system ready to be used/rendered
  17174. * @return true if the system is ready
  17175. */
  17176. isReady(): boolean;
  17177. private _render;
  17178. /**
  17179. * Renders the particle system in its current state.
  17180. * @returns the current number of particles
  17181. */
  17182. render(): number;
  17183. /**
  17184. * Disposes the particle system and free the associated resources
  17185. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17186. */
  17187. dispose(disposeTexture?: boolean): void;
  17188. /**
  17189. * Clones the particle system.
  17190. * @param name The name of the cloned object
  17191. * @param newEmitter The new emitter to use
  17192. * @returns the cloned particle system
  17193. */
  17194. clone(name: string, newEmitter: any): ParticleSystem;
  17195. /**
  17196. * Serializes the particle system to a JSON object.
  17197. * @returns the JSON object
  17198. */
  17199. serialize(): any;
  17200. /** @hidden */
  17201. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17202. /** @hidden */
  17203. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17204. /**
  17205. * Parses a JSON object to create a particle system.
  17206. * @param parsedParticleSystem The JSON object to parse
  17207. * @param scene The scene to create the particle system in
  17208. * @param rootUrl The root url to use to load external dependencies like texture
  17209. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17210. * @returns the Parsed particle system
  17211. */
  17212. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17213. }
  17214. }
  17215. declare module BABYLON {
  17216. /**
  17217. * A particle represents one of the element emitted by a particle system.
  17218. * This is mainly define by its coordinates, direction, velocity and age.
  17219. */
  17220. export class Particle {
  17221. /**
  17222. * The particle system the particle belongs to.
  17223. */
  17224. particleSystem: ParticleSystem;
  17225. private static _Count;
  17226. /**
  17227. * Unique ID of the particle
  17228. */
  17229. id: number;
  17230. /**
  17231. * The world position of the particle in the scene.
  17232. */
  17233. position: Vector3;
  17234. /**
  17235. * The world direction of the particle in the scene.
  17236. */
  17237. direction: Vector3;
  17238. /**
  17239. * The color of the particle.
  17240. */
  17241. color: Color4;
  17242. /**
  17243. * The color change of the particle per step.
  17244. */
  17245. colorStep: Color4;
  17246. /**
  17247. * Defines how long will the life of the particle be.
  17248. */
  17249. lifeTime: number;
  17250. /**
  17251. * The current age of the particle.
  17252. */
  17253. age: number;
  17254. /**
  17255. * The current size of the particle.
  17256. */
  17257. size: number;
  17258. /**
  17259. * The current scale of the particle.
  17260. */
  17261. scale: Vector2;
  17262. /**
  17263. * The current angle of the particle.
  17264. */
  17265. angle: number;
  17266. /**
  17267. * Defines how fast is the angle changing.
  17268. */
  17269. angularSpeed: number;
  17270. /**
  17271. * Defines the cell index used by the particle to be rendered from a sprite.
  17272. */
  17273. cellIndex: number;
  17274. /**
  17275. * The information required to support color remapping
  17276. */
  17277. remapData: Vector4;
  17278. /** @hidden */
  17279. _randomCellOffset?: number;
  17280. /** @hidden */
  17281. _initialDirection: Nullable<Vector3>;
  17282. /** @hidden */
  17283. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17284. /** @hidden */
  17285. _initialStartSpriteCellID: number;
  17286. /** @hidden */
  17287. _initialEndSpriteCellID: number;
  17288. /** @hidden */
  17289. _currentColorGradient: Nullable<ColorGradient>;
  17290. /** @hidden */
  17291. _currentColor1: Color4;
  17292. /** @hidden */
  17293. _currentColor2: Color4;
  17294. /** @hidden */
  17295. _currentSizeGradient: Nullable<FactorGradient>;
  17296. /** @hidden */
  17297. _currentSize1: number;
  17298. /** @hidden */
  17299. _currentSize2: number;
  17300. /** @hidden */
  17301. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17302. /** @hidden */
  17303. _currentAngularSpeed1: number;
  17304. /** @hidden */
  17305. _currentAngularSpeed2: number;
  17306. /** @hidden */
  17307. _currentVelocityGradient: Nullable<FactorGradient>;
  17308. /** @hidden */
  17309. _currentVelocity1: number;
  17310. /** @hidden */
  17311. _currentVelocity2: number;
  17312. /** @hidden */
  17313. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17314. /** @hidden */
  17315. _currentLimitVelocity1: number;
  17316. /** @hidden */
  17317. _currentLimitVelocity2: number;
  17318. /** @hidden */
  17319. _currentDragGradient: Nullable<FactorGradient>;
  17320. /** @hidden */
  17321. _currentDrag1: number;
  17322. /** @hidden */
  17323. _currentDrag2: number;
  17324. /** @hidden */
  17325. _randomNoiseCoordinates1: Vector3;
  17326. /** @hidden */
  17327. _randomNoiseCoordinates2: Vector3;
  17328. /**
  17329. * Creates a new instance Particle
  17330. * @param particleSystem the particle system the particle belongs to
  17331. */
  17332. constructor(
  17333. /**
  17334. * The particle system the particle belongs to.
  17335. */
  17336. particleSystem: ParticleSystem);
  17337. private updateCellInfoFromSystem;
  17338. /**
  17339. * Defines how the sprite cell index is updated for the particle
  17340. */
  17341. updateCellIndex(): void;
  17342. /** @hidden */
  17343. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17344. /** @hidden */
  17345. _inheritParticleInfoToSubEmitters(): void;
  17346. /** @hidden */
  17347. _reset(): void;
  17348. /**
  17349. * Copy the properties of particle to another one.
  17350. * @param other the particle to copy the information to.
  17351. */
  17352. copyTo(other: Particle): void;
  17353. }
  17354. }
  17355. declare module BABYLON {
  17356. /**
  17357. * Particle emitter represents a volume emitting particles.
  17358. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17359. */
  17360. export interface IParticleEmitterType {
  17361. /**
  17362. * Called by the particle System when the direction is computed for the created particle.
  17363. * @param worldMatrix is the world matrix of the particle system
  17364. * @param directionToUpdate is the direction vector to update with the result
  17365. * @param particle is the particle we are computed the direction for
  17366. */
  17367. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17368. /**
  17369. * Called by the particle System when the position is computed for the created particle.
  17370. * @param worldMatrix is the world matrix of the particle system
  17371. * @param positionToUpdate is the position vector to update with the result
  17372. * @param particle is the particle we are computed the position for
  17373. */
  17374. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17375. /**
  17376. * Clones the current emitter and returns a copy of it
  17377. * @returns the new emitter
  17378. */
  17379. clone(): IParticleEmitterType;
  17380. /**
  17381. * Called by the GPUParticleSystem to setup the update shader
  17382. * @param effect defines the update shader
  17383. */
  17384. applyToShader(effect: Effect): void;
  17385. /**
  17386. * Returns a string to use to update the GPU particles update shader
  17387. * @returns the effect defines string
  17388. */
  17389. getEffectDefines(): string;
  17390. /**
  17391. * Returns a string representing the class name
  17392. * @returns a string containing the class name
  17393. */
  17394. getClassName(): string;
  17395. /**
  17396. * Serializes the particle system to a JSON object.
  17397. * @returns the JSON object
  17398. */
  17399. serialize(): any;
  17400. /**
  17401. * Parse properties from a JSON object
  17402. * @param serializationObject defines the JSON object
  17403. */
  17404. parse(serializationObject: any): void;
  17405. }
  17406. }
  17407. declare module BABYLON {
  17408. /**
  17409. * Particle emitter emitting particles from the inside of a box.
  17410. * It emits the particles randomly between 2 given directions.
  17411. */
  17412. export class BoxParticleEmitter implements IParticleEmitterType {
  17413. /**
  17414. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17415. */
  17416. direction1: Vector3;
  17417. /**
  17418. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17419. */
  17420. direction2: Vector3;
  17421. /**
  17422. * 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.
  17423. */
  17424. minEmitBox: Vector3;
  17425. /**
  17426. * 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.
  17427. */
  17428. maxEmitBox: Vector3;
  17429. /**
  17430. * Creates a new instance BoxParticleEmitter
  17431. */
  17432. constructor();
  17433. /**
  17434. * Called by the particle System when the direction is computed for the created particle.
  17435. * @param worldMatrix is the world matrix of the particle system
  17436. * @param directionToUpdate is the direction vector to update with the result
  17437. * @param particle is the particle we are computed the direction for
  17438. */
  17439. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17440. /**
  17441. * Called by the particle System when the position is computed for the created particle.
  17442. * @param worldMatrix is the world matrix of the particle system
  17443. * @param positionToUpdate is the position vector to update with the result
  17444. * @param particle is the particle we are computed the position for
  17445. */
  17446. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17447. /**
  17448. * Clones the current emitter and returns a copy of it
  17449. * @returns the new emitter
  17450. */
  17451. clone(): BoxParticleEmitter;
  17452. /**
  17453. * Called by the GPUParticleSystem to setup the update shader
  17454. * @param effect defines the update shader
  17455. */
  17456. applyToShader(effect: Effect): void;
  17457. /**
  17458. * Returns a string to use to update the GPU particles update shader
  17459. * @returns a string containng the defines string
  17460. */
  17461. getEffectDefines(): string;
  17462. /**
  17463. * Returns the string "BoxParticleEmitter"
  17464. * @returns a string containing the class name
  17465. */
  17466. getClassName(): string;
  17467. /**
  17468. * Serializes the particle system to a JSON object.
  17469. * @returns the JSON object
  17470. */
  17471. serialize(): any;
  17472. /**
  17473. * Parse properties from a JSON object
  17474. * @param serializationObject defines the JSON object
  17475. */
  17476. parse(serializationObject: any): void;
  17477. }
  17478. }
  17479. declare module BABYLON {
  17480. /**
  17481. * Particle emitter emitting particles from the inside of a cone.
  17482. * It emits the particles alongside the cone volume from the base to the particle.
  17483. * The emission direction might be randomized.
  17484. */
  17485. export class ConeParticleEmitter implements IParticleEmitterType {
  17486. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17487. directionRandomizer: number;
  17488. private _radius;
  17489. private _angle;
  17490. private _height;
  17491. /**
  17492. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17493. */
  17494. radiusRange: number;
  17495. /**
  17496. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17497. */
  17498. heightRange: number;
  17499. /**
  17500. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17501. */
  17502. emitFromSpawnPointOnly: boolean;
  17503. /**
  17504. * Gets or sets the radius of the emission cone
  17505. */
  17506. radius: number;
  17507. /**
  17508. * Gets or sets the angle of the emission cone
  17509. */
  17510. angle: number;
  17511. private _buildHeight;
  17512. /**
  17513. * Creates a new instance ConeParticleEmitter
  17514. * @param radius the radius of the emission cone (1 by default)
  17515. * @param angle the cone base angle (PI by default)
  17516. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17517. */
  17518. constructor(radius?: number, angle?: number,
  17519. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17520. directionRandomizer?: number);
  17521. /**
  17522. * Called by the particle System when the direction is computed for the created particle.
  17523. * @param worldMatrix is the world matrix of the particle system
  17524. * @param directionToUpdate is the direction vector to update with the result
  17525. * @param particle is the particle we are computed the direction for
  17526. */
  17527. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17528. /**
  17529. * Called by the particle System when the position is computed for the created particle.
  17530. * @param worldMatrix is the world matrix of the particle system
  17531. * @param positionToUpdate is the position vector to update with the result
  17532. * @param particle is the particle we are computed the position for
  17533. */
  17534. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17535. /**
  17536. * Clones the current emitter and returns a copy of it
  17537. * @returns the new emitter
  17538. */
  17539. clone(): ConeParticleEmitter;
  17540. /**
  17541. * Called by the GPUParticleSystem to setup the update shader
  17542. * @param effect defines the update shader
  17543. */
  17544. applyToShader(effect: Effect): void;
  17545. /**
  17546. * Returns a string to use to update the GPU particles update shader
  17547. * @returns a string containng the defines string
  17548. */
  17549. getEffectDefines(): string;
  17550. /**
  17551. * Returns the string "ConeParticleEmitter"
  17552. * @returns a string containing the class name
  17553. */
  17554. getClassName(): string;
  17555. /**
  17556. * Serializes the particle system to a JSON object.
  17557. * @returns the JSON object
  17558. */
  17559. serialize(): any;
  17560. /**
  17561. * Parse properties from a JSON object
  17562. * @param serializationObject defines the JSON object
  17563. */
  17564. parse(serializationObject: any): void;
  17565. }
  17566. }
  17567. declare module BABYLON {
  17568. /**
  17569. * Particle emitter emitting particles from the inside of a cylinder.
  17570. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17571. */
  17572. export class CylinderParticleEmitter implements IParticleEmitterType {
  17573. /**
  17574. * The radius of the emission cylinder.
  17575. */
  17576. radius: number;
  17577. /**
  17578. * The height of the emission cylinder.
  17579. */
  17580. height: number;
  17581. /**
  17582. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17583. */
  17584. radiusRange: number;
  17585. /**
  17586. * How much to randomize the particle direction [0-1].
  17587. */
  17588. directionRandomizer: number;
  17589. /**
  17590. * Creates a new instance CylinderParticleEmitter
  17591. * @param radius the radius of the emission cylinder (1 by default)
  17592. * @param height the height of the emission cylinder (1 by default)
  17593. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17594. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17595. */
  17596. constructor(
  17597. /**
  17598. * The radius of the emission cylinder.
  17599. */
  17600. radius?: number,
  17601. /**
  17602. * The height of the emission cylinder.
  17603. */
  17604. height?: number,
  17605. /**
  17606. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17607. */
  17608. radiusRange?: number,
  17609. /**
  17610. * How much to randomize the particle direction [0-1].
  17611. */
  17612. directionRandomizer?: number);
  17613. /**
  17614. * Called by the particle System when the direction is computed for the created particle.
  17615. * @param worldMatrix is the world matrix of the particle system
  17616. * @param directionToUpdate is the direction vector to update with the result
  17617. * @param particle is the particle we are computed the direction for
  17618. */
  17619. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17620. /**
  17621. * Called by the particle System when the position is computed for the created particle.
  17622. * @param worldMatrix is the world matrix of the particle system
  17623. * @param positionToUpdate is the position vector to update with the result
  17624. * @param particle is the particle we are computed the position for
  17625. */
  17626. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17627. /**
  17628. * Clones the current emitter and returns a copy of it
  17629. * @returns the new emitter
  17630. */
  17631. clone(): CylinderParticleEmitter;
  17632. /**
  17633. * Called by the GPUParticleSystem to setup the update shader
  17634. * @param effect defines the update shader
  17635. */
  17636. applyToShader(effect: Effect): void;
  17637. /**
  17638. * Returns a string to use to update the GPU particles update shader
  17639. * @returns a string containng the defines string
  17640. */
  17641. getEffectDefines(): string;
  17642. /**
  17643. * Returns the string "CylinderParticleEmitter"
  17644. * @returns a string containing the class name
  17645. */
  17646. getClassName(): string;
  17647. /**
  17648. * Serializes the particle system to a JSON object.
  17649. * @returns the JSON object
  17650. */
  17651. serialize(): any;
  17652. /**
  17653. * Parse properties from a JSON object
  17654. * @param serializationObject defines the JSON object
  17655. */
  17656. parse(serializationObject: any): void;
  17657. }
  17658. /**
  17659. * Particle emitter emitting particles from the inside of a cylinder.
  17660. * It emits the particles randomly between two vectors.
  17661. */
  17662. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17663. /**
  17664. * The min limit of the emission direction.
  17665. */
  17666. direction1: Vector3;
  17667. /**
  17668. * The max limit of the emission direction.
  17669. */
  17670. direction2: Vector3;
  17671. /**
  17672. * Creates a new instance CylinderDirectedParticleEmitter
  17673. * @param radius the radius of the emission cylinder (1 by default)
  17674. * @param height the height of the emission cylinder (1 by default)
  17675. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17676. * @param direction1 the min limit of the emission direction (up vector by default)
  17677. * @param direction2 the max limit of the emission direction (up vector by default)
  17678. */
  17679. constructor(radius?: number, height?: number, radiusRange?: number,
  17680. /**
  17681. * The min limit of the emission direction.
  17682. */
  17683. direction1?: Vector3,
  17684. /**
  17685. * The max limit of the emission direction.
  17686. */
  17687. direction2?: Vector3);
  17688. /**
  17689. * Called by the particle System when the direction is computed for the created particle.
  17690. * @param worldMatrix is the world matrix of the particle system
  17691. * @param directionToUpdate is the direction vector to update with the result
  17692. * @param particle is the particle we are computed the direction for
  17693. */
  17694. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17695. /**
  17696. * Clones the current emitter and returns a copy of it
  17697. * @returns the new emitter
  17698. */
  17699. clone(): CylinderDirectedParticleEmitter;
  17700. /**
  17701. * Called by the GPUParticleSystem to setup the update shader
  17702. * @param effect defines the update shader
  17703. */
  17704. applyToShader(effect: Effect): void;
  17705. /**
  17706. * Returns a string to use to update the GPU particles update shader
  17707. * @returns a string containng the defines string
  17708. */
  17709. getEffectDefines(): string;
  17710. /**
  17711. * Returns the string "CylinderDirectedParticleEmitter"
  17712. * @returns a string containing the class name
  17713. */
  17714. getClassName(): string;
  17715. /**
  17716. * Serializes the particle system to a JSON object.
  17717. * @returns the JSON object
  17718. */
  17719. serialize(): any;
  17720. /**
  17721. * Parse properties from a JSON object
  17722. * @param serializationObject defines the JSON object
  17723. */
  17724. parse(serializationObject: any): void;
  17725. }
  17726. }
  17727. declare module BABYLON {
  17728. /**
  17729. * Particle emitter emitting particles from the inside of a hemisphere.
  17730. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17731. */
  17732. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17733. /**
  17734. * The radius of the emission hemisphere.
  17735. */
  17736. radius: number;
  17737. /**
  17738. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17739. */
  17740. radiusRange: number;
  17741. /**
  17742. * How much to randomize the particle direction [0-1].
  17743. */
  17744. directionRandomizer: number;
  17745. /**
  17746. * Creates a new instance HemisphericParticleEmitter
  17747. * @param radius the radius of the emission hemisphere (1 by default)
  17748. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17749. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17750. */
  17751. constructor(
  17752. /**
  17753. * The radius of the emission hemisphere.
  17754. */
  17755. radius?: number,
  17756. /**
  17757. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17758. */
  17759. radiusRange?: number,
  17760. /**
  17761. * How much to randomize the particle direction [0-1].
  17762. */
  17763. directionRandomizer?: number);
  17764. /**
  17765. * Called by the particle System when the direction is computed for the created particle.
  17766. * @param worldMatrix is the world matrix of the particle system
  17767. * @param directionToUpdate is the direction vector to update with the result
  17768. * @param particle is the particle we are computed the direction for
  17769. */
  17770. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17771. /**
  17772. * Called by the particle System when the position is computed for the created particle.
  17773. * @param worldMatrix is the world matrix of the particle system
  17774. * @param positionToUpdate is the position vector to update with the result
  17775. * @param particle is the particle we are computed the position for
  17776. */
  17777. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17778. /**
  17779. * Clones the current emitter and returns a copy of it
  17780. * @returns the new emitter
  17781. */
  17782. clone(): HemisphericParticleEmitter;
  17783. /**
  17784. * Called by the GPUParticleSystem to setup the update shader
  17785. * @param effect defines the update shader
  17786. */
  17787. applyToShader(effect: Effect): void;
  17788. /**
  17789. * Returns a string to use to update the GPU particles update shader
  17790. * @returns a string containng the defines string
  17791. */
  17792. getEffectDefines(): string;
  17793. /**
  17794. * Returns the string "HemisphericParticleEmitter"
  17795. * @returns a string containing the class name
  17796. */
  17797. getClassName(): string;
  17798. /**
  17799. * Serializes the particle system to a JSON object.
  17800. * @returns the JSON object
  17801. */
  17802. serialize(): any;
  17803. /**
  17804. * Parse properties from a JSON object
  17805. * @param serializationObject defines the JSON object
  17806. */
  17807. parse(serializationObject: any): void;
  17808. }
  17809. }
  17810. declare module BABYLON {
  17811. /**
  17812. * Particle emitter emitting particles from a point.
  17813. * It emits the particles randomly between 2 given directions.
  17814. */
  17815. export class PointParticleEmitter implements IParticleEmitterType {
  17816. /**
  17817. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17818. */
  17819. direction1: Vector3;
  17820. /**
  17821. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17822. */
  17823. direction2: Vector3;
  17824. /**
  17825. * Creates a new instance PointParticleEmitter
  17826. */
  17827. constructor();
  17828. /**
  17829. * Called by the particle System when the direction is computed for the created particle.
  17830. * @param worldMatrix is the world matrix of the particle system
  17831. * @param directionToUpdate is the direction vector to update with the result
  17832. * @param particle is the particle we are computed the direction for
  17833. */
  17834. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17835. /**
  17836. * Called by the particle System when the position is computed for the created particle.
  17837. * @param worldMatrix is the world matrix of the particle system
  17838. * @param positionToUpdate is the position vector to update with the result
  17839. * @param particle is the particle we are computed the position for
  17840. */
  17841. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17842. /**
  17843. * Clones the current emitter and returns a copy of it
  17844. * @returns the new emitter
  17845. */
  17846. clone(): PointParticleEmitter;
  17847. /**
  17848. * Called by the GPUParticleSystem to setup the update shader
  17849. * @param effect defines the update shader
  17850. */
  17851. applyToShader(effect: Effect): void;
  17852. /**
  17853. * Returns a string to use to update the GPU particles update shader
  17854. * @returns a string containng the defines string
  17855. */
  17856. getEffectDefines(): string;
  17857. /**
  17858. * Returns the string "PointParticleEmitter"
  17859. * @returns a string containing the class name
  17860. */
  17861. getClassName(): string;
  17862. /**
  17863. * Serializes the particle system to a JSON object.
  17864. * @returns the JSON object
  17865. */
  17866. serialize(): any;
  17867. /**
  17868. * Parse properties from a JSON object
  17869. * @param serializationObject defines the JSON object
  17870. */
  17871. parse(serializationObject: any): void;
  17872. }
  17873. }
  17874. declare module BABYLON {
  17875. /**
  17876. * Particle emitter emitting particles from the inside of a sphere.
  17877. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  17878. */
  17879. export class SphereParticleEmitter implements IParticleEmitterType {
  17880. /**
  17881. * The radius of the emission sphere.
  17882. */
  17883. radius: number;
  17884. /**
  17885. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17886. */
  17887. radiusRange: number;
  17888. /**
  17889. * How much to randomize the particle direction [0-1].
  17890. */
  17891. directionRandomizer: number;
  17892. /**
  17893. * Creates a new instance SphereParticleEmitter
  17894. * @param radius the radius of the emission sphere (1 by default)
  17895. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17896. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17897. */
  17898. constructor(
  17899. /**
  17900. * The radius of the emission sphere.
  17901. */
  17902. radius?: number,
  17903. /**
  17904. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17905. */
  17906. radiusRange?: number,
  17907. /**
  17908. * How much to randomize the particle direction [0-1].
  17909. */
  17910. directionRandomizer?: number);
  17911. /**
  17912. * Called by the particle System when the direction is computed for the created particle.
  17913. * @param worldMatrix is the world matrix of the particle system
  17914. * @param directionToUpdate is the direction vector to update with the result
  17915. * @param particle is the particle we are computed the direction for
  17916. */
  17917. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17918. /**
  17919. * Called by the particle System when the position is computed for the created particle.
  17920. * @param worldMatrix is the world matrix of the particle system
  17921. * @param positionToUpdate is the position vector to update with the result
  17922. * @param particle is the particle we are computed the position for
  17923. */
  17924. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17925. /**
  17926. * Clones the current emitter and returns a copy of it
  17927. * @returns the new emitter
  17928. */
  17929. clone(): SphereParticleEmitter;
  17930. /**
  17931. * Called by the GPUParticleSystem to setup the update shader
  17932. * @param effect defines the update shader
  17933. */
  17934. applyToShader(effect: Effect): void;
  17935. /**
  17936. * Returns a string to use to update the GPU particles update shader
  17937. * @returns a string containng the defines string
  17938. */
  17939. getEffectDefines(): string;
  17940. /**
  17941. * Returns the string "SphereParticleEmitter"
  17942. * @returns a string containing the class name
  17943. */
  17944. getClassName(): string;
  17945. /**
  17946. * Serializes the particle system to a JSON object.
  17947. * @returns the JSON object
  17948. */
  17949. serialize(): any;
  17950. /**
  17951. * Parse properties from a JSON object
  17952. * @param serializationObject defines the JSON object
  17953. */
  17954. parse(serializationObject: any): void;
  17955. }
  17956. /**
  17957. * Particle emitter emitting particles from the inside of a sphere.
  17958. * It emits the particles randomly between two vectors.
  17959. */
  17960. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  17961. /**
  17962. * The min limit of the emission direction.
  17963. */
  17964. direction1: Vector3;
  17965. /**
  17966. * The max limit of the emission direction.
  17967. */
  17968. direction2: Vector3;
  17969. /**
  17970. * Creates a new instance SphereDirectedParticleEmitter
  17971. * @param radius the radius of the emission sphere (1 by default)
  17972. * @param direction1 the min limit of the emission direction (up vector by default)
  17973. * @param direction2 the max limit of the emission direction (up vector by default)
  17974. */
  17975. constructor(radius?: number,
  17976. /**
  17977. * The min limit of the emission direction.
  17978. */
  17979. direction1?: Vector3,
  17980. /**
  17981. * The max limit of the emission direction.
  17982. */
  17983. direction2?: Vector3);
  17984. /**
  17985. * Called by the particle System when the direction is computed for the created particle.
  17986. * @param worldMatrix is the world matrix of the particle system
  17987. * @param directionToUpdate is the direction vector to update with the result
  17988. * @param particle is the particle we are computed the direction for
  17989. */
  17990. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17991. /**
  17992. * Clones the current emitter and returns a copy of it
  17993. * @returns the new emitter
  17994. */
  17995. clone(): SphereDirectedParticleEmitter;
  17996. /**
  17997. * Called by the GPUParticleSystem to setup the update shader
  17998. * @param effect defines the update shader
  17999. */
  18000. applyToShader(effect: Effect): void;
  18001. /**
  18002. * Returns a string to use to update the GPU particles update shader
  18003. * @returns a string containng the defines string
  18004. */
  18005. getEffectDefines(): string;
  18006. /**
  18007. * Returns the string "SphereDirectedParticleEmitter"
  18008. * @returns a string containing the class name
  18009. */
  18010. getClassName(): string;
  18011. /**
  18012. * Serializes the particle system to a JSON object.
  18013. * @returns the JSON object
  18014. */
  18015. serialize(): any;
  18016. /**
  18017. * Parse properties from a JSON object
  18018. * @param serializationObject defines the JSON object
  18019. */
  18020. parse(serializationObject: any): void;
  18021. }
  18022. }
  18023. declare module BABYLON {
  18024. /**
  18025. * Interface representing a particle system in Babylon.js.
  18026. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18027. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18028. */
  18029. export interface IParticleSystem {
  18030. /**
  18031. * List of animations used by the particle system.
  18032. */
  18033. animations: Animation[];
  18034. /**
  18035. * The id of the Particle system.
  18036. */
  18037. id: string;
  18038. /**
  18039. * The name of the Particle system.
  18040. */
  18041. name: string;
  18042. /**
  18043. * The emitter represents the Mesh or position we are attaching the particle system to.
  18044. */
  18045. emitter: Nullable<AbstractMesh | Vector3>;
  18046. /**
  18047. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18048. */
  18049. isBillboardBased: boolean;
  18050. /**
  18051. * The rendering group used by the Particle system to chose when to render.
  18052. */
  18053. renderingGroupId: number;
  18054. /**
  18055. * The layer mask we are rendering the particles through.
  18056. */
  18057. layerMask: number;
  18058. /**
  18059. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18060. */
  18061. updateSpeed: number;
  18062. /**
  18063. * The amount of time the particle system is running (depends of the overall update speed).
  18064. */
  18065. targetStopDuration: number;
  18066. /**
  18067. * The texture used to render each particle. (this can be a spritesheet)
  18068. */
  18069. particleTexture: Nullable<Texture>;
  18070. /**
  18071. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18072. */
  18073. blendMode: number;
  18074. /**
  18075. * Minimum life time of emitting particles.
  18076. */
  18077. minLifeTime: number;
  18078. /**
  18079. * Maximum life time of emitting particles.
  18080. */
  18081. maxLifeTime: number;
  18082. /**
  18083. * Minimum Size of emitting particles.
  18084. */
  18085. minSize: number;
  18086. /**
  18087. * Maximum Size of emitting particles.
  18088. */
  18089. maxSize: number;
  18090. /**
  18091. * Minimum scale of emitting particles on X axis.
  18092. */
  18093. minScaleX: number;
  18094. /**
  18095. * Maximum scale of emitting particles on X axis.
  18096. */
  18097. maxScaleX: number;
  18098. /**
  18099. * Minimum scale of emitting particles on Y axis.
  18100. */
  18101. minScaleY: number;
  18102. /**
  18103. * Maximum scale of emitting particles on Y axis.
  18104. */
  18105. maxScaleY: number;
  18106. /**
  18107. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18108. */
  18109. color1: Color4;
  18110. /**
  18111. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18112. */
  18113. color2: Color4;
  18114. /**
  18115. * Color the particle will have at the end of its lifetime.
  18116. */
  18117. colorDead: Color4;
  18118. /**
  18119. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18120. */
  18121. emitRate: number;
  18122. /**
  18123. * You can use gravity if you want to give an orientation to your particles.
  18124. */
  18125. gravity: Vector3;
  18126. /**
  18127. * Minimum power of emitting particles.
  18128. */
  18129. minEmitPower: number;
  18130. /**
  18131. * Maximum power of emitting particles.
  18132. */
  18133. maxEmitPower: number;
  18134. /**
  18135. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18136. */
  18137. minAngularSpeed: number;
  18138. /**
  18139. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18140. */
  18141. maxAngularSpeed: number;
  18142. /**
  18143. * Gets or sets the minimal initial rotation in radians.
  18144. */
  18145. minInitialRotation: number;
  18146. /**
  18147. * Gets or sets the maximal initial rotation in radians.
  18148. */
  18149. maxInitialRotation: number;
  18150. /**
  18151. * The particle emitter type defines the emitter used by the particle system.
  18152. * It can be for example box, sphere, or cone...
  18153. */
  18154. particleEmitterType: Nullable<IParticleEmitterType>;
  18155. /**
  18156. * Defines the delay in milliseconds before starting the system (0 by default)
  18157. */
  18158. startDelay: number;
  18159. /**
  18160. * 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
  18161. */
  18162. preWarmCycles: number;
  18163. /**
  18164. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18165. */
  18166. preWarmStepOffset: number;
  18167. /**
  18168. * 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)
  18169. */
  18170. spriteCellChangeSpeed: number;
  18171. /**
  18172. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18173. */
  18174. startSpriteCellID: number;
  18175. /**
  18176. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18177. */
  18178. endSpriteCellID: number;
  18179. /**
  18180. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18181. */
  18182. spriteCellWidth: number;
  18183. /**
  18184. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18185. */
  18186. spriteCellHeight: number;
  18187. /**
  18188. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18189. */
  18190. spriteRandomStartCell: boolean;
  18191. /**
  18192. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18193. */
  18194. isAnimationSheetEnabled: boolean;
  18195. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18196. translationPivot: Vector2;
  18197. /**
  18198. * Gets or sets a texture used to add random noise to particle positions
  18199. */
  18200. noiseTexture: Nullable<BaseTexture>;
  18201. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18202. noiseStrength: Vector3;
  18203. /**
  18204. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18205. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18206. */
  18207. billboardMode: number;
  18208. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18209. limitVelocityDamping: number;
  18210. /**
  18211. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18212. */
  18213. beginAnimationOnStart: boolean;
  18214. /**
  18215. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18216. */
  18217. beginAnimationFrom: number;
  18218. /**
  18219. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18220. */
  18221. beginAnimationTo: number;
  18222. /**
  18223. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18224. */
  18225. beginAnimationLoop: boolean;
  18226. /**
  18227. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18228. */
  18229. disposeOnStop: boolean;
  18230. /**
  18231. * Gets the maximum number of particles active at the same time.
  18232. * @returns The max number of active particles.
  18233. */
  18234. getCapacity(): number;
  18235. /**
  18236. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18237. * @returns True if it has been started, otherwise false.
  18238. */
  18239. isStarted(): boolean;
  18240. /**
  18241. * Animates the particle system for this frame.
  18242. */
  18243. animate(): void;
  18244. /**
  18245. * Renders the particle system in its current state.
  18246. * @returns the current number of particles
  18247. */
  18248. render(): number;
  18249. /**
  18250. * Dispose the particle system and frees its associated resources.
  18251. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18252. */
  18253. dispose(disposeTexture?: boolean): void;
  18254. /**
  18255. * Clones the particle system.
  18256. * @param name The name of the cloned object
  18257. * @param newEmitter The new emitter to use
  18258. * @returns the cloned particle system
  18259. */
  18260. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18261. /**
  18262. * Serializes the particle system to a JSON object.
  18263. * @returns the JSON object
  18264. */
  18265. serialize(): any;
  18266. /**
  18267. * Rebuild the particle system
  18268. */
  18269. rebuild(): void;
  18270. /**
  18271. * Starts the particle system and begins to emit
  18272. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18273. */
  18274. start(delay?: number): void;
  18275. /**
  18276. * Stops the particle system.
  18277. */
  18278. stop(): void;
  18279. /**
  18280. * Remove all active particles
  18281. */
  18282. reset(): void;
  18283. /**
  18284. * Is this system ready to be used/rendered
  18285. * @return true if the system is ready
  18286. */
  18287. isReady(): boolean;
  18288. /**
  18289. * Adds a new color gradient
  18290. * @param gradient defines the gradient to use (between 0 and 1)
  18291. * @param color1 defines the color to affect to the specified gradient
  18292. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18293. * @returns the current particle system
  18294. */
  18295. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18296. /**
  18297. * Remove a specific color gradient
  18298. * @param gradient defines the gradient to remove
  18299. * @returns the current particle system
  18300. */
  18301. removeColorGradient(gradient: number): IParticleSystem;
  18302. /**
  18303. * Adds a new size gradient
  18304. * @param gradient defines the gradient to use (between 0 and 1)
  18305. * @param factor defines the size factor to affect to the specified gradient
  18306. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18307. * @returns the current particle system
  18308. */
  18309. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18310. /**
  18311. * Remove a specific size gradient
  18312. * @param gradient defines the gradient to remove
  18313. * @returns the current particle system
  18314. */
  18315. removeSizeGradient(gradient: number): IParticleSystem;
  18316. /**
  18317. * Gets the current list of color gradients.
  18318. * You must use addColorGradient and removeColorGradient to udpate this list
  18319. * @returns the list of color gradients
  18320. */
  18321. getColorGradients(): Nullable<Array<ColorGradient>>;
  18322. /**
  18323. * Gets the current list of size gradients.
  18324. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18325. * @returns the list of size gradients
  18326. */
  18327. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18328. /**
  18329. * Gets the current list of angular speed gradients.
  18330. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18331. * @returns the list of angular speed gradients
  18332. */
  18333. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18334. /**
  18335. * Adds a new angular speed gradient
  18336. * @param gradient defines the gradient to use (between 0 and 1)
  18337. * @param factor defines the angular speed to affect to the specified gradient
  18338. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18339. * @returns the current particle system
  18340. */
  18341. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18342. /**
  18343. * Remove a specific angular speed gradient
  18344. * @param gradient defines the gradient to remove
  18345. * @returns the current particle system
  18346. */
  18347. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18348. /**
  18349. * Gets the current list of velocity gradients.
  18350. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18351. * @returns the list of velocity gradients
  18352. */
  18353. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18354. /**
  18355. * Adds a new velocity gradient
  18356. * @param gradient defines the gradient to use (between 0 and 1)
  18357. * @param factor defines the velocity to affect to the specified gradient
  18358. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18359. * @returns the current particle system
  18360. */
  18361. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18362. /**
  18363. * Remove a specific velocity gradient
  18364. * @param gradient defines the gradient to remove
  18365. * @returns the current particle system
  18366. */
  18367. removeVelocityGradient(gradient: number): IParticleSystem;
  18368. /**
  18369. * Gets the current list of limit velocity gradients.
  18370. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18371. * @returns the list of limit velocity gradients
  18372. */
  18373. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18374. /**
  18375. * Adds a new limit velocity gradient
  18376. * @param gradient defines the gradient to use (between 0 and 1)
  18377. * @param factor defines the limit velocity to affect to the specified gradient
  18378. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18379. * @returns the current particle system
  18380. */
  18381. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18382. /**
  18383. * Remove a specific limit velocity gradient
  18384. * @param gradient defines the gradient to remove
  18385. * @returns the current particle system
  18386. */
  18387. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18388. /**
  18389. * Adds a new drag gradient
  18390. * @param gradient defines the gradient to use (between 0 and 1)
  18391. * @param factor defines the drag to affect to the specified gradient
  18392. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18393. * @returns the current particle system
  18394. */
  18395. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18396. /**
  18397. * Remove a specific drag gradient
  18398. * @param gradient defines the gradient to remove
  18399. * @returns the current particle system
  18400. */
  18401. removeDragGradient(gradient: number): IParticleSystem;
  18402. /**
  18403. * Gets the current list of drag gradients.
  18404. * You must use addDragGradient and removeDragGradient to udpate this list
  18405. * @returns the list of drag gradients
  18406. */
  18407. getDragGradients(): Nullable<Array<FactorGradient>>;
  18408. /**
  18409. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18410. * @param gradient defines the gradient to use (between 0 and 1)
  18411. * @param factor defines the emit rate to affect to the specified gradient
  18412. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18413. * @returns the current particle system
  18414. */
  18415. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18416. /**
  18417. * Remove a specific emit rate gradient
  18418. * @param gradient defines the gradient to remove
  18419. * @returns the current particle system
  18420. */
  18421. removeEmitRateGradient(gradient: number): IParticleSystem;
  18422. /**
  18423. * Gets the current list of emit rate gradients.
  18424. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18425. * @returns the list of emit rate gradients
  18426. */
  18427. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18428. /**
  18429. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18430. * @param gradient defines the gradient to use (between 0 and 1)
  18431. * @param factor defines the start size to affect to the specified gradient
  18432. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18433. * @returns the current particle system
  18434. */
  18435. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18436. /**
  18437. * Remove a specific start size gradient
  18438. * @param gradient defines the gradient to remove
  18439. * @returns the current particle system
  18440. */
  18441. removeStartSizeGradient(gradient: number): IParticleSystem;
  18442. /**
  18443. * Gets the current list of start size gradients.
  18444. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18445. * @returns the list of start size gradients
  18446. */
  18447. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18448. /**
  18449. * Adds a new life time gradient
  18450. * @param gradient defines the gradient to use (between 0 and 1)
  18451. * @param factor defines the life time factor to affect to the specified gradient
  18452. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18453. * @returns the current particle system
  18454. */
  18455. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18456. /**
  18457. * Remove a specific life time gradient
  18458. * @param gradient defines the gradient to remove
  18459. * @returns the current particle system
  18460. */
  18461. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18462. /**
  18463. * Gets the current list of life time gradients.
  18464. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18465. * @returns the list of life time gradients
  18466. */
  18467. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18468. /**
  18469. * Gets the current list of color gradients.
  18470. * You must use addColorGradient and removeColorGradient to udpate this list
  18471. * @returns the list of color gradients
  18472. */
  18473. getColorGradients(): Nullable<Array<ColorGradient>>;
  18474. /**
  18475. * Adds a new ramp gradient used to remap particle colors
  18476. * @param gradient defines the gradient to use (between 0 and 1)
  18477. * @param color defines the color to affect to the specified gradient
  18478. * @returns the current particle system
  18479. */
  18480. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18481. /**
  18482. * Gets the current list of ramp gradients.
  18483. * You must use addRampGradient and removeRampGradient to udpate this list
  18484. * @returns the list of ramp gradients
  18485. */
  18486. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18487. /** Gets or sets a boolean indicating that ramp gradients must be used
  18488. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18489. */
  18490. useRampGradients: boolean;
  18491. /**
  18492. * Adds a new color remap gradient
  18493. * @param gradient defines the gradient to use (between 0 and 1)
  18494. * @param min defines the color remap minimal range
  18495. * @param max defines the color remap maximal range
  18496. * @returns the current particle system
  18497. */
  18498. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18499. /**
  18500. * Gets the current list of color remap gradients.
  18501. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18502. * @returns the list of color remap gradients
  18503. */
  18504. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18505. /**
  18506. * Adds a new alpha remap gradient
  18507. * @param gradient defines the gradient to use (between 0 and 1)
  18508. * @param min defines the alpha remap minimal range
  18509. * @param max defines the alpha remap maximal range
  18510. * @returns the current particle system
  18511. */
  18512. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18513. /**
  18514. * Gets the current list of alpha remap gradients.
  18515. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18516. * @returns the list of alpha remap gradients
  18517. */
  18518. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18519. /**
  18520. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18521. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18522. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18523. * @returns the emitter
  18524. */
  18525. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18526. /**
  18527. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18528. * @param radius The radius of the hemisphere to emit from
  18529. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18530. * @returns the emitter
  18531. */
  18532. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18533. /**
  18534. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18535. * @param radius The radius of the sphere to emit from
  18536. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18537. * @returns the emitter
  18538. */
  18539. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18540. /**
  18541. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18542. * @param radius The radius of the sphere to emit from
  18543. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18544. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18545. * @returns the emitter
  18546. */
  18547. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18548. /**
  18549. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18550. * @param radius The radius of the emission cylinder
  18551. * @param height The height of the emission cylinder
  18552. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18553. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18554. * @returns the emitter
  18555. */
  18556. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18557. /**
  18558. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18559. * @param radius The radius of the cylinder to emit from
  18560. * @param height The height of the emission cylinder
  18561. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18562. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18563. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18564. * @returns the emitter
  18565. */
  18566. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18567. /**
  18568. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18569. * @param radius The radius of the cone to emit from
  18570. * @param angle The base angle of the cone
  18571. * @returns the emitter
  18572. */
  18573. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18574. /**
  18575. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18576. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18577. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18578. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18579. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18580. * @returns the emitter
  18581. */
  18582. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18583. /**
  18584. * Get hosting scene
  18585. * @returns the scene
  18586. */
  18587. getScene(): Scene;
  18588. }
  18589. }
  18590. declare module BABYLON {
  18591. /**
  18592. * Creates an instance based on a source mesh.
  18593. */
  18594. export class InstancedMesh extends AbstractMesh {
  18595. private _sourceMesh;
  18596. private _currentLOD;
  18597. /** @hidden */
  18598. _indexInSourceMeshInstanceArray: number;
  18599. constructor(name: string, source: Mesh);
  18600. /**
  18601. * Returns the string "InstancedMesh".
  18602. */
  18603. getClassName(): string;
  18604. /** Gets the list of lights affecting that mesh */
  18605. readonly lightSources: Light[];
  18606. _resyncLightSources(): void;
  18607. _resyncLighSource(light: Light): void;
  18608. _removeLightSource(light: Light, dispose: boolean): void;
  18609. /**
  18610. * If the source mesh receives shadows
  18611. */
  18612. readonly receiveShadows: boolean;
  18613. /**
  18614. * The material of the source mesh
  18615. */
  18616. readonly material: Nullable<Material>;
  18617. /**
  18618. * Visibility of the source mesh
  18619. */
  18620. readonly visibility: number;
  18621. /**
  18622. * Skeleton of the source mesh
  18623. */
  18624. readonly skeleton: Nullable<Skeleton>;
  18625. /**
  18626. * Rendering ground id of the source mesh
  18627. */
  18628. renderingGroupId: number;
  18629. /**
  18630. * Returns the total number of vertices (integer).
  18631. */
  18632. getTotalVertices(): number;
  18633. /**
  18634. * Returns a positive integer : the total number of indices in this mesh geometry.
  18635. * @returns the numner of indices or zero if the mesh has no geometry.
  18636. */
  18637. getTotalIndices(): number;
  18638. /**
  18639. * The source mesh of the instance
  18640. */
  18641. readonly sourceMesh: Mesh;
  18642. /**
  18643. * Is this node ready to be used/rendered
  18644. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18645. * @return {boolean} is it ready
  18646. */
  18647. isReady(completeCheck?: boolean): boolean;
  18648. /**
  18649. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18650. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  18651. * @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.
  18652. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18653. */
  18654. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18655. /**
  18656. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18657. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18658. * The `data` are either a numeric array either a Float32Array.
  18659. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  18660. * 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).
  18661. * Note that a new underlying VertexBuffer object is created each call.
  18662. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18663. *
  18664. * Possible `kind` values :
  18665. * - VertexBuffer.PositionKind
  18666. * - VertexBuffer.UVKind
  18667. * - VertexBuffer.UV2Kind
  18668. * - VertexBuffer.UV3Kind
  18669. * - VertexBuffer.UV4Kind
  18670. * - VertexBuffer.UV5Kind
  18671. * - VertexBuffer.UV6Kind
  18672. * - VertexBuffer.ColorKind
  18673. * - VertexBuffer.MatricesIndicesKind
  18674. * - VertexBuffer.MatricesIndicesExtraKind
  18675. * - VertexBuffer.MatricesWeightsKind
  18676. * - VertexBuffer.MatricesWeightsExtraKind
  18677. *
  18678. * Returns the Mesh.
  18679. */
  18680. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  18681. /**
  18682. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18683. * If the mesh has no geometry, it is simply returned as it is.
  18684. * The `data` are either a numeric array either a Float32Array.
  18685. * No new underlying VertexBuffer object is created.
  18686. * 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.
  18687. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  18688. *
  18689. * Possible `kind` values :
  18690. * - VertexBuffer.PositionKind
  18691. * - VertexBuffer.UVKind
  18692. * - VertexBuffer.UV2Kind
  18693. * - VertexBuffer.UV3Kind
  18694. * - VertexBuffer.UV4Kind
  18695. * - VertexBuffer.UV5Kind
  18696. * - VertexBuffer.UV6Kind
  18697. * - VertexBuffer.ColorKind
  18698. * - VertexBuffer.MatricesIndicesKind
  18699. * - VertexBuffer.MatricesIndicesExtraKind
  18700. * - VertexBuffer.MatricesWeightsKind
  18701. * - VertexBuffer.MatricesWeightsExtraKind
  18702. *
  18703. * Returns the Mesh.
  18704. */
  18705. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18706. /**
  18707. * Sets the mesh indices.
  18708. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  18709. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18710. * This method creates a new index buffer each call.
  18711. * Returns the Mesh.
  18712. */
  18713. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  18714. /**
  18715. * Boolean : True if the mesh owns the requested kind of data.
  18716. */
  18717. isVerticesDataPresent(kind: string): boolean;
  18718. /**
  18719. * Returns an array of indices (IndicesArray).
  18720. */
  18721. getIndices(): Nullable<IndicesArray>;
  18722. readonly _positions: Nullable<Vector3[]>;
  18723. /**
  18724. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  18725. * This means the mesh underlying bounding box and sphere are recomputed.
  18726. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  18727. * @returns the current mesh
  18728. */
  18729. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  18730. /** @hidden */
  18731. _preActivate(): InstancedMesh;
  18732. /** @hidden */
  18733. _activate(renderId: number, intermediateRendering: boolean): boolean;
  18734. /** @hidden */
  18735. _postActivate(): void;
  18736. getWorldMatrix(): Matrix;
  18737. readonly isAnInstance: boolean;
  18738. /**
  18739. * Returns the current associated LOD AbstractMesh.
  18740. */
  18741. getLOD(camera: Camera): AbstractMesh;
  18742. /** @hidden */
  18743. _syncSubMeshes(): InstancedMesh;
  18744. /** @hidden */
  18745. _generatePointsArray(): boolean;
  18746. /**
  18747. * Creates a new InstancedMesh from the current mesh.
  18748. * - name (string) : the cloned mesh name
  18749. * - newParent (optional Node) : the optional Node to parent the clone to.
  18750. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  18751. *
  18752. * Returns the clone.
  18753. */
  18754. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  18755. /**
  18756. * Disposes the InstancedMesh.
  18757. * Returns nothing.
  18758. */
  18759. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18760. }
  18761. }
  18762. declare module BABYLON {
  18763. /**
  18764. * Defines the options associated with the creation of a shader material.
  18765. */
  18766. export interface IShaderMaterialOptions {
  18767. /**
  18768. * Does the material work in alpha blend mode
  18769. */
  18770. needAlphaBlending: boolean;
  18771. /**
  18772. * Does the material work in alpha test mode
  18773. */
  18774. needAlphaTesting: boolean;
  18775. /**
  18776. * The list of attribute names used in the shader
  18777. */
  18778. attributes: string[];
  18779. /**
  18780. * The list of unifrom names used in the shader
  18781. */
  18782. uniforms: string[];
  18783. /**
  18784. * The list of UBO names used in the shader
  18785. */
  18786. uniformBuffers: string[];
  18787. /**
  18788. * The list of sampler names used in the shader
  18789. */
  18790. samplers: string[];
  18791. /**
  18792. * The list of defines used in the shader
  18793. */
  18794. defines: string[];
  18795. }
  18796. /**
  18797. * 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.
  18798. *
  18799. * This returned material effects how the mesh will look based on the code in the shaders.
  18800. *
  18801. * @see http://doc.babylonjs.com/how_to/shader_material
  18802. */
  18803. export class ShaderMaterial extends Material {
  18804. private _shaderPath;
  18805. private _options;
  18806. private _textures;
  18807. private _textureArrays;
  18808. private _floats;
  18809. private _ints;
  18810. private _floatsArrays;
  18811. private _colors3;
  18812. private _colors3Arrays;
  18813. private _colors4;
  18814. private _colors4Arrays;
  18815. private _vectors2;
  18816. private _vectors3;
  18817. private _vectors4;
  18818. private _matrices;
  18819. private _matrices3x3;
  18820. private _matrices2x2;
  18821. private _vectors2Arrays;
  18822. private _vectors3Arrays;
  18823. private _vectors4Arrays;
  18824. private _cachedWorldViewMatrix;
  18825. private _cachedWorldViewProjectionMatrix;
  18826. private _renderId;
  18827. /**
  18828. * Instantiate a new shader material.
  18829. * 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.
  18830. * This returned material effects how the mesh will look based on the code in the shaders.
  18831. * @see http://doc.babylonjs.com/how_to/shader_material
  18832. * @param name Define the name of the material in the scene
  18833. * @param scene Define the scene the material belongs to
  18834. * @param shaderPath Defines the route to the shader code in one of three ways:
  18835. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  18836. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  18837. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18838. * @param options Define the options used to create the shader
  18839. */
  18840. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18841. /**
  18842. * Gets the options used to compile the shader.
  18843. * They can be modified to trigger a new compilation
  18844. */
  18845. readonly options: IShaderMaterialOptions;
  18846. /**
  18847. * Gets the current class name of the material e.g. "ShaderMaterial"
  18848. * Mainly use in serialization.
  18849. * @returns the class name
  18850. */
  18851. getClassName(): string;
  18852. /**
  18853. * Specifies if the material will require alpha blending
  18854. * @returns a boolean specifying if alpha blending is needed
  18855. */
  18856. needAlphaBlending(): boolean;
  18857. /**
  18858. * Specifies if this material should be rendered in alpha test mode
  18859. * @returns a boolean specifying if an alpha test is needed.
  18860. */
  18861. needAlphaTesting(): boolean;
  18862. private _checkUniform;
  18863. /**
  18864. * Set a texture in the shader.
  18865. * @param name Define the name of the uniform samplers as defined in the shader
  18866. * @param texture Define the texture to bind to this sampler
  18867. * @return the material itself allowing "fluent" like uniform updates
  18868. */
  18869. setTexture(name: string, texture: Texture): ShaderMaterial;
  18870. /**
  18871. * Set a texture array in the shader.
  18872. * @param name Define the name of the uniform sampler array as defined in the shader
  18873. * @param textures Define the list of textures to bind to this sampler
  18874. * @return the material itself allowing "fluent" like uniform updates
  18875. */
  18876. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18877. /**
  18878. * Set a float in the shader.
  18879. * @param name Define the name of the uniform as defined in the shader
  18880. * @param value Define the value to give to the uniform
  18881. * @return the material itself allowing "fluent" like uniform updates
  18882. */
  18883. setFloat(name: string, value: number): ShaderMaterial;
  18884. /**
  18885. * Set a int in the shader.
  18886. * @param name Define the name of the uniform as defined in the shader
  18887. * @param value Define the value to give to the uniform
  18888. * @return the material itself allowing "fluent" like uniform updates
  18889. */
  18890. setInt(name: string, value: number): ShaderMaterial;
  18891. /**
  18892. * Set an array of floats in the shader.
  18893. * @param name Define the name of the uniform as defined in the shader
  18894. * @param value Define the value to give to the uniform
  18895. * @return the material itself allowing "fluent" like uniform updates
  18896. */
  18897. setFloats(name: string, value: number[]): ShaderMaterial;
  18898. /**
  18899. * Set a vec3 in the shader from a Color3.
  18900. * @param name Define the name of the uniform as defined in the shader
  18901. * @param value Define the value to give to the uniform
  18902. * @return the material itself allowing "fluent" like uniform updates
  18903. */
  18904. setColor3(name: string, value: Color3): ShaderMaterial;
  18905. /**
  18906. * Set a vec3 array in the shader from a Color3 array.
  18907. * @param name Define the name of the uniform as defined in the shader
  18908. * @param value Define the value to give to the uniform
  18909. * @return the material itself allowing "fluent" like uniform updates
  18910. */
  18911. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  18912. /**
  18913. * Set a vec4 in the shader from a Color4.
  18914. * @param name Define the name of the uniform as defined in the shader
  18915. * @param value Define the value to give to the uniform
  18916. * @return the material itself allowing "fluent" like uniform updates
  18917. */
  18918. setColor4(name: string, value: Color4): ShaderMaterial;
  18919. /**
  18920. * Set a vec4 array in the shader from a Color4 array.
  18921. * @param name Define the name of the uniform as defined in the shader
  18922. * @param value Define the value to give to the uniform
  18923. * @return the material itself allowing "fluent" like uniform updates
  18924. */
  18925. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  18926. /**
  18927. * Set a vec2 in the shader from a Vector2.
  18928. * @param name Define the name of the uniform as defined in the shader
  18929. * @param value Define the value to give to the uniform
  18930. * @return the material itself allowing "fluent" like uniform updates
  18931. */
  18932. setVector2(name: string, value: Vector2): ShaderMaterial;
  18933. /**
  18934. * Set a vec3 in the shader from a Vector3.
  18935. * @param name Define the name of the uniform as defined in the shader
  18936. * @param value Define the value to give to the uniform
  18937. * @return the material itself allowing "fluent" like uniform updates
  18938. */
  18939. setVector3(name: string, value: Vector3): ShaderMaterial;
  18940. /**
  18941. * Set a vec4 in the shader from a Vector4.
  18942. * @param name Define the name of the uniform as defined in the shader
  18943. * @param value Define the value to give to the uniform
  18944. * @return the material itself allowing "fluent" like uniform updates
  18945. */
  18946. setVector4(name: string, value: Vector4): ShaderMaterial;
  18947. /**
  18948. * Set a mat4 in the shader from a Matrix.
  18949. * @param name Define the name of the uniform as defined in the shader
  18950. * @param value Define the value to give to the uniform
  18951. * @return the material itself allowing "fluent" like uniform updates
  18952. */
  18953. setMatrix(name: string, value: Matrix): ShaderMaterial;
  18954. /**
  18955. * Set a mat3 in the shader from a Float32Array.
  18956. * @param name Define the name of the uniform as defined in the shader
  18957. * @param value Define the value to give to the uniform
  18958. * @return the material itself allowing "fluent" like uniform updates
  18959. */
  18960. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  18961. /**
  18962. * Set a mat2 in the shader from a Float32Array.
  18963. * @param name Define the name of the uniform as defined in the shader
  18964. * @param value Define the value to give to the uniform
  18965. * @return the material itself allowing "fluent" like uniform updates
  18966. */
  18967. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  18968. /**
  18969. * Set a vec2 array in the shader from a number array.
  18970. * @param name Define the name of the uniform as defined in the shader
  18971. * @param value Define the value to give to the uniform
  18972. * @return the material itself allowing "fluent" like uniform updates
  18973. */
  18974. setArray2(name: string, value: number[]): ShaderMaterial;
  18975. /**
  18976. * Set a vec3 array in the shader from a number array.
  18977. * @param name Define the name of the uniform as defined in the shader
  18978. * @param value Define the value to give to the uniform
  18979. * @return the material itself allowing "fluent" like uniform updates
  18980. */
  18981. setArray3(name: string, value: number[]): ShaderMaterial;
  18982. /**
  18983. * Set a vec4 array in the shader from a number array.
  18984. * @param name Define the name of the uniform as defined in the shader
  18985. * @param value Define the value to give to the uniform
  18986. * @return the material itself allowing "fluent" like uniform updates
  18987. */
  18988. setArray4(name: string, value: number[]): ShaderMaterial;
  18989. private _checkCache;
  18990. /**
  18991. * Specifies that the submesh is ready to be used
  18992. * @param mesh defines the mesh to check
  18993. * @param subMesh defines which submesh to check
  18994. * @param useInstances specifies that instances should be used
  18995. * @returns a boolean indicating that the submesh is ready or not
  18996. */
  18997. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18998. /**
  18999. * Checks if the material is ready to render the requested mesh
  19000. * @param mesh Define the mesh to render
  19001. * @param useInstances Define whether or not the material is used with instances
  19002. * @returns true if ready, otherwise false
  19003. */
  19004. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19005. /**
  19006. * Binds the world matrix to the material
  19007. * @param world defines the world transformation matrix
  19008. */
  19009. bindOnlyWorldMatrix(world: Matrix): void;
  19010. /**
  19011. * Binds the material to the mesh
  19012. * @param world defines the world transformation matrix
  19013. * @param mesh defines the mesh to bind the material to
  19014. */
  19015. bind(world: Matrix, mesh?: Mesh): void;
  19016. /**
  19017. * Gets the active textures from the material
  19018. * @returns an array of textures
  19019. */
  19020. getActiveTextures(): BaseTexture[];
  19021. /**
  19022. * Specifies if the material uses a texture
  19023. * @param texture defines the texture to check against the material
  19024. * @returns a boolean specifying if the material uses the texture
  19025. */
  19026. hasTexture(texture: BaseTexture): boolean;
  19027. /**
  19028. * Makes a duplicate of the material, and gives it a new name
  19029. * @param name defines the new name for the duplicated material
  19030. * @returns the cloned material
  19031. */
  19032. clone(name: string): ShaderMaterial;
  19033. /**
  19034. * Disposes the material
  19035. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19036. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19037. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19038. */
  19039. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19040. /**
  19041. * Serializes this material in a JSON representation
  19042. * @returns the serialized material object
  19043. */
  19044. serialize(): any;
  19045. /**
  19046. * Creates a shader material from parsed shader material data
  19047. * @param source defines the JSON represnetation of the material
  19048. * @param scene defines the hosting scene
  19049. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19050. * @returns a new material
  19051. */
  19052. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19053. }
  19054. }
  19055. declare module BABYLON {
  19056. /** @hidden */
  19057. export var colorPixelShader: {
  19058. name: string;
  19059. shader: string;
  19060. };
  19061. }
  19062. declare module BABYLON {
  19063. /** @hidden */
  19064. export var colorVertexShader: {
  19065. name: string;
  19066. shader: string;
  19067. };
  19068. }
  19069. declare module BABYLON {
  19070. /**
  19071. * Line mesh
  19072. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19073. */
  19074. export class LinesMesh extends Mesh {
  19075. /**
  19076. * If vertex color should be applied to the mesh
  19077. */
  19078. readonly useVertexColor?: boolean | undefined;
  19079. /**
  19080. * If vertex alpha should be applied to the mesh
  19081. */
  19082. readonly useVertexAlpha?: boolean | undefined;
  19083. /**
  19084. * Color of the line (Default: White)
  19085. */
  19086. color: Color3;
  19087. /**
  19088. * Alpha of the line (Default: 1)
  19089. */
  19090. alpha: number;
  19091. /**
  19092. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19093. * This margin is expressed in world space coordinates, so its value may vary.
  19094. * Default value is 0.1
  19095. */
  19096. intersectionThreshold: number;
  19097. private _colorShader;
  19098. private color4;
  19099. /**
  19100. * Creates a new LinesMesh
  19101. * @param name defines the name
  19102. * @param scene defines the hosting scene
  19103. * @param parent defines the parent mesh if any
  19104. * @param source defines the optional source LinesMesh used to clone data from
  19105. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19106. * When false, achieved by calling a clone(), also passing False.
  19107. * This will make creation of children, recursive.
  19108. * @param useVertexColor defines if this LinesMesh supports vertex color
  19109. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19110. */
  19111. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19112. /**
  19113. * If vertex color should be applied to the mesh
  19114. */
  19115. useVertexColor?: boolean | undefined,
  19116. /**
  19117. * If vertex alpha should be applied to the mesh
  19118. */
  19119. useVertexAlpha?: boolean | undefined);
  19120. private _addClipPlaneDefine;
  19121. private _removeClipPlaneDefine;
  19122. isReady(): boolean;
  19123. /**
  19124. * Returns the string "LineMesh"
  19125. */
  19126. getClassName(): string;
  19127. /**
  19128. * @hidden
  19129. */
  19130. /**
  19131. * @hidden
  19132. */
  19133. material: Material;
  19134. /**
  19135. * @hidden
  19136. */
  19137. readonly checkCollisions: boolean;
  19138. /** @hidden */
  19139. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19140. /** @hidden */
  19141. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19142. /**
  19143. * Disposes of the line mesh
  19144. * @param doNotRecurse If children should be disposed
  19145. */
  19146. dispose(doNotRecurse?: boolean): void;
  19147. /**
  19148. * Returns a new LineMesh object cloned from the current one.
  19149. */
  19150. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19151. /**
  19152. * Creates a new InstancedLinesMesh object from the mesh model.
  19153. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19154. * @param name defines the name of the new instance
  19155. * @returns a new InstancedLinesMesh
  19156. */
  19157. createInstance(name: string): InstancedLinesMesh;
  19158. }
  19159. /**
  19160. * Creates an instance based on a source LinesMesh
  19161. */
  19162. export class InstancedLinesMesh extends InstancedMesh {
  19163. /**
  19164. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19165. * This margin is expressed in world space coordinates, so its value may vary.
  19166. * Initilized with the intersectionThreshold value of the source LinesMesh
  19167. */
  19168. intersectionThreshold: number;
  19169. constructor(name: string, source: LinesMesh);
  19170. /**
  19171. * Returns the string "InstancedLinesMesh".
  19172. */
  19173. getClassName(): string;
  19174. }
  19175. }
  19176. declare module BABYLON {
  19177. /** @hidden */
  19178. export var linePixelShader: {
  19179. name: string;
  19180. shader: string;
  19181. };
  19182. }
  19183. declare module BABYLON {
  19184. /** @hidden */
  19185. export var lineVertexShader: {
  19186. name: string;
  19187. shader: string;
  19188. };
  19189. }
  19190. declare module BABYLON {
  19191. interface AbstractMesh {
  19192. /**
  19193. * Gets the edgesRenderer associated with the mesh
  19194. */
  19195. edgesRenderer: Nullable<EdgesRenderer>;
  19196. }
  19197. interface LinesMesh {
  19198. /**
  19199. * Enables the edge rendering mode on the mesh.
  19200. * This mode makes the mesh edges visible
  19201. * @param epsilon defines the maximal distance between two angles to detect a face
  19202. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19203. * @returns the currentAbstractMesh
  19204. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19205. */
  19206. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19207. }
  19208. interface InstancedLinesMesh {
  19209. /**
  19210. * Enables the edge rendering mode on the mesh.
  19211. * This mode makes the mesh edges visible
  19212. * @param epsilon defines the maximal distance between two angles to detect a face
  19213. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19214. * @returns the current InstancedLinesMesh
  19215. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19216. */
  19217. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19218. }
  19219. /**
  19220. * Defines the minimum contract an Edges renderer should follow.
  19221. */
  19222. export interface IEdgesRenderer extends IDisposable {
  19223. /**
  19224. * Gets or sets a boolean indicating if the edgesRenderer is active
  19225. */
  19226. isEnabled: boolean;
  19227. /**
  19228. * Renders the edges of the attached mesh,
  19229. */
  19230. render(): void;
  19231. /**
  19232. * Checks wether or not the edges renderer is ready to render.
  19233. * @return true if ready, otherwise false.
  19234. */
  19235. isReady(): boolean;
  19236. }
  19237. /**
  19238. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19239. */
  19240. export class EdgesRenderer implements IEdgesRenderer {
  19241. /**
  19242. * Define the size of the edges with an orthographic camera
  19243. */
  19244. edgesWidthScalerForOrthographic: number;
  19245. /**
  19246. * Define the size of the edges with a perspective camera
  19247. */
  19248. edgesWidthScalerForPerspective: number;
  19249. protected _source: AbstractMesh;
  19250. protected _linesPositions: number[];
  19251. protected _linesNormals: number[];
  19252. protected _linesIndices: number[];
  19253. protected _epsilon: number;
  19254. protected _indicesCount: number;
  19255. protected _lineShader: ShaderMaterial;
  19256. protected _ib: DataBuffer;
  19257. protected _buffers: {
  19258. [key: string]: Nullable<VertexBuffer>;
  19259. };
  19260. protected _checkVerticesInsteadOfIndices: boolean;
  19261. private _meshRebuildObserver;
  19262. private _meshDisposeObserver;
  19263. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19264. isEnabled: boolean;
  19265. /**
  19266. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19267. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19268. * @param source Mesh used to create edges
  19269. * @param epsilon sum of angles in adjacency to check for edge
  19270. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19271. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19272. */
  19273. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19274. protected _prepareRessources(): void;
  19275. /** @hidden */
  19276. _rebuild(): void;
  19277. /**
  19278. * Releases the required resources for the edges renderer
  19279. */
  19280. dispose(): void;
  19281. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19282. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19283. /**
  19284. * Checks if the pair of p0 and p1 is en edge
  19285. * @param faceIndex
  19286. * @param edge
  19287. * @param faceNormals
  19288. * @param p0
  19289. * @param p1
  19290. * @private
  19291. */
  19292. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19293. /**
  19294. * push line into the position, normal and index buffer
  19295. * @protected
  19296. */
  19297. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19298. /**
  19299. * Generates lines edges from adjacencjes
  19300. * @private
  19301. */
  19302. _generateEdgesLines(): void;
  19303. /**
  19304. * Checks wether or not the edges renderer is ready to render.
  19305. * @return true if ready, otherwise false.
  19306. */
  19307. isReady(): boolean;
  19308. /**
  19309. * Renders the edges of the attached mesh,
  19310. */
  19311. render(): void;
  19312. }
  19313. /**
  19314. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19315. */
  19316. export class LineEdgesRenderer extends EdgesRenderer {
  19317. /**
  19318. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19319. * @param source LineMesh used to generate edges
  19320. * @param epsilon not important (specified angle for edge detection)
  19321. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19322. */
  19323. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19324. /**
  19325. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19326. */
  19327. _generateEdgesLines(): void;
  19328. }
  19329. }
  19330. declare module BABYLON {
  19331. /**
  19332. * This represents the object necessary to create a rendering group.
  19333. * This is exclusively used and created by the rendering manager.
  19334. * To modify the behavior, you use the available helpers in your scene or meshes.
  19335. * @hidden
  19336. */
  19337. export class RenderingGroup {
  19338. index: number;
  19339. private static _zeroVector;
  19340. private _scene;
  19341. private _opaqueSubMeshes;
  19342. private _transparentSubMeshes;
  19343. private _alphaTestSubMeshes;
  19344. private _depthOnlySubMeshes;
  19345. private _particleSystems;
  19346. private _spriteManagers;
  19347. private _opaqueSortCompareFn;
  19348. private _alphaTestSortCompareFn;
  19349. private _transparentSortCompareFn;
  19350. private _renderOpaque;
  19351. private _renderAlphaTest;
  19352. private _renderTransparent;
  19353. /** @hidden */
  19354. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19355. onBeforeTransparentRendering: () => void;
  19356. /**
  19357. * Set the opaque sort comparison function.
  19358. * If null the sub meshes will be render in the order they were created
  19359. */
  19360. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19361. /**
  19362. * Set the alpha test sort comparison function.
  19363. * If null the sub meshes will be render in the order they were created
  19364. */
  19365. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19366. /**
  19367. * Set the transparent sort comparison function.
  19368. * If null the sub meshes will be render in the order they were created
  19369. */
  19370. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19371. /**
  19372. * Creates a new rendering group.
  19373. * @param index The rendering group index
  19374. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19375. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19376. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19377. */
  19378. 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>);
  19379. /**
  19380. * Render all the sub meshes contained in the group.
  19381. * @param customRenderFunction Used to override the default render behaviour of the group.
  19382. * @returns true if rendered some submeshes.
  19383. */
  19384. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19385. /**
  19386. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19387. * @param subMeshes The submeshes to render
  19388. */
  19389. private renderOpaqueSorted;
  19390. /**
  19391. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19392. * @param subMeshes The submeshes to render
  19393. */
  19394. private renderAlphaTestSorted;
  19395. /**
  19396. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19397. * @param subMeshes The submeshes to render
  19398. */
  19399. private renderTransparentSorted;
  19400. /**
  19401. * Renders the submeshes in a specified order.
  19402. * @param subMeshes The submeshes to sort before render
  19403. * @param sortCompareFn The comparison function use to sort
  19404. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19405. * @param transparent Specifies to activate blending if true
  19406. */
  19407. private static renderSorted;
  19408. /**
  19409. * Renders the submeshes in the order they were dispatched (no sort applied).
  19410. * @param subMeshes The submeshes to render
  19411. */
  19412. private static renderUnsorted;
  19413. /**
  19414. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19415. * are rendered back to front if in the same alpha index.
  19416. *
  19417. * @param a The first submesh
  19418. * @param b The second submesh
  19419. * @returns The result of the comparison
  19420. */
  19421. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19422. /**
  19423. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19424. * are rendered back to front.
  19425. *
  19426. * @param a The first submesh
  19427. * @param b The second submesh
  19428. * @returns The result of the comparison
  19429. */
  19430. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19431. /**
  19432. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19433. * are rendered front to back (prevent overdraw).
  19434. *
  19435. * @param a The first submesh
  19436. * @param b The second submesh
  19437. * @returns The result of the comparison
  19438. */
  19439. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19440. /**
  19441. * Resets the different lists of submeshes to prepare a new frame.
  19442. */
  19443. prepare(): void;
  19444. dispose(): void;
  19445. /**
  19446. * Inserts the submesh in its correct queue depending on its material.
  19447. * @param subMesh The submesh to dispatch
  19448. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19449. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19450. */
  19451. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19452. dispatchSprites(spriteManager: ISpriteManager): void;
  19453. dispatchParticles(particleSystem: IParticleSystem): void;
  19454. private _renderParticles;
  19455. private _renderSprites;
  19456. }
  19457. }
  19458. declare module BABYLON {
  19459. /**
  19460. * Interface describing the different options available in the rendering manager
  19461. * regarding Auto Clear between groups.
  19462. */
  19463. export interface IRenderingManagerAutoClearSetup {
  19464. /**
  19465. * Defines whether or not autoclear is enable.
  19466. */
  19467. autoClear: boolean;
  19468. /**
  19469. * Defines whether or not to autoclear the depth buffer.
  19470. */
  19471. depth: boolean;
  19472. /**
  19473. * Defines whether or not to autoclear the stencil buffer.
  19474. */
  19475. stencil: boolean;
  19476. }
  19477. /**
  19478. * This class is used by the onRenderingGroupObservable
  19479. */
  19480. export class RenderingGroupInfo {
  19481. /**
  19482. * The Scene that being rendered
  19483. */
  19484. scene: Scene;
  19485. /**
  19486. * The camera currently used for the rendering pass
  19487. */
  19488. camera: Nullable<Camera>;
  19489. /**
  19490. * The ID of the renderingGroup being processed
  19491. */
  19492. renderingGroupId: number;
  19493. }
  19494. /**
  19495. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19496. * It is enable to manage the different groups as well as the different necessary sort functions.
  19497. * This should not be used directly aside of the few static configurations
  19498. */
  19499. export class RenderingManager {
  19500. /**
  19501. * The max id used for rendering groups (not included)
  19502. */
  19503. static MAX_RENDERINGGROUPS: number;
  19504. /**
  19505. * The min id used for rendering groups (included)
  19506. */
  19507. static MIN_RENDERINGGROUPS: number;
  19508. /**
  19509. * Used to globally prevent autoclearing scenes.
  19510. */
  19511. static AUTOCLEAR: boolean;
  19512. /**
  19513. * @hidden
  19514. */
  19515. _useSceneAutoClearSetup: boolean;
  19516. private _scene;
  19517. private _renderingGroups;
  19518. private _depthStencilBufferAlreadyCleaned;
  19519. private _autoClearDepthStencil;
  19520. private _customOpaqueSortCompareFn;
  19521. private _customAlphaTestSortCompareFn;
  19522. private _customTransparentSortCompareFn;
  19523. private _renderingGroupInfo;
  19524. /**
  19525. * Instantiates a new rendering group for a particular scene
  19526. * @param scene Defines the scene the groups belongs to
  19527. */
  19528. constructor(scene: Scene);
  19529. private _clearDepthStencilBuffer;
  19530. /**
  19531. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19532. * @hidden
  19533. */
  19534. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19535. /**
  19536. * Resets the different information of the group to prepare a new frame
  19537. * @hidden
  19538. */
  19539. reset(): void;
  19540. /**
  19541. * Dispose and release the group and its associated resources.
  19542. * @hidden
  19543. */
  19544. dispose(): void;
  19545. /**
  19546. * Clear the info related to rendering groups preventing retention points during dispose.
  19547. */
  19548. freeRenderingGroups(): void;
  19549. private _prepareRenderingGroup;
  19550. /**
  19551. * Add a sprite manager to the rendering manager in order to render it this frame.
  19552. * @param spriteManager Define the sprite manager to render
  19553. */
  19554. dispatchSprites(spriteManager: ISpriteManager): void;
  19555. /**
  19556. * Add a particle system to the rendering manager in order to render it this frame.
  19557. * @param particleSystem Define the particle system to render
  19558. */
  19559. dispatchParticles(particleSystem: IParticleSystem): void;
  19560. /**
  19561. * Add a submesh to the manager in order to render it this frame
  19562. * @param subMesh The submesh to dispatch
  19563. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19564. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19565. */
  19566. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19567. /**
  19568. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19569. * This allowed control for front to back rendering or reversly depending of the special needs.
  19570. *
  19571. * @param renderingGroupId The rendering group id corresponding to its index
  19572. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19573. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19574. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19575. */
  19576. 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;
  19577. /**
  19578. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19579. *
  19580. * @param renderingGroupId The rendering group id corresponding to its index
  19581. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19582. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19583. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19584. */
  19585. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19586. /**
  19587. * Gets the current auto clear configuration for one rendering group of the rendering
  19588. * manager.
  19589. * @param index the rendering group index to get the information for
  19590. * @returns The auto clear setup for the requested rendering group
  19591. */
  19592. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19593. }
  19594. }
  19595. declare module BABYLON {
  19596. /**
  19597. * This Helps creating a texture that will be created from a camera in your scene.
  19598. * It is basically a dynamic texture that could be used to create special effects for instance.
  19599. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19600. */
  19601. export class RenderTargetTexture extends Texture {
  19602. isCube: boolean;
  19603. /**
  19604. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19605. */
  19606. static readonly REFRESHRATE_RENDER_ONCE: number;
  19607. /**
  19608. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19609. */
  19610. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19611. /**
  19612. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19613. * the central point of your effect and can save a lot of performances.
  19614. */
  19615. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19616. /**
  19617. * Use this predicate to dynamically define the list of mesh you want to render.
  19618. * If set, the renderList property will be overwritten.
  19619. */
  19620. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19621. private _renderList;
  19622. /**
  19623. * Use this list to define the list of mesh you want to render.
  19624. */
  19625. renderList: Nullable<Array<AbstractMesh>>;
  19626. private _hookArray;
  19627. /**
  19628. * Define if particles should be rendered in your texture.
  19629. */
  19630. renderParticles: boolean;
  19631. /**
  19632. * Define if sprites should be rendered in your texture.
  19633. */
  19634. renderSprites: boolean;
  19635. /**
  19636. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19637. */
  19638. coordinatesMode: number;
  19639. /**
  19640. * Define the camera used to render the texture.
  19641. */
  19642. activeCamera: Nullable<Camera>;
  19643. /**
  19644. * Override the render function of the texture with your own one.
  19645. */
  19646. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19647. /**
  19648. * Define if camera post processes should be use while rendering the texture.
  19649. */
  19650. useCameraPostProcesses: boolean;
  19651. /**
  19652. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19653. */
  19654. ignoreCameraViewport: boolean;
  19655. private _postProcessManager;
  19656. private _postProcesses;
  19657. private _resizeObserver;
  19658. /**
  19659. * An event triggered when the texture is unbind.
  19660. */
  19661. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19662. /**
  19663. * An event triggered when the texture is unbind.
  19664. */
  19665. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19666. private _onAfterUnbindObserver;
  19667. /**
  19668. * Set a after unbind callback in the texture.
  19669. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19670. */
  19671. onAfterUnbind: () => void;
  19672. /**
  19673. * An event triggered before rendering the texture
  19674. */
  19675. onBeforeRenderObservable: Observable<number>;
  19676. private _onBeforeRenderObserver;
  19677. /**
  19678. * Set a before render callback in the texture.
  19679. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19680. */
  19681. onBeforeRender: (faceIndex: number) => void;
  19682. /**
  19683. * An event triggered after rendering the texture
  19684. */
  19685. onAfterRenderObservable: Observable<number>;
  19686. private _onAfterRenderObserver;
  19687. /**
  19688. * Set a after render callback in the texture.
  19689. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  19690. */
  19691. onAfterRender: (faceIndex: number) => void;
  19692. /**
  19693. * An event triggered after the texture clear
  19694. */
  19695. onClearObservable: Observable<Engine>;
  19696. private _onClearObserver;
  19697. /**
  19698. * Set a clear callback in the texture.
  19699. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  19700. */
  19701. onClear: (Engine: Engine) => void;
  19702. /**
  19703. * An event triggered when the texture is resized.
  19704. */
  19705. onResizeObservable: Observable<RenderTargetTexture>;
  19706. /**
  19707. * Define the clear color of the Render Target if it should be different from the scene.
  19708. */
  19709. clearColor: Color4;
  19710. protected _size: number | {
  19711. width: number;
  19712. height: number;
  19713. };
  19714. protected _initialSizeParameter: number | {
  19715. width: number;
  19716. height: number;
  19717. } | {
  19718. ratio: number;
  19719. };
  19720. protected _sizeRatio: Nullable<number>;
  19721. /** @hidden */
  19722. _generateMipMaps: boolean;
  19723. protected _renderingManager: RenderingManager;
  19724. /** @hidden */
  19725. _waitingRenderList: string[];
  19726. protected _doNotChangeAspectRatio: boolean;
  19727. protected _currentRefreshId: number;
  19728. protected _refreshRate: number;
  19729. protected _textureMatrix: Matrix;
  19730. protected _samples: number;
  19731. protected _renderTargetOptions: RenderTargetCreationOptions;
  19732. /**
  19733. * Gets render target creation options that were used.
  19734. */
  19735. readonly renderTargetOptions: RenderTargetCreationOptions;
  19736. protected _engine: Engine;
  19737. protected _onRatioRescale(): void;
  19738. /**
  19739. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  19740. * It must define where the camera used to render the texture is set
  19741. */
  19742. boundingBoxPosition: Vector3;
  19743. private _boundingBoxSize;
  19744. /**
  19745. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  19746. * When defined, the cubemap will switch to local mode
  19747. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  19748. * @example https://www.babylonjs-playground.com/#RNASML
  19749. */
  19750. boundingBoxSize: Vector3;
  19751. /**
  19752. * In case the RTT has been created with a depth texture, get the associated
  19753. * depth texture.
  19754. * Otherwise, return null.
  19755. */
  19756. depthStencilTexture: Nullable<InternalTexture>;
  19757. /**
  19758. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  19759. * or used a shadow, depth texture...
  19760. * @param name The friendly name of the texture
  19761. * @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)
  19762. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  19763. * @param generateMipMaps True if mip maps need to be generated after render.
  19764. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  19765. * @param type The type of the buffer in the RTT (int, half float, float...)
  19766. * @param isCube True if a cube texture needs to be created
  19767. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  19768. * @param generateDepthBuffer True to generate a depth buffer
  19769. * @param generateStencilBuffer True to generate a stencil buffer
  19770. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  19771. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  19772. * @param delayAllocation if the texture allocation should be delayed (default: false)
  19773. */
  19774. constructor(name: string, size: number | {
  19775. width: number;
  19776. height: number;
  19777. } | {
  19778. ratio: number;
  19779. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  19780. /**
  19781. * Creates a depth stencil texture.
  19782. * This is only available in WebGL 2 or with the depth texture extension available.
  19783. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  19784. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  19785. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  19786. */
  19787. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  19788. private _processSizeParameter;
  19789. /**
  19790. * Define the number of samples to use in case of MSAA.
  19791. * It defaults to one meaning no MSAA has been enabled.
  19792. */
  19793. samples: number;
  19794. /**
  19795. * Resets the refresh counter of the texture and start bak from scratch.
  19796. * Could be useful to regenerate the texture if it is setup to render only once.
  19797. */
  19798. resetRefreshCounter(): void;
  19799. /**
  19800. * Define the refresh rate of the texture or the rendering frequency.
  19801. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19802. */
  19803. refreshRate: number;
  19804. /**
  19805. * Adds a post process to the render target rendering passes.
  19806. * @param postProcess define the post process to add
  19807. */
  19808. addPostProcess(postProcess: PostProcess): void;
  19809. /**
  19810. * Clear all the post processes attached to the render target
  19811. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  19812. */
  19813. clearPostProcesses(dispose?: boolean): void;
  19814. /**
  19815. * Remove one of the post process from the list of attached post processes to the texture
  19816. * @param postProcess define the post process to remove from the list
  19817. */
  19818. removePostProcess(postProcess: PostProcess): void;
  19819. /** @hidden */
  19820. _shouldRender(): boolean;
  19821. /**
  19822. * Gets the actual render size of the texture.
  19823. * @returns the width of the render size
  19824. */
  19825. getRenderSize(): number;
  19826. /**
  19827. * Gets the actual render width of the texture.
  19828. * @returns the width of the render size
  19829. */
  19830. getRenderWidth(): number;
  19831. /**
  19832. * Gets the actual render height of the texture.
  19833. * @returns the height of the render size
  19834. */
  19835. getRenderHeight(): number;
  19836. /**
  19837. * Get if the texture can be rescaled or not.
  19838. */
  19839. readonly canRescale: boolean;
  19840. /**
  19841. * Resize the texture using a ratio.
  19842. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  19843. */
  19844. scale(ratio: number): void;
  19845. /**
  19846. * Get the texture reflection matrix used to rotate/transform the reflection.
  19847. * @returns the reflection matrix
  19848. */
  19849. getReflectionTextureMatrix(): Matrix;
  19850. /**
  19851. * Resize the texture to a new desired size.
  19852. * Be carrefull as it will recreate all the data in the new texture.
  19853. * @param size Define the new size. It can be:
  19854. * - a number for squared texture,
  19855. * - an object containing { width: number, height: number }
  19856. * - or an object containing a ratio { ratio: number }
  19857. */
  19858. resize(size: number | {
  19859. width: number;
  19860. height: number;
  19861. } | {
  19862. ratio: number;
  19863. }): void;
  19864. /**
  19865. * Renders all the objects from the render list into the texture.
  19866. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  19867. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  19868. */
  19869. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  19870. private _bestReflectionRenderTargetDimension;
  19871. /**
  19872. * @hidden
  19873. * @param faceIndex face index to bind to if this is a cubetexture
  19874. */
  19875. _bindFrameBuffer(faceIndex?: number): void;
  19876. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  19877. private renderToTarget;
  19878. /**
  19879. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19880. * This allowed control for front to back rendering or reversly depending of the special needs.
  19881. *
  19882. * @param renderingGroupId The rendering group id corresponding to its index
  19883. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19884. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19885. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19886. */
  19887. 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;
  19888. /**
  19889. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19890. *
  19891. * @param renderingGroupId The rendering group id corresponding to its index
  19892. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19893. */
  19894. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  19895. /**
  19896. * Clones the texture.
  19897. * @returns the cloned texture
  19898. */
  19899. clone(): RenderTargetTexture;
  19900. /**
  19901. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  19902. * @returns The JSON representation of the texture
  19903. */
  19904. serialize(): any;
  19905. /**
  19906. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  19907. */
  19908. disposeFramebufferObjects(): void;
  19909. /**
  19910. * Dispose the texture and release its associated resources.
  19911. */
  19912. dispose(): void;
  19913. /** @hidden */
  19914. _rebuild(): void;
  19915. /**
  19916. * Clear the info related to rendering groups preventing retention point in material dispose.
  19917. */
  19918. freeRenderingGroups(): void;
  19919. /**
  19920. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19921. * @returns the view count
  19922. */
  19923. getViewCount(): number;
  19924. }
  19925. }
  19926. declare module BABYLON {
  19927. /**
  19928. * Base class for the main features of a material in Babylon.js
  19929. */
  19930. export class Material implements IAnimatable {
  19931. /**
  19932. * Returns the triangle fill mode
  19933. */
  19934. static readonly TriangleFillMode: number;
  19935. /**
  19936. * Returns the wireframe mode
  19937. */
  19938. static readonly WireFrameFillMode: number;
  19939. /**
  19940. * Returns the point fill mode
  19941. */
  19942. static readonly PointFillMode: number;
  19943. /**
  19944. * Returns the point list draw mode
  19945. */
  19946. static readonly PointListDrawMode: number;
  19947. /**
  19948. * Returns the line list draw mode
  19949. */
  19950. static readonly LineListDrawMode: number;
  19951. /**
  19952. * Returns the line loop draw mode
  19953. */
  19954. static readonly LineLoopDrawMode: number;
  19955. /**
  19956. * Returns the line strip draw mode
  19957. */
  19958. static readonly LineStripDrawMode: number;
  19959. /**
  19960. * Returns the triangle strip draw mode
  19961. */
  19962. static readonly TriangleStripDrawMode: number;
  19963. /**
  19964. * Returns the triangle fan draw mode
  19965. */
  19966. static readonly TriangleFanDrawMode: number;
  19967. /**
  19968. * Stores the clock-wise side orientation
  19969. */
  19970. static readonly ClockWiseSideOrientation: number;
  19971. /**
  19972. * Stores the counter clock-wise side orientation
  19973. */
  19974. static readonly CounterClockWiseSideOrientation: number;
  19975. /**
  19976. * The dirty texture flag value
  19977. */
  19978. static readonly TextureDirtyFlag: number;
  19979. /**
  19980. * The dirty light flag value
  19981. */
  19982. static readonly LightDirtyFlag: number;
  19983. /**
  19984. * The dirty fresnel flag value
  19985. */
  19986. static readonly FresnelDirtyFlag: number;
  19987. /**
  19988. * The dirty attribute flag value
  19989. */
  19990. static readonly AttributesDirtyFlag: number;
  19991. /**
  19992. * The dirty misc flag value
  19993. */
  19994. static readonly MiscDirtyFlag: number;
  19995. /**
  19996. * The all dirty flag value
  19997. */
  19998. static readonly AllDirtyFlag: number;
  19999. /**
  20000. * The ID of the material
  20001. */
  20002. id: string;
  20003. /**
  20004. * Gets or sets the unique id of the material
  20005. */
  20006. uniqueId: number;
  20007. /**
  20008. * The name of the material
  20009. */
  20010. name: string;
  20011. /**
  20012. * Gets or sets user defined metadata
  20013. */
  20014. metadata: any;
  20015. /**
  20016. * For internal use only. Please do not use.
  20017. */
  20018. reservedDataStore: any;
  20019. /**
  20020. * Specifies if the ready state should be checked on each call
  20021. */
  20022. checkReadyOnEveryCall: boolean;
  20023. /**
  20024. * Specifies if the ready state should be checked once
  20025. */
  20026. checkReadyOnlyOnce: boolean;
  20027. /**
  20028. * The state of the material
  20029. */
  20030. state: string;
  20031. /**
  20032. * The alpha value of the material
  20033. */
  20034. protected _alpha: number;
  20035. /**
  20036. * List of inspectable custom properties (used by the Inspector)
  20037. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20038. */
  20039. inspectableCustomProperties: IInspectable[];
  20040. /**
  20041. * Sets the alpha value of the material
  20042. */
  20043. /**
  20044. * Gets the alpha value of the material
  20045. */
  20046. alpha: number;
  20047. /**
  20048. * Specifies if back face culling is enabled
  20049. */
  20050. protected _backFaceCulling: boolean;
  20051. /**
  20052. * Sets the back-face culling state
  20053. */
  20054. /**
  20055. * Gets the back-face culling state
  20056. */
  20057. backFaceCulling: boolean;
  20058. /**
  20059. * Stores the value for side orientation
  20060. */
  20061. sideOrientation: number;
  20062. /**
  20063. * Callback triggered when the material is compiled
  20064. */
  20065. onCompiled: Nullable<(effect: Effect) => void>;
  20066. /**
  20067. * Callback triggered when an error occurs
  20068. */
  20069. onError: Nullable<(effect: Effect, errors: string) => void>;
  20070. /**
  20071. * Callback triggered to get the render target textures
  20072. */
  20073. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20074. /**
  20075. * Gets a boolean indicating that current material needs to register RTT
  20076. */
  20077. readonly hasRenderTargetTextures: boolean;
  20078. /**
  20079. * Specifies if the material should be serialized
  20080. */
  20081. doNotSerialize: boolean;
  20082. /**
  20083. * @hidden
  20084. */
  20085. _storeEffectOnSubMeshes: boolean;
  20086. /**
  20087. * Stores the animations for the material
  20088. */
  20089. animations: Nullable<Array<Animation>>;
  20090. /**
  20091. * An event triggered when the material is disposed
  20092. */
  20093. onDisposeObservable: Observable<Material>;
  20094. /**
  20095. * An observer which watches for dispose events
  20096. */
  20097. private _onDisposeObserver;
  20098. private _onUnBindObservable;
  20099. /**
  20100. * Called during a dispose event
  20101. */
  20102. onDispose: () => void;
  20103. private _onBindObservable;
  20104. /**
  20105. * An event triggered when the material is bound
  20106. */
  20107. readonly onBindObservable: Observable<AbstractMesh>;
  20108. /**
  20109. * An observer which watches for bind events
  20110. */
  20111. private _onBindObserver;
  20112. /**
  20113. * Called during a bind event
  20114. */
  20115. onBind: (Mesh: AbstractMesh) => void;
  20116. /**
  20117. * An event triggered when the material is unbound
  20118. */
  20119. readonly onUnBindObservable: Observable<Material>;
  20120. /**
  20121. * Stores the value of the alpha mode
  20122. */
  20123. private _alphaMode;
  20124. /**
  20125. * Sets the value of the alpha mode.
  20126. *
  20127. * | Value | Type | Description |
  20128. * | --- | --- | --- |
  20129. * | 0 | ALPHA_DISABLE | |
  20130. * | 1 | ALPHA_ADD | |
  20131. * | 2 | ALPHA_COMBINE | |
  20132. * | 3 | ALPHA_SUBTRACT | |
  20133. * | 4 | ALPHA_MULTIPLY | |
  20134. * | 5 | ALPHA_MAXIMIZED | |
  20135. * | 6 | ALPHA_ONEONE | |
  20136. * | 7 | ALPHA_PREMULTIPLIED | |
  20137. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20138. * | 9 | ALPHA_INTERPOLATE | |
  20139. * | 10 | ALPHA_SCREENMODE | |
  20140. *
  20141. */
  20142. /**
  20143. * Gets the value of the alpha mode
  20144. */
  20145. alphaMode: number;
  20146. /**
  20147. * Stores the state of the need depth pre-pass value
  20148. */
  20149. private _needDepthPrePass;
  20150. /**
  20151. * Sets the need depth pre-pass value
  20152. */
  20153. /**
  20154. * Gets the depth pre-pass value
  20155. */
  20156. needDepthPrePass: boolean;
  20157. /**
  20158. * Specifies if depth writing should be disabled
  20159. */
  20160. disableDepthWrite: boolean;
  20161. /**
  20162. * Specifies if depth writing should be forced
  20163. */
  20164. forceDepthWrite: boolean;
  20165. /**
  20166. * Specifies if there should be a separate pass for culling
  20167. */
  20168. separateCullingPass: boolean;
  20169. /**
  20170. * Stores the state specifing if fog should be enabled
  20171. */
  20172. private _fogEnabled;
  20173. /**
  20174. * Sets the state for enabling fog
  20175. */
  20176. /**
  20177. * Gets the value of the fog enabled state
  20178. */
  20179. fogEnabled: boolean;
  20180. /**
  20181. * Stores the size of points
  20182. */
  20183. pointSize: number;
  20184. /**
  20185. * Stores the z offset value
  20186. */
  20187. zOffset: number;
  20188. /**
  20189. * Gets a value specifying if wireframe mode is enabled
  20190. */
  20191. /**
  20192. * Sets the state of wireframe mode
  20193. */
  20194. wireframe: boolean;
  20195. /**
  20196. * Gets the value specifying if point clouds are enabled
  20197. */
  20198. /**
  20199. * Sets the state of point cloud mode
  20200. */
  20201. pointsCloud: boolean;
  20202. /**
  20203. * Gets the material fill mode
  20204. */
  20205. /**
  20206. * Sets the material fill mode
  20207. */
  20208. fillMode: number;
  20209. /**
  20210. * @hidden
  20211. * Stores the effects for the material
  20212. */
  20213. _effect: Nullable<Effect>;
  20214. /**
  20215. * @hidden
  20216. * Specifies if the material was previously ready
  20217. */
  20218. _wasPreviouslyReady: boolean;
  20219. /**
  20220. * Specifies if uniform buffers should be used
  20221. */
  20222. private _useUBO;
  20223. /**
  20224. * Stores a reference to the scene
  20225. */
  20226. private _scene;
  20227. /**
  20228. * Stores the fill mode state
  20229. */
  20230. private _fillMode;
  20231. /**
  20232. * Specifies if the depth write state should be cached
  20233. */
  20234. private _cachedDepthWriteState;
  20235. /**
  20236. * Stores the uniform buffer
  20237. */
  20238. protected _uniformBuffer: UniformBuffer;
  20239. /** @hidden */
  20240. _indexInSceneMaterialArray: number;
  20241. /** @hidden */
  20242. meshMap: Nullable<{
  20243. [id: string]: AbstractMesh | undefined;
  20244. }>;
  20245. /**
  20246. * Creates a material instance
  20247. * @param name defines the name of the material
  20248. * @param scene defines the scene to reference
  20249. * @param doNotAdd specifies if the material should be added to the scene
  20250. */
  20251. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20252. /**
  20253. * Returns a string representation of the current material
  20254. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20255. * @returns a string with material information
  20256. */
  20257. toString(fullDetails?: boolean): string;
  20258. /**
  20259. * Gets the class name of the material
  20260. * @returns a string with the class name of the material
  20261. */
  20262. getClassName(): string;
  20263. /**
  20264. * Specifies if updates for the material been locked
  20265. */
  20266. readonly isFrozen: boolean;
  20267. /**
  20268. * Locks updates for the material
  20269. */
  20270. freeze(): void;
  20271. /**
  20272. * Unlocks updates for the material
  20273. */
  20274. unfreeze(): void;
  20275. /**
  20276. * Specifies if the material is ready to be used
  20277. * @param mesh defines the mesh to check
  20278. * @param useInstances specifies if instances should be used
  20279. * @returns a boolean indicating if the material is ready to be used
  20280. */
  20281. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20282. /**
  20283. * Specifies that the submesh is ready to be used
  20284. * @param mesh defines the mesh to check
  20285. * @param subMesh defines which submesh to check
  20286. * @param useInstances specifies that instances should be used
  20287. * @returns a boolean indicating that the submesh is ready or not
  20288. */
  20289. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20290. /**
  20291. * Returns the material effect
  20292. * @returns the effect associated with the material
  20293. */
  20294. getEffect(): Nullable<Effect>;
  20295. /**
  20296. * Returns the current scene
  20297. * @returns a Scene
  20298. */
  20299. getScene(): Scene;
  20300. /**
  20301. * Specifies if the material will require alpha blending
  20302. * @returns a boolean specifying if alpha blending is needed
  20303. */
  20304. needAlphaBlending(): boolean;
  20305. /**
  20306. * Specifies if the mesh will require alpha blending
  20307. * @param mesh defines the mesh to check
  20308. * @returns a boolean specifying if alpha blending is needed for the mesh
  20309. */
  20310. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20311. /**
  20312. * Specifies if this material should be rendered in alpha test mode
  20313. * @returns a boolean specifying if an alpha test is needed.
  20314. */
  20315. needAlphaTesting(): boolean;
  20316. /**
  20317. * Gets the texture used for the alpha test
  20318. * @returns the texture to use for alpha testing
  20319. */
  20320. getAlphaTestTexture(): Nullable<BaseTexture>;
  20321. /**
  20322. * Marks the material to indicate that it needs to be re-calculated
  20323. */
  20324. markDirty(): void;
  20325. /** @hidden */
  20326. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20327. /**
  20328. * Binds the material to the mesh
  20329. * @param world defines the world transformation matrix
  20330. * @param mesh defines the mesh to bind the material to
  20331. */
  20332. bind(world: Matrix, mesh?: Mesh): void;
  20333. /**
  20334. * Binds the submesh to the material
  20335. * @param world defines the world transformation matrix
  20336. * @param mesh defines the mesh containing the submesh
  20337. * @param subMesh defines the submesh to bind the material to
  20338. */
  20339. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20340. /**
  20341. * Binds the world matrix to the material
  20342. * @param world defines the world transformation matrix
  20343. */
  20344. bindOnlyWorldMatrix(world: Matrix): void;
  20345. /**
  20346. * Binds the scene's uniform buffer to the effect.
  20347. * @param effect defines the effect to bind to the scene uniform buffer
  20348. * @param sceneUbo defines the uniform buffer storing scene data
  20349. */
  20350. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20351. /**
  20352. * Binds the view matrix to the effect
  20353. * @param effect defines the effect to bind the view matrix to
  20354. */
  20355. bindView(effect: Effect): void;
  20356. /**
  20357. * Binds the view projection matrix to the effect
  20358. * @param effect defines the effect to bind the view projection matrix to
  20359. */
  20360. bindViewProjection(effect: Effect): void;
  20361. /**
  20362. * Specifies if material alpha testing should be turned on for the mesh
  20363. * @param mesh defines the mesh to check
  20364. */
  20365. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20366. /**
  20367. * Processes to execute after binding the material to a mesh
  20368. * @param mesh defines the rendered mesh
  20369. */
  20370. protected _afterBind(mesh?: Mesh): void;
  20371. /**
  20372. * Unbinds the material from the mesh
  20373. */
  20374. unbind(): void;
  20375. /**
  20376. * Gets the active textures from the material
  20377. * @returns an array of textures
  20378. */
  20379. getActiveTextures(): BaseTexture[];
  20380. /**
  20381. * Specifies if the material uses a texture
  20382. * @param texture defines the texture to check against the material
  20383. * @returns a boolean specifying if the material uses the texture
  20384. */
  20385. hasTexture(texture: BaseTexture): boolean;
  20386. /**
  20387. * Makes a duplicate of the material, and gives it a new name
  20388. * @param name defines the new name for the duplicated material
  20389. * @returns the cloned material
  20390. */
  20391. clone(name: string): Nullable<Material>;
  20392. /**
  20393. * Gets the meshes bound to the material
  20394. * @returns an array of meshes bound to the material
  20395. */
  20396. getBindedMeshes(): AbstractMesh[];
  20397. /**
  20398. * Force shader compilation
  20399. * @param mesh defines the mesh associated with this material
  20400. * @param onCompiled defines a function to execute once the material is compiled
  20401. * @param options defines the options to configure the compilation
  20402. */
  20403. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20404. clipPlane: boolean;
  20405. }>): void;
  20406. /**
  20407. * Force shader compilation
  20408. * @param mesh defines the mesh that will use this material
  20409. * @param options defines additional options for compiling the shaders
  20410. * @returns a promise that resolves when the compilation completes
  20411. */
  20412. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20413. clipPlane: boolean;
  20414. }>): Promise<void>;
  20415. private static readonly _AllDirtyCallBack;
  20416. private static readonly _ImageProcessingDirtyCallBack;
  20417. private static readonly _TextureDirtyCallBack;
  20418. private static readonly _FresnelDirtyCallBack;
  20419. private static readonly _MiscDirtyCallBack;
  20420. private static readonly _LightsDirtyCallBack;
  20421. private static readonly _AttributeDirtyCallBack;
  20422. private static _FresnelAndMiscDirtyCallBack;
  20423. private static _TextureAndMiscDirtyCallBack;
  20424. private static readonly _DirtyCallbackArray;
  20425. private static readonly _RunDirtyCallBacks;
  20426. /**
  20427. * Marks a define in the material to indicate that it needs to be re-computed
  20428. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20429. */
  20430. markAsDirty(flag: number): void;
  20431. /**
  20432. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20433. * @param func defines a function which checks material defines against the submeshes
  20434. */
  20435. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20436. /**
  20437. * Indicates that we need to re-calculated for all submeshes
  20438. */
  20439. protected _markAllSubMeshesAsAllDirty(): void;
  20440. /**
  20441. * Indicates that image processing needs to be re-calculated for all submeshes
  20442. */
  20443. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20444. /**
  20445. * Indicates that textures need to be re-calculated for all submeshes
  20446. */
  20447. protected _markAllSubMeshesAsTexturesDirty(): void;
  20448. /**
  20449. * Indicates that fresnel needs to be re-calculated for all submeshes
  20450. */
  20451. protected _markAllSubMeshesAsFresnelDirty(): void;
  20452. /**
  20453. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20454. */
  20455. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20456. /**
  20457. * Indicates that lights need to be re-calculated for all submeshes
  20458. */
  20459. protected _markAllSubMeshesAsLightsDirty(): void;
  20460. /**
  20461. * Indicates that attributes need to be re-calculated for all submeshes
  20462. */
  20463. protected _markAllSubMeshesAsAttributesDirty(): void;
  20464. /**
  20465. * Indicates that misc needs to be re-calculated for all submeshes
  20466. */
  20467. protected _markAllSubMeshesAsMiscDirty(): void;
  20468. /**
  20469. * Indicates that textures and misc need to be re-calculated for all submeshes
  20470. */
  20471. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20472. /**
  20473. * Disposes the material
  20474. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20475. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20476. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20477. */
  20478. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20479. /** @hidden */
  20480. private releaseVertexArrayObject;
  20481. /**
  20482. * Serializes this material
  20483. * @returns the serialized material object
  20484. */
  20485. serialize(): any;
  20486. /**
  20487. * Creates a material from parsed material data
  20488. * @param parsedMaterial defines parsed material data
  20489. * @param scene defines the hosting scene
  20490. * @param rootUrl defines the root URL to use to load textures
  20491. * @returns a new material
  20492. */
  20493. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20494. }
  20495. }
  20496. declare module BABYLON {
  20497. /**
  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. */
  20502. export class MultiMaterial extends Material {
  20503. private _subMaterials;
  20504. /**
  20505. * Gets or Sets the list of Materials used within the multi material.
  20506. * They need to be ordered according to the submeshes order in the associated mesh
  20507. */
  20508. subMaterials: Nullable<Material>[];
  20509. /**
  20510. * Function used to align with Node.getChildren()
  20511. * @returns the list of Materials used within the multi material
  20512. */
  20513. getChildren(): Nullable<Material>[];
  20514. /**
  20515. * Instantiates a new Multi Material
  20516. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20517. * separate meshes. This can be use to improve performances.
  20518. * @see http://doc.babylonjs.com/how_to/multi_materials
  20519. * @param name Define the name in the scene
  20520. * @param scene Define the scene the material belongs to
  20521. */
  20522. constructor(name: string, scene: Scene);
  20523. private _hookArray;
  20524. /**
  20525. * Get one of the submaterial by its index in the submaterials array
  20526. * @param index The index to look the sub material at
  20527. * @returns The Material if the index has been defined
  20528. */
  20529. getSubMaterial(index: number): Nullable<Material>;
  20530. /**
  20531. * Get the list of active textures for the whole sub materials list.
  20532. * @returns All the textures that will be used during the rendering
  20533. */
  20534. getActiveTextures(): BaseTexture[];
  20535. /**
  20536. * Gets the current class name of the material e.g. "MultiMaterial"
  20537. * Mainly use in serialization.
  20538. * @returns the class name
  20539. */
  20540. getClassName(): string;
  20541. /**
  20542. * Checks if the material is ready to render the requested sub mesh
  20543. * @param mesh Define the mesh the submesh belongs to
  20544. * @param subMesh Define the sub mesh to look readyness for
  20545. * @param useInstances Define whether or not the material is used with instances
  20546. * @returns true if ready, otherwise false
  20547. */
  20548. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20549. /**
  20550. * Clones the current material and its related sub materials
  20551. * @param name Define the name of the newly cloned material
  20552. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20553. * @returns the cloned material
  20554. */
  20555. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20556. /**
  20557. * Serializes the materials into a JSON representation.
  20558. * @returns the JSON representation
  20559. */
  20560. serialize(): any;
  20561. /**
  20562. * Dispose the material and release its associated resources
  20563. * @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)
  20564. * @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)
  20565. * @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)
  20566. */
  20567. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20568. /**
  20569. * Creates a MultiMaterial from parsed MultiMaterial data.
  20570. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20571. * @param scene defines the hosting scene
  20572. * @returns a new MultiMaterial
  20573. */
  20574. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20575. }
  20576. }
  20577. declare module BABYLON {
  20578. /**
  20579. * Base class for submeshes
  20580. */
  20581. export class BaseSubMesh {
  20582. /** @hidden */
  20583. _materialDefines: Nullable<MaterialDefines>;
  20584. /** @hidden */
  20585. _materialEffect: Nullable<Effect>;
  20586. /**
  20587. * Gets associated effect
  20588. */
  20589. readonly effect: Nullable<Effect>;
  20590. /**
  20591. * Sets associated effect (effect used to render this submesh)
  20592. * @param effect defines the effect to associate with
  20593. * @param defines defines the set of defines used to compile this effect
  20594. */
  20595. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20596. }
  20597. /**
  20598. * Defines a subdivision inside a mesh
  20599. */
  20600. export class SubMesh extends BaseSubMesh implements ICullable {
  20601. /** the material index to use */
  20602. materialIndex: number;
  20603. /** vertex index start */
  20604. verticesStart: number;
  20605. /** vertices count */
  20606. verticesCount: number;
  20607. /** index start */
  20608. indexStart: number;
  20609. /** indices count */
  20610. indexCount: number;
  20611. /** @hidden */
  20612. _linesIndexCount: number;
  20613. private _mesh;
  20614. private _renderingMesh;
  20615. private _boundingInfo;
  20616. private _linesIndexBuffer;
  20617. /** @hidden */
  20618. _lastColliderWorldVertices: Nullable<Vector3[]>;
  20619. /** @hidden */
  20620. _trianglePlanes: Plane[];
  20621. /** @hidden */
  20622. _lastColliderTransformMatrix: Nullable<Matrix>;
  20623. /** @hidden */
  20624. _renderId: number;
  20625. /** @hidden */
  20626. _alphaIndex: number;
  20627. /** @hidden */
  20628. _distanceToCamera: number;
  20629. /** @hidden */
  20630. _id: number;
  20631. private _currentMaterial;
  20632. /**
  20633. * Add a new submesh to a mesh
  20634. * @param materialIndex defines the material index to use
  20635. * @param verticesStart defines vertex index start
  20636. * @param verticesCount defines vertices count
  20637. * @param indexStart defines index start
  20638. * @param indexCount defines indices count
  20639. * @param mesh defines the parent mesh
  20640. * @param renderingMesh defines an optional rendering mesh
  20641. * @param createBoundingBox defines if bounding box should be created for this submesh
  20642. * @returns the new submesh
  20643. */
  20644. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20645. /**
  20646. * Creates a new submesh
  20647. * @param materialIndex defines the material index to use
  20648. * @param verticesStart defines vertex index start
  20649. * @param verticesCount defines vertices count
  20650. * @param indexStart defines index start
  20651. * @param indexCount defines indices count
  20652. * @param mesh defines the parent mesh
  20653. * @param renderingMesh defines an optional rendering mesh
  20654. * @param createBoundingBox defines if bounding box should be created for this submesh
  20655. */
  20656. constructor(
  20657. /** the material index to use */
  20658. materialIndex: number,
  20659. /** vertex index start */
  20660. verticesStart: number,
  20661. /** vertices count */
  20662. verticesCount: number,
  20663. /** index start */
  20664. indexStart: number,
  20665. /** indices count */
  20666. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20667. /**
  20668. * Returns true if this submesh covers the entire parent mesh
  20669. * @ignorenaming
  20670. */
  20671. readonly IsGlobal: boolean;
  20672. /**
  20673. * Returns the submesh BoudingInfo object
  20674. * @returns current bounding info (or mesh's one if the submesh is global)
  20675. */
  20676. getBoundingInfo(): BoundingInfo;
  20677. /**
  20678. * Sets the submesh BoundingInfo
  20679. * @param boundingInfo defines the new bounding info to use
  20680. * @returns the SubMesh
  20681. */
  20682. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20683. /**
  20684. * Returns the mesh of the current submesh
  20685. * @return the parent mesh
  20686. */
  20687. getMesh(): AbstractMesh;
  20688. /**
  20689. * Returns the rendering mesh of the submesh
  20690. * @returns the rendering mesh (could be different from parent mesh)
  20691. */
  20692. getRenderingMesh(): Mesh;
  20693. /**
  20694. * Returns the submesh material
  20695. * @returns null or the current material
  20696. */
  20697. getMaterial(): Nullable<Material>;
  20698. /**
  20699. * Sets a new updated BoundingInfo object to the submesh
  20700. * @param data defines an optional position array to use to determine the bounding info
  20701. * @returns the SubMesh
  20702. */
  20703. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  20704. /** @hidden */
  20705. _checkCollision(collider: Collider): boolean;
  20706. /**
  20707. * Updates the submesh BoundingInfo
  20708. * @param world defines the world matrix to use to update the bounding info
  20709. * @returns the submesh
  20710. */
  20711. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20712. /**
  20713. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20714. * @param frustumPlanes defines the frustum planes
  20715. * @returns true if the submesh is intersecting with the frustum
  20716. */
  20717. isInFrustum(frustumPlanes: Plane[]): boolean;
  20718. /**
  20719. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20720. * @param frustumPlanes defines the frustum planes
  20721. * @returns true if the submesh is inside the frustum
  20722. */
  20723. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20724. /**
  20725. * Renders the submesh
  20726. * @param enableAlphaMode defines if alpha needs to be used
  20727. * @returns the submesh
  20728. */
  20729. render(enableAlphaMode: boolean): SubMesh;
  20730. /**
  20731. * @hidden
  20732. */
  20733. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  20734. /**
  20735. * Checks if the submesh intersects with a ray
  20736. * @param ray defines the ray to test
  20737. * @returns true is the passed ray intersects the submesh bounding box
  20738. */
  20739. canIntersects(ray: Ray): boolean;
  20740. /**
  20741. * Intersects current submesh with a ray
  20742. * @param ray defines the ray to test
  20743. * @param positions defines mesh's positions array
  20744. * @param indices defines mesh's indices array
  20745. * @param fastCheck defines if only bounding info should be used
  20746. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  20747. * @returns intersection info or null if no intersection
  20748. */
  20749. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  20750. /** @hidden */
  20751. private _intersectLines;
  20752. /** @hidden */
  20753. private _intersectUnIndexedLines;
  20754. /** @hidden */
  20755. private _intersectTriangles;
  20756. /** @hidden */
  20757. private _intersectUnIndexedTriangles;
  20758. /** @hidden */
  20759. _rebuild(): void;
  20760. /**
  20761. * Creates a new submesh from the passed mesh
  20762. * @param newMesh defines the new hosting mesh
  20763. * @param newRenderingMesh defines an optional rendering mesh
  20764. * @returns the new submesh
  20765. */
  20766. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  20767. /**
  20768. * Release associated resources
  20769. */
  20770. dispose(): void;
  20771. /**
  20772. * Gets the class name
  20773. * @returns the string "SubMesh".
  20774. */
  20775. getClassName(): string;
  20776. /**
  20777. * Creates a new submesh from indices data
  20778. * @param materialIndex the index of the main mesh material
  20779. * @param startIndex the index where to start the copy in the mesh indices array
  20780. * @param indexCount the number of indices to copy then from the startIndex
  20781. * @param mesh the main mesh to create the submesh from
  20782. * @param renderingMesh the optional rendering mesh
  20783. * @returns a new submesh
  20784. */
  20785. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  20786. }
  20787. }
  20788. declare module BABYLON {
  20789. /**
  20790. * Class used to represent data loading progression
  20791. */
  20792. export class SceneLoaderFlags {
  20793. private static _ForceFullSceneLoadingForIncremental;
  20794. private static _ShowLoadingScreen;
  20795. private static _CleanBoneMatrixWeights;
  20796. private static _loggingLevel;
  20797. /**
  20798. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  20799. */
  20800. static ForceFullSceneLoadingForIncremental: boolean;
  20801. /**
  20802. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  20803. */
  20804. static ShowLoadingScreen: boolean;
  20805. /**
  20806. * Defines the current logging level (while loading the scene)
  20807. * @ignorenaming
  20808. */
  20809. static loggingLevel: number;
  20810. /**
  20811. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  20812. */
  20813. static CleanBoneMatrixWeights: boolean;
  20814. }
  20815. }
  20816. declare module BABYLON {
  20817. /**
  20818. * Class used to store geometry data (vertex buffers + index buffer)
  20819. */
  20820. export class Geometry implements IGetSetVerticesData {
  20821. /**
  20822. * Gets or sets the ID of the geometry
  20823. */
  20824. id: string;
  20825. /**
  20826. * Gets or sets the unique ID of the geometry
  20827. */
  20828. uniqueId: number;
  20829. /**
  20830. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20831. */
  20832. delayLoadState: number;
  20833. /**
  20834. * Gets the file containing the data to load when running in delay load state
  20835. */
  20836. delayLoadingFile: Nullable<string>;
  20837. /**
  20838. * Callback called when the geometry is updated
  20839. */
  20840. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20841. private _scene;
  20842. private _engine;
  20843. private _meshes;
  20844. private _totalVertices;
  20845. /** @hidden */
  20846. _indices: IndicesArray;
  20847. /** @hidden */
  20848. _vertexBuffers: {
  20849. [key: string]: VertexBuffer;
  20850. };
  20851. private _isDisposed;
  20852. private _extend;
  20853. private _boundingBias;
  20854. /** @hidden */
  20855. _delayInfo: Array<string>;
  20856. private _indexBuffer;
  20857. private _indexBufferIsUpdatable;
  20858. /** @hidden */
  20859. _boundingInfo: Nullable<BoundingInfo>;
  20860. /** @hidden */
  20861. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20862. /** @hidden */
  20863. _softwareSkinningFrameId: number;
  20864. private _vertexArrayObjects;
  20865. private _updatable;
  20866. /** @hidden */
  20867. _positions: Nullable<Vector3[]>;
  20868. /**
  20869. * 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
  20870. */
  20871. /**
  20872. * 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
  20873. */
  20874. boundingBias: Vector2;
  20875. /**
  20876. * Static function used to attach a new empty geometry to a mesh
  20877. * @param mesh defines the mesh to attach the geometry to
  20878. * @returns the new Geometry
  20879. */
  20880. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  20881. /**
  20882. * Creates a new geometry
  20883. * @param id defines the unique ID
  20884. * @param scene defines the hosting scene
  20885. * @param vertexData defines the VertexData used to get geometry data
  20886. * @param updatable defines if geometry must be updatable (false by default)
  20887. * @param mesh defines the mesh that will be associated with the geometry
  20888. */
  20889. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  20890. /**
  20891. * Gets the current extend of the geometry
  20892. */
  20893. readonly extend: {
  20894. minimum: Vector3;
  20895. maximum: Vector3;
  20896. };
  20897. /**
  20898. * Gets the hosting scene
  20899. * @returns the hosting Scene
  20900. */
  20901. getScene(): Scene;
  20902. /**
  20903. * Gets the hosting engine
  20904. * @returns the hosting Engine
  20905. */
  20906. getEngine(): Engine;
  20907. /**
  20908. * Defines if the geometry is ready to use
  20909. * @returns true if the geometry is ready to be used
  20910. */
  20911. isReady(): boolean;
  20912. /**
  20913. * Gets a value indicating that the geometry should not be serialized
  20914. */
  20915. readonly doNotSerialize: boolean;
  20916. /** @hidden */
  20917. _rebuild(): void;
  20918. /**
  20919. * Affects all geometry data in one call
  20920. * @param vertexData defines the geometry data
  20921. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  20922. */
  20923. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20924. /**
  20925. * Set specific vertex data
  20926. * @param kind defines the data kind (Position, normal, etc...)
  20927. * @param data defines the vertex data to use
  20928. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20929. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20930. */
  20931. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  20932. /**
  20933. * Removes a specific vertex data
  20934. * @param kind defines the data kind (Position, normal, etc...)
  20935. */
  20936. removeVerticesData(kind: string): void;
  20937. /**
  20938. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  20939. * @param buffer defines the vertex buffer to use
  20940. * @param totalVertices defines the total number of vertices for position kind (could be null)
  20941. */
  20942. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  20943. /**
  20944. * Update a specific vertex buffer
  20945. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  20946. * It will do nothing if the buffer is not updatable
  20947. * @param kind defines the data kind (Position, normal, etc...)
  20948. * @param data defines the data to use
  20949. * @param offset defines the offset in the target buffer where to store the data
  20950. * @param useBytes set to true if the offset is in bytes
  20951. */
  20952. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  20953. /**
  20954. * Update a specific vertex buffer
  20955. * This function will create a new buffer if the current one is not updatable
  20956. * @param kind defines the data kind (Position, normal, etc...)
  20957. * @param data defines the data to use
  20958. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  20959. */
  20960. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  20961. private _updateBoundingInfo;
  20962. /** @hidden */
  20963. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  20964. /**
  20965. * Gets total number of vertices
  20966. * @returns the total number of vertices
  20967. */
  20968. getTotalVertices(): number;
  20969. /**
  20970. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20971. * @param kind defines the data kind (Position, normal, etc...)
  20972. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20973. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20974. * @returns a float array containing vertex data
  20975. */
  20976. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20977. /**
  20978. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  20979. * @param kind defines the data kind (Position, normal, etc...)
  20980. * @returns true if the vertex buffer with the specified kind is updatable
  20981. */
  20982. isVertexBufferUpdatable(kind: string): boolean;
  20983. /**
  20984. * Gets a specific vertex buffer
  20985. * @param kind defines the data kind (Position, normal, etc...)
  20986. * @returns a VertexBuffer
  20987. */
  20988. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20989. /**
  20990. * Returns all vertex buffers
  20991. * @return an object holding all vertex buffers indexed by kind
  20992. */
  20993. getVertexBuffers(): Nullable<{
  20994. [key: string]: VertexBuffer;
  20995. }>;
  20996. /**
  20997. * Gets a boolean indicating if specific vertex buffer is present
  20998. * @param kind defines the data kind (Position, normal, etc...)
  20999. * @returns true if data is present
  21000. */
  21001. isVerticesDataPresent(kind: string): boolean;
  21002. /**
  21003. * Gets a list of all attached data kinds (Position, normal, etc...)
  21004. * @returns a list of string containing all kinds
  21005. */
  21006. getVerticesDataKinds(): string[];
  21007. /**
  21008. * Update index buffer
  21009. * @param indices defines the indices to store in the index buffer
  21010. * @param offset defines the offset in the target buffer where to store the data
  21011. * @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)
  21012. */
  21013. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21014. /**
  21015. * Creates a new index buffer
  21016. * @param indices defines the indices to store in the index buffer
  21017. * @param totalVertices defines the total number of vertices (could be null)
  21018. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21019. */
  21020. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21021. /**
  21022. * Return the total number of indices
  21023. * @returns the total number of indices
  21024. */
  21025. getTotalIndices(): number;
  21026. /**
  21027. * Gets the index buffer array
  21028. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21029. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21030. * @returns the index buffer array
  21031. */
  21032. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21033. /**
  21034. * Gets the index buffer
  21035. * @return the index buffer
  21036. */
  21037. getIndexBuffer(): Nullable<DataBuffer>;
  21038. /** @hidden */
  21039. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21040. /**
  21041. * Release the associated resources for a specific mesh
  21042. * @param mesh defines the source mesh
  21043. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21044. */
  21045. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21046. /**
  21047. * Apply current geometry to a given mesh
  21048. * @param mesh defines the mesh to apply geometry to
  21049. */
  21050. applyToMesh(mesh: Mesh): void;
  21051. private _updateExtend;
  21052. private _applyToMesh;
  21053. private notifyUpdate;
  21054. /**
  21055. * Load the geometry if it was flagged as delay loaded
  21056. * @param scene defines the hosting scene
  21057. * @param onLoaded defines a callback called when the geometry is loaded
  21058. */
  21059. load(scene: Scene, onLoaded?: () => void): void;
  21060. private _queueLoad;
  21061. /**
  21062. * Invert the geometry to move from a right handed system to a left handed one.
  21063. */
  21064. toLeftHanded(): void;
  21065. /** @hidden */
  21066. _resetPointsArrayCache(): void;
  21067. /** @hidden */
  21068. _generatePointsArray(): boolean;
  21069. /**
  21070. * Gets a value indicating if the geometry is disposed
  21071. * @returns true if the geometry was disposed
  21072. */
  21073. isDisposed(): boolean;
  21074. private _disposeVertexArrayObjects;
  21075. /**
  21076. * Free all associated resources
  21077. */
  21078. dispose(): void;
  21079. /**
  21080. * Clone the current geometry into a new geometry
  21081. * @param id defines the unique ID of the new geometry
  21082. * @returns a new geometry object
  21083. */
  21084. copy(id: string): Geometry;
  21085. /**
  21086. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21087. * @return a JSON representation of the current geometry data (without the vertices data)
  21088. */
  21089. serialize(): any;
  21090. private toNumberArray;
  21091. /**
  21092. * Serialize all vertices data into a JSON oject
  21093. * @returns a JSON representation of the current geometry data
  21094. */
  21095. serializeVerticeData(): any;
  21096. /**
  21097. * Extracts a clone of a mesh geometry
  21098. * @param mesh defines the source mesh
  21099. * @param id defines the unique ID of the new geometry object
  21100. * @returns the new geometry object
  21101. */
  21102. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21103. /**
  21104. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21105. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21106. * Be aware Math.random() could cause collisions, but:
  21107. * "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"
  21108. * @returns a string containing a new GUID
  21109. */
  21110. static RandomId(): string;
  21111. /** @hidden */
  21112. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21113. private static _CleanMatricesWeights;
  21114. /**
  21115. * Create a new geometry from persisted data (Using .babylon file format)
  21116. * @param parsedVertexData defines the persisted data
  21117. * @param scene defines the hosting scene
  21118. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21119. * @returns the new geometry object
  21120. */
  21121. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21122. }
  21123. }
  21124. declare module BABYLON {
  21125. /**
  21126. * Define an interface for all classes that will get and set the data on vertices
  21127. */
  21128. export interface IGetSetVerticesData {
  21129. /**
  21130. * Gets a boolean indicating if specific vertex data is present
  21131. * @param kind defines the vertex data kind to use
  21132. * @returns true is data kind is present
  21133. */
  21134. isVerticesDataPresent(kind: string): boolean;
  21135. /**
  21136. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21137. * @param kind defines the data kind (Position, normal, etc...)
  21138. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21139. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21140. * @returns a float array containing vertex data
  21141. */
  21142. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21143. /**
  21144. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21145. * @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.
  21146. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21147. * @returns the indices array or an empty array if the mesh has no geometry
  21148. */
  21149. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21150. /**
  21151. * Set specific vertex data
  21152. * @param kind defines the data kind (Position, normal, etc...)
  21153. * @param data defines the vertex data to use
  21154. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21155. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21156. */
  21157. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21158. /**
  21159. * Update a specific associated vertex buffer
  21160. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21161. * - VertexBuffer.PositionKind
  21162. * - VertexBuffer.UVKind
  21163. * - VertexBuffer.UV2Kind
  21164. * - VertexBuffer.UV3Kind
  21165. * - VertexBuffer.UV4Kind
  21166. * - VertexBuffer.UV5Kind
  21167. * - VertexBuffer.UV6Kind
  21168. * - VertexBuffer.ColorKind
  21169. * - VertexBuffer.MatricesIndicesKind
  21170. * - VertexBuffer.MatricesIndicesExtraKind
  21171. * - VertexBuffer.MatricesWeightsKind
  21172. * - VertexBuffer.MatricesWeightsExtraKind
  21173. * @param data defines the data source
  21174. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21175. * @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)
  21176. */
  21177. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21178. /**
  21179. * Creates a new index buffer
  21180. * @param indices defines the indices to store in the index buffer
  21181. * @param totalVertices defines the total number of vertices (could be null)
  21182. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21183. */
  21184. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21185. }
  21186. /**
  21187. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21188. */
  21189. export class VertexData {
  21190. /**
  21191. * Mesh side orientation : usually the external or front surface
  21192. */
  21193. static readonly FRONTSIDE: number;
  21194. /**
  21195. * Mesh side orientation : usually the internal or back surface
  21196. */
  21197. static readonly BACKSIDE: number;
  21198. /**
  21199. * Mesh side orientation : both internal and external or front and back surfaces
  21200. */
  21201. static readonly DOUBLESIDE: number;
  21202. /**
  21203. * Mesh side orientation : by default, `FRONTSIDE`
  21204. */
  21205. static readonly DEFAULTSIDE: number;
  21206. /**
  21207. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21208. */
  21209. positions: Nullable<FloatArray>;
  21210. /**
  21211. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21212. */
  21213. normals: Nullable<FloatArray>;
  21214. /**
  21215. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21216. */
  21217. tangents: Nullable<FloatArray>;
  21218. /**
  21219. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21220. */
  21221. uvs: Nullable<FloatArray>;
  21222. /**
  21223. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21224. */
  21225. uvs2: Nullable<FloatArray>;
  21226. /**
  21227. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21228. */
  21229. uvs3: Nullable<FloatArray>;
  21230. /**
  21231. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21232. */
  21233. uvs4: Nullable<FloatArray>;
  21234. /**
  21235. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21236. */
  21237. uvs5: Nullable<FloatArray>;
  21238. /**
  21239. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21240. */
  21241. uvs6: Nullable<FloatArray>;
  21242. /**
  21243. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21244. */
  21245. colors: Nullable<FloatArray>;
  21246. /**
  21247. * 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).
  21248. */
  21249. matricesIndices: Nullable<FloatArray>;
  21250. /**
  21251. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21252. */
  21253. matricesWeights: Nullable<FloatArray>;
  21254. /**
  21255. * An array extending the number of possible indices
  21256. */
  21257. matricesIndicesExtra: Nullable<FloatArray>;
  21258. /**
  21259. * An array extending the number of possible weights when the number of indices is extended
  21260. */
  21261. matricesWeightsExtra: Nullable<FloatArray>;
  21262. /**
  21263. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21264. */
  21265. indices: Nullable<IndicesArray>;
  21266. /**
  21267. * Uses the passed data array to set the set the values for the specified kind of data
  21268. * @param data a linear array of floating numbers
  21269. * @param kind the type of data that is being set, eg positions, colors etc
  21270. */
  21271. set(data: FloatArray, kind: string): void;
  21272. /**
  21273. * Associates the vertexData to the passed Mesh.
  21274. * Sets it as updatable or not (default `false`)
  21275. * @param mesh the mesh the vertexData is applied to
  21276. * @param updatable when used and having the value true allows new data to update the vertexData
  21277. * @returns the VertexData
  21278. */
  21279. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21280. /**
  21281. * Associates the vertexData to the passed Geometry.
  21282. * Sets it as updatable or not (default `false`)
  21283. * @param geometry the geometry the vertexData is applied to
  21284. * @param updatable when used and having the value true allows new data to update the vertexData
  21285. * @returns VertexData
  21286. */
  21287. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21288. /**
  21289. * Updates the associated mesh
  21290. * @param mesh the mesh to be updated
  21291. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21292. * @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
  21293. * @returns VertexData
  21294. */
  21295. updateMesh(mesh: Mesh): VertexData;
  21296. /**
  21297. * Updates the associated geometry
  21298. * @param geometry the geometry to be updated
  21299. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21300. * @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
  21301. * @returns VertexData.
  21302. */
  21303. updateGeometry(geometry: Geometry): VertexData;
  21304. private _applyTo;
  21305. private _update;
  21306. /**
  21307. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21308. * @param matrix the transforming matrix
  21309. * @returns the VertexData
  21310. */
  21311. transform(matrix: Matrix): VertexData;
  21312. /**
  21313. * Merges the passed VertexData into the current one
  21314. * @param other the VertexData to be merged into the current one
  21315. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21316. * @returns the modified VertexData
  21317. */
  21318. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21319. private _mergeElement;
  21320. private _validate;
  21321. /**
  21322. * Serializes the VertexData
  21323. * @returns a serialized object
  21324. */
  21325. serialize(): any;
  21326. /**
  21327. * Extracts the vertexData from a mesh
  21328. * @param mesh the mesh from which to extract the VertexData
  21329. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21330. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21331. * @returns the object VertexData associated to the passed mesh
  21332. */
  21333. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21334. /**
  21335. * Extracts the vertexData from the geometry
  21336. * @param geometry the geometry from which to extract the VertexData
  21337. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21338. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21339. * @returns the object VertexData associated to the passed mesh
  21340. */
  21341. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21342. private static _ExtractFrom;
  21343. /**
  21344. * Creates the VertexData for a Ribbon
  21345. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21346. * * pathArray array of paths, each of which an array of successive Vector3
  21347. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21348. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21349. * * 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
  21350. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21351. * * 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)
  21352. * * 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)
  21353. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21354. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21355. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21356. * @returns the VertexData of the ribbon
  21357. */
  21358. static CreateRibbon(options: {
  21359. pathArray: Vector3[][];
  21360. closeArray?: boolean;
  21361. closePath?: boolean;
  21362. offset?: number;
  21363. sideOrientation?: number;
  21364. frontUVs?: Vector4;
  21365. backUVs?: Vector4;
  21366. invertUV?: boolean;
  21367. uvs?: Vector2[];
  21368. colors?: Color4[];
  21369. }): VertexData;
  21370. /**
  21371. * Creates the VertexData for a box
  21372. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21373. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21374. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21375. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21376. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21377. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21378. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21379. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21380. * * 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)
  21381. * * 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)
  21382. * @returns the VertexData of the box
  21383. */
  21384. static CreateBox(options: {
  21385. size?: number;
  21386. width?: number;
  21387. height?: number;
  21388. depth?: number;
  21389. faceUV?: Vector4[];
  21390. faceColors?: Color4[];
  21391. sideOrientation?: number;
  21392. frontUVs?: Vector4;
  21393. backUVs?: Vector4;
  21394. }): VertexData;
  21395. /**
  21396. * Creates the VertexData for a tiled box
  21397. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21398. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21399. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21400. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21401. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21402. * @returns the VertexData of the box
  21403. */
  21404. static CreateTiledBox(options: {
  21405. pattern?: number;
  21406. width?: number;
  21407. height?: number;
  21408. depth?: number;
  21409. tileSize?: number;
  21410. tileWidth?: number;
  21411. tileHeight?: number;
  21412. alignHorizontal?: number;
  21413. alignVertical?: number;
  21414. faceUV?: Vector4[];
  21415. faceColors?: Color4[];
  21416. sideOrientation?: number;
  21417. }): VertexData;
  21418. /**
  21419. * Creates the VertexData for a tiled plane
  21420. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21421. * * pattern a limited pattern arrangement depending on the number
  21422. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21423. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21424. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21425. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21426. * * 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)
  21427. * * 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)
  21428. * @returns the VertexData of the tiled plane
  21429. */
  21430. static CreateTiledPlane(options: {
  21431. pattern?: number;
  21432. tileSize?: number;
  21433. tileWidth?: number;
  21434. tileHeight?: number;
  21435. size?: number;
  21436. width?: number;
  21437. height?: number;
  21438. alignHorizontal?: number;
  21439. alignVertical?: number;
  21440. sideOrientation?: number;
  21441. frontUVs?: Vector4;
  21442. backUVs?: Vector4;
  21443. }): VertexData;
  21444. /**
  21445. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21446. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21447. * * segments sets the number of horizontal strips optional, default 32
  21448. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21449. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21450. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21451. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21452. * * 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
  21453. * * 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
  21454. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21455. * * 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)
  21456. * * 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)
  21457. * @returns the VertexData of the ellipsoid
  21458. */
  21459. static CreateSphere(options: {
  21460. segments?: number;
  21461. diameter?: number;
  21462. diameterX?: number;
  21463. diameterY?: number;
  21464. diameterZ?: number;
  21465. arc?: number;
  21466. slice?: number;
  21467. sideOrientation?: number;
  21468. frontUVs?: Vector4;
  21469. backUVs?: Vector4;
  21470. }): VertexData;
  21471. /**
  21472. * Creates the VertexData for a cylinder, cone or prism
  21473. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21474. * * height sets the height (y direction) of the cylinder, optional, default 2
  21475. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21476. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21477. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21478. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21479. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21480. * * 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
  21481. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21482. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21483. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21484. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21485. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21486. * * 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)
  21487. * * 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)
  21488. * @returns the VertexData of the cylinder, cone or prism
  21489. */
  21490. static CreateCylinder(options: {
  21491. height?: number;
  21492. diameterTop?: number;
  21493. diameterBottom?: number;
  21494. diameter?: number;
  21495. tessellation?: number;
  21496. subdivisions?: number;
  21497. arc?: number;
  21498. faceColors?: Color4[];
  21499. faceUV?: Vector4[];
  21500. hasRings?: boolean;
  21501. enclose?: boolean;
  21502. sideOrientation?: number;
  21503. frontUVs?: Vector4;
  21504. backUVs?: Vector4;
  21505. }): VertexData;
  21506. /**
  21507. * Creates the VertexData for a torus
  21508. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21509. * * diameter the diameter of the torus, optional default 1
  21510. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21511. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21512. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21513. * * 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)
  21514. * * 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)
  21515. * @returns the VertexData of the torus
  21516. */
  21517. static CreateTorus(options: {
  21518. diameter?: number;
  21519. thickness?: number;
  21520. tessellation?: number;
  21521. sideOrientation?: number;
  21522. frontUVs?: Vector4;
  21523. backUVs?: Vector4;
  21524. }): VertexData;
  21525. /**
  21526. * Creates the VertexData of the LineSystem
  21527. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21528. * - lines an array of lines, each line being an array of successive Vector3
  21529. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21530. * @returns the VertexData of the LineSystem
  21531. */
  21532. static CreateLineSystem(options: {
  21533. lines: Vector3[][];
  21534. colors?: Nullable<Color4[][]>;
  21535. }): VertexData;
  21536. /**
  21537. * Create the VertexData for a DashedLines
  21538. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21539. * - points an array successive Vector3
  21540. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21541. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21542. * - dashNb the intended total number of dashes, optional, default 200
  21543. * @returns the VertexData for the DashedLines
  21544. */
  21545. static CreateDashedLines(options: {
  21546. points: Vector3[];
  21547. dashSize?: number;
  21548. gapSize?: number;
  21549. dashNb?: number;
  21550. }): VertexData;
  21551. /**
  21552. * Creates the VertexData for a Ground
  21553. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21554. * - width the width (x direction) of the ground, optional, default 1
  21555. * - height the height (z direction) of the ground, optional, default 1
  21556. * - subdivisions the number of subdivisions per side, optional, default 1
  21557. * @returns the VertexData of the Ground
  21558. */
  21559. static CreateGround(options: {
  21560. width?: number;
  21561. height?: number;
  21562. subdivisions?: number;
  21563. subdivisionsX?: number;
  21564. subdivisionsY?: number;
  21565. }): VertexData;
  21566. /**
  21567. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21568. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21569. * * xmin the ground minimum X coordinate, optional, default -1
  21570. * * zmin the ground minimum Z coordinate, optional, default -1
  21571. * * xmax the ground maximum X coordinate, optional, default 1
  21572. * * zmax the ground maximum Z coordinate, optional, default 1
  21573. * * 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}
  21574. * * 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}
  21575. * @returns the VertexData of the TiledGround
  21576. */
  21577. static CreateTiledGround(options: {
  21578. xmin: number;
  21579. zmin: number;
  21580. xmax: number;
  21581. zmax: number;
  21582. subdivisions?: {
  21583. w: number;
  21584. h: number;
  21585. };
  21586. precision?: {
  21587. w: number;
  21588. h: number;
  21589. };
  21590. }): VertexData;
  21591. /**
  21592. * Creates the VertexData of the Ground designed from a heightmap
  21593. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21594. * * width the width (x direction) of the ground
  21595. * * height the height (z direction) of the ground
  21596. * * subdivisions the number of subdivisions per side
  21597. * * minHeight the minimum altitude on the ground, optional, default 0
  21598. * * maxHeight the maximum altitude on the ground, optional default 1
  21599. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21600. * * buffer the array holding the image color data
  21601. * * bufferWidth the width of image
  21602. * * bufferHeight the height of image
  21603. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21604. * @returns the VertexData of the Ground designed from a heightmap
  21605. */
  21606. static CreateGroundFromHeightMap(options: {
  21607. width: number;
  21608. height: number;
  21609. subdivisions: number;
  21610. minHeight: number;
  21611. maxHeight: number;
  21612. colorFilter: Color3;
  21613. buffer: Uint8Array;
  21614. bufferWidth: number;
  21615. bufferHeight: number;
  21616. alphaFilter: number;
  21617. }): VertexData;
  21618. /**
  21619. * Creates the VertexData for a Plane
  21620. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21621. * * size sets the width and height of the plane to the value of size, optional default 1
  21622. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21623. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21624. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21625. * * 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)
  21626. * * 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)
  21627. * @returns the VertexData of the box
  21628. */
  21629. static CreatePlane(options: {
  21630. size?: number;
  21631. width?: number;
  21632. height?: number;
  21633. sideOrientation?: number;
  21634. frontUVs?: Vector4;
  21635. backUVs?: Vector4;
  21636. }): VertexData;
  21637. /**
  21638. * Creates the VertexData of the Disc or regular Polygon
  21639. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21640. * * radius the radius of the disc, optional default 0.5
  21641. * * tessellation the number of polygon sides, optional, default 64
  21642. * * 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
  21643. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21644. * * 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)
  21645. * * 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)
  21646. * @returns the VertexData of the box
  21647. */
  21648. static CreateDisc(options: {
  21649. radius?: number;
  21650. tessellation?: number;
  21651. arc?: number;
  21652. sideOrientation?: number;
  21653. frontUVs?: Vector4;
  21654. backUVs?: Vector4;
  21655. }): VertexData;
  21656. /**
  21657. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21658. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21659. * @param polygon a mesh built from polygonTriangulation.build()
  21660. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21661. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21662. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21663. * @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)
  21664. * @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)
  21665. * @returns the VertexData of the Polygon
  21666. */
  21667. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21668. /**
  21669. * Creates the VertexData of the IcoSphere
  21670. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21671. * * radius the radius of the IcoSphere, optional default 1
  21672. * * radiusX allows stretching in the x direction, optional, default radius
  21673. * * radiusY allows stretching in the y direction, optional, default radius
  21674. * * radiusZ allows stretching in the z direction, optional, default radius
  21675. * * flat when true creates a flat shaded mesh, optional, default true
  21676. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21677. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21678. * * 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)
  21679. * * 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)
  21680. * @returns the VertexData of the IcoSphere
  21681. */
  21682. static CreateIcoSphere(options: {
  21683. radius?: number;
  21684. radiusX?: number;
  21685. radiusY?: number;
  21686. radiusZ?: number;
  21687. flat?: boolean;
  21688. subdivisions?: number;
  21689. sideOrientation?: number;
  21690. frontUVs?: Vector4;
  21691. backUVs?: Vector4;
  21692. }): VertexData;
  21693. /**
  21694. * Creates the VertexData for a Polyhedron
  21695. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21696. * * type provided types are:
  21697. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21698. * * 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)
  21699. * * size the size of the IcoSphere, optional default 1
  21700. * * sizeX allows stretching in the x direction, optional, default size
  21701. * * sizeY allows stretching in the y direction, optional, default size
  21702. * * sizeZ allows stretching in the z direction, optional, default size
  21703. * * 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
  21704. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21705. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21706. * * flat when true creates a flat shaded mesh, optional, default true
  21707. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21708. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21709. * * 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)
  21710. * * 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)
  21711. * @returns the VertexData of the Polyhedron
  21712. */
  21713. static CreatePolyhedron(options: {
  21714. type?: number;
  21715. size?: number;
  21716. sizeX?: number;
  21717. sizeY?: number;
  21718. sizeZ?: number;
  21719. custom?: any;
  21720. faceUV?: Vector4[];
  21721. faceColors?: Color4[];
  21722. flat?: boolean;
  21723. sideOrientation?: number;
  21724. frontUVs?: Vector4;
  21725. backUVs?: Vector4;
  21726. }): VertexData;
  21727. /**
  21728. * Creates the VertexData for a TorusKnot
  21729. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21730. * * radius the radius of the torus knot, optional, default 2
  21731. * * tube the thickness of the tube, optional, default 0.5
  21732. * * radialSegments the number of sides on each tube segments, optional, default 32
  21733. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21734. * * p the number of windings around the z axis, optional, default 2
  21735. * * q the number of windings around the x axis, optional, default 3
  21736. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21737. * * 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)
  21738. * * 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)
  21739. * @returns the VertexData of the Torus Knot
  21740. */
  21741. static CreateTorusKnot(options: {
  21742. radius?: number;
  21743. tube?: number;
  21744. radialSegments?: number;
  21745. tubularSegments?: number;
  21746. p?: number;
  21747. q?: number;
  21748. sideOrientation?: number;
  21749. frontUVs?: Vector4;
  21750. backUVs?: Vector4;
  21751. }): VertexData;
  21752. /**
  21753. * Compute normals for given positions and indices
  21754. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21755. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21756. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21757. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21758. * * facetNormals : optional array of facet normals (vector3)
  21759. * * facetPositions : optional array of facet positions (vector3)
  21760. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21761. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21762. * * bInfo : optional bounding info, required for facetPartitioning computation
  21763. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21764. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21765. * * useRightHandedSystem: optional boolean to for right handed system computation
  21766. * * depthSort : optional boolean to enable the facet depth sort computation
  21767. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21768. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21769. */
  21770. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21771. facetNormals?: any;
  21772. facetPositions?: any;
  21773. facetPartitioning?: any;
  21774. ratio?: number;
  21775. bInfo?: any;
  21776. bbSize?: Vector3;
  21777. subDiv?: any;
  21778. useRightHandedSystem?: boolean;
  21779. depthSort?: boolean;
  21780. distanceTo?: Vector3;
  21781. depthSortedFacets?: any;
  21782. }): void;
  21783. /** @hidden */
  21784. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  21785. /**
  21786. * Applies VertexData created from the imported parameters to the geometry
  21787. * @param parsedVertexData the parsed data from an imported file
  21788. * @param geometry the geometry to apply the VertexData to
  21789. */
  21790. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21791. }
  21792. }
  21793. declare module BABYLON {
  21794. /**
  21795. * Defines a target to use with MorphTargetManager
  21796. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21797. */
  21798. export class MorphTarget implements IAnimatable {
  21799. /** defines the name of the target */
  21800. name: string;
  21801. /**
  21802. * Gets or sets the list of animations
  21803. */
  21804. animations: Animation[];
  21805. private _scene;
  21806. private _positions;
  21807. private _normals;
  21808. private _tangents;
  21809. private _uvs;
  21810. private _influence;
  21811. /**
  21812. * Observable raised when the influence changes
  21813. */
  21814. onInfluenceChanged: Observable<boolean>;
  21815. /** @hidden */
  21816. _onDataLayoutChanged: Observable<void>;
  21817. /**
  21818. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  21819. */
  21820. influence: number;
  21821. /**
  21822. * Gets or sets the id of the morph Target
  21823. */
  21824. id: string;
  21825. private _animationPropertiesOverride;
  21826. /**
  21827. * Gets or sets the animation properties override
  21828. */
  21829. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  21830. /**
  21831. * Creates a new MorphTarget
  21832. * @param name defines the name of the target
  21833. * @param influence defines the influence to use
  21834. * @param scene defines the scene the morphtarget belongs to
  21835. */
  21836. constructor(
  21837. /** defines the name of the target */
  21838. name: string, influence?: number, scene?: Nullable<Scene>);
  21839. /**
  21840. * Gets a boolean defining if the target contains position data
  21841. */
  21842. readonly hasPositions: boolean;
  21843. /**
  21844. * Gets a boolean defining if the target contains normal data
  21845. */
  21846. readonly hasNormals: boolean;
  21847. /**
  21848. * Gets a boolean defining if the target contains tangent data
  21849. */
  21850. readonly hasTangents: boolean;
  21851. /**
  21852. * Gets a boolean defining if the target contains texture coordinates data
  21853. */
  21854. readonly hasUVs: boolean;
  21855. /**
  21856. * Affects position data to this target
  21857. * @param data defines the position data to use
  21858. */
  21859. setPositions(data: Nullable<FloatArray>): void;
  21860. /**
  21861. * Gets the position data stored in this target
  21862. * @returns a FloatArray containing the position data (or null if not present)
  21863. */
  21864. getPositions(): Nullable<FloatArray>;
  21865. /**
  21866. * Affects normal data to this target
  21867. * @param data defines the normal data to use
  21868. */
  21869. setNormals(data: Nullable<FloatArray>): void;
  21870. /**
  21871. * Gets the normal data stored in this target
  21872. * @returns a FloatArray containing the normal data (or null if not present)
  21873. */
  21874. getNormals(): Nullable<FloatArray>;
  21875. /**
  21876. * Affects tangent data to this target
  21877. * @param data defines the tangent data to use
  21878. */
  21879. setTangents(data: Nullable<FloatArray>): void;
  21880. /**
  21881. * Gets the tangent data stored in this target
  21882. * @returns a FloatArray containing the tangent data (or null if not present)
  21883. */
  21884. getTangents(): Nullable<FloatArray>;
  21885. /**
  21886. * Affects texture coordinates data to this target
  21887. * @param data defines the texture coordinates data to use
  21888. */
  21889. setUVs(data: Nullable<FloatArray>): void;
  21890. /**
  21891. * Gets the texture coordinates data stored in this target
  21892. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  21893. */
  21894. getUVs(): Nullable<FloatArray>;
  21895. /**
  21896. * Serializes the current target into a Serialization object
  21897. * @returns the serialized object
  21898. */
  21899. serialize(): any;
  21900. /**
  21901. * Returns the string "MorphTarget"
  21902. * @returns "MorphTarget"
  21903. */
  21904. getClassName(): string;
  21905. /**
  21906. * Creates a new target from serialized data
  21907. * @param serializationObject defines the serialized data to use
  21908. * @returns a new MorphTarget
  21909. */
  21910. static Parse(serializationObject: any): MorphTarget;
  21911. /**
  21912. * Creates a MorphTarget from mesh data
  21913. * @param mesh defines the source mesh
  21914. * @param name defines the name to use for the new target
  21915. * @param influence defines the influence to attach to the target
  21916. * @returns a new MorphTarget
  21917. */
  21918. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  21919. }
  21920. }
  21921. declare module BABYLON {
  21922. /**
  21923. * This class is used to deform meshes using morphing between different targets
  21924. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21925. */
  21926. export class MorphTargetManager {
  21927. private _targets;
  21928. private _targetInfluenceChangedObservers;
  21929. private _targetDataLayoutChangedObservers;
  21930. private _activeTargets;
  21931. private _scene;
  21932. private _influences;
  21933. private _supportsNormals;
  21934. private _supportsTangents;
  21935. private _supportsUVs;
  21936. private _vertexCount;
  21937. private _uniqueId;
  21938. private _tempInfluences;
  21939. /**
  21940. * Gets or sets a boolean indicating if normals must be morphed
  21941. */
  21942. enableNormalMorphing: boolean;
  21943. /**
  21944. * Gets or sets a boolean indicating if tangents must be morphed
  21945. */
  21946. enableTangentMorphing: boolean;
  21947. /**
  21948. * Gets or sets a boolean indicating if UV must be morphed
  21949. */
  21950. enableUVMorphing: boolean;
  21951. /**
  21952. * Creates a new MorphTargetManager
  21953. * @param scene defines the current scene
  21954. */
  21955. constructor(scene?: Nullable<Scene>);
  21956. /**
  21957. * Gets the unique ID of this manager
  21958. */
  21959. readonly uniqueId: number;
  21960. /**
  21961. * Gets the number of vertices handled by this manager
  21962. */
  21963. readonly vertexCount: number;
  21964. /**
  21965. * Gets a boolean indicating if this manager supports morphing of normals
  21966. */
  21967. readonly supportsNormals: boolean;
  21968. /**
  21969. * Gets a boolean indicating if this manager supports morphing of tangents
  21970. */
  21971. readonly supportsTangents: boolean;
  21972. /**
  21973. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  21974. */
  21975. readonly supportsUVs: boolean;
  21976. /**
  21977. * Gets the number of targets stored in this manager
  21978. */
  21979. readonly numTargets: number;
  21980. /**
  21981. * Gets the number of influencers (ie. the number of targets with influences > 0)
  21982. */
  21983. readonly numInfluencers: number;
  21984. /**
  21985. * Gets the list of influences (one per target)
  21986. */
  21987. readonly influences: Float32Array;
  21988. /**
  21989. * Gets the active target at specified index. An active target is a target with an influence > 0
  21990. * @param index defines the index to check
  21991. * @returns the requested target
  21992. */
  21993. getActiveTarget(index: number): MorphTarget;
  21994. /**
  21995. * Gets the target at specified index
  21996. * @param index defines the index to check
  21997. * @returns the requested target
  21998. */
  21999. getTarget(index: number): MorphTarget;
  22000. /**
  22001. * Add a new target to this manager
  22002. * @param target defines the target to add
  22003. */
  22004. addTarget(target: MorphTarget): void;
  22005. /**
  22006. * Removes a target from the manager
  22007. * @param target defines the target to remove
  22008. */
  22009. removeTarget(target: MorphTarget): void;
  22010. /**
  22011. * Serializes the current manager into a Serialization object
  22012. * @returns the serialized object
  22013. */
  22014. serialize(): any;
  22015. private _syncActiveTargets;
  22016. /**
  22017. * Syncrhonize the targets with all the meshes using this morph target manager
  22018. */
  22019. synchronize(): void;
  22020. /**
  22021. * Creates a new MorphTargetManager from serialized data
  22022. * @param serializationObject defines the serialized data
  22023. * @param scene defines the hosting scene
  22024. * @returns the new MorphTargetManager
  22025. */
  22026. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22027. }
  22028. }
  22029. declare module BABYLON {
  22030. /**
  22031. * Class used to represent a specific level of detail of a mesh
  22032. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22033. */
  22034. export class MeshLODLevel {
  22035. /** Defines the distance where this level should star being displayed */
  22036. distance: number;
  22037. /** Defines the mesh to use to render this level */
  22038. mesh: Nullable<Mesh>;
  22039. /**
  22040. * Creates a new LOD level
  22041. * @param distance defines the distance where this level should star being displayed
  22042. * @param mesh defines the mesh to use to render this level
  22043. */
  22044. constructor(
  22045. /** Defines the distance where this level should star being displayed */
  22046. distance: number,
  22047. /** Defines the mesh to use to render this level */
  22048. mesh: Nullable<Mesh>);
  22049. }
  22050. }
  22051. declare module BABYLON {
  22052. /**
  22053. * Mesh representing the gorund
  22054. */
  22055. export class GroundMesh extends Mesh {
  22056. /** If octree should be generated */
  22057. generateOctree: boolean;
  22058. private _heightQuads;
  22059. /** @hidden */
  22060. _subdivisionsX: number;
  22061. /** @hidden */
  22062. _subdivisionsY: number;
  22063. /** @hidden */
  22064. _width: number;
  22065. /** @hidden */
  22066. _height: number;
  22067. /** @hidden */
  22068. _minX: number;
  22069. /** @hidden */
  22070. _maxX: number;
  22071. /** @hidden */
  22072. _minZ: number;
  22073. /** @hidden */
  22074. _maxZ: number;
  22075. constructor(name: string, scene: Scene);
  22076. /**
  22077. * "GroundMesh"
  22078. * @returns "GroundMesh"
  22079. */
  22080. getClassName(): string;
  22081. /**
  22082. * The minimum of x and y subdivisions
  22083. */
  22084. readonly subdivisions: number;
  22085. /**
  22086. * X subdivisions
  22087. */
  22088. readonly subdivisionsX: number;
  22089. /**
  22090. * Y subdivisions
  22091. */
  22092. readonly subdivisionsY: number;
  22093. /**
  22094. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22095. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22096. * @param chunksCount the number of subdivisions for x and y
  22097. * @param octreeBlocksSize (Default: 32)
  22098. */
  22099. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22100. /**
  22101. * Returns a height (y) value in the Worl system :
  22102. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22103. * @param x x coordinate
  22104. * @param z z coordinate
  22105. * @returns the ground y position if (x, z) are outside the ground surface.
  22106. */
  22107. getHeightAtCoordinates(x: number, z: number): number;
  22108. /**
  22109. * Returns a normalized vector (Vector3) orthogonal to the ground
  22110. * at the ground coordinates (x, z) expressed in the World system.
  22111. * @param x x coordinate
  22112. * @param z z coordinate
  22113. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22114. */
  22115. getNormalAtCoordinates(x: number, z: number): Vector3;
  22116. /**
  22117. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22118. * at the ground coordinates (x, z) expressed in the World system.
  22119. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22120. * @param x x coordinate
  22121. * @param z z coordinate
  22122. * @param ref vector to store the result
  22123. * @returns the GroundMesh.
  22124. */
  22125. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22126. /**
  22127. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22128. * if the ground has been updated.
  22129. * This can be used in the render loop.
  22130. * @returns the GroundMesh.
  22131. */
  22132. updateCoordinateHeights(): GroundMesh;
  22133. private _getFacetAt;
  22134. private _initHeightQuads;
  22135. private _computeHeightQuads;
  22136. /**
  22137. * Serializes this ground mesh
  22138. * @param serializationObject object to write serialization to
  22139. */
  22140. serialize(serializationObject: any): void;
  22141. /**
  22142. * Parses a serialized ground mesh
  22143. * @param parsedMesh the serialized mesh
  22144. * @param scene the scene to create the ground mesh in
  22145. * @returns the created ground mesh
  22146. */
  22147. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22148. }
  22149. }
  22150. declare module BABYLON {
  22151. /**
  22152. * Interface for Physics-Joint data
  22153. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22154. */
  22155. export interface PhysicsJointData {
  22156. /**
  22157. * The main pivot of the joint
  22158. */
  22159. mainPivot?: Vector3;
  22160. /**
  22161. * The connected pivot of the joint
  22162. */
  22163. connectedPivot?: Vector3;
  22164. /**
  22165. * The main axis of the joint
  22166. */
  22167. mainAxis?: Vector3;
  22168. /**
  22169. * The connected axis of the joint
  22170. */
  22171. connectedAxis?: Vector3;
  22172. /**
  22173. * The collision of the joint
  22174. */
  22175. collision?: boolean;
  22176. /**
  22177. * Native Oimo/Cannon/Energy data
  22178. */
  22179. nativeParams?: any;
  22180. }
  22181. /**
  22182. * This is a holder class for the physics joint created by the physics plugin
  22183. * It holds a set of functions to control the underlying joint
  22184. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22185. */
  22186. export class PhysicsJoint {
  22187. /**
  22188. * The type of the physics joint
  22189. */
  22190. type: number;
  22191. /**
  22192. * The data for the physics joint
  22193. */
  22194. jointData: PhysicsJointData;
  22195. private _physicsJoint;
  22196. protected _physicsPlugin: IPhysicsEnginePlugin;
  22197. /**
  22198. * Initializes the physics joint
  22199. * @param type The type of the physics joint
  22200. * @param jointData The data for the physics joint
  22201. */
  22202. constructor(
  22203. /**
  22204. * The type of the physics joint
  22205. */
  22206. type: number,
  22207. /**
  22208. * The data for the physics joint
  22209. */
  22210. jointData: PhysicsJointData);
  22211. /**
  22212. * Gets the physics joint
  22213. */
  22214. /**
  22215. * Sets the physics joint
  22216. */
  22217. physicsJoint: any;
  22218. /**
  22219. * Sets the physics plugin
  22220. */
  22221. physicsPlugin: IPhysicsEnginePlugin;
  22222. /**
  22223. * Execute a function that is physics-plugin specific.
  22224. * @param {Function} func the function that will be executed.
  22225. * It accepts two parameters: the physics world and the physics joint
  22226. */
  22227. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22228. /**
  22229. * Distance-Joint type
  22230. */
  22231. static DistanceJoint: number;
  22232. /**
  22233. * Hinge-Joint type
  22234. */
  22235. static HingeJoint: number;
  22236. /**
  22237. * Ball-and-Socket joint type
  22238. */
  22239. static BallAndSocketJoint: number;
  22240. /**
  22241. * Wheel-Joint type
  22242. */
  22243. static WheelJoint: number;
  22244. /**
  22245. * Slider-Joint type
  22246. */
  22247. static SliderJoint: number;
  22248. /**
  22249. * Prismatic-Joint type
  22250. */
  22251. static PrismaticJoint: number;
  22252. /**
  22253. * Universal-Joint type
  22254. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22255. */
  22256. static UniversalJoint: number;
  22257. /**
  22258. * Hinge-Joint 2 type
  22259. */
  22260. static Hinge2Joint: number;
  22261. /**
  22262. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22263. */
  22264. static PointToPointJoint: number;
  22265. /**
  22266. * Spring-Joint type
  22267. */
  22268. static SpringJoint: number;
  22269. /**
  22270. * Lock-Joint type
  22271. */
  22272. static LockJoint: number;
  22273. }
  22274. /**
  22275. * A class representing a physics distance joint
  22276. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22277. */
  22278. export class DistanceJoint extends PhysicsJoint {
  22279. /**
  22280. *
  22281. * @param jointData The data for the Distance-Joint
  22282. */
  22283. constructor(jointData: DistanceJointData);
  22284. /**
  22285. * Update the predefined distance.
  22286. * @param maxDistance The maximum preferred distance
  22287. * @param minDistance The minimum preferred distance
  22288. */
  22289. updateDistance(maxDistance: number, minDistance?: number): void;
  22290. }
  22291. /**
  22292. * Represents a Motor-Enabled Joint
  22293. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22294. */
  22295. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22296. /**
  22297. * Initializes the Motor-Enabled Joint
  22298. * @param type The type of the joint
  22299. * @param jointData The physica joint data for the joint
  22300. */
  22301. constructor(type: number, jointData: PhysicsJointData);
  22302. /**
  22303. * Set the motor values.
  22304. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22305. * @param force the force to apply
  22306. * @param maxForce max force for this motor.
  22307. */
  22308. setMotor(force?: number, maxForce?: number): void;
  22309. /**
  22310. * Set the motor's limits.
  22311. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22312. * @param upperLimit The upper limit of the motor
  22313. * @param lowerLimit The lower limit of the motor
  22314. */
  22315. setLimit(upperLimit: number, lowerLimit?: number): void;
  22316. }
  22317. /**
  22318. * This class represents a single physics Hinge-Joint
  22319. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22320. */
  22321. export class HingeJoint extends MotorEnabledJoint {
  22322. /**
  22323. * Initializes the Hinge-Joint
  22324. * @param jointData The joint data for the Hinge-Joint
  22325. */
  22326. constructor(jointData: PhysicsJointData);
  22327. /**
  22328. * Set the motor values.
  22329. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22330. * @param {number} force the force to apply
  22331. * @param {number} maxForce max force for this motor.
  22332. */
  22333. setMotor(force?: number, maxForce?: number): void;
  22334. /**
  22335. * Set the motor's limits.
  22336. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22337. * @param upperLimit The upper limit of the motor
  22338. * @param lowerLimit The lower limit of the motor
  22339. */
  22340. setLimit(upperLimit: number, lowerLimit?: number): void;
  22341. }
  22342. /**
  22343. * This class represents a dual hinge physics joint (same as wheel joint)
  22344. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22345. */
  22346. export class Hinge2Joint extends MotorEnabledJoint {
  22347. /**
  22348. * Initializes the Hinge2-Joint
  22349. * @param jointData The joint data for the Hinge2-Joint
  22350. */
  22351. constructor(jointData: PhysicsJointData);
  22352. /**
  22353. * Set the motor values.
  22354. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22355. * @param {number} targetSpeed the speed the motor is to reach
  22356. * @param {number} maxForce max force for this motor.
  22357. * @param {motorIndex} the motor's index, 0 or 1.
  22358. */
  22359. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22360. /**
  22361. * Set the motor limits.
  22362. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22363. * @param {number} upperLimit the upper limit
  22364. * @param {number} lowerLimit lower limit
  22365. * @param {motorIndex} the motor's index, 0 or 1.
  22366. */
  22367. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22368. }
  22369. /**
  22370. * Interface for a motor enabled joint
  22371. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22372. */
  22373. export interface IMotorEnabledJoint {
  22374. /**
  22375. * Physics joint
  22376. */
  22377. physicsJoint: any;
  22378. /**
  22379. * Sets the motor of the motor-enabled joint
  22380. * @param force The force of the motor
  22381. * @param maxForce The maximum force of the motor
  22382. * @param motorIndex The index of the motor
  22383. */
  22384. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22385. /**
  22386. * Sets the limit of the motor
  22387. * @param upperLimit The upper limit of the motor
  22388. * @param lowerLimit The lower limit of the motor
  22389. * @param motorIndex The index of the motor
  22390. */
  22391. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22392. }
  22393. /**
  22394. * Joint data for a Distance-Joint
  22395. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22396. */
  22397. export interface DistanceJointData extends PhysicsJointData {
  22398. /**
  22399. * Max distance the 2 joint objects can be apart
  22400. */
  22401. maxDistance: number;
  22402. }
  22403. /**
  22404. * Joint data from a spring joint
  22405. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22406. */
  22407. export interface SpringJointData extends PhysicsJointData {
  22408. /**
  22409. * Length of the spring
  22410. */
  22411. length: number;
  22412. /**
  22413. * Stiffness of the spring
  22414. */
  22415. stiffness: number;
  22416. /**
  22417. * Damping of the spring
  22418. */
  22419. damping: number;
  22420. /** this callback will be called when applying the force to the impostors. */
  22421. forceApplicationCallback: () => void;
  22422. }
  22423. }
  22424. declare module BABYLON {
  22425. /**
  22426. * Holds the data for the raycast result
  22427. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22428. */
  22429. export class PhysicsRaycastResult {
  22430. private _hasHit;
  22431. private _hitDistance;
  22432. private _hitNormalWorld;
  22433. private _hitPointWorld;
  22434. private _rayFromWorld;
  22435. private _rayToWorld;
  22436. /**
  22437. * Gets if there was a hit
  22438. */
  22439. readonly hasHit: boolean;
  22440. /**
  22441. * Gets the distance from the hit
  22442. */
  22443. readonly hitDistance: number;
  22444. /**
  22445. * Gets the hit normal/direction in the world
  22446. */
  22447. readonly hitNormalWorld: Vector3;
  22448. /**
  22449. * Gets the hit point in the world
  22450. */
  22451. readonly hitPointWorld: Vector3;
  22452. /**
  22453. * Gets the ray "start point" of the ray in the world
  22454. */
  22455. readonly rayFromWorld: Vector3;
  22456. /**
  22457. * Gets the ray "end point" of the ray in the world
  22458. */
  22459. readonly rayToWorld: Vector3;
  22460. /**
  22461. * Sets the hit data (normal & point in world space)
  22462. * @param hitNormalWorld defines the normal in world space
  22463. * @param hitPointWorld defines the point in world space
  22464. */
  22465. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22466. /**
  22467. * Sets the distance from the start point to the hit point
  22468. * @param distance
  22469. */
  22470. setHitDistance(distance: number): void;
  22471. /**
  22472. * Calculates the distance manually
  22473. */
  22474. calculateHitDistance(): void;
  22475. /**
  22476. * Resets all the values to default
  22477. * @param from The from point on world space
  22478. * @param to The to point on world space
  22479. */
  22480. reset(from?: Vector3, to?: Vector3): void;
  22481. }
  22482. /**
  22483. * Interface for the size containing width and height
  22484. */
  22485. interface IXYZ {
  22486. /**
  22487. * X
  22488. */
  22489. x: number;
  22490. /**
  22491. * Y
  22492. */
  22493. y: number;
  22494. /**
  22495. * Z
  22496. */
  22497. z: number;
  22498. }
  22499. }
  22500. declare module BABYLON {
  22501. /**
  22502. * Interface used to describe a physics joint
  22503. */
  22504. export interface PhysicsImpostorJoint {
  22505. /** Defines the main impostor to which the joint is linked */
  22506. mainImpostor: PhysicsImpostor;
  22507. /** Defines the impostor that is connected to the main impostor using this joint */
  22508. connectedImpostor: PhysicsImpostor;
  22509. /** Defines the joint itself */
  22510. joint: PhysicsJoint;
  22511. }
  22512. /** @hidden */
  22513. export interface IPhysicsEnginePlugin {
  22514. world: any;
  22515. name: string;
  22516. setGravity(gravity: Vector3): void;
  22517. setTimeStep(timeStep: number): void;
  22518. getTimeStep(): number;
  22519. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22520. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22521. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22522. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22523. removePhysicsBody(impostor: PhysicsImpostor): void;
  22524. generateJoint(joint: PhysicsImpostorJoint): void;
  22525. removeJoint(joint: PhysicsImpostorJoint): void;
  22526. isSupported(): boolean;
  22527. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22528. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22529. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22530. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22531. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22532. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22533. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22534. getBodyMass(impostor: PhysicsImpostor): number;
  22535. getBodyFriction(impostor: PhysicsImpostor): number;
  22536. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22537. getBodyRestitution(impostor: PhysicsImpostor): number;
  22538. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22539. getBodyPressure?(impostor: PhysicsImpostor): number;
  22540. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22541. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22542. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22543. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22544. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22545. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22546. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22547. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22548. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22549. sleepBody(impostor: PhysicsImpostor): void;
  22550. wakeUpBody(impostor: PhysicsImpostor): void;
  22551. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22552. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22553. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22554. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22555. getRadius(impostor: PhysicsImpostor): number;
  22556. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22557. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22558. dispose(): void;
  22559. }
  22560. /**
  22561. * Interface used to define a physics engine
  22562. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22563. */
  22564. export interface IPhysicsEngine {
  22565. /**
  22566. * Gets the gravity vector used by the simulation
  22567. */
  22568. gravity: Vector3;
  22569. /**
  22570. * Sets the gravity vector used by the simulation
  22571. * @param gravity defines the gravity vector to use
  22572. */
  22573. setGravity(gravity: Vector3): void;
  22574. /**
  22575. * Set the time step of the physics engine.
  22576. * Default is 1/60.
  22577. * To slow it down, enter 1/600 for example.
  22578. * To speed it up, 1/30
  22579. * @param newTimeStep the new timestep to apply to this world.
  22580. */
  22581. setTimeStep(newTimeStep: number): void;
  22582. /**
  22583. * Get the time step of the physics engine.
  22584. * @returns the current time step
  22585. */
  22586. getTimeStep(): number;
  22587. /**
  22588. * Release all resources
  22589. */
  22590. dispose(): void;
  22591. /**
  22592. * Gets the name of the current physics plugin
  22593. * @returns the name of the plugin
  22594. */
  22595. getPhysicsPluginName(): string;
  22596. /**
  22597. * Adding a new impostor for the impostor tracking.
  22598. * This will be done by the impostor itself.
  22599. * @param impostor the impostor to add
  22600. */
  22601. addImpostor(impostor: PhysicsImpostor): void;
  22602. /**
  22603. * Remove an impostor from the engine.
  22604. * This impostor and its mesh will not longer be updated by the physics engine.
  22605. * @param impostor the impostor to remove
  22606. */
  22607. removeImpostor(impostor: PhysicsImpostor): void;
  22608. /**
  22609. * Add a joint to the physics engine
  22610. * @param mainImpostor defines the main impostor to which the joint is added.
  22611. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22612. * @param joint defines the joint that will connect both impostors.
  22613. */
  22614. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22615. /**
  22616. * Removes a joint from the simulation
  22617. * @param mainImpostor defines the impostor used with the joint
  22618. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22619. * @param joint defines the joint to remove
  22620. */
  22621. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22622. /**
  22623. * Gets the current plugin used to run the simulation
  22624. * @returns current plugin
  22625. */
  22626. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22627. /**
  22628. * Gets the list of physic impostors
  22629. * @returns an array of PhysicsImpostor
  22630. */
  22631. getImpostors(): Array<PhysicsImpostor>;
  22632. /**
  22633. * Gets the impostor for a physics enabled object
  22634. * @param object defines the object impersonated by the impostor
  22635. * @returns the PhysicsImpostor or null if not found
  22636. */
  22637. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22638. /**
  22639. * Gets the impostor for a physics body object
  22640. * @param body defines physics body used by the impostor
  22641. * @returns the PhysicsImpostor or null if not found
  22642. */
  22643. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22644. /**
  22645. * Does a raycast in the physics world
  22646. * @param from when should the ray start?
  22647. * @param to when should the ray end?
  22648. * @returns PhysicsRaycastResult
  22649. */
  22650. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22651. /**
  22652. * Called by the scene. No need to call it.
  22653. * @param delta defines the timespam between frames
  22654. */
  22655. _step(delta: number): void;
  22656. }
  22657. }
  22658. declare module BABYLON {
  22659. /**
  22660. * The interface for the physics imposter parameters
  22661. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22662. */
  22663. export interface PhysicsImpostorParameters {
  22664. /**
  22665. * The mass of the physics imposter
  22666. */
  22667. mass: number;
  22668. /**
  22669. * The friction of the physics imposter
  22670. */
  22671. friction?: number;
  22672. /**
  22673. * The coefficient of restitution of the physics imposter
  22674. */
  22675. restitution?: number;
  22676. /**
  22677. * The native options of the physics imposter
  22678. */
  22679. nativeOptions?: any;
  22680. /**
  22681. * Specifies if the parent should be ignored
  22682. */
  22683. ignoreParent?: boolean;
  22684. /**
  22685. * Specifies if bi-directional transformations should be disabled
  22686. */
  22687. disableBidirectionalTransformation?: boolean;
  22688. /**
  22689. * The pressure inside the physics imposter, soft object only
  22690. */
  22691. pressure?: number;
  22692. /**
  22693. * The stiffness the physics imposter, soft object only
  22694. */
  22695. stiffness?: number;
  22696. /**
  22697. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  22698. */
  22699. velocityIterations?: number;
  22700. /**
  22701. * The number of iterations used in maintaining consistent vertex positions, soft object only
  22702. */
  22703. positionIterations?: number;
  22704. /**
  22705. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  22706. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  22707. * Add to fix multiple points
  22708. */
  22709. fixedPoints?: number;
  22710. /**
  22711. * The collision margin around a soft object
  22712. */
  22713. margin?: number;
  22714. /**
  22715. * The collision margin around a soft object
  22716. */
  22717. damping?: number;
  22718. /**
  22719. * The path for a rope based on an extrusion
  22720. */
  22721. path?: any;
  22722. /**
  22723. * The shape of an extrusion used for a rope based on an extrusion
  22724. */
  22725. shape?: any;
  22726. }
  22727. /**
  22728. * Interface for a physics-enabled object
  22729. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22730. */
  22731. export interface IPhysicsEnabledObject {
  22732. /**
  22733. * The position of the physics-enabled object
  22734. */
  22735. position: Vector3;
  22736. /**
  22737. * The rotation of the physics-enabled object
  22738. */
  22739. rotationQuaternion: Nullable<Quaternion>;
  22740. /**
  22741. * The scale of the physics-enabled object
  22742. */
  22743. scaling: Vector3;
  22744. /**
  22745. * The rotation of the physics-enabled object
  22746. */
  22747. rotation?: Vector3;
  22748. /**
  22749. * The parent of the physics-enabled object
  22750. */
  22751. parent?: any;
  22752. /**
  22753. * The bounding info of the physics-enabled object
  22754. * @returns The bounding info of the physics-enabled object
  22755. */
  22756. getBoundingInfo(): BoundingInfo;
  22757. /**
  22758. * Computes the world matrix
  22759. * @param force Specifies if the world matrix should be computed by force
  22760. * @returns A world matrix
  22761. */
  22762. computeWorldMatrix(force: boolean): Matrix;
  22763. /**
  22764. * Gets the world matrix
  22765. * @returns A world matrix
  22766. */
  22767. getWorldMatrix?(): Matrix;
  22768. /**
  22769. * Gets the child meshes
  22770. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  22771. * @returns An array of abstract meshes
  22772. */
  22773. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  22774. /**
  22775. * Gets the vertex data
  22776. * @param kind The type of vertex data
  22777. * @returns A nullable array of numbers, or a float32 array
  22778. */
  22779. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  22780. /**
  22781. * Gets the indices from the mesh
  22782. * @returns A nullable array of index arrays
  22783. */
  22784. getIndices?(): Nullable<IndicesArray>;
  22785. /**
  22786. * Gets the scene from the mesh
  22787. * @returns the indices array or null
  22788. */
  22789. getScene?(): Scene;
  22790. /**
  22791. * Gets the absolute position from the mesh
  22792. * @returns the absolute position
  22793. */
  22794. getAbsolutePosition(): Vector3;
  22795. /**
  22796. * Gets the absolute pivot point from the mesh
  22797. * @returns the absolute pivot point
  22798. */
  22799. getAbsolutePivotPoint(): Vector3;
  22800. /**
  22801. * Rotates the mesh
  22802. * @param axis The axis of rotation
  22803. * @param amount The amount of rotation
  22804. * @param space The space of the rotation
  22805. * @returns The rotation transform node
  22806. */
  22807. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  22808. /**
  22809. * Translates the mesh
  22810. * @param axis The axis of translation
  22811. * @param distance The distance of translation
  22812. * @param space The space of the translation
  22813. * @returns The transform node
  22814. */
  22815. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  22816. /**
  22817. * Sets the absolute position of the mesh
  22818. * @param absolutePosition The absolute position of the mesh
  22819. * @returns The transform node
  22820. */
  22821. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  22822. /**
  22823. * Gets the class name of the mesh
  22824. * @returns The class name
  22825. */
  22826. getClassName(): string;
  22827. }
  22828. /**
  22829. * Represents a physics imposter
  22830. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22831. */
  22832. export class PhysicsImpostor {
  22833. /**
  22834. * The physics-enabled object used as the physics imposter
  22835. */
  22836. object: IPhysicsEnabledObject;
  22837. /**
  22838. * The type of the physics imposter
  22839. */
  22840. type: number;
  22841. private _options;
  22842. private _scene?;
  22843. /**
  22844. * The default object size of the imposter
  22845. */
  22846. static DEFAULT_OBJECT_SIZE: Vector3;
  22847. /**
  22848. * The identity quaternion of the imposter
  22849. */
  22850. static IDENTITY_QUATERNION: Quaternion;
  22851. /** @hidden */
  22852. _pluginData: any;
  22853. private _physicsEngine;
  22854. private _physicsBody;
  22855. private _bodyUpdateRequired;
  22856. private _onBeforePhysicsStepCallbacks;
  22857. private _onAfterPhysicsStepCallbacks;
  22858. /** @hidden */
  22859. _onPhysicsCollideCallbacks: Array<{
  22860. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  22861. otherImpostors: Array<PhysicsImpostor>;
  22862. }>;
  22863. private _deltaPosition;
  22864. private _deltaRotation;
  22865. private _deltaRotationConjugated;
  22866. /** @hidden */
  22867. _isFromLine: boolean;
  22868. private _parent;
  22869. private _isDisposed;
  22870. private static _tmpVecs;
  22871. private static _tmpQuat;
  22872. /**
  22873. * Specifies if the physics imposter is disposed
  22874. */
  22875. readonly isDisposed: boolean;
  22876. /**
  22877. * Gets the mass of the physics imposter
  22878. */
  22879. mass: number;
  22880. /**
  22881. * Gets the coefficient of friction
  22882. */
  22883. /**
  22884. * Sets the coefficient of friction
  22885. */
  22886. friction: number;
  22887. /**
  22888. * Gets the coefficient of restitution
  22889. */
  22890. /**
  22891. * Sets the coefficient of restitution
  22892. */
  22893. restitution: number;
  22894. /**
  22895. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  22896. */
  22897. /**
  22898. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  22899. */
  22900. pressure: number;
  22901. /**
  22902. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22903. */
  22904. /**
  22905. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22906. */
  22907. stiffness: number;
  22908. /**
  22909. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22910. */
  22911. /**
  22912. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22913. */
  22914. velocityIterations: number;
  22915. /**
  22916. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22917. */
  22918. /**
  22919. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22920. */
  22921. positionIterations: number;
  22922. /**
  22923. * The unique id of the physics imposter
  22924. * set by the physics engine when adding this impostor to the array
  22925. */
  22926. uniqueId: number;
  22927. /**
  22928. * @hidden
  22929. */
  22930. soft: boolean;
  22931. /**
  22932. * @hidden
  22933. */
  22934. segments: number;
  22935. private _joints;
  22936. /**
  22937. * Initializes the physics imposter
  22938. * @param object The physics-enabled object used as the physics imposter
  22939. * @param type The type of the physics imposter
  22940. * @param _options The options for the physics imposter
  22941. * @param _scene The Babylon scene
  22942. */
  22943. constructor(
  22944. /**
  22945. * The physics-enabled object used as the physics imposter
  22946. */
  22947. object: IPhysicsEnabledObject,
  22948. /**
  22949. * The type of the physics imposter
  22950. */
  22951. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  22952. /**
  22953. * This function will completly initialize this impostor.
  22954. * It will create a new body - but only if this mesh has no parent.
  22955. * If it has, this impostor will not be used other than to define the impostor
  22956. * of the child mesh.
  22957. * @hidden
  22958. */
  22959. _init(): void;
  22960. private _getPhysicsParent;
  22961. /**
  22962. * Should a new body be generated.
  22963. * @returns boolean specifying if body initialization is required
  22964. */
  22965. isBodyInitRequired(): boolean;
  22966. /**
  22967. * Sets the updated scaling
  22968. * @param updated Specifies if the scaling is updated
  22969. */
  22970. setScalingUpdated(): void;
  22971. /**
  22972. * Force a regeneration of this or the parent's impostor's body.
  22973. * Use under cautious - This will remove all joints already implemented.
  22974. */
  22975. forceUpdate(): void;
  22976. /**
  22977. * Gets the body that holds this impostor. Either its own, or its parent.
  22978. */
  22979. /**
  22980. * Set the physics body. Used mainly by the physics engine/plugin
  22981. */
  22982. physicsBody: any;
  22983. /**
  22984. * Get the parent of the physics imposter
  22985. * @returns Physics imposter or null
  22986. */
  22987. /**
  22988. * Sets the parent of the physics imposter
  22989. */
  22990. parent: Nullable<PhysicsImpostor>;
  22991. /**
  22992. * Resets the update flags
  22993. */
  22994. resetUpdateFlags(): void;
  22995. /**
  22996. * Gets the object extend size
  22997. * @returns the object extend size
  22998. */
  22999. getObjectExtendSize(): Vector3;
  23000. /**
  23001. * Gets the object center
  23002. * @returns The object center
  23003. */
  23004. getObjectCenter(): Vector3;
  23005. /**
  23006. * Get a specific parametes from the options parameter
  23007. * @param paramName The object parameter name
  23008. * @returns The object parameter
  23009. */
  23010. getParam(paramName: string): any;
  23011. /**
  23012. * Sets a specific parameter in the options given to the physics plugin
  23013. * @param paramName The parameter name
  23014. * @param value The value of the parameter
  23015. */
  23016. setParam(paramName: string, value: number): void;
  23017. /**
  23018. * Specifically change the body's mass option. Won't recreate the physics body object
  23019. * @param mass The mass of the physics imposter
  23020. */
  23021. setMass(mass: number): void;
  23022. /**
  23023. * Gets the linear velocity
  23024. * @returns linear velocity or null
  23025. */
  23026. getLinearVelocity(): Nullable<Vector3>;
  23027. /**
  23028. * Sets the linear velocity
  23029. * @param velocity linear velocity or null
  23030. */
  23031. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23032. /**
  23033. * Gets the angular velocity
  23034. * @returns angular velocity or null
  23035. */
  23036. getAngularVelocity(): Nullable<Vector3>;
  23037. /**
  23038. * Sets the angular velocity
  23039. * @param velocity The velocity or null
  23040. */
  23041. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23042. /**
  23043. * Execute a function with the physics plugin native code
  23044. * Provide a function the will have two variables - the world object and the physics body object
  23045. * @param func The function to execute with the physics plugin native code
  23046. */
  23047. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23048. /**
  23049. * Register a function that will be executed before the physics world is stepping forward
  23050. * @param func The function to execute before the physics world is stepped forward
  23051. */
  23052. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23053. /**
  23054. * Unregister a function that will be executed before the physics world is stepping forward
  23055. * @param func The function to execute before the physics world is stepped forward
  23056. */
  23057. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23058. /**
  23059. * Register a function that will be executed after the physics step
  23060. * @param func The function to execute after physics step
  23061. */
  23062. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23063. /**
  23064. * Unregisters a function that will be executed after the physics step
  23065. * @param func The function to execute after physics step
  23066. */
  23067. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23068. /**
  23069. * register a function that will be executed when this impostor collides against a different body
  23070. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23071. * @param func Callback that is executed on collision
  23072. */
  23073. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23074. /**
  23075. * Unregisters the physics imposter on contact
  23076. * @param collideAgainst The physics object to collide against
  23077. * @param func Callback to execute on collision
  23078. */
  23079. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23080. private _tmpQuat;
  23081. private _tmpQuat2;
  23082. /**
  23083. * Get the parent rotation
  23084. * @returns The parent rotation
  23085. */
  23086. getParentsRotation(): Quaternion;
  23087. /**
  23088. * this function is executed by the physics engine.
  23089. */
  23090. beforeStep: () => void;
  23091. /**
  23092. * this function is executed by the physics engine
  23093. */
  23094. afterStep: () => void;
  23095. /**
  23096. * Legacy collision detection event support
  23097. */
  23098. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23099. /**
  23100. * event and body object due to cannon's event-based architecture.
  23101. */
  23102. onCollide: (e: {
  23103. body: any;
  23104. }) => void;
  23105. /**
  23106. * Apply a force
  23107. * @param force The force to apply
  23108. * @param contactPoint The contact point for the force
  23109. * @returns The physics imposter
  23110. */
  23111. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23112. /**
  23113. * Apply an impulse
  23114. * @param force The impulse force
  23115. * @param contactPoint The contact point for the impulse force
  23116. * @returns The physics imposter
  23117. */
  23118. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23119. /**
  23120. * A help function to create a joint
  23121. * @param otherImpostor A physics imposter used to create a joint
  23122. * @param jointType The type of joint
  23123. * @param jointData The data for the joint
  23124. * @returns The physics imposter
  23125. */
  23126. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23127. /**
  23128. * Add a joint to this impostor with a different impostor
  23129. * @param otherImpostor A physics imposter used to add a joint
  23130. * @param joint The joint to add
  23131. * @returns The physics imposter
  23132. */
  23133. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23134. /**
  23135. * Add an anchor to a cloth impostor
  23136. * @param otherImpostor rigid impostor to anchor to
  23137. * @param width ratio across width from 0 to 1
  23138. * @param height ratio up height from 0 to 1
  23139. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23140. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23141. * @returns impostor the soft imposter
  23142. */
  23143. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23144. /**
  23145. * Add a hook to a rope impostor
  23146. * @param otherImpostor rigid impostor to anchor to
  23147. * @param length ratio across rope from 0 to 1
  23148. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23149. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23150. * @returns impostor the rope imposter
  23151. */
  23152. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23153. /**
  23154. * Will keep this body still, in a sleep mode.
  23155. * @returns the physics imposter
  23156. */
  23157. sleep(): PhysicsImpostor;
  23158. /**
  23159. * Wake the body up.
  23160. * @returns The physics imposter
  23161. */
  23162. wakeUp(): PhysicsImpostor;
  23163. /**
  23164. * Clones the physics imposter
  23165. * @param newObject The physics imposter clones to this physics-enabled object
  23166. * @returns A nullable physics imposter
  23167. */
  23168. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23169. /**
  23170. * Disposes the physics imposter
  23171. */
  23172. dispose(): void;
  23173. /**
  23174. * Sets the delta position
  23175. * @param position The delta position amount
  23176. */
  23177. setDeltaPosition(position: Vector3): void;
  23178. /**
  23179. * Sets the delta rotation
  23180. * @param rotation The delta rotation amount
  23181. */
  23182. setDeltaRotation(rotation: Quaternion): void;
  23183. /**
  23184. * Gets the box size of the physics imposter and stores the result in the input parameter
  23185. * @param result Stores the box size
  23186. * @returns The physics imposter
  23187. */
  23188. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23189. /**
  23190. * Gets the radius of the physics imposter
  23191. * @returns Radius of the physics imposter
  23192. */
  23193. getRadius(): number;
  23194. /**
  23195. * Sync a bone with this impostor
  23196. * @param bone The bone to sync to the impostor.
  23197. * @param boneMesh The mesh that the bone is influencing.
  23198. * @param jointPivot The pivot of the joint / bone in local space.
  23199. * @param distToJoint Optional distance from the impostor to the joint.
  23200. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23201. */
  23202. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23203. /**
  23204. * Sync impostor to a bone
  23205. * @param bone The bone that the impostor will be synced to.
  23206. * @param boneMesh The mesh that the bone is influencing.
  23207. * @param jointPivot The pivot of the joint / bone in local space.
  23208. * @param distToJoint Optional distance from the impostor to the joint.
  23209. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23210. * @param boneAxis Optional vector3 axis the bone is aligned with
  23211. */
  23212. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23213. /**
  23214. * No-Imposter type
  23215. */
  23216. static NoImpostor: number;
  23217. /**
  23218. * Sphere-Imposter type
  23219. */
  23220. static SphereImpostor: number;
  23221. /**
  23222. * Box-Imposter type
  23223. */
  23224. static BoxImpostor: number;
  23225. /**
  23226. * Plane-Imposter type
  23227. */
  23228. static PlaneImpostor: number;
  23229. /**
  23230. * Mesh-imposter type
  23231. */
  23232. static MeshImpostor: number;
  23233. /**
  23234. * Capsule-Impostor type (Ammo.js plugin only)
  23235. */
  23236. static CapsuleImpostor: number;
  23237. /**
  23238. * Cylinder-Imposter type
  23239. */
  23240. static CylinderImpostor: number;
  23241. /**
  23242. * Particle-Imposter type
  23243. */
  23244. static ParticleImpostor: number;
  23245. /**
  23246. * Heightmap-Imposter type
  23247. */
  23248. static HeightmapImpostor: number;
  23249. /**
  23250. * ConvexHull-Impostor type (Ammo.js plugin only)
  23251. */
  23252. static ConvexHullImpostor: number;
  23253. /**
  23254. * Rope-Imposter type
  23255. */
  23256. static RopeImpostor: number;
  23257. /**
  23258. * Cloth-Imposter type
  23259. */
  23260. static ClothImpostor: number;
  23261. /**
  23262. * Softbody-Imposter type
  23263. */
  23264. static SoftbodyImpostor: number;
  23265. }
  23266. }
  23267. declare module BABYLON {
  23268. /**
  23269. * @hidden
  23270. **/
  23271. export class _CreationDataStorage {
  23272. closePath?: boolean;
  23273. closeArray?: boolean;
  23274. idx: number[];
  23275. dashSize: number;
  23276. gapSize: number;
  23277. path3D: Path3D;
  23278. pathArray: Vector3[][];
  23279. arc: number;
  23280. radius: number;
  23281. cap: number;
  23282. tessellation: number;
  23283. }
  23284. /**
  23285. * @hidden
  23286. **/
  23287. class _InstanceDataStorage {
  23288. visibleInstances: any;
  23289. batchCache: _InstancesBatch;
  23290. instancesBufferSize: number;
  23291. instancesBuffer: Nullable<Buffer>;
  23292. instancesData: Float32Array;
  23293. overridenInstanceCount: number;
  23294. isFrozen: boolean;
  23295. previousBatch: Nullable<_InstancesBatch>;
  23296. hardwareInstancedRendering: boolean;
  23297. sideOrientation: number;
  23298. }
  23299. /**
  23300. * @hidden
  23301. **/
  23302. export class _InstancesBatch {
  23303. mustReturn: boolean;
  23304. visibleInstances: Nullable<InstancedMesh[]>[];
  23305. renderSelf: boolean[];
  23306. hardwareInstancedRendering: boolean[];
  23307. }
  23308. /**
  23309. * Class used to represent renderable models
  23310. */
  23311. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23312. /**
  23313. * Mesh side orientation : usually the external or front surface
  23314. */
  23315. static readonly FRONTSIDE: number;
  23316. /**
  23317. * Mesh side orientation : usually the internal or back surface
  23318. */
  23319. static readonly BACKSIDE: number;
  23320. /**
  23321. * Mesh side orientation : both internal and external or front and back surfaces
  23322. */
  23323. static readonly DOUBLESIDE: number;
  23324. /**
  23325. * Mesh side orientation : by default, `FRONTSIDE`
  23326. */
  23327. static readonly DEFAULTSIDE: number;
  23328. /**
  23329. * Mesh cap setting : no cap
  23330. */
  23331. static readonly NO_CAP: number;
  23332. /**
  23333. * Mesh cap setting : one cap at the beginning of the mesh
  23334. */
  23335. static readonly CAP_START: number;
  23336. /**
  23337. * Mesh cap setting : one cap at the end of the mesh
  23338. */
  23339. static readonly CAP_END: number;
  23340. /**
  23341. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23342. */
  23343. static readonly CAP_ALL: number;
  23344. /**
  23345. * Mesh pattern setting : no flip or rotate
  23346. */
  23347. static readonly NO_FLIP: number;
  23348. /**
  23349. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23350. */
  23351. static readonly FLIP_TILE: number;
  23352. /**
  23353. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23354. */
  23355. static readonly ROTATE_TILE: number;
  23356. /**
  23357. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23358. */
  23359. static readonly FLIP_ROW: number;
  23360. /**
  23361. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23362. */
  23363. static readonly ROTATE_ROW: number;
  23364. /**
  23365. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23366. */
  23367. static readonly FLIP_N_ROTATE_TILE: number;
  23368. /**
  23369. * Mesh pattern setting : rotate pattern and rotate
  23370. */
  23371. static readonly FLIP_N_ROTATE_ROW: number;
  23372. /**
  23373. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23374. */
  23375. static readonly CENTER: number;
  23376. /**
  23377. * Mesh tile positioning : part tiles on left
  23378. */
  23379. static readonly LEFT: number;
  23380. /**
  23381. * Mesh tile positioning : part tiles on right
  23382. */
  23383. static readonly RIGHT: number;
  23384. /**
  23385. * Mesh tile positioning : part tiles on top
  23386. */
  23387. static readonly TOP: number;
  23388. /**
  23389. * Mesh tile positioning : part tiles on bottom
  23390. */
  23391. static readonly BOTTOM: number;
  23392. /**
  23393. * Gets the default side orientation.
  23394. * @param orientation the orientation to value to attempt to get
  23395. * @returns the default orientation
  23396. * @hidden
  23397. */
  23398. static _GetDefaultSideOrientation(orientation?: number): number;
  23399. private _internalMeshDataInfo;
  23400. /**
  23401. * An event triggered before rendering the mesh
  23402. */
  23403. readonly onBeforeRenderObservable: Observable<Mesh>;
  23404. /**
  23405. * An event triggered before binding the mesh
  23406. */
  23407. readonly onBeforeBindObservable: Observable<Mesh>;
  23408. /**
  23409. * An event triggered after rendering the mesh
  23410. */
  23411. readonly onAfterRenderObservable: Observable<Mesh>;
  23412. /**
  23413. * An event triggered before drawing the mesh
  23414. */
  23415. readonly onBeforeDrawObservable: Observable<Mesh>;
  23416. private _onBeforeDrawObserver;
  23417. /**
  23418. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23419. */
  23420. onBeforeDraw: () => void;
  23421. readonly hasInstances: boolean;
  23422. /**
  23423. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23424. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23425. */
  23426. delayLoadState: number;
  23427. /**
  23428. * Gets the list of instances created from this mesh
  23429. * it is not supposed to be modified manually.
  23430. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23431. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23432. */
  23433. instances: InstancedMesh[];
  23434. /**
  23435. * Gets the file containing delay loading data for this mesh
  23436. */
  23437. delayLoadingFile: string;
  23438. /** @hidden */
  23439. _binaryInfo: any;
  23440. /**
  23441. * User defined function used to change how LOD level selection is done
  23442. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23443. */
  23444. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23445. /**
  23446. * Gets or sets the morph target manager
  23447. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23448. */
  23449. morphTargetManager: Nullable<MorphTargetManager>;
  23450. /** @hidden */
  23451. _creationDataStorage: Nullable<_CreationDataStorage>;
  23452. /** @hidden */
  23453. _geometry: Nullable<Geometry>;
  23454. /** @hidden */
  23455. _delayInfo: Array<string>;
  23456. /** @hidden */
  23457. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23458. /** @hidden */
  23459. _instanceDataStorage: _InstanceDataStorage;
  23460. private _effectiveMaterial;
  23461. /** @hidden */
  23462. _shouldGenerateFlatShading: boolean;
  23463. /** @hidden */
  23464. _originalBuilderSideOrientation: number;
  23465. /**
  23466. * Use this property to change the original side orientation defined at construction time
  23467. */
  23468. overrideMaterialSideOrientation: Nullable<number>;
  23469. /**
  23470. * Gets the source mesh (the one used to clone this one from)
  23471. */
  23472. readonly source: Nullable<Mesh>;
  23473. /**
  23474. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23475. */
  23476. isUnIndexed: boolean;
  23477. /**
  23478. * @constructor
  23479. * @param name The value used by scene.getMeshByName() to do a lookup.
  23480. * @param scene The scene to add this mesh to.
  23481. * @param parent The parent of this mesh, if it has one
  23482. * @param source An optional Mesh from which geometry is shared, cloned.
  23483. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23484. * When false, achieved by calling a clone(), also passing False.
  23485. * This will make creation of children, recursive.
  23486. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23487. */
  23488. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23489. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  23490. /**
  23491. * Gets the class name
  23492. * @returns the string "Mesh".
  23493. */
  23494. getClassName(): string;
  23495. /** @hidden */
  23496. readonly _isMesh: boolean;
  23497. /**
  23498. * Returns a description of this mesh
  23499. * @param fullDetails define if full details about this mesh must be used
  23500. * @returns a descriptive string representing this mesh
  23501. */
  23502. toString(fullDetails?: boolean): string;
  23503. /** @hidden */
  23504. _unBindEffect(): void;
  23505. /**
  23506. * Gets a boolean indicating if this mesh has LOD
  23507. */
  23508. readonly hasLODLevels: boolean;
  23509. /**
  23510. * Gets the list of MeshLODLevel associated with the current mesh
  23511. * @returns an array of MeshLODLevel
  23512. */
  23513. getLODLevels(): MeshLODLevel[];
  23514. private _sortLODLevels;
  23515. /**
  23516. * Add a mesh as LOD level triggered at the given distance.
  23517. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23518. * @param distance The distance from the center of the object to show this level
  23519. * @param mesh The mesh to be added as LOD level (can be null)
  23520. * @return This mesh (for chaining)
  23521. */
  23522. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23523. /**
  23524. * Returns the LOD level mesh at the passed distance or null if not found.
  23525. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23526. * @param distance The distance from the center of the object to show this level
  23527. * @returns a Mesh or `null`
  23528. */
  23529. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23530. /**
  23531. * Remove a mesh from the LOD array
  23532. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23533. * @param mesh defines the mesh to be removed
  23534. * @return This mesh (for chaining)
  23535. */
  23536. removeLODLevel(mesh: Mesh): Mesh;
  23537. /**
  23538. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23539. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23540. * @param camera defines the camera to use to compute distance
  23541. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23542. * @return This mesh (for chaining)
  23543. */
  23544. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23545. /**
  23546. * Gets the mesh internal Geometry object
  23547. */
  23548. readonly geometry: Nullable<Geometry>;
  23549. /**
  23550. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23551. * @returns the total number of vertices
  23552. */
  23553. getTotalVertices(): number;
  23554. /**
  23555. * Returns the content of an associated vertex buffer
  23556. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23557. * - VertexBuffer.PositionKind
  23558. * - VertexBuffer.UVKind
  23559. * - VertexBuffer.UV2Kind
  23560. * - VertexBuffer.UV3Kind
  23561. * - VertexBuffer.UV4Kind
  23562. * - VertexBuffer.UV5Kind
  23563. * - VertexBuffer.UV6Kind
  23564. * - VertexBuffer.ColorKind
  23565. * - VertexBuffer.MatricesIndicesKind
  23566. * - VertexBuffer.MatricesIndicesExtraKind
  23567. * - VertexBuffer.MatricesWeightsKind
  23568. * - VertexBuffer.MatricesWeightsExtraKind
  23569. * @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
  23570. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23571. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23572. */
  23573. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23574. /**
  23575. * Returns the mesh VertexBuffer object from the requested `kind`
  23576. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23577. * - VertexBuffer.PositionKind
  23578. * - VertexBuffer.NormalKind
  23579. * - VertexBuffer.UVKind
  23580. * - VertexBuffer.UV2Kind
  23581. * - VertexBuffer.UV3Kind
  23582. * - VertexBuffer.UV4Kind
  23583. * - VertexBuffer.UV5Kind
  23584. * - VertexBuffer.UV6Kind
  23585. * - VertexBuffer.ColorKind
  23586. * - VertexBuffer.MatricesIndicesKind
  23587. * - VertexBuffer.MatricesIndicesExtraKind
  23588. * - VertexBuffer.MatricesWeightsKind
  23589. * - VertexBuffer.MatricesWeightsExtraKind
  23590. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23591. */
  23592. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23593. /**
  23594. * Tests if a specific vertex buffer is associated with this mesh
  23595. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23596. * - VertexBuffer.PositionKind
  23597. * - VertexBuffer.NormalKind
  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. isVerticesDataPresent(kind: string): boolean;
  23612. /**
  23613. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23614. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23615. * - VertexBuffer.PositionKind
  23616. * - VertexBuffer.UVKind
  23617. * - VertexBuffer.UV2Kind
  23618. * - VertexBuffer.UV3Kind
  23619. * - VertexBuffer.UV4Kind
  23620. * - VertexBuffer.UV5Kind
  23621. * - VertexBuffer.UV6Kind
  23622. * - VertexBuffer.ColorKind
  23623. * - VertexBuffer.MatricesIndicesKind
  23624. * - VertexBuffer.MatricesIndicesExtraKind
  23625. * - VertexBuffer.MatricesWeightsKind
  23626. * - VertexBuffer.MatricesWeightsExtraKind
  23627. * @returns a boolean
  23628. */
  23629. isVertexBufferUpdatable(kind: string): boolean;
  23630. /**
  23631. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23632. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23633. * - VertexBuffer.PositionKind
  23634. * - VertexBuffer.NormalKind
  23635. * - VertexBuffer.UVKind
  23636. * - VertexBuffer.UV2Kind
  23637. * - VertexBuffer.UV3Kind
  23638. * - VertexBuffer.UV4Kind
  23639. * - VertexBuffer.UV5Kind
  23640. * - VertexBuffer.UV6Kind
  23641. * - VertexBuffer.ColorKind
  23642. * - VertexBuffer.MatricesIndicesKind
  23643. * - VertexBuffer.MatricesIndicesExtraKind
  23644. * - VertexBuffer.MatricesWeightsKind
  23645. * - VertexBuffer.MatricesWeightsExtraKind
  23646. * @returns an array of strings
  23647. */
  23648. getVerticesDataKinds(): string[];
  23649. /**
  23650. * Returns a positive integer : the total number of indices in this mesh geometry.
  23651. * @returns the numner of indices or zero if the mesh has no geometry.
  23652. */
  23653. getTotalIndices(): number;
  23654. /**
  23655. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23656. * @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.
  23657. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23658. * @returns the indices array or an empty array if the mesh has no geometry
  23659. */
  23660. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23661. readonly isBlocked: boolean;
  23662. /**
  23663. * Determine if the current mesh is ready to be rendered
  23664. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23665. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23666. * @returns true if all associated assets are ready (material, textures, shaders)
  23667. */
  23668. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23669. /**
  23670. * 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.
  23671. */
  23672. readonly areNormalsFrozen: boolean;
  23673. /**
  23674. * 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.
  23675. * @returns the current mesh
  23676. */
  23677. freezeNormals(): Mesh;
  23678. /**
  23679. * 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
  23680. * @returns the current mesh
  23681. */
  23682. unfreezeNormals(): Mesh;
  23683. /**
  23684. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23685. */
  23686. overridenInstanceCount: number;
  23687. /** @hidden */
  23688. _preActivate(): Mesh;
  23689. /** @hidden */
  23690. _preActivateForIntermediateRendering(renderId: number): Mesh;
  23691. /** @hidden */
  23692. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  23693. /**
  23694. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23695. * This means the mesh underlying bounding box and sphere are recomputed.
  23696. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23697. * @returns the current mesh
  23698. */
  23699. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  23700. /** @hidden */
  23701. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  23702. /**
  23703. * This function will subdivide the mesh into multiple submeshes
  23704. * @param count defines the expected number of submeshes
  23705. */
  23706. subdivide(count: number): void;
  23707. /**
  23708. * Copy a FloatArray into a specific associated vertex buffer
  23709. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23710. * - VertexBuffer.PositionKind
  23711. * - VertexBuffer.UVKind
  23712. * - VertexBuffer.UV2Kind
  23713. * - VertexBuffer.UV3Kind
  23714. * - VertexBuffer.UV4Kind
  23715. * - VertexBuffer.UV5Kind
  23716. * - VertexBuffer.UV6Kind
  23717. * - VertexBuffer.ColorKind
  23718. * - VertexBuffer.MatricesIndicesKind
  23719. * - VertexBuffer.MatricesIndicesExtraKind
  23720. * - VertexBuffer.MatricesWeightsKind
  23721. * - VertexBuffer.MatricesWeightsExtraKind
  23722. * @param data defines the data source
  23723. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23724. * @param stride defines the data stride size (can be null)
  23725. * @returns the current mesh
  23726. */
  23727. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23728. /**
  23729. * Flags an associated vertex buffer as updatable
  23730. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  23731. * - VertexBuffer.PositionKind
  23732. * - VertexBuffer.UVKind
  23733. * - VertexBuffer.UV2Kind
  23734. * - VertexBuffer.UV3Kind
  23735. * - VertexBuffer.UV4Kind
  23736. * - VertexBuffer.UV5Kind
  23737. * - VertexBuffer.UV6Kind
  23738. * - VertexBuffer.ColorKind
  23739. * - VertexBuffer.MatricesIndicesKind
  23740. * - VertexBuffer.MatricesIndicesExtraKind
  23741. * - VertexBuffer.MatricesWeightsKind
  23742. * - VertexBuffer.MatricesWeightsExtraKind
  23743. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23744. */
  23745. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  23746. /**
  23747. * Sets the mesh global Vertex Buffer
  23748. * @param buffer defines the buffer to use
  23749. * @returns the current mesh
  23750. */
  23751. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  23752. /**
  23753. * Update a specific associated vertex buffer
  23754. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23755. * - VertexBuffer.PositionKind
  23756. * - VertexBuffer.UVKind
  23757. * - VertexBuffer.UV2Kind
  23758. * - VertexBuffer.UV3Kind
  23759. * - VertexBuffer.UV4Kind
  23760. * - VertexBuffer.UV5Kind
  23761. * - VertexBuffer.UV6Kind
  23762. * - VertexBuffer.ColorKind
  23763. * - VertexBuffer.MatricesIndicesKind
  23764. * - VertexBuffer.MatricesIndicesExtraKind
  23765. * - VertexBuffer.MatricesWeightsKind
  23766. * - VertexBuffer.MatricesWeightsExtraKind
  23767. * @param data defines the data source
  23768. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23769. * @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)
  23770. * @returns the current mesh
  23771. */
  23772. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23773. /**
  23774. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  23775. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  23776. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  23777. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  23778. * @returns the current mesh
  23779. */
  23780. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  23781. /**
  23782. * Creates a un-shared specific occurence of the geometry for the mesh.
  23783. * @returns the current mesh
  23784. */
  23785. makeGeometryUnique(): Mesh;
  23786. /**
  23787. * Set the index buffer of this mesh
  23788. * @param indices defines the source data
  23789. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  23790. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  23791. * @returns the current mesh
  23792. */
  23793. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  23794. /**
  23795. * Update the current index buffer
  23796. * @param indices defines the source data
  23797. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  23798. * @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)
  23799. * @returns the current mesh
  23800. */
  23801. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  23802. /**
  23803. * Invert the geometry to move from a right handed system to a left handed one.
  23804. * @returns the current mesh
  23805. */
  23806. toLeftHanded(): Mesh;
  23807. /** @hidden */
  23808. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  23809. /** @hidden */
  23810. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  23811. /**
  23812. * Registers for this mesh a javascript function called just before the rendering process
  23813. * @param func defines the function to call before rendering this mesh
  23814. * @returns the current mesh
  23815. */
  23816. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23817. /**
  23818. * Disposes a previously registered javascript function called before the rendering
  23819. * @param func defines the function to remove
  23820. * @returns the current mesh
  23821. */
  23822. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23823. /**
  23824. * Registers for this mesh a javascript function called just after the rendering is complete
  23825. * @param func defines the function to call after rendering this mesh
  23826. * @returns the current mesh
  23827. */
  23828. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23829. /**
  23830. * Disposes a previously registered javascript function called after the rendering.
  23831. * @param func defines the function to remove
  23832. * @returns the current mesh
  23833. */
  23834. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23835. /** @hidden */
  23836. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  23837. /** @hidden */
  23838. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  23839. /** @hidden */
  23840. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  23841. /** @hidden */
  23842. _rebuild(): void;
  23843. /** @hidden */
  23844. _freeze(): void;
  23845. /** @hidden */
  23846. _unFreeze(): void;
  23847. /**
  23848. * 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
  23849. * @param subMesh defines the subMesh to render
  23850. * @param enableAlphaMode defines if alpha mode can be changed
  23851. * @returns the current mesh
  23852. */
  23853. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  23854. private _onBeforeDraw;
  23855. /**
  23856. * Renormalize the mesh and patch it up if there are no weights
  23857. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  23858. * However in the case of zero weights then we set just a single influence to 1.
  23859. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  23860. */
  23861. cleanMatrixWeights(): void;
  23862. private normalizeSkinFourWeights;
  23863. private normalizeSkinWeightsAndExtra;
  23864. /**
  23865. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  23866. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  23867. * the user know there was an issue with importing the mesh
  23868. * @returns a validation object with skinned, valid and report string
  23869. */
  23870. validateSkinning(): {
  23871. skinned: boolean;
  23872. valid: boolean;
  23873. report: string;
  23874. };
  23875. /** @hidden */
  23876. _checkDelayState(): Mesh;
  23877. private _queueLoad;
  23878. /**
  23879. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23880. * A mesh is in the frustum if its bounding box intersects the frustum
  23881. * @param frustumPlanes defines the frustum to test
  23882. * @returns true if the mesh is in the frustum planes
  23883. */
  23884. isInFrustum(frustumPlanes: Plane[]): boolean;
  23885. /**
  23886. * Sets the mesh material by the material or multiMaterial `id` property
  23887. * @param id is a string identifying the material or the multiMaterial
  23888. * @returns the current mesh
  23889. */
  23890. setMaterialByID(id: string): Mesh;
  23891. /**
  23892. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  23893. * @returns an array of IAnimatable
  23894. */
  23895. getAnimatables(): IAnimatable[];
  23896. /**
  23897. * Modifies the mesh geometry according to the passed transformation matrix.
  23898. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  23899. * The mesh normals are modified using the same transformation.
  23900. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23901. * @param transform defines the transform matrix to use
  23902. * @see http://doc.babylonjs.com/resources/baking_transformations
  23903. * @returns the current mesh
  23904. */
  23905. bakeTransformIntoVertices(transform: Matrix): Mesh;
  23906. /**
  23907. * Modifies the mesh geometry according to its own current World Matrix.
  23908. * The mesh World Matrix is then reset.
  23909. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  23910. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23911. * @see http://doc.babylonjs.com/resources/baking_transformations
  23912. * @returns the current mesh
  23913. */
  23914. bakeCurrentTransformIntoVertices(): Mesh;
  23915. /** @hidden */
  23916. readonly _positions: Nullable<Vector3[]>;
  23917. /** @hidden */
  23918. _resetPointsArrayCache(): Mesh;
  23919. /** @hidden */
  23920. _generatePointsArray(): boolean;
  23921. /**
  23922. * Returns a new Mesh object generated from the current mesh properties.
  23923. * This method must not get confused with createInstance()
  23924. * @param name is a string, the name given to the new mesh
  23925. * @param newParent can be any Node object (default `null`)
  23926. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  23927. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  23928. * @returns a new mesh
  23929. */
  23930. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  23931. /**
  23932. * Releases resources associated with this mesh.
  23933. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23934. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23935. */
  23936. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23937. /**
  23938. * Modifies the mesh geometry according to a displacement map.
  23939. * 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.
  23940. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23941. * @param url is a string, the URL from the image file is to be downloaded.
  23942. * @param minHeight is the lower limit of the displacement.
  23943. * @param maxHeight is the upper limit of the displacement.
  23944. * @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.
  23945. * @param uvOffset is an optional vector2 used to offset UV.
  23946. * @param uvScale is an optional vector2 used to scale UV.
  23947. * @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.
  23948. * @returns the Mesh.
  23949. */
  23950. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23951. /**
  23952. * Modifies the mesh geometry according to a displacementMap buffer.
  23953. * 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.
  23954. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23955. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  23956. * @param heightMapWidth is the width of the buffer image.
  23957. * @param heightMapHeight is the height of the buffer image.
  23958. * @param minHeight is the lower limit of the displacement.
  23959. * @param maxHeight is the upper limit of the displacement.
  23960. * @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.
  23961. * @param uvOffset is an optional vector2 used to offset UV.
  23962. * @param uvScale is an optional vector2 used to scale UV.
  23963. * @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.
  23964. * @returns the Mesh.
  23965. */
  23966. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23967. /**
  23968. * Modify the mesh to get a flat shading rendering.
  23969. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  23970. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  23971. * @returns current mesh
  23972. */
  23973. convertToFlatShadedMesh(): Mesh;
  23974. /**
  23975. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  23976. * In other words, more vertices, no more indices and a single bigger VBO.
  23977. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  23978. * @returns current mesh
  23979. */
  23980. convertToUnIndexedMesh(): Mesh;
  23981. /**
  23982. * Inverses facet orientations.
  23983. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23984. * @param flipNormals will also inverts the normals
  23985. * @returns current mesh
  23986. */
  23987. flipFaces(flipNormals?: boolean): Mesh;
  23988. /**
  23989. * Increase the number of facets and hence vertices in a mesh
  23990. * Vertex normals are interpolated from existing vertex normals
  23991. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23992. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  23993. */
  23994. increaseVertices(numberPerEdge: number): void;
  23995. /**
  23996. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  23997. * This will undo any application of covertToFlatShadedMesh
  23998. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23999. */
  24000. forceSharedVertices(): void;
  24001. /** @hidden */
  24002. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24003. /** @hidden */
  24004. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24005. /**
  24006. * Creates a new InstancedMesh object from the mesh model.
  24007. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24008. * @param name defines the name of the new instance
  24009. * @returns a new InstancedMesh
  24010. */
  24011. createInstance(name: string): InstancedMesh;
  24012. /**
  24013. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24014. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24015. * @returns the current mesh
  24016. */
  24017. synchronizeInstances(): Mesh;
  24018. /**
  24019. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24020. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24021. * This should be used together with the simplification to avoid disappearing triangles.
  24022. * @param successCallback an optional success callback to be called after the optimization finished.
  24023. * @returns the current mesh
  24024. */
  24025. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24026. /**
  24027. * Serialize current mesh
  24028. * @param serializationObject defines the object which will receive the serialization data
  24029. */
  24030. serialize(serializationObject: any): void;
  24031. /** @hidden */
  24032. _syncGeometryWithMorphTargetManager(): void;
  24033. /** @hidden */
  24034. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24035. /**
  24036. * Returns a new Mesh object parsed from the source provided.
  24037. * @param parsedMesh is the source
  24038. * @param scene defines the hosting scene
  24039. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24040. * @returns a new Mesh
  24041. */
  24042. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24043. /**
  24044. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24045. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24046. * @param name defines the name of the mesh to create
  24047. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24048. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24049. * @param closePath creates a seam between the first and the last points of each path of the path array
  24050. * @param offset is taken in account only if the `pathArray` is containing a single path
  24051. * @param scene defines the hosting scene
  24052. * @param updatable defines if the mesh must be flagged as updatable
  24053. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24054. * @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)
  24055. * @returns a new Mesh
  24056. */
  24057. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24058. /**
  24059. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24060. * @param name defines the name of the mesh to create
  24061. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24062. * @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
  24063. * @param scene defines the hosting scene
  24064. * @param updatable defines if the mesh must be flagged as updatable
  24065. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24066. * @returns a new Mesh
  24067. */
  24068. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24069. /**
  24070. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24071. * @param name defines the name of the mesh to create
  24072. * @param size sets the size (float) of each box side (default 1)
  24073. * @param scene defines the hosting scene
  24074. * @param updatable defines if the mesh must be flagged as updatable
  24075. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24076. * @returns a new Mesh
  24077. */
  24078. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24079. /**
  24080. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24081. * @param name defines the name of the mesh to create
  24082. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24083. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24084. * @param scene defines the hosting scene
  24085. * @param updatable defines if the mesh must be flagged as updatable
  24086. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24087. * @returns a new Mesh
  24088. */
  24089. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24090. /**
  24091. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24092. * @param name defines the name of the mesh to create
  24093. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24094. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24095. * @param scene defines the hosting scene
  24096. * @returns a new Mesh
  24097. */
  24098. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24099. /**
  24100. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24101. * @param name defines the name of the mesh to create
  24102. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24103. * @param diameterTop set the top cap diameter (floats, default 1)
  24104. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24105. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24106. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24107. * @param scene defines the hosting scene
  24108. * @param updatable defines if the mesh must be flagged as updatable
  24109. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24110. * @returns a new Mesh
  24111. */
  24112. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24113. /**
  24114. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24115. * @param name defines the name of the mesh to create
  24116. * @param diameter sets the diameter size (float) of the torus (default 1)
  24117. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24118. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24119. * @param scene defines the hosting scene
  24120. * @param updatable defines if the mesh must be flagged as updatable
  24121. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24122. * @returns a new Mesh
  24123. */
  24124. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24125. /**
  24126. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24127. * @param name defines the name of the mesh to create
  24128. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24129. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24130. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24131. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24132. * @param p the number of windings on X axis (positive integers, default 2)
  24133. * @param q the number of windings on Y axis (positive integers, default 3)
  24134. * @param scene defines the hosting scene
  24135. * @param updatable defines if the mesh must be flagged as updatable
  24136. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24137. * @returns a new Mesh
  24138. */
  24139. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24140. /**
  24141. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24142. * @param name defines the name of the mesh to create
  24143. * @param points is an array successive Vector3
  24144. * @param scene defines the hosting scene
  24145. * @param updatable defines if the mesh must be flagged as updatable
  24146. * @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).
  24147. * @returns a new Mesh
  24148. */
  24149. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24150. /**
  24151. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24152. * @param name defines the name of the mesh to create
  24153. * @param points is an array successive Vector3
  24154. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24155. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24156. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24157. * @param scene defines the hosting scene
  24158. * @param updatable defines if the mesh must be flagged as updatable
  24159. * @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)
  24160. * @returns a new Mesh
  24161. */
  24162. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24163. /**
  24164. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24165. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24166. * 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.
  24167. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24168. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24169. * Remember you can only change the shape positions, not their number when updating a polygon.
  24170. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24171. * @param name defines the name of the mesh to create
  24172. * @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
  24173. * @param scene defines the hosting scene
  24174. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24175. * @param updatable defines if the mesh must be flagged as updatable
  24176. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24177. * @param earcutInjection can be used to inject your own earcut reference
  24178. * @returns a new Mesh
  24179. */
  24180. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24181. /**
  24182. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24183. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24184. * @param name defines the name of the mesh to create
  24185. * @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
  24186. * @param depth defines the height of extrusion
  24187. * @param scene defines the hosting scene
  24188. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  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 earcutInjection can be used to inject your own earcut reference
  24192. * @returns a new Mesh
  24193. */
  24194. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24195. /**
  24196. * Creates an extruded shape mesh.
  24197. * 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
  24198. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24199. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24200. * @param name defines the name of the mesh to create
  24201. * @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
  24202. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24203. * @param scale is the value to scale the shape
  24204. * @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
  24205. * @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
  24206. * @param scene defines the hosting scene
  24207. * @param updatable defines if the mesh must be flagged as updatable
  24208. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24209. * @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)
  24210. * @returns a new Mesh
  24211. */
  24212. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24213. /**
  24214. * Creates an custom extruded shape mesh.
  24215. * The custom extrusion is a parametric shape.
  24216. * It has no predefined shape. Its final shape will depend on the input parameters.
  24217. * Please consider using the same method from the MeshBuilder class instead
  24218. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24219. * @param name defines the name of the mesh to create
  24220. * @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
  24221. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24222. * @param scaleFunction is a custom Javascript function called on each path point
  24223. * @param rotationFunction is a custom Javascript function called on each path point
  24224. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24225. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24226. * @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
  24227. * @param scene defines the hosting scene
  24228. * @param updatable defines if the mesh must be flagged as updatable
  24229. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24230. * @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)
  24231. * @returns a new Mesh
  24232. */
  24233. 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;
  24234. /**
  24235. * Creates lathe mesh.
  24236. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24237. * Please consider using the same method from the MeshBuilder class instead
  24238. * @param name defines the name of the mesh to create
  24239. * @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
  24240. * @param radius is the radius value of the lathe
  24241. * @param tessellation is the side number of the lathe.
  24242. * @param scene defines the hosting scene
  24243. * @param updatable defines if the mesh must be flagged as updatable
  24244. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24245. * @returns a new Mesh
  24246. */
  24247. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24248. /**
  24249. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24250. * @param name defines the name of the mesh to create
  24251. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24252. * @param scene defines the hosting scene
  24253. * @param updatable defines if the mesh must be flagged as updatable
  24254. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24255. * @returns a new Mesh
  24256. */
  24257. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24258. /**
  24259. * Creates a ground mesh.
  24260. * Please consider using the same method from the MeshBuilder class instead
  24261. * @param name defines the name of the mesh to create
  24262. * @param width set the width of the ground
  24263. * @param height set the height of the ground
  24264. * @param subdivisions sets the number of subdivisions per side
  24265. * @param scene defines the hosting scene
  24266. * @param updatable defines if the mesh must be flagged as updatable
  24267. * @returns a new Mesh
  24268. */
  24269. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24270. /**
  24271. * Creates a tiled ground mesh.
  24272. * Please consider using the same method from the MeshBuilder class instead
  24273. * @param name defines the name of the mesh to create
  24274. * @param xmin set the ground minimum X coordinate
  24275. * @param zmin set the ground minimum Y coordinate
  24276. * @param xmax set the ground maximum X coordinate
  24277. * @param zmax set the ground maximum Z coordinate
  24278. * @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
  24279. * @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
  24280. * @param scene defines the hosting scene
  24281. * @param updatable defines if the mesh must be flagged as updatable
  24282. * @returns a new Mesh
  24283. */
  24284. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24285. w: number;
  24286. h: number;
  24287. }, precision: {
  24288. w: number;
  24289. h: number;
  24290. }, scene: Scene, updatable?: boolean): Mesh;
  24291. /**
  24292. * Creates a ground mesh from a height map.
  24293. * Please consider using the same method from the MeshBuilder class instead
  24294. * @see http://doc.babylonjs.com/babylon101/height_map
  24295. * @param name defines the name of the mesh to create
  24296. * @param url sets the URL of the height map image resource
  24297. * @param width set the ground width size
  24298. * @param height set the ground height size
  24299. * @param subdivisions sets the number of subdivision per side
  24300. * @param minHeight is the minimum altitude on the ground
  24301. * @param maxHeight is the maximum altitude on the ground
  24302. * @param scene defines the hosting scene
  24303. * @param updatable defines if the mesh must be flagged as updatable
  24304. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24305. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24306. * @returns a new Mesh
  24307. */
  24308. 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;
  24309. /**
  24310. * Creates a tube mesh.
  24311. * The tube is a parametric shape.
  24312. * It has no predefined shape. Its final shape will depend on the input parameters.
  24313. * Please consider using the same method from the MeshBuilder class instead
  24314. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24315. * @param name defines the name of the mesh to create
  24316. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24317. * @param radius sets the tube radius size
  24318. * @param tessellation is the number of sides on the tubular surface
  24319. * @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
  24320. * @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
  24321. * @param scene defines the hosting scene
  24322. * @param updatable defines if the mesh must be flagged as updatable
  24323. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24324. * @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)
  24325. * @returns a new Mesh
  24326. */
  24327. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24328. (i: number, distance: number): number;
  24329. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24330. /**
  24331. * Creates a polyhedron mesh.
  24332. * Please consider using the same method from the MeshBuilder class instead.
  24333. * * 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
  24334. * * The parameter `size` (positive float, default 1) sets the polygon size
  24335. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24336. * * 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`
  24337. * * 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
  24338. * * 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)`)
  24339. * * 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
  24340. * * 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
  24341. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24342. * * 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
  24343. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24344. * @param name defines the name of the mesh to create
  24345. * @param options defines the options used to create the mesh
  24346. * @param scene defines the hosting scene
  24347. * @returns a new Mesh
  24348. */
  24349. static CreatePolyhedron(name: string, options: {
  24350. type?: number;
  24351. size?: number;
  24352. sizeX?: number;
  24353. sizeY?: number;
  24354. sizeZ?: number;
  24355. custom?: any;
  24356. faceUV?: Vector4[];
  24357. faceColors?: Color4[];
  24358. updatable?: boolean;
  24359. sideOrientation?: number;
  24360. }, scene: Scene): Mesh;
  24361. /**
  24362. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24363. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24364. * * 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`)
  24365. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24366. * * 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
  24367. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24368. * * 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
  24369. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24370. * @param name defines the name of the mesh
  24371. * @param options defines the options used to create the mesh
  24372. * @param scene defines the hosting scene
  24373. * @returns a new Mesh
  24374. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24375. */
  24376. static CreateIcoSphere(name: string, options: {
  24377. radius?: number;
  24378. flat?: boolean;
  24379. subdivisions?: number;
  24380. sideOrientation?: number;
  24381. updatable?: boolean;
  24382. }, scene: Scene): Mesh;
  24383. /**
  24384. * Creates a decal mesh.
  24385. * Please consider using the same method from the MeshBuilder class instead.
  24386. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24387. * @param name defines the name of the mesh
  24388. * @param sourceMesh defines the mesh receiving the decal
  24389. * @param position sets the position of the decal in world coordinates
  24390. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24391. * @param size sets the decal scaling
  24392. * @param angle sets the angle to rotate the decal
  24393. * @returns a new Mesh
  24394. */
  24395. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24396. /**
  24397. * Prepare internal position array for software CPU skinning
  24398. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24399. */
  24400. setPositionsForCPUSkinning(): Float32Array;
  24401. /**
  24402. * Prepare internal normal array for software CPU skinning
  24403. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24404. */
  24405. setNormalsForCPUSkinning(): Float32Array;
  24406. /**
  24407. * Updates the vertex buffer by applying transformation from the bones
  24408. * @param skeleton defines the skeleton to apply to current mesh
  24409. * @returns the current mesh
  24410. */
  24411. applySkeleton(skeleton: Skeleton): Mesh;
  24412. /**
  24413. * 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
  24414. * @param meshes defines the list of meshes to scan
  24415. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24416. */
  24417. static MinMax(meshes: AbstractMesh[]): {
  24418. min: Vector3;
  24419. max: Vector3;
  24420. };
  24421. /**
  24422. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24423. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24424. * @returns a vector3
  24425. */
  24426. static Center(meshesOrMinMaxVector: {
  24427. min: Vector3;
  24428. max: Vector3;
  24429. } | AbstractMesh[]): Vector3;
  24430. /**
  24431. * Merge the array of meshes into a single mesh for performance reasons.
  24432. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24433. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24434. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24435. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24436. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24437. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24438. * @returns a new mesh
  24439. */
  24440. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24441. /** @hidden */
  24442. addInstance(instance: InstancedMesh): void;
  24443. /** @hidden */
  24444. removeInstance(instance: InstancedMesh): void;
  24445. }
  24446. }
  24447. declare module BABYLON {
  24448. /**
  24449. * This is the base class of all the camera used in the application.
  24450. * @see http://doc.babylonjs.com/features/cameras
  24451. */
  24452. export class Camera extends Node {
  24453. /** @hidden */
  24454. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24455. /**
  24456. * This is the default projection mode used by the cameras.
  24457. * It helps recreating a feeling of perspective and better appreciate depth.
  24458. * This is the best way to simulate real life cameras.
  24459. */
  24460. static readonly PERSPECTIVE_CAMERA: number;
  24461. /**
  24462. * This helps creating camera with an orthographic mode.
  24463. * 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.
  24464. */
  24465. static readonly ORTHOGRAPHIC_CAMERA: number;
  24466. /**
  24467. * This is the default FOV mode for perspective cameras.
  24468. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24469. */
  24470. static readonly FOVMODE_VERTICAL_FIXED: number;
  24471. /**
  24472. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24473. */
  24474. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24475. /**
  24476. * This specifies ther is no need for a camera rig.
  24477. * Basically only one eye is rendered corresponding to the camera.
  24478. */
  24479. static readonly RIG_MODE_NONE: number;
  24480. /**
  24481. * Simulates a camera Rig with one blue eye and one red eye.
  24482. * This can be use with 3d blue and red glasses.
  24483. */
  24484. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24485. /**
  24486. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24487. */
  24488. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24489. /**
  24490. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24491. */
  24492. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24493. /**
  24494. * Defines that both eyes of the camera will be rendered over under each other.
  24495. */
  24496. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24497. /**
  24498. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24499. */
  24500. static readonly RIG_MODE_VR: number;
  24501. /**
  24502. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24503. */
  24504. static readonly RIG_MODE_WEBVR: number;
  24505. /**
  24506. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24507. */
  24508. static readonly RIG_MODE_CUSTOM: number;
  24509. /**
  24510. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24511. */
  24512. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24513. /**
  24514. * Define the input manager associated with the camera.
  24515. */
  24516. inputs: CameraInputsManager<Camera>;
  24517. /** @hidden */
  24518. _position: Vector3;
  24519. /**
  24520. * Define the current local position of the camera in the scene
  24521. */
  24522. position: Vector3;
  24523. /**
  24524. * The vector the camera should consider as up.
  24525. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24526. */
  24527. upVector: Vector3;
  24528. /**
  24529. * Define the current limit on the left side for an orthographic camera
  24530. * In scene unit
  24531. */
  24532. orthoLeft: Nullable<number>;
  24533. /**
  24534. * Define the current limit on the right side for an orthographic camera
  24535. * In scene unit
  24536. */
  24537. orthoRight: Nullable<number>;
  24538. /**
  24539. * Define the current limit on the bottom side for an orthographic camera
  24540. * In scene unit
  24541. */
  24542. orthoBottom: Nullable<number>;
  24543. /**
  24544. * Define the current limit on the top side for an orthographic camera
  24545. * In scene unit
  24546. */
  24547. orthoTop: Nullable<number>;
  24548. /**
  24549. * Field Of View is set in Radians. (default is 0.8)
  24550. */
  24551. fov: number;
  24552. /**
  24553. * Define the minimum distance the camera can see from.
  24554. * This is important to note that the depth buffer are not infinite and the closer it starts
  24555. * the more your scene might encounter depth fighting issue.
  24556. */
  24557. minZ: number;
  24558. /**
  24559. * Define the maximum distance the camera can see to.
  24560. * This is important to note that the depth buffer are not infinite and the further it end
  24561. * the more your scene might encounter depth fighting issue.
  24562. */
  24563. maxZ: number;
  24564. /**
  24565. * Define the default inertia of the camera.
  24566. * This helps giving a smooth feeling to the camera movement.
  24567. */
  24568. inertia: number;
  24569. /**
  24570. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24571. */
  24572. mode: number;
  24573. /**
  24574. * Define wether the camera is intermediate.
  24575. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24576. */
  24577. isIntermediate: boolean;
  24578. /**
  24579. * Define the viewport of the camera.
  24580. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24581. */
  24582. viewport: Viewport;
  24583. /**
  24584. * Restricts the camera to viewing objects with the same layerMask.
  24585. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24586. */
  24587. layerMask: number;
  24588. /**
  24589. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24590. */
  24591. fovMode: number;
  24592. /**
  24593. * Rig mode of the camera.
  24594. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24595. * This is normally controlled byt the camera themselves as internal use.
  24596. */
  24597. cameraRigMode: number;
  24598. /**
  24599. * Defines the distance between both "eyes" in case of a RIG
  24600. */
  24601. interaxialDistance: number;
  24602. /**
  24603. * Defines if stereoscopic rendering is done side by side or over under.
  24604. */
  24605. isStereoscopicSideBySide: boolean;
  24606. /**
  24607. * 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
  24608. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24609. * else in the scene. (Eg. security camera)
  24610. *
  24611. * 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)
  24612. */
  24613. customRenderTargets: RenderTargetTexture[];
  24614. /**
  24615. * When set, the camera will render to this render target instead of the default canvas
  24616. *
  24617. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24618. */
  24619. outputRenderTarget: Nullable<RenderTargetTexture>;
  24620. /**
  24621. * Observable triggered when the camera view matrix has changed.
  24622. */
  24623. onViewMatrixChangedObservable: Observable<Camera>;
  24624. /**
  24625. * Observable triggered when the camera Projection matrix has changed.
  24626. */
  24627. onProjectionMatrixChangedObservable: Observable<Camera>;
  24628. /**
  24629. * Observable triggered when the inputs have been processed.
  24630. */
  24631. onAfterCheckInputsObservable: Observable<Camera>;
  24632. /**
  24633. * Observable triggered when reset has been called and applied to the camera.
  24634. */
  24635. onRestoreStateObservable: Observable<Camera>;
  24636. /** @hidden */
  24637. _cameraRigParams: any;
  24638. /** @hidden */
  24639. _rigCameras: Camera[];
  24640. /** @hidden */
  24641. _rigPostProcess: Nullable<PostProcess>;
  24642. protected _webvrViewMatrix: Matrix;
  24643. /** @hidden */
  24644. _skipRendering: boolean;
  24645. /** @hidden */
  24646. _projectionMatrix: Matrix;
  24647. /** @hidden */
  24648. _postProcesses: Nullable<PostProcess>[];
  24649. /** @hidden */
  24650. _activeMeshes: SmartArray<AbstractMesh>;
  24651. protected _globalPosition: Vector3;
  24652. /** @hidden */
  24653. _computedViewMatrix: Matrix;
  24654. private _doNotComputeProjectionMatrix;
  24655. private _transformMatrix;
  24656. private _frustumPlanes;
  24657. private _refreshFrustumPlanes;
  24658. private _storedFov;
  24659. private _stateStored;
  24660. /**
  24661. * Instantiates a new camera object.
  24662. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  24663. * @see http://doc.babylonjs.com/features/cameras
  24664. * @param name Defines the name of the camera in the scene
  24665. * @param position Defines the position of the camera
  24666. * @param scene Defines the scene the camera belongs too
  24667. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  24668. */
  24669. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24670. /**
  24671. * Store current camera state (fov, position, etc..)
  24672. * @returns the camera
  24673. */
  24674. storeState(): Camera;
  24675. /**
  24676. * Restores the camera state values if it has been stored. You must call storeState() first
  24677. */
  24678. protected _restoreStateValues(): boolean;
  24679. /**
  24680. * Restored camera state. You must call storeState() first.
  24681. * @returns true if restored and false otherwise
  24682. */
  24683. restoreState(): boolean;
  24684. /**
  24685. * Gets the class name of the camera.
  24686. * @returns the class name
  24687. */
  24688. getClassName(): string;
  24689. /** @hidden */
  24690. readonly _isCamera: boolean;
  24691. /**
  24692. * Gets a string representation of the camera useful for debug purpose.
  24693. * @param fullDetails Defines that a more verboe level of logging is required
  24694. * @returns the string representation
  24695. */
  24696. toString(fullDetails?: boolean): string;
  24697. /**
  24698. * Gets the current world space position of the camera.
  24699. */
  24700. readonly globalPosition: Vector3;
  24701. /**
  24702. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  24703. * @returns the active meshe list
  24704. */
  24705. getActiveMeshes(): SmartArray<AbstractMesh>;
  24706. /**
  24707. * Check wether a mesh is part of the current active mesh list of the camera
  24708. * @param mesh Defines the mesh to check
  24709. * @returns true if active, false otherwise
  24710. */
  24711. isActiveMesh(mesh: Mesh): boolean;
  24712. /**
  24713. * Is this camera ready to be used/rendered
  24714. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  24715. * @return true if the camera is ready
  24716. */
  24717. isReady(completeCheck?: boolean): boolean;
  24718. /** @hidden */
  24719. _initCache(): void;
  24720. /** @hidden */
  24721. _updateCache(ignoreParentClass?: boolean): void;
  24722. /** @hidden */
  24723. _isSynchronized(): boolean;
  24724. /** @hidden */
  24725. _isSynchronizedViewMatrix(): boolean;
  24726. /** @hidden */
  24727. _isSynchronizedProjectionMatrix(): boolean;
  24728. /**
  24729. * Attach the input controls to a specific dom element to get the input from.
  24730. * @param element Defines the element the controls should be listened from
  24731. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24732. */
  24733. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24734. /**
  24735. * Detach the current controls from the specified dom element.
  24736. * @param element Defines the element to stop listening the inputs from
  24737. */
  24738. detachControl(element: HTMLElement): void;
  24739. /**
  24740. * Update the camera state according to the different inputs gathered during the frame.
  24741. */
  24742. update(): void;
  24743. /** @hidden */
  24744. _checkInputs(): void;
  24745. /** @hidden */
  24746. readonly rigCameras: Camera[];
  24747. /**
  24748. * Gets the post process used by the rig cameras
  24749. */
  24750. readonly rigPostProcess: Nullable<PostProcess>;
  24751. /**
  24752. * Internal, gets the first post proces.
  24753. * @returns the first post process to be run on this camera.
  24754. */
  24755. _getFirstPostProcess(): Nullable<PostProcess>;
  24756. private _cascadePostProcessesToRigCams;
  24757. /**
  24758. * Attach a post process to the camera.
  24759. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24760. * @param postProcess The post process to attach to the camera
  24761. * @param insertAt The position of the post process in case several of them are in use in the scene
  24762. * @returns the position the post process has been inserted at
  24763. */
  24764. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  24765. /**
  24766. * Detach a post process to the camera.
  24767. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24768. * @param postProcess The post process to detach from the camera
  24769. */
  24770. detachPostProcess(postProcess: PostProcess): void;
  24771. /**
  24772. * Gets the current world matrix of the camera
  24773. */
  24774. getWorldMatrix(): Matrix;
  24775. /** @hidden */
  24776. _getViewMatrix(): Matrix;
  24777. /**
  24778. * Gets the current view matrix of the camera.
  24779. * @param force forces the camera to recompute the matrix without looking at the cached state
  24780. * @returns the view matrix
  24781. */
  24782. getViewMatrix(force?: boolean): Matrix;
  24783. /**
  24784. * Freeze the projection matrix.
  24785. * It will prevent the cache check of the camera projection compute and can speed up perf
  24786. * if no parameter of the camera are meant to change
  24787. * @param projection Defines manually a projection if necessary
  24788. */
  24789. freezeProjectionMatrix(projection?: Matrix): void;
  24790. /**
  24791. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  24792. */
  24793. unfreezeProjectionMatrix(): void;
  24794. /**
  24795. * Gets the current projection matrix of the camera.
  24796. * @param force forces the camera to recompute the matrix without looking at the cached state
  24797. * @returns the projection matrix
  24798. */
  24799. getProjectionMatrix(force?: boolean): Matrix;
  24800. /**
  24801. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  24802. * @returns a Matrix
  24803. */
  24804. getTransformationMatrix(): Matrix;
  24805. private _updateFrustumPlanes;
  24806. /**
  24807. * Checks if a cullable object (mesh...) is in the camera frustum
  24808. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  24809. * @param target The object to check
  24810. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  24811. * @returns true if the object is in frustum otherwise false
  24812. */
  24813. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  24814. /**
  24815. * Checks if a cullable object (mesh...) is in the camera frustum
  24816. * Unlike isInFrustum this cheks the full bounding box
  24817. * @param target The object to check
  24818. * @returns true if the object is in frustum otherwise false
  24819. */
  24820. isCompletelyInFrustum(target: ICullable): boolean;
  24821. /**
  24822. * Gets a ray in the forward direction from the camera.
  24823. * @param length Defines the length of the ray to create
  24824. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  24825. * @param origin Defines the start point of the ray which defaults to the camera position
  24826. * @returns the forward ray
  24827. */
  24828. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  24829. /**
  24830. * Releases resources associated with this node.
  24831. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24832. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24833. */
  24834. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24835. /** @hidden */
  24836. _isLeftCamera: boolean;
  24837. /**
  24838. * Gets the left camera of a rig setup in case of Rigged Camera
  24839. */
  24840. readonly isLeftCamera: boolean;
  24841. /** @hidden */
  24842. _isRightCamera: boolean;
  24843. /**
  24844. * Gets the right camera of a rig setup in case of Rigged Camera
  24845. */
  24846. readonly isRightCamera: boolean;
  24847. /**
  24848. * Gets the left camera of a rig setup in case of Rigged Camera
  24849. */
  24850. readonly leftCamera: Nullable<FreeCamera>;
  24851. /**
  24852. * Gets the right camera of a rig setup in case of Rigged Camera
  24853. */
  24854. readonly rightCamera: Nullable<FreeCamera>;
  24855. /**
  24856. * Gets the left camera target of a rig setup in case of Rigged Camera
  24857. * @returns the target position
  24858. */
  24859. getLeftTarget(): Nullable<Vector3>;
  24860. /**
  24861. * Gets the right camera target of a rig setup in case of Rigged Camera
  24862. * @returns the target position
  24863. */
  24864. getRightTarget(): Nullable<Vector3>;
  24865. /**
  24866. * @hidden
  24867. */
  24868. setCameraRigMode(mode: number, rigParams: any): void;
  24869. /** @hidden */
  24870. static _setStereoscopicRigMode(camera: Camera): void;
  24871. /** @hidden */
  24872. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  24873. /** @hidden */
  24874. static _setVRRigMode(camera: Camera, rigParams: any): void;
  24875. /** @hidden */
  24876. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  24877. /** @hidden */
  24878. _getVRProjectionMatrix(): Matrix;
  24879. protected _updateCameraRotationMatrix(): void;
  24880. protected _updateWebVRCameraRotationMatrix(): void;
  24881. /**
  24882. * This function MUST be overwritten by the different WebVR cameras available.
  24883. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24884. * @hidden
  24885. */
  24886. _getWebVRProjectionMatrix(): Matrix;
  24887. /**
  24888. * This function MUST be overwritten by the different WebVR cameras available.
  24889. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24890. * @hidden
  24891. */
  24892. _getWebVRViewMatrix(): Matrix;
  24893. /** @hidden */
  24894. setCameraRigParameter(name: string, value: any): void;
  24895. /**
  24896. * needs to be overridden by children so sub has required properties to be copied
  24897. * @hidden
  24898. */
  24899. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  24900. /**
  24901. * May need to be overridden by children
  24902. * @hidden
  24903. */
  24904. _updateRigCameras(): void;
  24905. /** @hidden */
  24906. _setupInputs(): void;
  24907. /**
  24908. * Serialiaze the camera setup to a json represention
  24909. * @returns the JSON representation
  24910. */
  24911. serialize(): any;
  24912. /**
  24913. * Clones the current camera.
  24914. * @param name The cloned camera name
  24915. * @returns the cloned camera
  24916. */
  24917. clone(name: string): Camera;
  24918. /**
  24919. * Gets the direction of the camera relative to a given local axis.
  24920. * @param localAxis Defines the reference axis to provide a relative direction.
  24921. * @return the direction
  24922. */
  24923. getDirection(localAxis: Vector3): Vector3;
  24924. /**
  24925. * Gets the direction of the camera relative to a given local axis into a passed vector.
  24926. * @param localAxis Defines the reference axis to provide a relative direction.
  24927. * @param result Defines the vector to store the result in
  24928. */
  24929. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  24930. /**
  24931. * Gets a camera constructor for a given camera type
  24932. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  24933. * @param name The name of the camera the result will be able to instantiate
  24934. * @param scene The scene the result will construct the camera in
  24935. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  24936. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  24937. * @returns a factory method to construc the camera
  24938. */
  24939. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  24940. /**
  24941. * Compute the world matrix of the camera.
  24942. * @returns the camera workd matrix
  24943. */
  24944. computeWorldMatrix(): Matrix;
  24945. /**
  24946. * Parse a JSON and creates the camera from the parsed information
  24947. * @param parsedCamera The JSON to parse
  24948. * @param scene The scene to instantiate the camera in
  24949. * @returns the newly constructed camera
  24950. */
  24951. static Parse(parsedCamera: any, scene: Scene): Camera;
  24952. }
  24953. }
  24954. declare module BABYLON {
  24955. /**
  24956. * Class containing static functions to help procedurally build meshes
  24957. */
  24958. export class DiscBuilder {
  24959. /**
  24960. * Creates a plane polygonal mesh. By default, this is a disc
  24961. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24962. * * 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
  24963. * * 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
  24964. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24965. * * 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
  24966. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24967. * @param name defines the name of the mesh
  24968. * @param options defines the options used to create the mesh
  24969. * @param scene defines the hosting scene
  24970. * @returns the plane polygonal mesh
  24971. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24972. */
  24973. static CreateDisc(name: string, options: {
  24974. radius?: number;
  24975. tessellation?: number;
  24976. arc?: number;
  24977. updatable?: boolean;
  24978. sideOrientation?: number;
  24979. frontUVs?: Vector4;
  24980. backUVs?: Vector4;
  24981. }, scene?: Nullable<Scene>): Mesh;
  24982. }
  24983. }
  24984. declare module BABYLON {
  24985. /**
  24986. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24987. *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.
  24988. * The SPS is also a particle system. It provides some methods to manage the particles.
  24989. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24990. *
  24991. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  24992. */
  24993. export class SolidParticleSystem implements IDisposable {
  24994. /**
  24995. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24996. * Example : var p = SPS.particles[i];
  24997. */
  24998. particles: SolidParticle[];
  24999. /**
  25000. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25001. */
  25002. nbParticles: number;
  25003. /**
  25004. * If the particles must ever face the camera (default false). Useful for planar particles.
  25005. */
  25006. billboard: boolean;
  25007. /**
  25008. * Recompute normals when adding a shape
  25009. */
  25010. recomputeNormals: boolean;
  25011. /**
  25012. * This a counter ofr your own usage. It's not set by any SPS functions.
  25013. */
  25014. counter: number;
  25015. /**
  25016. * The SPS name. This name is also given to the underlying mesh.
  25017. */
  25018. name: string;
  25019. /**
  25020. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25021. */
  25022. mesh: Mesh;
  25023. /**
  25024. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25025. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25026. */
  25027. vars: any;
  25028. /**
  25029. * This array is populated when the SPS is set as 'pickable'.
  25030. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25031. * Each element of this array is an object `{idx: int, faceId: int}`.
  25032. * `idx` is the picked particle index in the `SPS.particles` array
  25033. * `faceId` is the picked face index counted within this particle.
  25034. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25035. */
  25036. pickedParticles: {
  25037. idx: number;
  25038. faceId: number;
  25039. }[];
  25040. /**
  25041. * This array is populated when `enableDepthSort` is set to true.
  25042. * Each element of this array is an instance of the class DepthSortedParticle.
  25043. */
  25044. depthSortedParticles: DepthSortedParticle[];
  25045. /**
  25046. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25047. * @hidden
  25048. */
  25049. _bSphereOnly: boolean;
  25050. /**
  25051. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25052. * @hidden
  25053. */
  25054. _bSphereRadiusFactor: number;
  25055. private _scene;
  25056. private _positions;
  25057. private _indices;
  25058. private _normals;
  25059. private _colors;
  25060. private _uvs;
  25061. private _indices32;
  25062. private _positions32;
  25063. private _normals32;
  25064. private _fixedNormal32;
  25065. private _colors32;
  25066. private _uvs32;
  25067. private _index;
  25068. private _updatable;
  25069. private _pickable;
  25070. private _isVisibilityBoxLocked;
  25071. private _alwaysVisible;
  25072. private _depthSort;
  25073. private _shapeCounter;
  25074. private _copy;
  25075. private _color;
  25076. private _computeParticleColor;
  25077. private _computeParticleTexture;
  25078. private _computeParticleRotation;
  25079. private _computeParticleVertex;
  25080. private _computeBoundingBox;
  25081. private _depthSortParticles;
  25082. private _camera;
  25083. private _mustUnrotateFixedNormals;
  25084. private _particlesIntersect;
  25085. private _needs32Bits;
  25086. /**
  25087. * Creates a SPS (Solid Particle System) object.
  25088. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25089. * @param scene (Scene) is the scene in which the SPS is added.
  25090. * @param options defines the options of the sps e.g.
  25091. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25092. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25093. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25094. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25095. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25096. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25097. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25098. */
  25099. constructor(name: string, scene: Scene, options?: {
  25100. updatable?: boolean;
  25101. isPickable?: boolean;
  25102. enableDepthSort?: boolean;
  25103. particleIntersection?: boolean;
  25104. boundingSphereOnly?: boolean;
  25105. bSphereRadiusFactor?: number;
  25106. });
  25107. /**
  25108. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25109. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25110. * @returns the created mesh
  25111. */
  25112. buildMesh(): Mesh;
  25113. /**
  25114. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25115. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25116. * Thus the particles generated from `digest()` have their property `position` set yet.
  25117. * @param mesh ( Mesh ) is the mesh to be digested
  25118. * @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
  25119. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25120. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25121. * @returns the current SPS
  25122. */
  25123. digest(mesh: Mesh, options?: {
  25124. facetNb?: number;
  25125. number?: number;
  25126. delta?: number;
  25127. }): SolidParticleSystem;
  25128. private _unrotateFixedNormals;
  25129. private _resetCopy;
  25130. private _meshBuilder;
  25131. private _posToShape;
  25132. private _uvsToShapeUV;
  25133. private _addParticle;
  25134. /**
  25135. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25136. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25137. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25138. * @param nb (positive integer) the number of particles to be created from this model
  25139. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25140. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25141. * @returns the number of shapes in the system
  25142. */
  25143. addShape(mesh: Mesh, nb: number, options?: {
  25144. positionFunction?: any;
  25145. vertexFunction?: any;
  25146. }): number;
  25147. private _rebuildParticle;
  25148. /**
  25149. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25150. * @returns the SPS.
  25151. */
  25152. rebuildMesh(): SolidParticleSystem;
  25153. /**
  25154. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25155. * This method calls `updateParticle()` for each particle of the SPS.
  25156. * For an animated SPS, it is usually called within the render loop.
  25157. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25158. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25159. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25160. * @returns the SPS.
  25161. */
  25162. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25163. /**
  25164. * Disposes the SPS.
  25165. */
  25166. dispose(): void;
  25167. /**
  25168. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25169. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25170. * @returns the SPS.
  25171. */
  25172. refreshVisibleSize(): SolidParticleSystem;
  25173. /**
  25174. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25175. * @param size the size (float) of the visibility box
  25176. * note : this doesn't lock the SPS mesh bounding box.
  25177. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25178. */
  25179. setVisibilityBox(size: number): void;
  25180. /**
  25181. * Gets whether the SPS as always visible or not
  25182. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25183. */
  25184. /**
  25185. * Sets the SPS as always visible or not
  25186. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25187. */
  25188. isAlwaysVisible: boolean;
  25189. /**
  25190. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25191. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25192. */
  25193. /**
  25194. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25195. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25196. */
  25197. isVisibilityBoxLocked: boolean;
  25198. /**
  25199. * Tells to `setParticles()` to compute the particle rotations or not.
  25200. * Default value : true. The SPS is faster when it's set to false.
  25201. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25202. */
  25203. /**
  25204. * Gets if `setParticles()` computes the particle rotations or not.
  25205. * Default value : true. The SPS is faster when it's set to false.
  25206. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25207. */
  25208. computeParticleRotation: boolean;
  25209. /**
  25210. * Tells to `setParticles()` to compute the particle colors or not.
  25211. * Default value : true. The SPS is faster when it's set to false.
  25212. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25213. */
  25214. /**
  25215. * Gets if `setParticles()` computes the particle colors or not.
  25216. * Default value : true. The SPS is faster when it's set to false.
  25217. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25218. */
  25219. computeParticleColor: boolean;
  25220. /**
  25221. * Gets if `setParticles()` computes the particle textures or not.
  25222. * Default value : true. The SPS is faster when it's set to false.
  25223. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25224. */
  25225. computeParticleTexture: boolean;
  25226. /**
  25227. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25228. * Default value : false. The SPS is faster when it's set to false.
  25229. * Note : the particle custom vertex positions aren't stored values.
  25230. */
  25231. /**
  25232. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25233. * Default value : false. The SPS is faster when it's set to false.
  25234. * Note : the particle custom vertex positions aren't stored values.
  25235. */
  25236. computeParticleVertex: boolean;
  25237. /**
  25238. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25239. */
  25240. /**
  25241. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25242. */
  25243. computeBoundingBox: boolean;
  25244. /**
  25245. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25246. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25247. * Default : `true`
  25248. */
  25249. /**
  25250. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25251. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25252. * Default : `true`
  25253. */
  25254. depthSortParticles: boolean;
  25255. /**
  25256. * This function does nothing. It may be overwritten to set all the particle first values.
  25257. * The SPS doesn't call this function, you may have to call it by your own.
  25258. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25259. */
  25260. initParticles(): void;
  25261. /**
  25262. * This function does nothing. It may be overwritten to recycle a particle.
  25263. * The SPS doesn't call this function, you may have to call it by your own.
  25264. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25265. * @param particle The particle to recycle
  25266. * @returns the recycled particle
  25267. */
  25268. recycleParticle(particle: SolidParticle): SolidParticle;
  25269. /**
  25270. * Updates a particle : this function should be overwritten by the user.
  25271. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25272. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25273. * @example : just set a particle position or velocity and recycle conditions
  25274. * @param particle The particle to update
  25275. * @returns the updated particle
  25276. */
  25277. updateParticle(particle: SolidParticle): SolidParticle;
  25278. /**
  25279. * Updates a vertex of a particle : it can be overwritten by the user.
  25280. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25281. * @param particle the current particle
  25282. * @param vertex the current index of the current particle
  25283. * @param pt the index of the current vertex in the particle shape
  25284. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25285. * @example : just set a vertex particle position
  25286. * @returns the updated vertex
  25287. */
  25288. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25289. /**
  25290. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25291. * This does nothing and may be overwritten by the user.
  25292. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25293. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25294. * @param update the boolean update value actually passed to setParticles()
  25295. */
  25296. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25297. /**
  25298. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25299. * This will be passed three parameters.
  25300. * This does nothing and may be overwritten by the user.
  25301. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25302. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25303. * @param update the boolean update value actually passed to setParticles()
  25304. */
  25305. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25306. }
  25307. }
  25308. declare module BABYLON {
  25309. /**
  25310. * Represents one particle of a solid particle system.
  25311. */
  25312. export class SolidParticle {
  25313. /**
  25314. * particle global index
  25315. */
  25316. idx: number;
  25317. /**
  25318. * The color of the particle
  25319. */
  25320. color: Nullable<Color4>;
  25321. /**
  25322. * The world space position of the particle.
  25323. */
  25324. position: Vector3;
  25325. /**
  25326. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25327. */
  25328. rotation: Vector3;
  25329. /**
  25330. * The world space rotation quaternion of the particle.
  25331. */
  25332. rotationQuaternion: Nullable<Quaternion>;
  25333. /**
  25334. * The scaling of the particle.
  25335. */
  25336. scaling: Vector3;
  25337. /**
  25338. * The uvs of the particle.
  25339. */
  25340. uvs: Vector4;
  25341. /**
  25342. * The current speed of the particle.
  25343. */
  25344. velocity: Vector3;
  25345. /**
  25346. * The pivot point in the particle local space.
  25347. */
  25348. pivot: Vector3;
  25349. /**
  25350. * Must the particle be translated from its pivot point in its local space ?
  25351. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25352. * Default : false
  25353. */
  25354. translateFromPivot: boolean;
  25355. /**
  25356. * Is the particle active or not ?
  25357. */
  25358. alive: boolean;
  25359. /**
  25360. * Is the particle visible or not ?
  25361. */
  25362. isVisible: boolean;
  25363. /**
  25364. * Index of this particle in the global "positions" array (Internal use)
  25365. * @hidden
  25366. */
  25367. _pos: number;
  25368. /**
  25369. * @hidden Index of this particle in the global "indices" array (Internal use)
  25370. */
  25371. _ind: number;
  25372. /**
  25373. * @hidden ModelShape of this particle (Internal use)
  25374. */
  25375. _model: ModelShape;
  25376. /**
  25377. * ModelShape id of this particle
  25378. */
  25379. shapeId: number;
  25380. /**
  25381. * Index of the particle in its shape id
  25382. */
  25383. idxInShape: number;
  25384. /**
  25385. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25386. */
  25387. _modelBoundingInfo: BoundingInfo;
  25388. /**
  25389. * @hidden Particle BoundingInfo object (Internal use)
  25390. */
  25391. _boundingInfo: BoundingInfo;
  25392. /**
  25393. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  25394. */
  25395. _sps: SolidParticleSystem;
  25396. /**
  25397. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  25398. */
  25399. _stillInvisible: boolean;
  25400. /**
  25401. * @hidden Last computed particle rotation matrix
  25402. */
  25403. _rotationMatrix: number[];
  25404. /**
  25405. * Parent particle Id, if any.
  25406. * Default null.
  25407. */
  25408. parentId: Nullable<number>;
  25409. /**
  25410. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25411. * The possible values are :
  25412. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25413. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25414. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25415. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25416. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25417. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25418. * */
  25419. cullingStrategy: number;
  25420. /**
  25421. * @hidden Internal global position in the SPS.
  25422. */
  25423. _globalPosition: Vector3;
  25424. /**
  25425. * Creates a Solid Particle object.
  25426. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25427. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25428. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25429. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25430. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25431. * @param shapeId (integer) is the model shape identifier in the SPS.
  25432. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25433. * @param sps defines the sps it is associated to
  25434. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25435. */
  25436. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25437. /**
  25438. * Legacy support, changed scale to scaling
  25439. */
  25440. /**
  25441. * Legacy support, changed scale to scaling
  25442. */
  25443. scale: Vector3;
  25444. /**
  25445. * Legacy support, changed quaternion to rotationQuaternion
  25446. */
  25447. /**
  25448. * Legacy support, changed quaternion to rotationQuaternion
  25449. */
  25450. quaternion: Nullable<Quaternion>;
  25451. /**
  25452. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25453. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25454. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25455. * @returns true if it intersects
  25456. */
  25457. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25458. /**
  25459. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25460. * A particle is in the frustum if its bounding box intersects the frustum
  25461. * @param frustumPlanes defines the frustum to test
  25462. * @returns true if the particle is in the frustum planes
  25463. */
  25464. isInFrustum(frustumPlanes: Plane[]): boolean;
  25465. /**
  25466. * get the rotation matrix of the particle
  25467. * @hidden
  25468. */
  25469. getRotationMatrix(m: Matrix): void;
  25470. }
  25471. /**
  25472. * Represents the shape of the model used by one particle of a solid particle system.
  25473. * SPS internal tool, don't use it manually.
  25474. */
  25475. export class ModelShape {
  25476. /**
  25477. * The shape id
  25478. * @hidden
  25479. */
  25480. shapeID: number;
  25481. /**
  25482. * flat array of model positions (internal use)
  25483. * @hidden
  25484. */
  25485. _shape: Vector3[];
  25486. /**
  25487. * flat array of model UVs (internal use)
  25488. * @hidden
  25489. */
  25490. _shapeUV: number[];
  25491. /**
  25492. * length of the shape in the model indices array (internal use)
  25493. * @hidden
  25494. */
  25495. _indicesLength: number;
  25496. /**
  25497. * Custom position function (internal use)
  25498. * @hidden
  25499. */
  25500. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25501. /**
  25502. * Custom vertex function (internal use)
  25503. * @hidden
  25504. */
  25505. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25506. /**
  25507. * 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.
  25508. * SPS internal tool, don't use it manually.
  25509. * @hidden
  25510. */
  25511. 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>);
  25512. }
  25513. /**
  25514. * Represents a Depth Sorted Particle in the solid particle system.
  25515. */
  25516. export class DepthSortedParticle {
  25517. /**
  25518. * Index of the particle in the "indices" array
  25519. */
  25520. ind: number;
  25521. /**
  25522. * Length of the particle shape in the "indices" array
  25523. */
  25524. indicesLength: number;
  25525. /**
  25526. * Squared distance from the particle to the camera
  25527. */
  25528. sqDistance: number;
  25529. }
  25530. }
  25531. declare module BABYLON {
  25532. /**
  25533. * @hidden
  25534. */
  25535. export class _MeshCollisionData {
  25536. _checkCollisions: boolean;
  25537. _collisionMask: number;
  25538. _collisionGroup: number;
  25539. _collider: Nullable<Collider>;
  25540. _oldPositionForCollisions: Vector3;
  25541. _diffPositionForCollisions: Vector3;
  25542. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25543. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25544. }
  25545. }
  25546. declare module BABYLON {
  25547. /** @hidden */
  25548. class _FacetDataStorage {
  25549. facetPositions: Vector3[];
  25550. facetNormals: Vector3[];
  25551. facetPartitioning: number[][];
  25552. facetNb: number;
  25553. partitioningSubdivisions: number;
  25554. partitioningBBoxRatio: number;
  25555. facetDataEnabled: boolean;
  25556. facetParameters: any;
  25557. bbSize: Vector3;
  25558. subDiv: {
  25559. max: number;
  25560. X: number;
  25561. Y: number;
  25562. Z: number;
  25563. };
  25564. facetDepthSort: boolean;
  25565. facetDepthSortEnabled: boolean;
  25566. depthSortedIndices: IndicesArray;
  25567. depthSortedFacets: {
  25568. ind: number;
  25569. sqDistance: number;
  25570. }[];
  25571. facetDepthSortFunction: (f1: {
  25572. ind: number;
  25573. sqDistance: number;
  25574. }, f2: {
  25575. ind: number;
  25576. sqDistance: number;
  25577. }) => number;
  25578. facetDepthSortFrom: Vector3;
  25579. facetDepthSortOrigin: Vector3;
  25580. invertedMatrix: Matrix;
  25581. }
  25582. /**
  25583. * @hidden
  25584. **/
  25585. class _InternalAbstractMeshDataInfo {
  25586. _hasVertexAlpha: boolean;
  25587. _useVertexColors: boolean;
  25588. _numBoneInfluencers: number;
  25589. _applyFog: boolean;
  25590. _receiveShadows: boolean;
  25591. _facetData: _FacetDataStorage;
  25592. _visibility: number;
  25593. _skeleton: Nullable<Skeleton>;
  25594. _layerMask: number;
  25595. _computeBonesUsingShaders: boolean;
  25596. _isActive: boolean;
  25597. _onlyForInstances: boolean;
  25598. _isActiveIntermediate: boolean;
  25599. _onlyForInstancesIntermediate: boolean;
  25600. }
  25601. /**
  25602. * Class used to store all common mesh properties
  25603. */
  25604. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25605. /** No occlusion */
  25606. static OCCLUSION_TYPE_NONE: number;
  25607. /** Occlusion set to optimisitic */
  25608. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25609. /** Occlusion set to strict */
  25610. static OCCLUSION_TYPE_STRICT: number;
  25611. /** Use an accurante occlusion algorithm */
  25612. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25613. /** Use a conservative occlusion algorithm */
  25614. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25615. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25616. * Test order :
  25617. * Is the bounding sphere outside the frustum ?
  25618. * If not, are the bounding box vertices outside the frustum ?
  25619. * It not, then the cullable object is in the frustum.
  25620. */
  25621. static readonly CULLINGSTRATEGY_STANDARD: number;
  25622. /** Culling strategy : Bounding Sphere Only.
  25623. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25624. * It's also less accurate than the standard because some not visible objects can still be selected.
  25625. * Test : is the bounding sphere outside the frustum ?
  25626. * If not, then the cullable object is in the frustum.
  25627. */
  25628. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25629. /** Culling strategy : Optimistic Inclusion.
  25630. * This in an inclusion test first, then the standard exclusion test.
  25631. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25632. * 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.
  25633. * Anyway, it's as accurate as the standard strategy.
  25634. * Test :
  25635. * Is the cullable object bounding sphere center in the frustum ?
  25636. * If not, apply the default culling strategy.
  25637. */
  25638. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25639. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25640. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25641. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25642. * 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.
  25643. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25644. * Test :
  25645. * Is the cullable object bounding sphere center in the frustum ?
  25646. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25647. */
  25648. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25649. /**
  25650. * No billboard
  25651. */
  25652. static readonly BILLBOARDMODE_NONE: number;
  25653. /** Billboard on X axis */
  25654. static readonly BILLBOARDMODE_X: number;
  25655. /** Billboard on Y axis */
  25656. static readonly BILLBOARDMODE_Y: number;
  25657. /** Billboard on Z axis */
  25658. static readonly BILLBOARDMODE_Z: number;
  25659. /** Billboard on all axes */
  25660. static readonly BILLBOARDMODE_ALL: number;
  25661. /** Billboard on using position instead of orientation */
  25662. static readonly BILLBOARDMODE_USE_POSITION: number;
  25663. /** @hidden */
  25664. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25665. /**
  25666. * The culling strategy to use to check whether the mesh must be rendered or not.
  25667. * This value can be changed at any time and will be used on the next render mesh selection.
  25668. * The possible values are :
  25669. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25670. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25671. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25672. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25673. * Please read each static variable documentation to get details about the culling process.
  25674. * */
  25675. cullingStrategy: number;
  25676. /**
  25677. * Gets the number of facets in the mesh
  25678. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25679. */
  25680. readonly facetNb: number;
  25681. /**
  25682. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25683. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25684. */
  25685. partitioningSubdivisions: number;
  25686. /**
  25687. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25688. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25689. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25690. */
  25691. partitioningBBoxRatio: number;
  25692. /**
  25693. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25694. * Works only for updatable meshes.
  25695. * Doesn't work with multi-materials
  25696. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25697. */
  25698. mustDepthSortFacets: boolean;
  25699. /**
  25700. * The location (Vector3) where the facet depth sort must be computed from.
  25701. * By default, the active camera position.
  25702. * Used only when facet depth sort is enabled
  25703. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25704. */
  25705. facetDepthSortFrom: Vector3;
  25706. /**
  25707. * gets a boolean indicating if facetData is enabled
  25708. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25709. */
  25710. readonly isFacetDataEnabled: boolean;
  25711. /** @hidden */
  25712. _updateNonUniformScalingState(value: boolean): boolean;
  25713. /**
  25714. * An event triggered when this mesh collides with another one
  25715. */
  25716. onCollideObservable: Observable<AbstractMesh>;
  25717. /** Set a function to call when this mesh collides with another one */
  25718. onCollide: () => void;
  25719. /**
  25720. * An event triggered when the collision's position changes
  25721. */
  25722. onCollisionPositionChangeObservable: Observable<Vector3>;
  25723. /** Set a function to call when the collision's position changes */
  25724. onCollisionPositionChange: () => void;
  25725. /**
  25726. * An event triggered when material is changed
  25727. */
  25728. onMaterialChangedObservable: Observable<AbstractMesh>;
  25729. /**
  25730. * Gets or sets the orientation for POV movement & rotation
  25731. */
  25732. definedFacingForward: boolean;
  25733. /** @hidden */
  25734. _occlusionQuery: Nullable<WebGLQuery>;
  25735. /** @hidden */
  25736. _renderingGroup: Nullable<RenderingGroup>;
  25737. /**
  25738. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25739. */
  25740. /**
  25741. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25742. */
  25743. visibility: number;
  25744. /** Gets or sets the alpha index used to sort transparent meshes
  25745. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25746. */
  25747. alphaIndex: number;
  25748. /**
  25749. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25750. */
  25751. isVisible: boolean;
  25752. /**
  25753. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25754. */
  25755. isPickable: boolean;
  25756. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25757. showSubMeshesBoundingBox: boolean;
  25758. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25759. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25760. */
  25761. isBlocker: boolean;
  25762. /**
  25763. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25764. */
  25765. enablePointerMoveEvents: boolean;
  25766. /**
  25767. * Specifies the rendering group id for this mesh (0 by default)
  25768. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25769. */
  25770. renderingGroupId: number;
  25771. private _material;
  25772. /** Gets or sets current material */
  25773. material: Nullable<Material>;
  25774. /**
  25775. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25776. * @see http://doc.babylonjs.com/babylon101/shadows
  25777. */
  25778. receiveShadows: boolean;
  25779. /** Defines color to use when rendering outline */
  25780. outlineColor: Color3;
  25781. /** Define width to use when rendering outline */
  25782. outlineWidth: number;
  25783. /** Defines color to use when rendering overlay */
  25784. overlayColor: Color3;
  25785. /** Defines alpha to use when rendering overlay */
  25786. overlayAlpha: number;
  25787. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25788. hasVertexAlpha: boolean;
  25789. /** 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) */
  25790. useVertexColors: boolean;
  25791. /**
  25792. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25793. */
  25794. computeBonesUsingShaders: boolean;
  25795. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25796. numBoneInfluencers: number;
  25797. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25798. applyFog: boolean;
  25799. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25800. useOctreeForRenderingSelection: boolean;
  25801. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25802. useOctreeForPicking: boolean;
  25803. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25804. useOctreeForCollisions: boolean;
  25805. /**
  25806. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25807. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25808. */
  25809. layerMask: number;
  25810. /**
  25811. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25812. */
  25813. alwaysSelectAsActiveMesh: boolean;
  25814. /**
  25815. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25816. */
  25817. doNotSyncBoundingInfo: boolean;
  25818. /**
  25819. * Gets or sets the current action manager
  25820. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25821. */
  25822. actionManager: Nullable<AbstractActionManager>;
  25823. private _meshCollisionData;
  25824. /**
  25825. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25826. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25827. */
  25828. ellipsoid: Vector3;
  25829. /**
  25830. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25831. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25832. */
  25833. ellipsoidOffset: Vector3;
  25834. /**
  25835. * Gets or sets a collision mask used to mask collisions (default is -1).
  25836. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25837. */
  25838. collisionMask: number;
  25839. /**
  25840. * Gets or sets the current collision group mask (-1 by default).
  25841. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25842. */
  25843. collisionGroup: number;
  25844. /**
  25845. * Defines edge width used when edgesRenderer is enabled
  25846. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25847. */
  25848. edgesWidth: number;
  25849. /**
  25850. * Defines edge color used when edgesRenderer is enabled
  25851. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25852. */
  25853. edgesColor: Color4;
  25854. /** @hidden */
  25855. _edgesRenderer: Nullable<IEdgesRenderer>;
  25856. /** @hidden */
  25857. _masterMesh: Nullable<AbstractMesh>;
  25858. /** @hidden */
  25859. _boundingInfo: Nullable<BoundingInfo>;
  25860. /** @hidden */
  25861. _renderId: number;
  25862. /**
  25863. * Gets or sets the list of subMeshes
  25864. * @see http://doc.babylonjs.com/how_to/multi_materials
  25865. */
  25866. subMeshes: SubMesh[];
  25867. /** @hidden */
  25868. _intersectionsInProgress: AbstractMesh[];
  25869. /** @hidden */
  25870. _unIndexed: boolean;
  25871. /** @hidden */
  25872. _lightSources: Light[];
  25873. /** Gets the list of lights affecting that mesh */
  25874. readonly lightSources: Light[];
  25875. /** @hidden */
  25876. readonly _positions: Nullable<Vector3[]>;
  25877. /** @hidden */
  25878. _waitingData: {
  25879. lods: Nullable<any>;
  25880. actions: Nullable<any>;
  25881. freezeWorldMatrix: Nullable<boolean>;
  25882. };
  25883. /** @hidden */
  25884. _bonesTransformMatrices: Nullable<Float32Array>;
  25885. /** @hidden */
  25886. _transformMatrixTexture: Nullable<RawTexture>;
  25887. /**
  25888. * Gets or sets a skeleton to apply skining transformations
  25889. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25890. */
  25891. skeleton: Nullable<Skeleton>;
  25892. /**
  25893. * An event triggered when the mesh is rebuilt.
  25894. */
  25895. onRebuildObservable: Observable<AbstractMesh>;
  25896. /**
  25897. * Creates a new AbstractMesh
  25898. * @param name defines the name of the mesh
  25899. * @param scene defines the hosting scene
  25900. */
  25901. constructor(name: string, scene?: Nullable<Scene>);
  25902. /**
  25903. * Returns the string "AbstractMesh"
  25904. * @returns "AbstractMesh"
  25905. */
  25906. getClassName(): string;
  25907. /**
  25908. * Gets a string representation of the current mesh
  25909. * @param fullDetails defines a boolean indicating if full details must be included
  25910. * @returns a string representation of the current mesh
  25911. */
  25912. toString(fullDetails?: boolean): string;
  25913. /**
  25914. * @hidden
  25915. */
  25916. protected _getEffectiveParent(): Nullable<Node>;
  25917. /** @hidden */
  25918. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25919. /** @hidden */
  25920. _rebuild(): void;
  25921. /** @hidden */
  25922. _resyncLightSources(): void;
  25923. /** @hidden */
  25924. _resyncLighSource(light: Light): void;
  25925. /** @hidden */
  25926. _unBindEffect(): void;
  25927. /** @hidden */
  25928. _removeLightSource(light: Light, dispose: boolean): void;
  25929. private _markSubMeshesAsDirty;
  25930. /** @hidden */
  25931. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  25932. /** @hidden */
  25933. _markSubMeshesAsAttributesDirty(): void;
  25934. /** @hidden */
  25935. _markSubMeshesAsMiscDirty(): void;
  25936. /**
  25937. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25938. */
  25939. scaling: Vector3;
  25940. /**
  25941. * Returns true if the mesh is blocked. Implemented by child classes
  25942. */
  25943. readonly isBlocked: boolean;
  25944. /**
  25945. * Returns the mesh itself by default. Implemented by child classes
  25946. * @param camera defines the camera to use to pick the right LOD level
  25947. * @returns the currentAbstractMesh
  25948. */
  25949. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25950. /**
  25951. * Returns 0 by default. Implemented by child classes
  25952. * @returns an integer
  25953. */
  25954. getTotalVertices(): number;
  25955. /**
  25956. * Returns a positive integer : the total number of indices in this mesh geometry.
  25957. * @returns the numner of indices or zero if the mesh has no geometry.
  25958. */
  25959. getTotalIndices(): number;
  25960. /**
  25961. * Returns null by default. Implemented by child classes
  25962. * @returns null
  25963. */
  25964. getIndices(): Nullable<IndicesArray>;
  25965. /**
  25966. * Returns the array of the requested vertex data kind. Implemented by child classes
  25967. * @param kind defines the vertex data kind to use
  25968. * @returns null
  25969. */
  25970. getVerticesData(kind: string): Nullable<FloatArray>;
  25971. /**
  25972. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25973. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25974. * Note that a new underlying VertexBuffer object is created each call.
  25975. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25976. * @param kind defines vertex data kind:
  25977. * * VertexBuffer.PositionKind
  25978. * * VertexBuffer.UVKind
  25979. * * VertexBuffer.UV2Kind
  25980. * * VertexBuffer.UV3Kind
  25981. * * VertexBuffer.UV4Kind
  25982. * * VertexBuffer.UV5Kind
  25983. * * VertexBuffer.UV6Kind
  25984. * * VertexBuffer.ColorKind
  25985. * * VertexBuffer.MatricesIndicesKind
  25986. * * VertexBuffer.MatricesIndicesExtraKind
  25987. * * VertexBuffer.MatricesWeightsKind
  25988. * * VertexBuffer.MatricesWeightsExtraKind
  25989. * @param data defines the data source
  25990. * @param updatable defines if the data must be flagged as updatable (or static)
  25991. * @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
  25992. * @returns the current mesh
  25993. */
  25994. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25995. /**
  25996. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25997. * If the mesh has no geometry, it is simply returned as it is.
  25998. * @param kind defines vertex data kind:
  25999. * * VertexBuffer.PositionKind
  26000. * * VertexBuffer.UVKind
  26001. * * VertexBuffer.UV2Kind
  26002. * * VertexBuffer.UV3Kind
  26003. * * VertexBuffer.UV4Kind
  26004. * * VertexBuffer.UV5Kind
  26005. * * VertexBuffer.UV6Kind
  26006. * * VertexBuffer.ColorKind
  26007. * * VertexBuffer.MatricesIndicesKind
  26008. * * VertexBuffer.MatricesIndicesExtraKind
  26009. * * VertexBuffer.MatricesWeightsKind
  26010. * * VertexBuffer.MatricesWeightsExtraKind
  26011. * @param data defines the data source
  26012. * @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
  26013. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26014. * @returns the current mesh
  26015. */
  26016. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26017. /**
  26018. * Sets the mesh indices,
  26019. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26020. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26021. * @param totalVertices Defines the total number of vertices
  26022. * @returns the current mesh
  26023. */
  26024. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26025. /**
  26026. * Gets a boolean indicating if specific vertex data is present
  26027. * @param kind defines the vertex data kind to use
  26028. * @returns true is data kind is present
  26029. */
  26030. isVerticesDataPresent(kind: string): boolean;
  26031. /**
  26032. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26033. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26034. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26035. * @returns a BoundingInfo
  26036. */
  26037. getBoundingInfo(): BoundingInfo;
  26038. /**
  26039. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26040. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26041. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26042. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26043. * @returns the current mesh
  26044. */
  26045. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26046. /**
  26047. * Overwrite the current bounding info
  26048. * @param boundingInfo defines the new bounding info
  26049. * @returns the current mesh
  26050. */
  26051. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26052. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26053. readonly useBones: boolean;
  26054. /** @hidden */
  26055. _preActivate(): void;
  26056. /** @hidden */
  26057. _preActivateForIntermediateRendering(renderId: number): void;
  26058. /** @hidden */
  26059. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26060. /** @hidden */
  26061. _postActivate(): void;
  26062. /** @hidden */
  26063. _freeze(): void;
  26064. /** @hidden */
  26065. _unFreeze(): void;
  26066. /**
  26067. * Gets the current world matrix
  26068. * @returns a Matrix
  26069. */
  26070. getWorldMatrix(): Matrix;
  26071. /** @hidden */
  26072. _getWorldMatrixDeterminant(): number;
  26073. /**
  26074. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26075. */
  26076. readonly isAnInstance: boolean;
  26077. /**
  26078. * Gets a boolean indicating if this mesh has instances
  26079. */
  26080. readonly hasInstances: boolean;
  26081. /**
  26082. * Perform relative position change from the point of view of behind the front of the mesh.
  26083. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26084. * Supports definition of mesh facing forward or backward
  26085. * @param amountRight defines the distance on the right axis
  26086. * @param amountUp defines the distance on the up axis
  26087. * @param amountForward defines the distance on the forward axis
  26088. * @returns the current mesh
  26089. */
  26090. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26091. /**
  26092. * Calculate relative position change from the point of view of behind the front of the mesh.
  26093. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26094. * Supports definition of mesh facing forward or backward
  26095. * @param amountRight defines the distance on the right axis
  26096. * @param amountUp defines the distance on the up axis
  26097. * @param amountForward defines the distance on the forward axis
  26098. * @returns the new displacement vector
  26099. */
  26100. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26101. /**
  26102. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26103. * Supports definition of mesh facing forward or backward
  26104. * @param flipBack defines the flip
  26105. * @param twirlClockwise defines the twirl
  26106. * @param tiltRight defines the tilt
  26107. * @returns the current mesh
  26108. */
  26109. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26110. /**
  26111. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26112. * Supports definition of mesh facing forward or backward.
  26113. * @param flipBack defines the flip
  26114. * @param twirlClockwise defines the twirl
  26115. * @param tiltRight defines the tilt
  26116. * @returns the new rotation vector
  26117. */
  26118. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26119. /**
  26120. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26121. * This means the mesh underlying bounding box and sphere are recomputed.
  26122. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26123. * @returns the current mesh
  26124. */
  26125. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26126. /** @hidden */
  26127. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26128. /** @hidden */
  26129. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26130. /** @hidden */
  26131. _updateBoundingInfo(): AbstractMesh;
  26132. /** @hidden */
  26133. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26134. /** @hidden */
  26135. protected _afterComputeWorldMatrix(): void;
  26136. /** @hidden */
  26137. readonly _effectiveMesh: AbstractMesh;
  26138. /**
  26139. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26140. * A mesh is in the frustum if its bounding box intersects the frustum
  26141. * @param frustumPlanes defines the frustum to test
  26142. * @returns true if the mesh is in the frustum planes
  26143. */
  26144. isInFrustum(frustumPlanes: Plane[]): boolean;
  26145. /**
  26146. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26147. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26148. * @param frustumPlanes defines the frustum to test
  26149. * @returns true if the mesh is completely in the frustum planes
  26150. */
  26151. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26152. /**
  26153. * True if the mesh intersects another mesh or a SolidParticle object
  26154. * @param mesh defines a target mesh or SolidParticle to test
  26155. * @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)
  26156. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26157. * @returns true if there is an intersection
  26158. */
  26159. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26160. /**
  26161. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26162. * @param point defines the point to test
  26163. * @returns true if there is an intersection
  26164. */
  26165. intersectsPoint(point: Vector3): boolean;
  26166. /**
  26167. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26168. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26169. */
  26170. checkCollisions: boolean;
  26171. /**
  26172. * Gets Collider object used to compute collisions (not physics)
  26173. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26174. */
  26175. readonly collider: Nullable<Collider>;
  26176. /**
  26177. * Move the mesh using collision engine
  26178. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26179. * @param displacement defines the requested displacement vector
  26180. * @returns the current mesh
  26181. */
  26182. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26183. private _onCollisionPositionChange;
  26184. /** @hidden */
  26185. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26186. /** @hidden */
  26187. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26188. /** @hidden */
  26189. _checkCollision(collider: Collider): AbstractMesh;
  26190. /** @hidden */
  26191. _generatePointsArray(): boolean;
  26192. /**
  26193. * Checks if the passed Ray intersects with the mesh
  26194. * @param ray defines the ray to use
  26195. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26196. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26197. * @returns the picking info
  26198. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26199. */
  26200. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26201. /**
  26202. * Clones the current mesh
  26203. * @param name defines the mesh name
  26204. * @param newParent defines the new mesh parent
  26205. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26206. * @returns the new mesh
  26207. */
  26208. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26209. /**
  26210. * Disposes all the submeshes of the current meshnp
  26211. * @returns the current mesh
  26212. */
  26213. releaseSubMeshes(): AbstractMesh;
  26214. /**
  26215. * Releases resources associated with this abstract mesh.
  26216. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26217. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26218. */
  26219. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26220. /**
  26221. * Adds the passed mesh as a child to the current mesh
  26222. * @param mesh defines the child mesh
  26223. * @returns the current mesh
  26224. */
  26225. addChild(mesh: AbstractMesh): AbstractMesh;
  26226. /**
  26227. * Removes the passed mesh from the current mesh children list
  26228. * @param mesh defines the child mesh
  26229. * @returns the current mesh
  26230. */
  26231. removeChild(mesh: AbstractMesh): AbstractMesh;
  26232. /** @hidden */
  26233. private _initFacetData;
  26234. /**
  26235. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26236. * This method can be called within the render loop.
  26237. * 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
  26238. * @returns the current mesh
  26239. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26240. */
  26241. updateFacetData(): AbstractMesh;
  26242. /**
  26243. * Returns the facetLocalNormals array.
  26244. * The normals are expressed in the mesh local spac
  26245. * @returns an array of Vector3
  26246. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26247. */
  26248. getFacetLocalNormals(): Vector3[];
  26249. /**
  26250. * Returns the facetLocalPositions array.
  26251. * The facet positions are expressed in the mesh local space
  26252. * @returns an array of Vector3
  26253. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26254. */
  26255. getFacetLocalPositions(): Vector3[];
  26256. /**
  26257. * Returns the facetLocalPartioning array
  26258. * @returns an array of array of numbers
  26259. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26260. */
  26261. getFacetLocalPartitioning(): number[][];
  26262. /**
  26263. * Returns the i-th facet position in the world system.
  26264. * This method allocates a new Vector3 per call
  26265. * @param i defines the facet index
  26266. * @returns a new Vector3
  26267. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26268. */
  26269. getFacetPosition(i: number): Vector3;
  26270. /**
  26271. * Sets the reference Vector3 with the i-th facet position in the world system
  26272. * @param i defines the facet index
  26273. * @param ref defines the target vector
  26274. * @returns the current mesh
  26275. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26276. */
  26277. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26278. /**
  26279. * Returns the i-th facet normal in the world system.
  26280. * This method allocates a new Vector3 per call
  26281. * @param i defines the facet index
  26282. * @returns a new Vector3
  26283. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26284. */
  26285. getFacetNormal(i: number): Vector3;
  26286. /**
  26287. * Sets the reference Vector3 with the i-th facet normal in the world system
  26288. * @param i defines the facet index
  26289. * @param ref defines the target vector
  26290. * @returns the current mesh
  26291. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26292. */
  26293. getFacetNormalToRef(i: number, ref: Vector3): this;
  26294. /**
  26295. * 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)
  26296. * @param x defines x coordinate
  26297. * @param y defines y coordinate
  26298. * @param z defines z coordinate
  26299. * @returns the array of facet indexes
  26300. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26301. */
  26302. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26303. /**
  26304. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26305. * @param projected sets as the (x,y,z) world projection on the facet
  26306. * @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
  26307. * @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
  26308. * @param x defines x coordinate
  26309. * @param y defines y coordinate
  26310. * @param z defines z coordinate
  26311. * @returns the face index if found (or null instead)
  26312. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26313. */
  26314. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26315. /**
  26316. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26317. * @param projected sets as the (x,y,z) local projection on the facet
  26318. * @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
  26319. * @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
  26320. * @param x defines x coordinate
  26321. * @param y defines y coordinate
  26322. * @param z defines z coordinate
  26323. * @returns the face index if found (or null instead)
  26324. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26325. */
  26326. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26327. /**
  26328. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26329. * @returns the parameters
  26330. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26331. */
  26332. getFacetDataParameters(): any;
  26333. /**
  26334. * Disables the feature FacetData and frees the related memory
  26335. * @returns the current mesh
  26336. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26337. */
  26338. disableFacetData(): AbstractMesh;
  26339. /**
  26340. * Updates the AbstractMesh indices array
  26341. * @param indices defines the data source
  26342. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26343. * @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)
  26344. * @returns the current mesh
  26345. */
  26346. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26347. /**
  26348. * Creates new normals data for the mesh
  26349. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26350. * @returns the current mesh
  26351. */
  26352. createNormals(updatable: boolean): AbstractMesh;
  26353. /**
  26354. * Align the mesh with a normal
  26355. * @param normal defines the normal to use
  26356. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26357. * @returns the current mesh
  26358. */
  26359. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  26360. /** @hidden */
  26361. _checkOcclusionQuery(): boolean;
  26362. /**
  26363. * Disables the mesh edge rendering mode
  26364. * @returns the currentAbstractMesh
  26365. */
  26366. disableEdgesRendering(): AbstractMesh;
  26367. /**
  26368. * Enables the edge rendering mode on the mesh.
  26369. * This mode makes the mesh edges visible
  26370. * @param epsilon defines the maximal distance between two angles to detect a face
  26371. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  26372. * @returns the currentAbstractMesh
  26373. * @see https://www.babylonjs-playground.com/#19O9TU#0
  26374. */
  26375. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  26376. }
  26377. }
  26378. declare module BABYLON {
  26379. /**
  26380. * Interface used to define ActionEvent
  26381. */
  26382. export interface IActionEvent {
  26383. /** The mesh or sprite that triggered the action */
  26384. source: any;
  26385. /** The X mouse cursor position at the time of the event */
  26386. pointerX: number;
  26387. /** The Y mouse cursor position at the time of the event */
  26388. pointerY: number;
  26389. /** The mesh that is currently pointed at (can be null) */
  26390. meshUnderPointer: Nullable<AbstractMesh>;
  26391. /** the original (browser) event that triggered the ActionEvent */
  26392. sourceEvent?: any;
  26393. /** additional data for the event */
  26394. additionalData?: any;
  26395. }
  26396. /**
  26397. * ActionEvent is the event being sent when an action is triggered.
  26398. */
  26399. export class ActionEvent implements IActionEvent {
  26400. /** The mesh or sprite that triggered the action */
  26401. source: any;
  26402. /** The X mouse cursor position at the time of the event */
  26403. pointerX: number;
  26404. /** The Y mouse cursor position at the time of the event */
  26405. pointerY: number;
  26406. /** The mesh that is currently pointed at (can be null) */
  26407. meshUnderPointer: Nullable<AbstractMesh>;
  26408. /** the original (browser) event that triggered the ActionEvent */
  26409. sourceEvent?: any;
  26410. /** additional data for the event */
  26411. additionalData?: any;
  26412. /**
  26413. * Creates a new ActionEvent
  26414. * @param source The mesh or sprite that triggered the action
  26415. * @param pointerX The X mouse cursor position at the time of the event
  26416. * @param pointerY The Y mouse cursor position at the time of the event
  26417. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26418. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26419. * @param additionalData additional data for the event
  26420. */
  26421. constructor(
  26422. /** The mesh or sprite that triggered the action */
  26423. source: any,
  26424. /** The X mouse cursor position at the time of the event */
  26425. pointerX: number,
  26426. /** The Y mouse cursor position at the time of the event */
  26427. pointerY: number,
  26428. /** The mesh that is currently pointed at (can be null) */
  26429. meshUnderPointer: Nullable<AbstractMesh>,
  26430. /** the original (browser) event that triggered the ActionEvent */
  26431. sourceEvent?: any,
  26432. /** additional data for the event */
  26433. additionalData?: any);
  26434. /**
  26435. * Helper function to auto-create an ActionEvent from a source mesh.
  26436. * @param source The source mesh that triggered the event
  26437. * @param evt The original (browser) event
  26438. * @param additionalData additional data for the event
  26439. * @returns the new ActionEvent
  26440. */
  26441. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26442. /**
  26443. * Helper function to auto-create an ActionEvent from a source sprite
  26444. * @param source The source sprite that triggered the event
  26445. * @param scene Scene associated with the sprite
  26446. * @param evt The original (browser) event
  26447. * @param additionalData additional data for the event
  26448. * @returns the new ActionEvent
  26449. */
  26450. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26451. /**
  26452. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26453. * @param scene the scene where the event occurred
  26454. * @param evt The original (browser) event
  26455. * @returns the new ActionEvent
  26456. */
  26457. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26458. /**
  26459. * Helper function to auto-create an ActionEvent from a primitive
  26460. * @param prim defines the target primitive
  26461. * @param pointerPos defines the pointer position
  26462. * @param evt The original (browser) event
  26463. * @param additionalData additional data for the event
  26464. * @returns the new ActionEvent
  26465. */
  26466. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26467. }
  26468. }
  26469. declare module BABYLON {
  26470. /**
  26471. * Abstract class used to decouple action Manager from scene and meshes.
  26472. * Do not instantiate.
  26473. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26474. */
  26475. export abstract class AbstractActionManager implements IDisposable {
  26476. /** Gets the list of active triggers */
  26477. static Triggers: {
  26478. [key: string]: number;
  26479. };
  26480. /** Gets the cursor to use when hovering items */
  26481. hoverCursor: string;
  26482. /** Gets the list of actions */
  26483. actions: IAction[];
  26484. /**
  26485. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26486. */
  26487. isRecursive: boolean;
  26488. /**
  26489. * Releases all associated resources
  26490. */
  26491. abstract dispose(): void;
  26492. /**
  26493. * Does this action manager has pointer triggers
  26494. */
  26495. abstract readonly hasPointerTriggers: boolean;
  26496. /**
  26497. * Does this action manager has pick triggers
  26498. */
  26499. abstract readonly hasPickTriggers: boolean;
  26500. /**
  26501. * Process a specific trigger
  26502. * @param trigger defines the trigger to process
  26503. * @param evt defines the event details to be processed
  26504. */
  26505. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26506. /**
  26507. * Does this action manager handles actions of any of the given triggers
  26508. * @param triggers defines the triggers to be tested
  26509. * @return a boolean indicating whether one (or more) of the triggers is handled
  26510. */
  26511. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26512. /**
  26513. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26514. * speed.
  26515. * @param triggerA defines the trigger to be tested
  26516. * @param triggerB defines the trigger to be tested
  26517. * @return a boolean indicating whether one (or more) of the triggers is handled
  26518. */
  26519. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26520. /**
  26521. * Does this action manager handles actions of a given trigger
  26522. * @param trigger defines the trigger to be tested
  26523. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26524. * @return whether the trigger is handled
  26525. */
  26526. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26527. /**
  26528. * Serialize this manager to a JSON object
  26529. * @param name defines the property name to store this manager
  26530. * @returns a JSON representation of this manager
  26531. */
  26532. abstract serialize(name: string): any;
  26533. /**
  26534. * Registers an action to this action manager
  26535. * @param action defines the action to be registered
  26536. * @return the action amended (prepared) after registration
  26537. */
  26538. abstract registerAction(action: IAction): Nullable<IAction>;
  26539. /**
  26540. * Unregisters an action to this action manager
  26541. * @param action defines the action to be unregistered
  26542. * @return a boolean indicating whether the action has been unregistered
  26543. */
  26544. abstract unregisterAction(action: IAction): Boolean;
  26545. /**
  26546. * Does exist one action manager with at least one trigger
  26547. **/
  26548. static readonly HasTriggers: boolean;
  26549. /**
  26550. * Does exist one action manager with at least one pick trigger
  26551. **/
  26552. static readonly HasPickTriggers: boolean;
  26553. /**
  26554. * Does exist one action manager that handles actions of a given trigger
  26555. * @param trigger defines the trigger to be tested
  26556. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26557. **/
  26558. static HasSpecificTrigger(trigger: number): boolean;
  26559. }
  26560. }
  26561. declare module BABYLON {
  26562. /**
  26563. * Defines how a node can be built from a string name.
  26564. */
  26565. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26566. /**
  26567. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26568. */
  26569. export class Node implements IBehaviorAware<Node> {
  26570. /** @hidden */
  26571. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26572. private static _NodeConstructors;
  26573. /**
  26574. * Add a new node constructor
  26575. * @param type defines the type name of the node to construct
  26576. * @param constructorFunc defines the constructor function
  26577. */
  26578. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26579. /**
  26580. * Returns a node constructor based on type name
  26581. * @param type defines the type name
  26582. * @param name defines the new node name
  26583. * @param scene defines the hosting scene
  26584. * @param options defines optional options to transmit to constructors
  26585. * @returns the new constructor or null
  26586. */
  26587. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26588. /**
  26589. * Gets or sets the name of the node
  26590. */
  26591. name: string;
  26592. /**
  26593. * Gets or sets the id of the node
  26594. */
  26595. id: string;
  26596. /**
  26597. * Gets or sets the unique id of the node
  26598. */
  26599. uniqueId: number;
  26600. /**
  26601. * Gets or sets a string used to store user defined state for the node
  26602. */
  26603. state: string;
  26604. /**
  26605. * Gets or sets an object used to store user defined information for the node
  26606. */
  26607. metadata: any;
  26608. /**
  26609. * For internal use only. Please do not use.
  26610. */
  26611. reservedDataStore: any;
  26612. /**
  26613. * List of inspectable custom properties (used by the Inspector)
  26614. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26615. */
  26616. inspectableCustomProperties: IInspectable[];
  26617. /**
  26618. * Gets or sets a boolean used to define if the node must be serialized
  26619. */
  26620. doNotSerialize: boolean;
  26621. /** @hidden */
  26622. _isDisposed: boolean;
  26623. /**
  26624. * Gets a list of Animations associated with the node
  26625. */
  26626. animations: Animation[];
  26627. protected _ranges: {
  26628. [name: string]: Nullable<AnimationRange>;
  26629. };
  26630. /**
  26631. * Callback raised when the node is ready to be used
  26632. */
  26633. onReady: Nullable<(node: Node) => void>;
  26634. private _isEnabled;
  26635. private _isParentEnabled;
  26636. private _isReady;
  26637. /** @hidden */
  26638. _currentRenderId: number;
  26639. private _parentUpdateId;
  26640. /** @hidden */
  26641. _childUpdateId: number;
  26642. /** @hidden */
  26643. _waitingParentId: Nullable<string>;
  26644. /** @hidden */
  26645. _scene: Scene;
  26646. /** @hidden */
  26647. _cache: any;
  26648. private _parentNode;
  26649. private _children;
  26650. /** @hidden */
  26651. _worldMatrix: Matrix;
  26652. /** @hidden */
  26653. _worldMatrixDeterminant: number;
  26654. /** @hidden */
  26655. _worldMatrixDeterminantIsDirty: boolean;
  26656. /** @hidden */
  26657. private _sceneRootNodesIndex;
  26658. /**
  26659. * Gets a boolean indicating if the node has been disposed
  26660. * @returns true if the node was disposed
  26661. */
  26662. isDisposed(): boolean;
  26663. /**
  26664. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26665. * @see https://doc.babylonjs.com/how_to/parenting
  26666. */
  26667. parent: Nullable<Node>;
  26668. private addToSceneRootNodes;
  26669. private removeFromSceneRootNodes;
  26670. private _animationPropertiesOverride;
  26671. /**
  26672. * Gets or sets the animation properties override
  26673. */
  26674. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26675. /**
  26676. * Gets a string idenfifying the name of the class
  26677. * @returns "Node" string
  26678. */
  26679. getClassName(): string;
  26680. /** @hidden */
  26681. readonly _isNode: boolean;
  26682. /**
  26683. * An event triggered when the mesh is disposed
  26684. */
  26685. onDisposeObservable: Observable<Node>;
  26686. private _onDisposeObserver;
  26687. /**
  26688. * Sets a callback that will be raised when the node will be disposed
  26689. */
  26690. onDispose: () => void;
  26691. /**
  26692. * Creates a new Node
  26693. * @param name the name and id to be given to this node
  26694. * @param scene the scene this node will be added to
  26695. * @param addToRootNodes the node will be added to scene.rootNodes
  26696. */
  26697. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26698. /**
  26699. * Gets the scene of the node
  26700. * @returns a scene
  26701. */
  26702. getScene(): Scene;
  26703. /**
  26704. * Gets the engine of the node
  26705. * @returns a Engine
  26706. */
  26707. getEngine(): Engine;
  26708. private _behaviors;
  26709. /**
  26710. * Attach a behavior to the node
  26711. * @see http://doc.babylonjs.com/features/behaviour
  26712. * @param behavior defines the behavior to attach
  26713. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26714. * @returns the current Node
  26715. */
  26716. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26717. /**
  26718. * Remove an attached behavior
  26719. * @see http://doc.babylonjs.com/features/behaviour
  26720. * @param behavior defines the behavior to attach
  26721. * @returns the current Node
  26722. */
  26723. removeBehavior(behavior: Behavior<Node>): Node;
  26724. /**
  26725. * Gets the list of attached behaviors
  26726. * @see http://doc.babylonjs.com/features/behaviour
  26727. */
  26728. readonly behaviors: Behavior<Node>[];
  26729. /**
  26730. * Gets an attached behavior by name
  26731. * @param name defines the name of the behavior to look for
  26732. * @see http://doc.babylonjs.com/features/behaviour
  26733. * @returns null if behavior was not found else the requested behavior
  26734. */
  26735. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26736. /**
  26737. * Returns the latest update of the World matrix
  26738. * @returns a Matrix
  26739. */
  26740. getWorldMatrix(): Matrix;
  26741. /** @hidden */
  26742. _getWorldMatrixDeterminant(): number;
  26743. /**
  26744. * Returns directly the latest state of the mesh World matrix.
  26745. * A Matrix is returned.
  26746. */
  26747. readonly worldMatrixFromCache: Matrix;
  26748. /** @hidden */
  26749. _initCache(): void;
  26750. /** @hidden */
  26751. updateCache(force?: boolean): void;
  26752. /** @hidden */
  26753. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26754. /** @hidden */
  26755. _updateCache(ignoreParentClass?: boolean): void;
  26756. /** @hidden */
  26757. _isSynchronized(): boolean;
  26758. /** @hidden */
  26759. _markSyncedWithParent(): void;
  26760. /** @hidden */
  26761. isSynchronizedWithParent(): boolean;
  26762. /** @hidden */
  26763. isSynchronized(): boolean;
  26764. /**
  26765. * Is this node ready to be used/rendered
  26766. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26767. * @return true if the node is ready
  26768. */
  26769. isReady(completeCheck?: boolean): boolean;
  26770. /**
  26771. * Is this node enabled?
  26772. * 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
  26773. * @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
  26774. * @return whether this node (and its parent) is enabled
  26775. */
  26776. isEnabled(checkAncestors?: boolean): boolean;
  26777. /** @hidden */
  26778. protected _syncParentEnabledState(): void;
  26779. /**
  26780. * Set the enabled state of this node
  26781. * @param value defines the new enabled state
  26782. */
  26783. setEnabled(value: boolean): void;
  26784. /**
  26785. * Is this node a descendant of the given node?
  26786. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26787. * @param ancestor defines the parent node to inspect
  26788. * @returns a boolean indicating if this node is a descendant of the given node
  26789. */
  26790. isDescendantOf(ancestor: Node): boolean;
  26791. /** @hidden */
  26792. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26793. /**
  26794. * Will return all nodes that have this node as ascendant
  26795. * @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
  26796. * @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
  26797. * @return all children nodes of all types
  26798. */
  26799. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26800. /**
  26801. * Get all child-meshes of this node
  26802. * @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)
  26803. * @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
  26804. * @returns an array of AbstractMesh
  26805. */
  26806. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26807. /**
  26808. * Get all direct children of this node
  26809. * @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
  26810. * @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)
  26811. * @returns an array of Node
  26812. */
  26813. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26814. /** @hidden */
  26815. _setReady(state: boolean): void;
  26816. /**
  26817. * Get an animation by name
  26818. * @param name defines the name of the animation to look for
  26819. * @returns null if not found else the requested animation
  26820. */
  26821. getAnimationByName(name: string): Nullable<Animation>;
  26822. /**
  26823. * Creates an animation range for this node
  26824. * @param name defines the name of the range
  26825. * @param from defines the starting key
  26826. * @param to defines the end key
  26827. */
  26828. createAnimationRange(name: string, from: number, to: number): void;
  26829. /**
  26830. * Delete a specific animation range
  26831. * @param name defines the name of the range to delete
  26832. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26833. */
  26834. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26835. /**
  26836. * Get an animation range by name
  26837. * @param name defines the name of the animation range to look for
  26838. * @returns null if not found else the requested animation range
  26839. */
  26840. getAnimationRange(name: string): Nullable<AnimationRange>;
  26841. /**
  26842. * Gets the list of all animation ranges defined on this node
  26843. * @returns an array
  26844. */
  26845. getAnimationRanges(): Nullable<AnimationRange>[];
  26846. /**
  26847. * Will start the animation sequence
  26848. * @param name defines the range frames for animation sequence
  26849. * @param loop defines if the animation should loop (false by default)
  26850. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26851. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26852. * @returns the object created for this animation. If range does not exist, it will return null
  26853. */
  26854. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26855. /**
  26856. * Serialize animation ranges into a JSON compatible object
  26857. * @returns serialization object
  26858. */
  26859. serializeAnimationRanges(): any;
  26860. /**
  26861. * Computes the world matrix of the node
  26862. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26863. * @returns the world matrix
  26864. */
  26865. computeWorldMatrix(force?: boolean): Matrix;
  26866. /**
  26867. * Releases resources associated with this node.
  26868. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26869. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26870. */
  26871. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26872. /**
  26873. * Parse animation range data from a serialization object and store them into a given node
  26874. * @param node defines where to store the animation ranges
  26875. * @param parsedNode defines the serialization object to read data from
  26876. * @param scene defines the hosting scene
  26877. */
  26878. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26879. /**
  26880. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26881. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26882. * @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
  26883. * @returns the new bounding vectors
  26884. */
  26885. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26886. min: Vector3;
  26887. max: Vector3;
  26888. };
  26889. }
  26890. }
  26891. declare module BABYLON {
  26892. /**
  26893. * @hidden
  26894. */
  26895. export class _IAnimationState {
  26896. key: number;
  26897. repeatCount: number;
  26898. workValue?: any;
  26899. loopMode?: number;
  26900. offsetValue?: any;
  26901. highLimitValue?: any;
  26902. }
  26903. /**
  26904. * Class used to store any kind of animation
  26905. */
  26906. export class Animation {
  26907. /**Name of the animation */
  26908. name: string;
  26909. /**Property to animate */
  26910. targetProperty: string;
  26911. /**The frames per second of the animation */
  26912. framePerSecond: number;
  26913. /**The data type of the animation */
  26914. dataType: number;
  26915. /**The loop mode of the animation */
  26916. loopMode?: number | undefined;
  26917. /**Specifies if blending should be enabled */
  26918. enableBlending?: boolean | undefined;
  26919. /**
  26920. * Use matrix interpolation instead of using direct key value when animating matrices
  26921. */
  26922. static AllowMatricesInterpolation: boolean;
  26923. /**
  26924. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26925. */
  26926. static AllowMatrixDecomposeForInterpolation: boolean;
  26927. /**
  26928. * Stores the key frames of the animation
  26929. */
  26930. private _keys;
  26931. /**
  26932. * Stores the easing function of the animation
  26933. */
  26934. private _easingFunction;
  26935. /**
  26936. * @hidden Internal use only
  26937. */
  26938. _runtimeAnimations: RuntimeAnimation[];
  26939. /**
  26940. * The set of event that will be linked to this animation
  26941. */
  26942. private _events;
  26943. /**
  26944. * Stores an array of target property paths
  26945. */
  26946. targetPropertyPath: string[];
  26947. /**
  26948. * Stores the blending speed of the animation
  26949. */
  26950. blendingSpeed: number;
  26951. /**
  26952. * Stores the animation ranges for the animation
  26953. */
  26954. private _ranges;
  26955. /**
  26956. * @hidden Internal use
  26957. */
  26958. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26959. /**
  26960. * Sets up an animation
  26961. * @param property The property to animate
  26962. * @param animationType The animation type to apply
  26963. * @param framePerSecond The frames per second of the animation
  26964. * @param easingFunction The easing function used in the animation
  26965. * @returns The created animation
  26966. */
  26967. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26968. /**
  26969. * Create and start an animation on a node
  26970. * @param name defines the name of the global animation that will be run on all nodes
  26971. * @param node defines the root node where the animation will take place
  26972. * @param targetProperty defines property to animate
  26973. * @param framePerSecond defines the number of frame per second yo use
  26974. * @param totalFrame defines the number of frames in total
  26975. * @param from defines the initial value
  26976. * @param to defines the final value
  26977. * @param loopMode defines which loop mode you want to use (off by default)
  26978. * @param easingFunction defines the easing function to use (linear by default)
  26979. * @param onAnimationEnd defines the callback to call when animation end
  26980. * @returns the animatable created for this animation
  26981. */
  26982. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26983. /**
  26984. * Create and start an animation on a node and its descendants
  26985. * @param name defines the name of the global animation that will be run on all nodes
  26986. * @param node defines the root node where the animation will take place
  26987. * @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
  26988. * @param targetProperty defines property to animate
  26989. * @param framePerSecond defines the number of frame per second to use
  26990. * @param totalFrame defines the number of frames in total
  26991. * @param from defines the initial value
  26992. * @param to defines the final value
  26993. * @param loopMode defines which loop mode you want to use (off by default)
  26994. * @param easingFunction defines the easing function to use (linear by default)
  26995. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26996. * @returns the list of animatables created for all nodes
  26997. * @example https://www.babylonjs-playground.com/#MH0VLI
  26998. */
  26999. 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[]>;
  27000. /**
  27001. * Creates a new animation, merges it with the existing animations and starts it
  27002. * @param name Name of the animation
  27003. * @param node Node which contains the scene that begins the animations
  27004. * @param targetProperty Specifies which property to animate
  27005. * @param framePerSecond The frames per second of the animation
  27006. * @param totalFrame The total number of frames
  27007. * @param from The frame at the beginning of the animation
  27008. * @param to The frame at the end of the animation
  27009. * @param loopMode Specifies the loop mode of the animation
  27010. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27011. * @param onAnimationEnd Callback to run once the animation is complete
  27012. * @returns Nullable animation
  27013. */
  27014. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27015. /**
  27016. * Transition property of an host to the target Value
  27017. * @param property The property to transition
  27018. * @param targetValue The target Value of the property
  27019. * @param host The object where the property to animate belongs
  27020. * @param scene Scene used to run the animation
  27021. * @param frameRate Framerate (in frame/s) to use
  27022. * @param transition The transition type we want to use
  27023. * @param duration The duration of the animation, in milliseconds
  27024. * @param onAnimationEnd Callback trigger at the end of the animation
  27025. * @returns Nullable animation
  27026. */
  27027. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27028. /**
  27029. * Return the array of runtime animations currently using this animation
  27030. */
  27031. readonly runtimeAnimations: RuntimeAnimation[];
  27032. /**
  27033. * Specifies if any of the runtime animations are currently running
  27034. */
  27035. readonly hasRunningRuntimeAnimations: boolean;
  27036. /**
  27037. * Initializes the animation
  27038. * @param name Name of the animation
  27039. * @param targetProperty Property to animate
  27040. * @param framePerSecond The frames per second of the animation
  27041. * @param dataType The data type of the animation
  27042. * @param loopMode The loop mode of the animation
  27043. * @param enableBlending Specifies if blending should be enabled
  27044. */
  27045. constructor(
  27046. /**Name of the animation */
  27047. name: string,
  27048. /**Property to animate */
  27049. targetProperty: string,
  27050. /**The frames per second of the animation */
  27051. framePerSecond: number,
  27052. /**The data type of the animation */
  27053. dataType: number,
  27054. /**The loop mode of the animation */
  27055. loopMode?: number | undefined,
  27056. /**Specifies if blending should be enabled */
  27057. enableBlending?: boolean | undefined);
  27058. /**
  27059. * Converts the animation to a string
  27060. * @param fullDetails support for multiple levels of logging within scene loading
  27061. * @returns String form of the animation
  27062. */
  27063. toString(fullDetails?: boolean): string;
  27064. /**
  27065. * Add an event to this animation
  27066. * @param event Event to add
  27067. */
  27068. addEvent(event: AnimationEvent): void;
  27069. /**
  27070. * Remove all events found at the given frame
  27071. * @param frame The frame to remove events from
  27072. */
  27073. removeEvents(frame: number): void;
  27074. /**
  27075. * Retrieves all the events from the animation
  27076. * @returns Events from the animation
  27077. */
  27078. getEvents(): AnimationEvent[];
  27079. /**
  27080. * Creates an animation range
  27081. * @param name Name of the animation range
  27082. * @param from Starting frame of the animation range
  27083. * @param to Ending frame of the animation
  27084. */
  27085. createRange(name: string, from: number, to: number): void;
  27086. /**
  27087. * Deletes an animation range by name
  27088. * @param name Name of the animation range to delete
  27089. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27090. */
  27091. deleteRange(name: string, deleteFrames?: boolean): void;
  27092. /**
  27093. * Gets the animation range by name, or null if not defined
  27094. * @param name Name of the animation range
  27095. * @returns Nullable animation range
  27096. */
  27097. getRange(name: string): Nullable<AnimationRange>;
  27098. /**
  27099. * Gets the key frames from the animation
  27100. * @returns The key frames of the animation
  27101. */
  27102. getKeys(): Array<IAnimationKey>;
  27103. /**
  27104. * Gets the highest frame rate of the animation
  27105. * @returns Highest frame rate of the animation
  27106. */
  27107. getHighestFrame(): number;
  27108. /**
  27109. * Gets the easing function of the animation
  27110. * @returns Easing function of the animation
  27111. */
  27112. getEasingFunction(): IEasingFunction;
  27113. /**
  27114. * Sets the easing function of the animation
  27115. * @param easingFunction A custom mathematical formula for animation
  27116. */
  27117. setEasingFunction(easingFunction: EasingFunction): void;
  27118. /**
  27119. * Interpolates a scalar linearly
  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 scalar value
  27124. */
  27125. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27126. /**
  27127. * Interpolates a scalar cubically
  27128. * @param startValue Start value of the animation curve
  27129. * @param outTangent End tangent of the animation
  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 scalar value
  27134. */
  27135. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27136. /**
  27137. * Interpolates a quaternion using a spherical linear interpolation
  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 quaternion value
  27142. */
  27143. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27144. /**
  27145. * Interpolates a quaternion cubically
  27146. * @param startValue Start value of the animation curve
  27147. * @param outTangent End tangent of the animation curve
  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 Interpolated quaternion value
  27152. */
  27153. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27154. /**
  27155. * Interpolates a Vector3 linearl
  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 scalar value
  27160. */
  27161. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27162. /**
  27163. * Interpolates a Vector3 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 InterpolatedVector3 value
  27170. */
  27171. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27172. /**
  27173. * Interpolates a Vector2 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 Vector2 value
  27178. */
  27179. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27180. /**
  27181. * Interpolates a Vector2 cubically
  27182. * @param startValue Start value of the animation curve
  27183. * @param outTangent End tangent of the animation
  27184. * @param endValue End value of the animation curve
  27185. * @param inTangent Start tangent of the animation curve
  27186. * @param gradient Scalar amount to interpolate
  27187. * @returns Interpolated Vector2 value
  27188. */
  27189. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27190. /**
  27191. * Interpolates a size linearly
  27192. * @param startValue Start value of the animation curve
  27193. * @param endValue End value of the animation curve
  27194. * @param gradient Scalar amount to interpolate
  27195. * @returns Interpolated Size value
  27196. */
  27197. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27198. /**
  27199. * Interpolates a Color3 linearly
  27200. * @param startValue Start value of the animation curve
  27201. * @param endValue End value of the animation curve
  27202. * @param gradient Scalar amount to interpolate
  27203. * @returns Interpolated Color3 value
  27204. */
  27205. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27206. /**
  27207. * @hidden Internal use only
  27208. */
  27209. _getKeyValue(value: any): any;
  27210. /**
  27211. * @hidden Internal use only
  27212. */
  27213. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27214. /**
  27215. * Defines the function to use to interpolate matrices
  27216. * @param startValue defines the start matrix
  27217. * @param endValue defines the end matrix
  27218. * @param gradient defines the gradient between both matrices
  27219. * @param result defines an optional target matrix where to store the interpolation
  27220. * @returns the interpolated matrix
  27221. */
  27222. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27223. /**
  27224. * Makes a copy of the animation
  27225. * @returns Cloned animation
  27226. */
  27227. clone(): Animation;
  27228. /**
  27229. * Sets the key frames of the animation
  27230. * @param values The animation key frames to set
  27231. */
  27232. setKeys(values: Array<IAnimationKey>): void;
  27233. /**
  27234. * Serializes the animation to an object
  27235. * @returns Serialized object
  27236. */
  27237. serialize(): any;
  27238. /**
  27239. * Float animation type
  27240. */
  27241. private static _ANIMATIONTYPE_FLOAT;
  27242. /**
  27243. * Vector3 animation type
  27244. */
  27245. private static _ANIMATIONTYPE_VECTOR3;
  27246. /**
  27247. * Quaternion animation type
  27248. */
  27249. private static _ANIMATIONTYPE_QUATERNION;
  27250. /**
  27251. * Matrix animation type
  27252. */
  27253. private static _ANIMATIONTYPE_MATRIX;
  27254. /**
  27255. * Color3 animation type
  27256. */
  27257. private static _ANIMATIONTYPE_COLOR3;
  27258. /**
  27259. * Vector2 animation type
  27260. */
  27261. private static _ANIMATIONTYPE_VECTOR2;
  27262. /**
  27263. * Size animation type
  27264. */
  27265. private static _ANIMATIONTYPE_SIZE;
  27266. /**
  27267. * Relative Loop Mode
  27268. */
  27269. private static _ANIMATIONLOOPMODE_RELATIVE;
  27270. /**
  27271. * Cycle Loop Mode
  27272. */
  27273. private static _ANIMATIONLOOPMODE_CYCLE;
  27274. /**
  27275. * Constant Loop Mode
  27276. */
  27277. private static _ANIMATIONLOOPMODE_CONSTANT;
  27278. /**
  27279. * Get the float animation type
  27280. */
  27281. static readonly ANIMATIONTYPE_FLOAT: number;
  27282. /**
  27283. * Get the Vector3 animation type
  27284. */
  27285. static readonly ANIMATIONTYPE_VECTOR3: number;
  27286. /**
  27287. * Get the Vector2 animation type
  27288. */
  27289. static readonly ANIMATIONTYPE_VECTOR2: number;
  27290. /**
  27291. * Get the Size animation type
  27292. */
  27293. static readonly ANIMATIONTYPE_SIZE: number;
  27294. /**
  27295. * Get the Quaternion animation type
  27296. */
  27297. static readonly ANIMATIONTYPE_QUATERNION: number;
  27298. /**
  27299. * Get the Matrix animation type
  27300. */
  27301. static readonly ANIMATIONTYPE_MATRIX: number;
  27302. /**
  27303. * Get the Color3 animation type
  27304. */
  27305. static readonly ANIMATIONTYPE_COLOR3: number;
  27306. /**
  27307. * Get the Relative Loop Mode
  27308. */
  27309. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27310. /**
  27311. * Get the Cycle Loop Mode
  27312. */
  27313. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27314. /**
  27315. * Get the Constant Loop Mode
  27316. */
  27317. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27318. /** @hidden */
  27319. static _UniversalLerp(left: any, right: any, amount: number): any;
  27320. /**
  27321. * Parses an animation object and creates an animation
  27322. * @param parsedAnimation Parsed animation object
  27323. * @returns Animation object
  27324. */
  27325. static Parse(parsedAnimation: any): Animation;
  27326. /**
  27327. * Appends the serialized animations from the source animations
  27328. * @param source Source containing the animations
  27329. * @param destination Target to store the animations
  27330. */
  27331. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27332. }
  27333. }
  27334. declare module BABYLON {
  27335. /**
  27336. * Interface containing an array of animations
  27337. */
  27338. export interface IAnimatable {
  27339. /**
  27340. * Array of animations
  27341. */
  27342. animations: Nullable<Array<Animation>>;
  27343. }
  27344. }
  27345. declare module BABYLON {
  27346. /**
  27347. * This represents all the required information to add a fresnel effect on a material:
  27348. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27349. */
  27350. export class FresnelParameters {
  27351. private _isEnabled;
  27352. /**
  27353. * Define if the fresnel effect is enable or not.
  27354. */
  27355. isEnabled: boolean;
  27356. /**
  27357. * Define the color used on edges (grazing angle)
  27358. */
  27359. leftColor: Color3;
  27360. /**
  27361. * Define the color used on center
  27362. */
  27363. rightColor: Color3;
  27364. /**
  27365. * Define bias applied to computed fresnel term
  27366. */
  27367. bias: number;
  27368. /**
  27369. * Defined the power exponent applied to fresnel term
  27370. */
  27371. power: number;
  27372. /**
  27373. * Clones the current fresnel and its valuues
  27374. * @returns a clone fresnel configuration
  27375. */
  27376. clone(): FresnelParameters;
  27377. /**
  27378. * Serializes the current fresnel parameters to a JSON representation.
  27379. * @return the JSON serialization
  27380. */
  27381. serialize(): any;
  27382. /**
  27383. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27384. * @param parsedFresnelParameters Define the JSON representation
  27385. * @returns the parsed parameters
  27386. */
  27387. static Parse(parsedFresnelParameters: any): FresnelParameters;
  27388. }
  27389. }
  27390. declare module BABYLON {
  27391. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27392. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27393. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27394. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27395. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27396. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27397. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27398. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27399. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27400. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27401. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27402. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27403. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27404. /**
  27405. * Decorator used to define property that can be serialized as reference to a camera
  27406. * @param sourceName defines the name of the property to decorate
  27407. */
  27408. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27409. /**
  27410. * Class used to help serialization objects
  27411. */
  27412. export class SerializationHelper {
  27413. /** @hidden */
  27414. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  27415. /** @hidden */
  27416. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  27417. /** @hidden */
  27418. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  27419. /** @hidden */
  27420. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  27421. /**
  27422. * Appends the serialized animations from the source animations
  27423. * @param source Source containing the animations
  27424. * @param destination Target to store the animations
  27425. */
  27426. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27427. /**
  27428. * Static function used to serialized a specific entity
  27429. * @param entity defines the entity to serialize
  27430. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  27431. * @returns a JSON compatible object representing the serialization of the entity
  27432. */
  27433. static Serialize<T>(entity: T, serializationObject?: any): any;
  27434. /**
  27435. * Creates a new entity from a serialization data object
  27436. * @param creationFunction defines a function used to instanciated the new entity
  27437. * @param source defines the source serialization data
  27438. * @param scene defines the hosting scene
  27439. * @param rootUrl defines the root url for resources
  27440. * @returns a new entity
  27441. */
  27442. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27443. /**
  27444. * Clones an object
  27445. * @param creationFunction defines the function used to instanciate the new object
  27446. * @param source defines the source object
  27447. * @returns the cloned object
  27448. */
  27449. static Clone<T>(creationFunction: () => T, source: T): T;
  27450. /**
  27451. * Instanciates a new object based on a source one (some data will be shared between both object)
  27452. * @param creationFunction defines the function used to instanciate the new object
  27453. * @param source defines the source object
  27454. * @returns the new object
  27455. */
  27456. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27457. }
  27458. }
  27459. declare module BABYLON {
  27460. /**
  27461. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  27462. */
  27463. export interface CubeMapInfo {
  27464. /**
  27465. * The pixel array for the front face.
  27466. * This is stored in format, left to right, up to down format.
  27467. */
  27468. front: Nullable<ArrayBufferView>;
  27469. /**
  27470. * The pixel array for the back face.
  27471. * This is stored in format, left to right, up to down format.
  27472. */
  27473. back: Nullable<ArrayBufferView>;
  27474. /**
  27475. * The pixel array for the left face.
  27476. * This is stored in format, left to right, up to down format.
  27477. */
  27478. left: Nullable<ArrayBufferView>;
  27479. /**
  27480. * The pixel array for the right face.
  27481. * This is stored in format, left to right, up to down format.
  27482. */
  27483. right: Nullable<ArrayBufferView>;
  27484. /**
  27485. * The pixel array for the up face.
  27486. * This is stored in format, left to right, up to down format.
  27487. */
  27488. up: Nullable<ArrayBufferView>;
  27489. /**
  27490. * The pixel array for the down face.
  27491. * This is stored in format, left to right, up to down format.
  27492. */
  27493. down: Nullable<ArrayBufferView>;
  27494. /**
  27495. * The size of the cubemap stored.
  27496. *
  27497. * Each faces will be size * size pixels.
  27498. */
  27499. size: number;
  27500. /**
  27501. * The format of the texture.
  27502. *
  27503. * RGBA, RGB.
  27504. */
  27505. format: number;
  27506. /**
  27507. * The type of the texture data.
  27508. *
  27509. * UNSIGNED_INT, FLOAT.
  27510. */
  27511. type: number;
  27512. /**
  27513. * Specifies whether the texture is in gamma space.
  27514. */
  27515. gammaSpace: boolean;
  27516. }
  27517. /**
  27518. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  27519. */
  27520. export class PanoramaToCubeMapTools {
  27521. private static FACE_FRONT;
  27522. private static FACE_BACK;
  27523. private static FACE_RIGHT;
  27524. private static FACE_LEFT;
  27525. private static FACE_DOWN;
  27526. private static FACE_UP;
  27527. /**
  27528. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  27529. *
  27530. * @param float32Array The source data.
  27531. * @param inputWidth The width of the input panorama.
  27532. * @param inputHeight The height of the input panorama.
  27533. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  27534. * @return The cubemap data
  27535. */
  27536. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  27537. private static CreateCubemapTexture;
  27538. private static CalcProjectionSpherical;
  27539. }
  27540. }
  27541. declare module BABYLON {
  27542. /**
  27543. * Helper class dealing with the extraction of spherical polynomial dataArray
  27544. * from a cube map.
  27545. */
  27546. export class CubeMapToSphericalPolynomialTools {
  27547. private static FileFaces;
  27548. /**
  27549. * Converts a texture to the according Spherical Polynomial data.
  27550. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27551. *
  27552. * @param texture The texture to extract the information from.
  27553. * @return The Spherical Polynomial data.
  27554. */
  27555. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  27556. /**
  27557. * Converts a cubemap to the according Spherical Polynomial data.
  27558. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27559. *
  27560. * @param cubeInfo The Cube map to extract the information from.
  27561. * @return The Spherical Polynomial data.
  27562. */
  27563. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  27564. }
  27565. }
  27566. declare module BABYLON {
  27567. /**
  27568. * Class used to manipulate GUIDs
  27569. */
  27570. export class GUID {
  27571. /**
  27572. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27573. * Be aware Math.random() could cause collisions, but:
  27574. * "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"
  27575. * @returns a pseudo random id
  27576. */
  27577. static RandomId(): string;
  27578. }
  27579. }
  27580. declare module BABYLON {
  27581. /**
  27582. * Base class of all the textures in babylon.
  27583. * It groups all the common properties the materials, post process, lights... might need
  27584. * in order to make a correct use of the texture.
  27585. */
  27586. export class BaseTexture implements IAnimatable {
  27587. /**
  27588. * Default anisotropic filtering level for the application.
  27589. * It is set to 4 as a good tradeoff between perf and quality.
  27590. */
  27591. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27592. /**
  27593. * Gets or sets the unique id of the texture
  27594. */
  27595. uniqueId: number;
  27596. /**
  27597. * Define the name of the texture.
  27598. */
  27599. name: string;
  27600. /**
  27601. * Gets or sets an object used to store user defined information.
  27602. */
  27603. metadata: any;
  27604. /**
  27605. * For internal use only. Please do not use.
  27606. */
  27607. reservedDataStore: any;
  27608. private _hasAlpha;
  27609. /**
  27610. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27611. */
  27612. hasAlpha: boolean;
  27613. /**
  27614. * Defines if the alpha value should be determined via the rgb values.
  27615. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27616. */
  27617. getAlphaFromRGB: boolean;
  27618. /**
  27619. * Intensity or strength of the texture.
  27620. * It is commonly used by materials to fine tune the intensity of the texture
  27621. */
  27622. level: number;
  27623. /**
  27624. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27625. * This is part of the texture as textures usually maps to one uv set.
  27626. */
  27627. coordinatesIndex: number;
  27628. private _coordinatesMode;
  27629. /**
  27630. * How a texture is mapped.
  27631. *
  27632. * | Value | Type | Description |
  27633. * | ----- | ----------------------------------- | ----------- |
  27634. * | 0 | EXPLICIT_MODE | |
  27635. * | 1 | SPHERICAL_MODE | |
  27636. * | 2 | PLANAR_MODE | |
  27637. * | 3 | CUBIC_MODE | |
  27638. * | 4 | PROJECTION_MODE | |
  27639. * | 5 | SKYBOX_MODE | |
  27640. * | 6 | INVCUBIC_MODE | |
  27641. * | 7 | EQUIRECTANGULAR_MODE | |
  27642. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27643. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27644. */
  27645. coordinatesMode: number;
  27646. /**
  27647. * | Value | Type | Description |
  27648. * | ----- | ------------------ | ----------- |
  27649. * | 0 | CLAMP_ADDRESSMODE | |
  27650. * | 1 | WRAP_ADDRESSMODE | |
  27651. * | 2 | MIRROR_ADDRESSMODE | |
  27652. */
  27653. wrapU: number;
  27654. /**
  27655. * | Value | Type | Description |
  27656. * | ----- | ------------------ | ----------- |
  27657. * | 0 | CLAMP_ADDRESSMODE | |
  27658. * | 1 | WRAP_ADDRESSMODE | |
  27659. * | 2 | MIRROR_ADDRESSMODE | |
  27660. */
  27661. wrapV: number;
  27662. /**
  27663. * | Value | Type | Description |
  27664. * | ----- | ------------------ | ----------- |
  27665. * | 0 | CLAMP_ADDRESSMODE | |
  27666. * | 1 | WRAP_ADDRESSMODE | |
  27667. * | 2 | MIRROR_ADDRESSMODE | |
  27668. */
  27669. wrapR: number;
  27670. /**
  27671. * With compliant hardware and browser (supporting anisotropic filtering)
  27672. * this defines the level of anisotropic filtering in the texture.
  27673. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27674. */
  27675. anisotropicFilteringLevel: number;
  27676. /**
  27677. * Define if the texture is a cube texture or if false a 2d texture.
  27678. */
  27679. isCube: boolean;
  27680. /**
  27681. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27682. */
  27683. is3D: boolean;
  27684. /**
  27685. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27686. * HDR texture are usually stored in linear space.
  27687. * This only impacts the PBR and Background materials
  27688. */
  27689. gammaSpace: boolean;
  27690. /**
  27691. * Gets whether or not the texture contains RGBD data.
  27692. */
  27693. readonly isRGBD: boolean;
  27694. /**
  27695. * Is Z inverted in the texture (useful in a cube texture).
  27696. */
  27697. invertZ: boolean;
  27698. /**
  27699. * Are mip maps generated for this texture or not.
  27700. */
  27701. readonly noMipmap: boolean;
  27702. /**
  27703. * @hidden
  27704. */
  27705. lodLevelInAlpha: boolean;
  27706. /**
  27707. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27708. */
  27709. lodGenerationOffset: number;
  27710. /**
  27711. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27712. */
  27713. lodGenerationScale: number;
  27714. /**
  27715. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27716. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27717. * average roughness values.
  27718. */
  27719. linearSpecularLOD: boolean;
  27720. /**
  27721. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27722. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27723. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27724. */
  27725. irradianceTexture: Nullable<BaseTexture>;
  27726. /**
  27727. * Define if the texture is a render target.
  27728. */
  27729. isRenderTarget: boolean;
  27730. /**
  27731. * Define the unique id of the texture in the scene.
  27732. */
  27733. readonly uid: string;
  27734. /**
  27735. * Return a string representation of the texture.
  27736. * @returns the texture as a string
  27737. */
  27738. toString(): string;
  27739. /**
  27740. * Get the class name of the texture.
  27741. * @returns "BaseTexture"
  27742. */
  27743. getClassName(): string;
  27744. /**
  27745. * Define the list of animation attached to the texture.
  27746. */
  27747. animations: Animation[];
  27748. /**
  27749. * An event triggered when the texture is disposed.
  27750. */
  27751. onDisposeObservable: Observable<BaseTexture>;
  27752. private _onDisposeObserver;
  27753. /**
  27754. * Callback triggered when the texture has been disposed.
  27755. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27756. */
  27757. onDispose: () => void;
  27758. /**
  27759. * Define the current state of the loading sequence when in delayed load mode.
  27760. */
  27761. delayLoadState: number;
  27762. private _scene;
  27763. /** @hidden */
  27764. _texture: Nullable<InternalTexture>;
  27765. private _uid;
  27766. /**
  27767. * Define if the texture is preventinga material to render or not.
  27768. * If not and the texture is not ready, the engine will use a default black texture instead.
  27769. */
  27770. readonly isBlocking: boolean;
  27771. /**
  27772. * Instantiates a new BaseTexture.
  27773. * Base class of all the textures in babylon.
  27774. * It groups all the common properties the materials, post process, lights... might need
  27775. * in order to make a correct use of the texture.
  27776. * @param scene Define the scene the texture blongs to
  27777. */
  27778. constructor(scene: Nullable<Scene>);
  27779. /**
  27780. * Get the scene the texture belongs to.
  27781. * @returns the scene or null if undefined
  27782. */
  27783. getScene(): Nullable<Scene>;
  27784. /**
  27785. * Get the texture transform matrix used to offset tile the texture for istance.
  27786. * @returns the transformation matrix
  27787. */
  27788. getTextureMatrix(): Matrix;
  27789. /**
  27790. * Get the texture reflection matrix used to rotate/transform the reflection.
  27791. * @returns the reflection matrix
  27792. */
  27793. getReflectionTextureMatrix(): Matrix;
  27794. /**
  27795. * Get the underlying lower level texture from Babylon.
  27796. * @returns the insternal texture
  27797. */
  27798. getInternalTexture(): Nullable<InternalTexture>;
  27799. /**
  27800. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27801. * @returns true if ready or not blocking
  27802. */
  27803. isReadyOrNotBlocking(): boolean;
  27804. /**
  27805. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27806. * @returns true if fully ready
  27807. */
  27808. isReady(): boolean;
  27809. private _cachedSize;
  27810. /**
  27811. * Get the size of the texture.
  27812. * @returns the texture size.
  27813. */
  27814. getSize(): ISize;
  27815. /**
  27816. * Get the base size of the texture.
  27817. * It can be different from the size if the texture has been resized for POT for instance
  27818. * @returns the base size
  27819. */
  27820. getBaseSize(): ISize;
  27821. /**
  27822. * Update the sampling mode of the texture.
  27823. * Default is Trilinear mode.
  27824. *
  27825. * | Value | Type | Description |
  27826. * | ----- | ------------------ | ----------- |
  27827. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27828. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27829. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27830. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27831. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27832. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27833. * | 7 | NEAREST_LINEAR | |
  27834. * | 8 | NEAREST_NEAREST | |
  27835. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27836. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27837. * | 11 | LINEAR_LINEAR | |
  27838. * | 12 | LINEAR_NEAREST | |
  27839. *
  27840. * > _mag_: magnification filter (close to the viewer)
  27841. * > _min_: minification filter (far from the viewer)
  27842. * > _mip_: filter used between mip map levels
  27843. *@param samplingMode Define the new sampling mode of the texture
  27844. */
  27845. updateSamplingMode(samplingMode: number): void;
  27846. /**
  27847. * Scales the texture if is `canRescale()`
  27848. * @param ratio the resize factor we want to use to rescale
  27849. */
  27850. scale(ratio: number): void;
  27851. /**
  27852. * Get if the texture can rescale.
  27853. */
  27854. readonly canRescale: boolean;
  27855. /** @hidden */
  27856. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27857. /** @hidden */
  27858. _rebuild(): void;
  27859. /**
  27860. * Triggers the load sequence in delayed load mode.
  27861. */
  27862. delayLoad(): void;
  27863. /**
  27864. * Clones the texture.
  27865. * @returns the cloned texture
  27866. */
  27867. clone(): Nullable<BaseTexture>;
  27868. /**
  27869. * Get the texture underlying type (INT, FLOAT...)
  27870. */
  27871. readonly textureType: number;
  27872. /**
  27873. * Get the texture underlying format (RGB, RGBA...)
  27874. */
  27875. readonly textureFormat: number;
  27876. /**
  27877. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27878. * This will returns an RGBA array buffer containing either in values (0-255) or
  27879. * float values (0-1) depending of the underlying buffer type.
  27880. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27881. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27882. * @param buffer defines a user defined buffer to fill with data (can be null)
  27883. * @returns The Array buffer containing the pixels data.
  27884. */
  27885. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27886. /**
  27887. * Release and destroy the underlying lower level texture aka internalTexture.
  27888. */
  27889. releaseInternalTexture(): void;
  27890. /**
  27891. * Get the polynomial representation of the texture data.
  27892. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27893. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27894. */
  27895. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27896. /** @hidden */
  27897. readonly _lodTextureHigh: Nullable<BaseTexture>;
  27898. /** @hidden */
  27899. readonly _lodTextureMid: Nullable<BaseTexture>;
  27900. /** @hidden */
  27901. readonly _lodTextureLow: Nullable<BaseTexture>;
  27902. /**
  27903. * Dispose the texture and release its associated resources.
  27904. */
  27905. dispose(): void;
  27906. /**
  27907. * Serialize the texture into a JSON representation that can be parsed later on.
  27908. * @returns the JSON representation of the texture
  27909. */
  27910. serialize(): any;
  27911. /**
  27912. * Helper function to be called back once a list of texture contains only ready textures.
  27913. * @param textures Define the list of textures to wait for
  27914. * @param callback Define the callback triggered once the entire list will be ready
  27915. */
  27916. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27917. }
  27918. }
  27919. declare module BABYLON {
  27920. /**
  27921. * Class used to store data associated with WebGL texture data for the engine
  27922. * This class should not be used directly
  27923. */
  27924. export class InternalTexture {
  27925. /** @hidden */
  27926. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  27927. /**
  27928. * The source of the texture data is unknown
  27929. */
  27930. static DATASOURCE_UNKNOWN: number;
  27931. /**
  27932. * Texture data comes from an URL
  27933. */
  27934. static DATASOURCE_URL: number;
  27935. /**
  27936. * Texture data is only used for temporary storage
  27937. */
  27938. static DATASOURCE_TEMP: number;
  27939. /**
  27940. * Texture data comes from raw data (ArrayBuffer)
  27941. */
  27942. static DATASOURCE_RAW: number;
  27943. /**
  27944. * Texture content is dynamic (video or dynamic texture)
  27945. */
  27946. static DATASOURCE_DYNAMIC: number;
  27947. /**
  27948. * Texture content is generated by rendering to it
  27949. */
  27950. static DATASOURCE_RENDERTARGET: number;
  27951. /**
  27952. * Texture content is part of a multi render target process
  27953. */
  27954. static DATASOURCE_MULTIRENDERTARGET: number;
  27955. /**
  27956. * Texture data comes from a cube data file
  27957. */
  27958. static DATASOURCE_CUBE: number;
  27959. /**
  27960. * Texture data comes from a raw cube data
  27961. */
  27962. static DATASOURCE_CUBERAW: number;
  27963. /**
  27964. * Texture data come from a prefiltered cube data file
  27965. */
  27966. static DATASOURCE_CUBEPREFILTERED: number;
  27967. /**
  27968. * Texture content is raw 3D data
  27969. */
  27970. static DATASOURCE_RAW3D: number;
  27971. /**
  27972. * Texture content is a depth texture
  27973. */
  27974. static DATASOURCE_DEPTHTEXTURE: number;
  27975. /**
  27976. * Texture data comes from a raw cube data encoded with RGBD
  27977. */
  27978. static DATASOURCE_CUBERAW_RGBD: number;
  27979. /**
  27980. * Defines if the texture is ready
  27981. */
  27982. isReady: boolean;
  27983. /**
  27984. * Defines if the texture is a cube texture
  27985. */
  27986. isCube: boolean;
  27987. /**
  27988. * Defines if the texture contains 3D data
  27989. */
  27990. is3D: boolean;
  27991. /**
  27992. * Defines if the texture contains multiview data
  27993. */
  27994. isMultiview: boolean;
  27995. /**
  27996. * Gets the URL used to load this texture
  27997. */
  27998. url: string;
  27999. /**
  28000. * Gets the sampling mode of the texture
  28001. */
  28002. samplingMode: number;
  28003. /**
  28004. * Gets a boolean indicating if the texture needs mipmaps generation
  28005. */
  28006. generateMipMaps: boolean;
  28007. /**
  28008. * Gets the number of samples used by the texture (WebGL2+ only)
  28009. */
  28010. samples: number;
  28011. /**
  28012. * Gets the type of the texture (int, float...)
  28013. */
  28014. type: number;
  28015. /**
  28016. * Gets the format of the texture (RGB, RGBA...)
  28017. */
  28018. format: number;
  28019. /**
  28020. * Observable called when the texture is loaded
  28021. */
  28022. onLoadedObservable: Observable<InternalTexture>;
  28023. /**
  28024. * Gets the width of the texture
  28025. */
  28026. width: number;
  28027. /**
  28028. * Gets the height of the texture
  28029. */
  28030. height: number;
  28031. /**
  28032. * Gets the depth of the texture
  28033. */
  28034. depth: number;
  28035. /**
  28036. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  28037. */
  28038. baseWidth: number;
  28039. /**
  28040. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  28041. */
  28042. baseHeight: number;
  28043. /**
  28044. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  28045. */
  28046. baseDepth: number;
  28047. /**
  28048. * Gets a boolean indicating if the texture is inverted on Y axis
  28049. */
  28050. invertY: boolean;
  28051. /** @hidden */
  28052. _invertVScale: boolean;
  28053. /** @hidden */
  28054. _associatedChannel: number;
  28055. /** @hidden */
  28056. _dataSource: number;
  28057. /** @hidden */
  28058. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  28059. /** @hidden */
  28060. _bufferView: Nullable<ArrayBufferView>;
  28061. /** @hidden */
  28062. _bufferViewArray: Nullable<ArrayBufferView[]>;
  28063. /** @hidden */
  28064. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  28065. /** @hidden */
  28066. _size: number;
  28067. /** @hidden */
  28068. _extension: string;
  28069. /** @hidden */
  28070. _files: Nullable<string[]>;
  28071. /** @hidden */
  28072. _workingCanvas: Nullable<HTMLCanvasElement>;
  28073. /** @hidden */
  28074. _workingContext: Nullable<CanvasRenderingContext2D>;
  28075. /** @hidden */
  28076. _framebuffer: Nullable<WebGLFramebuffer>;
  28077. /** @hidden */
  28078. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  28079. /** @hidden */
  28080. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  28081. /** @hidden */
  28082. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  28083. /** @hidden */
  28084. _attachments: Nullable<number[]>;
  28085. /** @hidden */
  28086. _cachedCoordinatesMode: Nullable<number>;
  28087. /** @hidden */
  28088. _cachedWrapU: Nullable<number>;
  28089. /** @hidden */
  28090. _cachedWrapV: Nullable<number>;
  28091. /** @hidden */
  28092. _cachedWrapR: Nullable<number>;
  28093. /** @hidden */
  28094. _cachedAnisotropicFilteringLevel: Nullable<number>;
  28095. /** @hidden */
  28096. _isDisabled: boolean;
  28097. /** @hidden */
  28098. _compression: Nullable<string>;
  28099. /** @hidden */
  28100. _generateStencilBuffer: boolean;
  28101. /** @hidden */
  28102. _generateDepthBuffer: boolean;
  28103. /** @hidden */
  28104. _comparisonFunction: number;
  28105. /** @hidden */
  28106. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  28107. /** @hidden */
  28108. _lodGenerationScale: number;
  28109. /** @hidden */
  28110. _lodGenerationOffset: number;
  28111. /** @hidden */
  28112. _colorTextureArray: Nullable<WebGLTexture>;
  28113. /** @hidden */
  28114. _depthStencilTextureArray: Nullable<WebGLTexture>;
  28115. /** @hidden */
  28116. _lodTextureHigh: Nullable<BaseTexture>;
  28117. /** @hidden */
  28118. _lodTextureMid: Nullable<BaseTexture>;
  28119. /** @hidden */
  28120. _lodTextureLow: Nullable<BaseTexture>;
  28121. /** @hidden */
  28122. _isRGBD: boolean;
  28123. /** @hidden */
  28124. _linearSpecularLOD: boolean;
  28125. /** @hidden */
  28126. _irradianceTexture: Nullable<BaseTexture>;
  28127. /** @hidden */
  28128. _webGLTexture: Nullable<WebGLTexture>;
  28129. /** @hidden */
  28130. _references: number;
  28131. private _engine;
  28132. /**
  28133. * Gets the Engine the texture belongs to.
  28134. * @returns The babylon engine
  28135. */
  28136. getEngine(): Engine;
  28137. /**
  28138. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  28139. */
  28140. readonly dataSource: number;
  28141. /**
  28142. * Creates a new InternalTexture
  28143. * @param engine defines the engine to use
  28144. * @param dataSource defines the type of data that will be used
  28145. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28146. */
  28147. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  28148. /**
  28149. * Increments the number of references (ie. the number of Texture that point to it)
  28150. */
  28151. incrementReferences(): void;
  28152. /**
  28153. * Change the size of the texture (not the size of the content)
  28154. * @param width defines the new width
  28155. * @param height defines the new height
  28156. * @param depth defines the new depth (1 by default)
  28157. */
  28158. updateSize(width: int, height: int, depth?: int): void;
  28159. /** @hidden */
  28160. _rebuild(): void;
  28161. /** @hidden */
  28162. _swapAndDie(target: InternalTexture): void;
  28163. /**
  28164. * Dispose the current allocated resources
  28165. */
  28166. dispose(): void;
  28167. }
  28168. }
  28169. declare module BABYLON {
  28170. /**
  28171. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28172. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28173. */
  28174. export class EffectFallbacks {
  28175. private _defines;
  28176. private _currentRank;
  28177. private _maxRank;
  28178. private _mesh;
  28179. /**
  28180. * Removes the fallback from the bound mesh.
  28181. */
  28182. unBindMesh(): void;
  28183. /**
  28184. * Adds a fallback on the specified property.
  28185. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28186. * @param define The name of the define in the shader
  28187. */
  28188. addFallback(rank: number, define: string): void;
  28189. /**
  28190. * Sets the mesh to use CPU skinning when needing to fallback.
  28191. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28192. * @param mesh The mesh to use the fallbacks.
  28193. */
  28194. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28195. /**
  28196. * Checks to see if more fallbacks are still availible.
  28197. */
  28198. readonly hasMoreFallbacks: boolean;
  28199. /**
  28200. * Removes the defines that should be removed when falling back.
  28201. * @param currentDefines defines the current define statements for the shader.
  28202. * @param effect defines the current effect we try to compile
  28203. * @returns The resulting defines with defines of the current rank removed.
  28204. */
  28205. reduce(currentDefines: string, effect: Effect): string;
  28206. }
  28207. /**
  28208. * Options to be used when creating an effect.
  28209. */
  28210. export class EffectCreationOptions {
  28211. /**
  28212. * Atrributes that will be used in the shader.
  28213. */
  28214. attributes: string[];
  28215. /**
  28216. * Uniform varible names that will be set in the shader.
  28217. */
  28218. uniformsNames: string[];
  28219. /**
  28220. * Uniform buffer varible names that will be set in the shader.
  28221. */
  28222. uniformBuffersNames: string[];
  28223. /**
  28224. * Sampler texture variable names that will be set in the shader.
  28225. */
  28226. samplers: string[];
  28227. /**
  28228. * Define statements that will be set in the shader.
  28229. */
  28230. defines: any;
  28231. /**
  28232. * Possible fallbacks for this effect to improve performance when needed.
  28233. */
  28234. fallbacks: Nullable<EffectFallbacks>;
  28235. /**
  28236. * Callback that will be called when the shader is compiled.
  28237. */
  28238. onCompiled: Nullable<(effect: Effect) => void>;
  28239. /**
  28240. * Callback that will be called if an error occurs during shader compilation.
  28241. */
  28242. onError: Nullable<(effect: Effect, errors: string) => void>;
  28243. /**
  28244. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28245. */
  28246. indexParameters: any;
  28247. /**
  28248. * Max number of lights that can be used in the shader.
  28249. */
  28250. maxSimultaneousLights: number;
  28251. /**
  28252. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28253. */
  28254. transformFeedbackVaryings: Nullable<string[]>;
  28255. }
  28256. /**
  28257. * Effect containing vertex and fragment shader that can be executed on an object.
  28258. */
  28259. export class Effect implements IDisposable {
  28260. /**
  28261. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28262. */
  28263. static ShadersRepository: string;
  28264. /**
  28265. * Name of the effect.
  28266. */
  28267. name: any;
  28268. /**
  28269. * String container all the define statements that should be set on the shader.
  28270. */
  28271. defines: string;
  28272. /**
  28273. * Callback that will be called when the shader is compiled.
  28274. */
  28275. onCompiled: Nullable<(effect: Effect) => void>;
  28276. /**
  28277. * Callback that will be called if an error occurs during shader compilation.
  28278. */
  28279. onError: Nullable<(effect: Effect, errors: string) => void>;
  28280. /**
  28281. * Callback that will be called when effect is bound.
  28282. */
  28283. onBind: Nullable<(effect: Effect) => void>;
  28284. /**
  28285. * Unique ID of the effect.
  28286. */
  28287. uniqueId: number;
  28288. /**
  28289. * Observable that will be called when the shader is compiled.
  28290. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28291. */
  28292. onCompileObservable: Observable<Effect>;
  28293. /**
  28294. * Observable that will be called if an error occurs during shader compilation.
  28295. */
  28296. onErrorObservable: Observable<Effect>;
  28297. /** @hidden */
  28298. _onBindObservable: Nullable<Observable<Effect>>;
  28299. /**
  28300. * Observable that will be called when effect is bound.
  28301. */
  28302. readonly onBindObservable: Observable<Effect>;
  28303. /** @hidden */
  28304. _bonesComputationForcedToCPU: boolean;
  28305. private static _uniqueIdSeed;
  28306. private _engine;
  28307. private _uniformBuffersNames;
  28308. private _uniformsNames;
  28309. private _samplerList;
  28310. private _samplers;
  28311. private _isReady;
  28312. private _compilationError;
  28313. private _attributesNames;
  28314. private _attributes;
  28315. private _uniforms;
  28316. /**
  28317. * Key for the effect.
  28318. * @hidden
  28319. */
  28320. _key: string;
  28321. private _indexParameters;
  28322. private _fallbacks;
  28323. private _vertexSourceCode;
  28324. private _fragmentSourceCode;
  28325. private _vertexSourceCodeOverride;
  28326. private _fragmentSourceCodeOverride;
  28327. private _transformFeedbackVaryings;
  28328. /**
  28329. * Compiled shader to webGL program.
  28330. * @hidden
  28331. */
  28332. _pipelineContext: Nullable<IPipelineContext>;
  28333. private _valueCache;
  28334. private static _baseCache;
  28335. /**
  28336. * Instantiates an effect.
  28337. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28338. * @param baseName Name of the effect.
  28339. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28340. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28341. * @param samplers List of sampler variables that will be passed to the shader.
  28342. * @param engine Engine to be used to render the effect
  28343. * @param defines Define statements to be added to the shader.
  28344. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28345. * @param onCompiled Callback that will be called when the shader is compiled.
  28346. * @param onError Callback that will be called if an error occurs during shader compilation.
  28347. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28348. */
  28349. 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);
  28350. private _useFinalCode;
  28351. /**
  28352. * Unique key for this effect
  28353. */
  28354. readonly key: string;
  28355. /**
  28356. * If the effect has been compiled and prepared.
  28357. * @returns if the effect is compiled and prepared.
  28358. */
  28359. isReady(): boolean;
  28360. private _isReadyInternal;
  28361. /**
  28362. * The engine the effect was initialized with.
  28363. * @returns the engine.
  28364. */
  28365. getEngine(): Engine;
  28366. /**
  28367. * The pipeline context for this effect
  28368. * @returns the associated pipeline context
  28369. */
  28370. getPipelineContext(): Nullable<IPipelineContext>;
  28371. /**
  28372. * The set of names of attribute variables for the shader.
  28373. * @returns An array of attribute names.
  28374. */
  28375. getAttributesNames(): string[];
  28376. /**
  28377. * Returns the attribute at the given index.
  28378. * @param index The index of the attribute.
  28379. * @returns The location of the attribute.
  28380. */
  28381. getAttributeLocation(index: number): number;
  28382. /**
  28383. * Returns the attribute based on the name of the variable.
  28384. * @param name of the attribute to look up.
  28385. * @returns the attribute location.
  28386. */
  28387. getAttributeLocationByName(name: string): number;
  28388. /**
  28389. * The number of attributes.
  28390. * @returns the numnber of attributes.
  28391. */
  28392. getAttributesCount(): number;
  28393. /**
  28394. * Gets the index of a uniform variable.
  28395. * @param uniformName of the uniform to look up.
  28396. * @returns the index.
  28397. */
  28398. getUniformIndex(uniformName: string): number;
  28399. /**
  28400. * Returns the attribute based on the name of the variable.
  28401. * @param uniformName of the uniform to look up.
  28402. * @returns the location of the uniform.
  28403. */
  28404. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28405. /**
  28406. * Returns an array of sampler variable names
  28407. * @returns The array of sampler variable neames.
  28408. */
  28409. getSamplers(): string[];
  28410. /**
  28411. * The error from the last compilation.
  28412. * @returns the error string.
  28413. */
  28414. getCompilationError(): string;
  28415. /**
  28416. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28417. * @param func The callback to be used.
  28418. */
  28419. executeWhenCompiled(func: (effect: Effect) => void): void;
  28420. private _checkIsReady;
  28421. /** @hidden */
  28422. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28423. /** @hidden */
  28424. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28425. /** @hidden */
  28426. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28427. /**
  28428. * Recompiles the webGL program
  28429. * @param vertexSourceCode The source code for the vertex shader.
  28430. * @param fragmentSourceCode The source code for the fragment shader.
  28431. * @param onCompiled Callback called when completed.
  28432. * @param onError Callback called on error.
  28433. * @hidden
  28434. */
  28435. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28436. /**
  28437. * Prepares the effect
  28438. * @hidden
  28439. */
  28440. _prepareEffect(): void;
  28441. private _processCompilationErrors;
  28442. /**
  28443. * Checks if the effect is supported. (Must be called after compilation)
  28444. */
  28445. readonly isSupported: boolean;
  28446. /**
  28447. * Binds a texture to the engine to be used as output of the shader.
  28448. * @param channel Name of the output variable.
  28449. * @param texture Texture to bind.
  28450. * @hidden
  28451. */
  28452. _bindTexture(channel: string, texture: InternalTexture): void;
  28453. /**
  28454. * Sets a texture on the engine to be used in the shader.
  28455. * @param channel Name of the sampler variable.
  28456. * @param texture Texture to set.
  28457. */
  28458. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28459. /**
  28460. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28461. * @param channel Name of the sampler variable.
  28462. * @param texture Texture to set.
  28463. */
  28464. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28465. /**
  28466. * Sets an array of textures on the engine to be used in the shader.
  28467. * @param channel Name of the variable.
  28468. * @param textures Textures to set.
  28469. */
  28470. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28471. /**
  28472. * 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)
  28473. * @param channel Name of the sampler variable.
  28474. * @param postProcess Post process to get the input texture from.
  28475. */
  28476. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28477. /**
  28478. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28479. * 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)
  28480. * @param channel Name of the sampler variable.
  28481. * @param postProcess Post process to get the output texture from.
  28482. */
  28483. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28484. /** @hidden */
  28485. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  28486. /** @hidden */
  28487. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28488. /** @hidden */
  28489. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28490. /** @hidden */
  28491. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28492. /**
  28493. * Binds a buffer to a uniform.
  28494. * @param buffer Buffer to bind.
  28495. * @param name Name of the uniform variable to bind to.
  28496. */
  28497. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28498. /**
  28499. * Binds block to a uniform.
  28500. * @param blockName Name of the block to bind.
  28501. * @param index Index to bind.
  28502. */
  28503. bindUniformBlock(blockName: string, index: number): void;
  28504. /**
  28505. * Sets an interger value on a uniform variable.
  28506. * @param uniformName Name of the variable.
  28507. * @param value Value to be set.
  28508. * @returns this effect.
  28509. */
  28510. setInt(uniformName: string, value: number): Effect;
  28511. /**
  28512. * Sets an int array on a uniform variable.
  28513. * @param uniformName Name of the variable.
  28514. * @param array array to be set.
  28515. * @returns this effect.
  28516. */
  28517. setIntArray(uniformName: string, array: Int32Array): Effect;
  28518. /**
  28519. * 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)
  28520. * @param uniformName Name of the variable.
  28521. * @param array array to be set.
  28522. * @returns this effect.
  28523. */
  28524. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28525. /**
  28526. * 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)
  28527. * @param uniformName Name of the variable.
  28528. * @param array array to be set.
  28529. * @returns this effect.
  28530. */
  28531. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28532. /**
  28533. * 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)
  28534. * @param uniformName Name of the variable.
  28535. * @param array array to be set.
  28536. * @returns this effect.
  28537. */
  28538. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28539. /**
  28540. * Sets an float array on a uniform variable.
  28541. * @param uniformName Name of the variable.
  28542. * @param array array to be set.
  28543. * @returns this effect.
  28544. */
  28545. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28546. /**
  28547. * 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)
  28548. * @param uniformName Name of the variable.
  28549. * @param array array to be set.
  28550. * @returns this effect.
  28551. */
  28552. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28553. /**
  28554. * 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)
  28555. * @param uniformName Name of the variable.
  28556. * @param array array to be set.
  28557. * @returns this effect.
  28558. */
  28559. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28560. /**
  28561. * 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)
  28562. * @param uniformName Name of the variable.
  28563. * @param array array to be set.
  28564. * @returns this effect.
  28565. */
  28566. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28567. /**
  28568. * Sets an array on a uniform variable.
  28569. * @param uniformName Name of the variable.
  28570. * @param array array to be set.
  28571. * @returns this effect.
  28572. */
  28573. setArray(uniformName: string, array: number[]): Effect;
  28574. /**
  28575. * 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)
  28576. * @param uniformName Name of the variable.
  28577. * @param array array to be set.
  28578. * @returns this effect.
  28579. */
  28580. setArray2(uniformName: string, array: number[]): Effect;
  28581. /**
  28582. * 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)
  28583. * @param uniformName Name of the variable.
  28584. * @param array array to be set.
  28585. * @returns this effect.
  28586. */
  28587. setArray3(uniformName: string, array: number[]): Effect;
  28588. /**
  28589. * 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)
  28590. * @param uniformName Name of the variable.
  28591. * @param array array to be set.
  28592. * @returns this effect.
  28593. */
  28594. setArray4(uniformName: string, array: number[]): Effect;
  28595. /**
  28596. * Sets matrices on a uniform variable.
  28597. * @param uniformName Name of the variable.
  28598. * @param matrices matrices to be set.
  28599. * @returns this effect.
  28600. */
  28601. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28602. /**
  28603. * Sets matrix on a uniform variable.
  28604. * @param uniformName Name of the variable.
  28605. * @param matrix matrix to be set.
  28606. * @returns this effect.
  28607. */
  28608. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28609. /**
  28610. * 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)
  28611. * @param uniformName Name of the variable.
  28612. * @param matrix matrix to be set.
  28613. * @returns this effect.
  28614. */
  28615. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28616. /**
  28617. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28618. * @param uniformName Name of the variable.
  28619. * @param matrix matrix to be set.
  28620. * @returns this effect.
  28621. */
  28622. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28623. /**
  28624. * Sets a float on a uniform variable.
  28625. * @param uniformName Name of the variable.
  28626. * @param value value to be set.
  28627. * @returns this effect.
  28628. */
  28629. setFloat(uniformName: string, value: number): Effect;
  28630. /**
  28631. * Sets a boolean on a uniform variable.
  28632. * @param uniformName Name of the variable.
  28633. * @param bool value to be set.
  28634. * @returns this effect.
  28635. */
  28636. setBool(uniformName: string, bool: boolean): Effect;
  28637. /**
  28638. * Sets a Vector2 on a uniform variable.
  28639. * @param uniformName Name of the variable.
  28640. * @param vector2 vector2 to be set.
  28641. * @returns this effect.
  28642. */
  28643. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28644. /**
  28645. * Sets a float2 on a uniform variable.
  28646. * @param uniformName Name of the variable.
  28647. * @param x First float in float2.
  28648. * @param y Second float in float2.
  28649. * @returns this effect.
  28650. */
  28651. setFloat2(uniformName: string, x: number, y: number): Effect;
  28652. /**
  28653. * Sets a Vector3 on a uniform variable.
  28654. * @param uniformName Name of the variable.
  28655. * @param vector3 Value to be set.
  28656. * @returns this effect.
  28657. */
  28658. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28659. /**
  28660. * Sets a float3 on a uniform variable.
  28661. * @param uniformName Name of the variable.
  28662. * @param x First float in float3.
  28663. * @param y Second float in float3.
  28664. * @param z Third float in float3.
  28665. * @returns this effect.
  28666. */
  28667. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28668. /**
  28669. * Sets a Vector4 on a uniform variable.
  28670. * @param uniformName Name of the variable.
  28671. * @param vector4 Value to be set.
  28672. * @returns this effect.
  28673. */
  28674. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28675. /**
  28676. * Sets a float4 on a uniform variable.
  28677. * @param uniformName Name of the variable.
  28678. * @param x First float in float4.
  28679. * @param y Second float in float4.
  28680. * @param z Third float in float4.
  28681. * @param w Fourth float in float4.
  28682. * @returns this effect.
  28683. */
  28684. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28685. /**
  28686. * Sets a Color3 on a uniform variable.
  28687. * @param uniformName Name of the variable.
  28688. * @param color3 Value to be set.
  28689. * @returns this effect.
  28690. */
  28691. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28692. /**
  28693. * Sets a Color4 on a uniform variable.
  28694. * @param uniformName Name of the variable.
  28695. * @param color3 Value to be set.
  28696. * @param alpha Alpha value to be set.
  28697. * @returns this effect.
  28698. */
  28699. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28700. /**
  28701. * Sets a Color4 on a uniform variable
  28702. * @param uniformName defines the name of the variable
  28703. * @param color4 defines the value to be set
  28704. * @returns this effect.
  28705. */
  28706. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28707. /** Release all associated resources */
  28708. dispose(): void;
  28709. /**
  28710. * This function will add a new shader to the shader store
  28711. * @param name the name of the shader
  28712. * @param pixelShader optional pixel shader content
  28713. * @param vertexShader optional vertex shader content
  28714. */
  28715. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28716. /**
  28717. * Store of each shader (The can be looked up using effect.key)
  28718. */
  28719. static ShadersStore: {
  28720. [key: string]: string;
  28721. };
  28722. /**
  28723. * Store of each included file for a shader (The can be looked up using effect.key)
  28724. */
  28725. static IncludesShadersStore: {
  28726. [key: string]: string;
  28727. };
  28728. /**
  28729. * Resets the cache of effects.
  28730. */
  28731. static ResetCache(): void;
  28732. }
  28733. }
  28734. declare module BABYLON {
  28735. /**
  28736. * Uniform buffer objects.
  28737. *
  28738. * Handles blocks of uniform on the GPU.
  28739. *
  28740. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28741. *
  28742. * For more information, please refer to :
  28743. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28744. */
  28745. export class UniformBuffer {
  28746. private _engine;
  28747. private _buffer;
  28748. private _data;
  28749. private _bufferData;
  28750. private _dynamic?;
  28751. private _uniformLocations;
  28752. private _uniformSizes;
  28753. private _uniformLocationPointer;
  28754. private _needSync;
  28755. private _noUBO;
  28756. private _currentEffect;
  28757. private static _MAX_UNIFORM_SIZE;
  28758. private static _tempBuffer;
  28759. /**
  28760. * Lambda to Update a 3x3 Matrix 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. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  28765. /**
  28766. * Lambda to Update a 2x2 Matrix 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. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  28771. /**
  28772. * Lambda to Update a single 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. updateFloat: (name: string, x: number) => void;
  28777. /**
  28778. * Lambda to Update a vec2 of float 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. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  28783. /**
  28784. * Lambda to Update a vec3 of float 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. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  28789. /**
  28790. * Lambda to Update a vec4 of float 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. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  28795. /**
  28796. * Lambda to Update a 4x4 Matrix 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. updateMatrix: (name: string, mat: Matrix) => void;
  28801. /**
  28802. * Lambda to Update vec3 of float from a Vector 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. updateVector3: (name: string, vector: Vector3) => void;
  28807. /**
  28808. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  28809. * This is dynamic to allow compat with webgl 1 and 2.
  28810. * You will need to pass the name of the uniform as well as the value.
  28811. */
  28812. updateVector4: (name: string, vector: Vector4) => void;
  28813. /**
  28814. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  28815. * This is dynamic to allow compat with webgl 1 and 2.
  28816. * You will need to pass the name of the uniform as well as the value.
  28817. */
  28818. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  28819. /**
  28820. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  28821. * This is dynamic to allow compat with webgl 1 and 2.
  28822. * You will need to pass the name of the uniform as well as the value.
  28823. */
  28824. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  28825. /**
  28826. * Instantiates a new Uniform buffer objects.
  28827. *
  28828. * Handles blocks of uniform on the GPU.
  28829. *
  28830. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28831. *
  28832. * For more information, please refer to :
  28833. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28834. * @param engine Define the engine the buffer is associated with
  28835. * @param data Define the data contained in the buffer
  28836. * @param dynamic Define if the buffer is updatable
  28837. */
  28838. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  28839. /**
  28840. * Indicates if the buffer is using the WebGL2 UBO implementation,
  28841. * or just falling back on setUniformXXX calls.
  28842. */
  28843. readonly useUbo: boolean;
  28844. /**
  28845. * Indicates if the WebGL underlying uniform buffer is in sync
  28846. * with the javascript cache data.
  28847. */
  28848. readonly isSync: boolean;
  28849. /**
  28850. * Indicates if the WebGL underlying uniform buffer is dynamic.
  28851. * Also, a dynamic UniformBuffer will disable cache verification and always
  28852. * update the underlying WebGL uniform buffer to the GPU.
  28853. * @returns if Dynamic, otherwise false
  28854. */
  28855. isDynamic(): boolean;
  28856. /**
  28857. * The data cache on JS side.
  28858. * @returns the underlying data as a float array
  28859. */
  28860. getData(): Float32Array;
  28861. /**
  28862. * The underlying WebGL Uniform buffer.
  28863. * @returns the webgl buffer
  28864. */
  28865. getBuffer(): Nullable<DataBuffer>;
  28866. /**
  28867. * std140 layout specifies how to align data within an UBO structure.
  28868. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  28869. * for specs.
  28870. */
  28871. private _fillAlignment;
  28872. /**
  28873. * Adds an uniform in the buffer.
  28874. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  28875. * for the layout to be correct !
  28876. * @param name Name of the uniform, as used in the uniform block in the shader.
  28877. * @param size Data size, or data directly.
  28878. */
  28879. addUniform(name: string, size: number | number[]): void;
  28880. /**
  28881. * Adds a Matrix 4x4 to the uniform buffer.
  28882. * @param name Name of the uniform, as used in the uniform block in the shader.
  28883. * @param mat A 4x4 matrix.
  28884. */
  28885. addMatrix(name: string, mat: Matrix): void;
  28886. /**
  28887. * Adds a vec2 to the uniform buffer.
  28888. * @param name Name of the uniform, as used in the uniform block in the shader.
  28889. * @param x Define the x component value of the vec2
  28890. * @param y Define the y component value of the vec2
  28891. */
  28892. addFloat2(name: string, x: number, y: number): void;
  28893. /**
  28894. * Adds a vec3 to the uniform buffer.
  28895. * @param name Name of the uniform, as used in the uniform block in the shader.
  28896. * @param x Define the x component value of the vec3
  28897. * @param y Define the y component value of the vec3
  28898. * @param z Define the z component value of the vec3
  28899. */
  28900. addFloat3(name: string, x: number, y: number, z: number): void;
  28901. /**
  28902. * Adds a vec3 to the uniform buffer.
  28903. * @param name Name of the uniform, as used in the uniform block in the shader.
  28904. * @param color Define the vec3 from a Color
  28905. */
  28906. addColor3(name: string, color: Color3): void;
  28907. /**
  28908. * Adds a vec4 to the uniform buffer.
  28909. * @param name Name of the uniform, as used in the uniform block in the shader.
  28910. * @param color Define the rgb components from a Color
  28911. * @param alpha Define the a component of the vec4
  28912. */
  28913. addColor4(name: string, color: Color3, alpha: number): void;
  28914. /**
  28915. * Adds a vec3 to the uniform buffer.
  28916. * @param name Name of the uniform, as used in the uniform block in the shader.
  28917. * @param vector Define the vec3 components from a Vector
  28918. */
  28919. addVector3(name: string, vector: Vector3): void;
  28920. /**
  28921. * Adds a Matrix 3x3 to the uniform buffer.
  28922. * @param name Name of the uniform, as used in the uniform block in the shader.
  28923. */
  28924. addMatrix3x3(name: string): void;
  28925. /**
  28926. * Adds a Matrix 2x2 to the uniform buffer.
  28927. * @param name Name of the uniform, as used in the uniform block in the shader.
  28928. */
  28929. addMatrix2x2(name: string): void;
  28930. /**
  28931. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  28932. */
  28933. create(): void;
  28934. /** @hidden */
  28935. _rebuild(): void;
  28936. /**
  28937. * Updates the WebGL Uniform Buffer on the GPU.
  28938. * If the `dynamic` flag is set to true, no cache comparison is done.
  28939. * Otherwise, the buffer will be updated only if the cache differs.
  28940. */
  28941. update(): void;
  28942. /**
  28943. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  28944. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  28945. * @param data Define the flattened data
  28946. * @param size Define the size of the data.
  28947. */
  28948. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  28949. private _valueCache;
  28950. private _cacheMatrix;
  28951. private _updateMatrix3x3ForUniform;
  28952. private _updateMatrix3x3ForEffect;
  28953. private _updateMatrix2x2ForEffect;
  28954. private _updateMatrix2x2ForUniform;
  28955. private _updateFloatForEffect;
  28956. private _updateFloatForUniform;
  28957. private _updateFloat2ForEffect;
  28958. private _updateFloat2ForUniform;
  28959. private _updateFloat3ForEffect;
  28960. private _updateFloat3ForUniform;
  28961. private _updateFloat4ForEffect;
  28962. private _updateFloat4ForUniform;
  28963. private _updateMatrixForEffect;
  28964. private _updateMatrixForUniform;
  28965. private _updateVector3ForEffect;
  28966. private _updateVector3ForUniform;
  28967. private _updateVector4ForEffect;
  28968. private _updateVector4ForUniform;
  28969. private _updateColor3ForEffect;
  28970. private _updateColor3ForUniform;
  28971. private _updateColor4ForEffect;
  28972. private _updateColor4ForUniform;
  28973. /**
  28974. * Sets a sampler uniform on the effect.
  28975. * @param name Define the name of the sampler.
  28976. * @param texture Define the texture to set in the sampler
  28977. */
  28978. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  28979. /**
  28980. * Directly updates the value of the uniform in the cache AND on the GPU.
  28981. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  28982. * @param data Define the flattened data
  28983. */
  28984. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  28985. /**
  28986. * Binds this uniform buffer to an effect.
  28987. * @param effect Define the effect to bind the buffer to
  28988. * @param name Name of the uniform block in the shader.
  28989. */
  28990. bindToEffect(effect: Effect, name: string): void;
  28991. /**
  28992. * Disposes the uniform buffer.
  28993. */
  28994. dispose(): void;
  28995. }
  28996. }
  28997. declare module BABYLON {
  28998. /**
  28999. * Class used to work with sound analyzer using fast fourier transform (FFT)
  29000. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29001. */
  29002. export class Analyser {
  29003. /**
  29004. * Gets or sets the smoothing
  29005. * @ignorenaming
  29006. */
  29007. SMOOTHING: number;
  29008. /**
  29009. * Gets or sets the FFT table size
  29010. * @ignorenaming
  29011. */
  29012. FFT_SIZE: number;
  29013. /**
  29014. * Gets or sets the bar graph amplitude
  29015. * @ignorenaming
  29016. */
  29017. BARGRAPHAMPLITUDE: number;
  29018. /**
  29019. * Gets or sets the position of the debug canvas
  29020. * @ignorenaming
  29021. */
  29022. DEBUGCANVASPOS: {
  29023. x: number;
  29024. y: number;
  29025. };
  29026. /**
  29027. * Gets or sets the debug canvas size
  29028. * @ignorenaming
  29029. */
  29030. DEBUGCANVASSIZE: {
  29031. width: number;
  29032. height: number;
  29033. };
  29034. private _byteFreqs;
  29035. private _byteTime;
  29036. private _floatFreqs;
  29037. private _webAudioAnalyser;
  29038. private _debugCanvas;
  29039. private _debugCanvasContext;
  29040. private _scene;
  29041. private _registerFunc;
  29042. private _audioEngine;
  29043. /**
  29044. * Creates a new analyser
  29045. * @param scene defines hosting scene
  29046. */
  29047. constructor(scene: Scene);
  29048. /**
  29049. * Get the number of data values you will have to play with for the visualization
  29050. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  29051. * @returns a number
  29052. */
  29053. getFrequencyBinCount(): number;
  29054. /**
  29055. * Gets the current frequency data as a byte array
  29056. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29057. * @returns a Uint8Array
  29058. */
  29059. getByteFrequencyData(): Uint8Array;
  29060. /**
  29061. * Gets the current waveform as a byte array
  29062. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  29063. * @returns a Uint8Array
  29064. */
  29065. getByteTimeDomainData(): Uint8Array;
  29066. /**
  29067. * Gets the current frequency data as a float array
  29068. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29069. * @returns a Float32Array
  29070. */
  29071. getFloatFrequencyData(): Float32Array;
  29072. /**
  29073. * Renders the debug canvas
  29074. */
  29075. drawDebugCanvas(): void;
  29076. /**
  29077. * Stops rendering the debug canvas and removes it
  29078. */
  29079. stopDebugCanvas(): void;
  29080. /**
  29081. * Connects two audio nodes
  29082. * @param inputAudioNode defines first node to connect
  29083. * @param outputAudioNode defines second node to connect
  29084. */
  29085. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  29086. /**
  29087. * Releases all associated resources
  29088. */
  29089. dispose(): void;
  29090. }
  29091. }
  29092. declare module BABYLON {
  29093. /**
  29094. * This represents an audio engine and it is responsible
  29095. * to play, synchronize and analyse sounds throughout the application.
  29096. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29097. */
  29098. export interface IAudioEngine extends IDisposable {
  29099. /**
  29100. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29101. */
  29102. readonly canUseWebAudio: boolean;
  29103. /**
  29104. * Gets the current AudioContext if available.
  29105. */
  29106. readonly audioContext: Nullable<AudioContext>;
  29107. /**
  29108. * The master gain node defines the global audio volume of your audio engine.
  29109. */
  29110. readonly masterGain: GainNode;
  29111. /**
  29112. * Gets whether or not mp3 are supported by your browser.
  29113. */
  29114. readonly isMP3supported: boolean;
  29115. /**
  29116. * Gets whether or not ogg are supported by your browser.
  29117. */
  29118. readonly isOGGsupported: boolean;
  29119. /**
  29120. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29121. * @ignoreNaming
  29122. */
  29123. WarnedWebAudioUnsupported: boolean;
  29124. /**
  29125. * Defines if the audio engine relies on a custom unlocked button.
  29126. * In this case, the embedded button will not be displayed.
  29127. */
  29128. useCustomUnlockedButton: boolean;
  29129. /**
  29130. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  29131. */
  29132. readonly unlocked: boolean;
  29133. /**
  29134. * Event raised when audio has been unlocked on the browser.
  29135. */
  29136. onAudioUnlockedObservable: Observable<AudioEngine>;
  29137. /**
  29138. * Event raised when audio has been locked on the browser.
  29139. */
  29140. onAudioLockedObservable: Observable<AudioEngine>;
  29141. /**
  29142. * Flags the audio engine in Locked state.
  29143. * This happens due to new browser policies preventing audio to autoplay.
  29144. */
  29145. lock(): void;
  29146. /**
  29147. * Unlocks the audio engine once a user action has been done on the dom.
  29148. * This is helpful to resume play once browser policies have been satisfied.
  29149. */
  29150. unlock(): void;
  29151. }
  29152. /**
  29153. * This represents the default audio engine used in babylon.
  29154. * It is responsible to play, synchronize and analyse sounds throughout the application.
  29155. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29156. */
  29157. export class AudioEngine implements IAudioEngine {
  29158. private _audioContext;
  29159. private _audioContextInitialized;
  29160. private _muteButton;
  29161. private _hostElement;
  29162. /**
  29163. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29164. */
  29165. canUseWebAudio: boolean;
  29166. /**
  29167. * The master gain node defines the global audio volume of your audio engine.
  29168. */
  29169. masterGain: GainNode;
  29170. /**
  29171. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29172. * @ignoreNaming
  29173. */
  29174. WarnedWebAudioUnsupported: boolean;
  29175. /**
  29176. * Gets whether or not mp3 are supported by your browser.
  29177. */
  29178. isMP3supported: boolean;
  29179. /**
  29180. * Gets whether or not ogg are supported by your browser.
  29181. */
  29182. isOGGsupported: boolean;
  29183. /**
  29184. * Gets whether audio has been unlocked on the device.
  29185. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  29186. * a user interaction has happened.
  29187. */
  29188. unlocked: boolean;
  29189. /**
  29190. * Defines if the audio engine relies on a custom unlocked button.
  29191. * In this case, the embedded button will not be displayed.
  29192. */
  29193. useCustomUnlockedButton: boolean;
  29194. /**
  29195. * Event raised when audio has been unlocked on the browser.
  29196. */
  29197. onAudioUnlockedObservable: Observable<AudioEngine>;
  29198. /**
  29199. * Event raised when audio has been locked on the browser.
  29200. */
  29201. onAudioLockedObservable: Observable<AudioEngine>;
  29202. /**
  29203. * Gets the current AudioContext if available.
  29204. */
  29205. readonly audioContext: Nullable<AudioContext>;
  29206. private _connectedAnalyser;
  29207. /**
  29208. * Instantiates a new audio engine.
  29209. *
  29210. * There should be only one per page as some browsers restrict the number
  29211. * of audio contexts you can create.
  29212. * @param hostElement defines the host element where to display the mute icon if necessary
  29213. */
  29214. constructor(hostElement?: Nullable<HTMLElement>);
  29215. /**
  29216. * Flags the audio engine in Locked state.
  29217. * This happens due to new browser policies preventing audio to autoplay.
  29218. */
  29219. lock(): void;
  29220. /**
  29221. * Unlocks the audio engine once a user action has been done on the dom.
  29222. * This is helpful to resume play once browser policies have been satisfied.
  29223. */
  29224. unlock(): void;
  29225. private _resumeAudioContext;
  29226. private _initializeAudioContext;
  29227. private _tryToRun;
  29228. private _triggerRunningState;
  29229. private _triggerSuspendedState;
  29230. private _displayMuteButton;
  29231. private _moveButtonToTopLeft;
  29232. private _onResize;
  29233. private _hideMuteButton;
  29234. /**
  29235. * Destroy and release the resources associated with the audio ccontext.
  29236. */
  29237. dispose(): void;
  29238. /**
  29239. * Gets the global volume sets on the master gain.
  29240. * @returns the global volume if set or -1 otherwise
  29241. */
  29242. getGlobalVolume(): number;
  29243. /**
  29244. * Sets the global volume of your experience (sets on the master gain).
  29245. * @param newVolume Defines the new global volume of the application
  29246. */
  29247. setGlobalVolume(newVolume: number): void;
  29248. /**
  29249. * Connect the audio engine to an audio analyser allowing some amazing
  29250. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  29251. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  29252. * @param analyser The analyser to connect to the engine
  29253. */
  29254. connectToAnalyser(analyser: Analyser): void;
  29255. }
  29256. }
  29257. declare module BABYLON {
  29258. /**
  29259. * Interface used to present a loading screen while loading a scene
  29260. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29261. */
  29262. export interface ILoadingScreen {
  29263. /**
  29264. * Function called to display the loading screen
  29265. */
  29266. displayLoadingUI: () => void;
  29267. /**
  29268. * Function called to hide the loading screen
  29269. */
  29270. hideLoadingUI: () => void;
  29271. /**
  29272. * Gets or sets the color to use for the background
  29273. */
  29274. loadingUIBackgroundColor: string;
  29275. /**
  29276. * Gets or sets the text to display while loading
  29277. */
  29278. loadingUIText: string;
  29279. }
  29280. /**
  29281. * Class used for the default loading screen
  29282. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29283. */
  29284. export class DefaultLoadingScreen implements ILoadingScreen {
  29285. private _renderingCanvas;
  29286. private _loadingText;
  29287. private _loadingDivBackgroundColor;
  29288. private _loadingDiv;
  29289. private _loadingTextDiv;
  29290. /** Gets or sets the logo url to use for the default loading screen */
  29291. static DefaultLogoUrl: string;
  29292. /** Gets or sets the spinner url to use for the default loading screen */
  29293. static DefaultSpinnerUrl: string;
  29294. /**
  29295. * Creates a new default loading screen
  29296. * @param _renderingCanvas defines the canvas used to render the scene
  29297. * @param _loadingText defines the default text to display
  29298. * @param _loadingDivBackgroundColor defines the default background color
  29299. */
  29300. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  29301. /**
  29302. * Function called to display the loading screen
  29303. */
  29304. displayLoadingUI(): void;
  29305. /**
  29306. * Function called to hide the loading screen
  29307. */
  29308. hideLoadingUI(): void;
  29309. /**
  29310. * Gets or sets the text to display while loading
  29311. */
  29312. loadingUIText: string;
  29313. /**
  29314. * Gets or sets the color to use for the background
  29315. */
  29316. loadingUIBackgroundColor: string;
  29317. private _resizeLoadingUI;
  29318. }
  29319. }
  29320. declare module BABYLON {
  29321. /** @hidden */
  29322. export class WebGLPipelineContext implements IPipelineContext {
  29323. engine: Engine;
  29324. program: Nullable<WebGLProgram>;
  29325. context?: WebGLRenderingContext;
  29326. vertexShader?: WebGLShader;
  29327. fragmentShader?: WebGLShader;
  29328. isParallelCompiled: boolean;
  29329. onCompiled?: () => void;
  29330. transformFeedback?: WebGLTransformFeedback | null;
  29331. readonly isAsync: boolean;
  29332. readonly isReady: boolean;
  29333. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  29334. }
  29335. }
  29336. declare module BABYLON {
  29337. /** @hidden */
  29338. export class WebGLDataBuffer extends DataBuffer {
  29339. private _buffer;
  29340. constructor(resource: WebGLBuffer);
  29341. readonly underlyingResource: any;
  29342. }
  29343. }
  29344. declare module BABYLON {
  29345. /** @hidden */
  29346. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29347. attributeProcessor(attribute: string): string;
  29348. varyingProcessor(varying: string, isFragment: boolean): string;
  29349. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29350. }
  29351. }
  29352. declare module BABYLON {
  29353. /**
  29354. * This class is used to track a performance counter which is number based.
  29355. * The user has access to many properties which give statistics of different nature.
  29356. *
  29357. * The implementer can track two kinds of Performance Counter: time and count.
  29358. * 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.
  29359. * 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.
  29360. */
  29361. export class PerfCounter {
  29362. /**
  29363. * Gets or sets a global boolean to turn on and off all the counters
  29364. */
  29365. static Enabled: boolean;
  29366. /**
  29367. * Returns the smallest value ever
  29368. */
  29369. readonly min: number;
  29370. /**
  29371. * Returns the biggest value ever
  29372. */
  29373. readonly max: number;
  29374. /**
  29375. * Returns the average value since the performance counter is running
  29376. */
  29377. readonly average: number;
  29378. /**
  29379. * Returns the average value of the last second the counter was monitored
  29380. */
  29381. readonly lastSecAverage: number;
  29382. /**
  29383. * Returns the current value
  29384. */
  29385. readonly current: number;
  29386. /**
  29387. * Gets the accumulated total
  29388. */
  29389. readonly total: number;
  29390. /**
  29391. * Gets the total value count
  29392. */
  29393. readonly count: number;
  29394. /**
  29395. * Creates a new counter
  29396. */
  29397. constructor();
  29398. /**
  29399. * Call this method to start monitoring a new frame.
  29400. * 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.
  29401. */
  29402. fetchNewFrame(): void;
  29403. /**
  29404. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  29405. * @param newCount the count value to add to the monitored count
  29406. * @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.
  29407. */
  29408. addCount(newCount: number, fetchResult: boolean): void;
  29409. /**
  29410. * Start monitoring this performance counter
  29411. */
  29412. beginMonitoring(): void;
  29413. /**
  29414. * Compute the time lapsed since the previous beginMonitoring() call.
  29415. * @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
  29416. */
  29417. endMonitoring(newFrame?: boolean): void;
  29418. private _fetchResult;
  29419. private _startMonitoringTime;
  29420. private _min;
  29421. private _max;
  29422. private _average;
  29423. private _current;
  29424. private _totalValueCount;
  29425. private _totalAccumulated;
  29426. private _lastSecAverage;
  29427. private _lastSecAccumulated;
  29428. private _lastSecTime;
  29429. private _lastSecValueCount;
  29430. }
  29431. }
  29432. declare module BABYLON {
  29433. /**
  29434. * Interface for any object that can request an animation frame
  29435. */
  29436. export interface ICustomAnimationFrameRequester {
  29437. /**
  29438. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  29439. */
  29440. renderFunction?: Function;
  29441. /**
  29442. * Called to request the next frame to render to
  29443. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  29444. */
  29445. requestAnimationFrame: Function;
  29446. /**
  29447. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  29448. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  29449. */
  29450. requestID?: number;
  29451. }
  29452. }
  29453. declare module BABYLON {
  29454. /**
  29455. * Settings for finer control over video usage
  29456. */
  29457. export interface VideoTextureSettings {
  29458. /**
  29459. * Applies `autoplay` to video, if specified
  29460. */
  29461. autoPlay?: boolean;
  29462. /**
  29463. * Applies `loop` to video, if specified
  29464. */
  29465. loop?: boolean;
  29466. /**
  29467. * Automatically updates internal texture from video at every frame in the render loop
  29468. */
  29469. autoUpdateTexture: boolean;
  29470. /**
  29471. * Image src displayed during the video loading or until the user interacts with the video.
  29472. */
  29473. poster?: string;
  29474. }
  29475. /**
  29476. * If you want to display a video in your scene, this is the special texture for that.
  29477. * This special texture works similar to other textures, with the exception of a few parameters.
  29478. * @see https://doc.babylonjs.com/how_to/video_texture
  29479. */
  29480. export class VideoTexture extends Texture {
  29481. /**
  29482. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29483. */
  29484. readonly autoUpdateTexture: boolean;
  29485. /**
  29486. * The video instance used by the texture internally
  29487. */
  29488. readonly video: HTMLVideoElement;
  29489. private _onUserActionRequestedObservable;
  29490. /**
  29491. * Event triggerd when a dom action is required by the user to play the video.
  29492. * This happens due to recent changes in browser policies preventing video to auto start.
  29493. */
  29494. readonly onUserActionRequestedObservable: Observable<Texture>;
  29495. private _generateMipMaps;
  29496. private _engine;
  29497. private _stillImageCaptured;
  29498. private _displayingPosterTexture;
  29499. private _settings;
  29500. private _createInternalTextureOnEvent;
  29501. private _frameId;
  29502. /**
  29503. * Creates a video texture.
  29504. * If you want to display a video in your scene, this is the special texture for that.
  29505. * This special texture works similar to other textures, with the exception of a few parameters.
  29506. * @see https://doc.babylonjs.com/how_to/video_texture
  29507. * @param name optional name, will detect from video source, if not defined
  29508. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29509. * @param scene is obviously the current scene.
  29510. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29511. * @param invertY is false by default but can be used to invert video on Y axis
  29512. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29513. * @param settings allows finer control over video usage
  29514. */
  29515. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29516. private _getName;
  29517. private _getVideo;
  29518. private _createInternalTexture;
  29519. private reset;
  29520. /**
  29521. * @hidden Internal method to initiate `update`.
  29522. */
  29523. _rebuild(): void;
  29524. /**
  29525. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29526. */
  29527. update(): void;
  29528. /**
  29529. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29530. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29531. */
  29532. updateTexture(isVisible: boolean): void;
  29533. protected _updateInternalTexture: () => void;
  29534. /**
  29535. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29536. * @param url New url.
  29537. */
  29538. updateURL(url: string): void;
  29539. /**
  29540. * Dispose the texture and release its associated resources.
  29541. */
  29542. dispose(): void;
  29543. /**
  29544. * Creates a video texture straight from a stream.
  29545. * @param scene Define the scene the texture should be created in
  29546. * @param stream Define the stream the texture should be created from
  29547. * @returns The created video texture as a promise
  29548. */
  29549. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29550. /**
  29551. * Creates a video texture straight from your WebCam video feed.
  29552. * @param scene Define the scene the texture should be created in
  29553. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29554. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29555. * @returns The created video texture as a promise
  29556. */
  29557. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29558. minWidth: number;
  29559. maxWidth: number;
  29560. minHeight: number;
  29561. maxHeight: number;
  29562. deviceId: string;
  29563. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29564. /**
  29565. * Creates a video texture straight from your WebCam video feed.
  29566. * @param scene Define the scene the texture should be created in
  29567. * @param onReady Define a callback to triggered once the texture will be ready
  29568. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29569. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29570. */
  29571. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29572. minWidth: number;
  29573. maxWidth: number;
  29574. minHeight: number;
  29575. maxHeight: number;
  29576. deviceId: string;
  29577. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29578. }
  29579. }
  29580. declare module BABYLON {
  29581. /**
  29582. * Defines the interface used by objects containing a viewport (like a camera)
  29583. */
  29584. interface IViewportOwnerLike {
  29585. /**
  29586. * Gets or sets the viewport
  29587. */
  29588. viewport: IViewportLike;
  29589. }
  29590. /**
  29591. * Interface for attribute information associated with buffer instanciation
  29592. */
  29593. export class InstancingAttributeInfo {
  29594. /**
  29595. * Index/offset of the attribute in the vertex shader
  29596. */
  29597. index: number;
  29598. /**
  29599. * size of the attribute, 1, 2, 3 or 4
  29600. */
  29601. attributeSize: number;
  29602. /**
  29603. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29604. * default is FLOAT
  29605. */
  29606. attribyteType: number;
  29607. /**
  29608. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29609. */
  29610. normalized: boolean;
  29611. /**
  29612. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29613. */
  29614. offset: number;
  29615. /**
  29616. * Name of the GLSL attribute, for debugging purpose only
  29617. */
  29618. attributeName: string;
  29619. }
  29620. /**
  29621. * Define options used to create a depth texture
  29622. */
  29623. export class DepthTextureCreationOptions {
  29624. /** Specifies whether or not a stencil should be allocated in the texture */
  29625. generateStencil?: boolean;
  29626. /** Specifies whether or not bilinear filtering is enable on the texture */
  29627. bilinearFiltering?: boolean;
  29628. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  29629. comparisonFunction?: number;
  29630. /** Specifies if the created texture is a cube texture */
  29631. isCube?: boolean;
  29632. }
  29633. /**
  29634. * Class used to describe the capabilities of the engine relatively to the current browser
  29635. */
  29636. export class EngineCapabilities {
  29637. /** Maximum textures units per fragment shader */
  29638. maxTexturesImageUnits: number;
  29639. /** Maximum texture units per vertex shader */
  29640. maxVertexTextureImageUnits: number;
  29641. /** Maximum textures units in the entire pipeline */
  29642. maxCombinedTexturesImageUnits: number;
  29643. /** Maximum texture size */
  29644. maxTextureSize: number;
  29645. /** Maximum cube texture size */
  29646. maxCubemapTextureSize: number;
  29647. /** Maximum render texture size */
  29648. maxRenderTextureSize: number;
  29649. /** Maximum number of vertex attributes */
  29650. maxVertexAttribs: number;
  29651. /** Maximum number of varyings */
  29652. maxVaryingVectors: number;
  29653. /** Maximum number of uniforms per vertex shader */
  29654. maxVertexUniformVectors: number;
  29655. /** Maximum number of uniforms per fragment shader */
  29656. maxFragmentUniformVectors: number;
  29657. /** Defines if standard derivates (dx/dy) are supported */
  29658. standardDerivatives: boolean;
  29659. /** Defines if s3tc texture compression is supported */
  29660. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  29661. /** Defines if pvrtc texture compression is supported */
  29662. pvrtc: any;
  29663. /** Defines if etc1 texture compression is supported */
  29664. etc1: any;
  29665. /** Defines if etc2 texture compression is supported */
  29666. etc2: any;
  29667. /** Defines if astc texture compression is supported */
  29668. astc: any;
  29669. /** Defines if float textures are supported */
  29670. textureFloat: boolean;
  29671. /** Defines if vertex array objects are supported */
  29672. vertexArrayObject: boolean;
  29673. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29674. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  29675. /** Gets the maximum level of anisotropy supported */
  29676. maxAnisotropy: number;
  29677. /** Defines if instancing is supported */
  29678. instancedArrays: boolean;
  29679. /** Defines if 32 bits indices are supported */
  29680. uintIndices: boolean;
  29681. /** Defines if high precision shaders are supported */
  29682. highPrecisionShaderSupported: boolean;
  29683. /** Defines if depth reading in the fragment shader is supported */
  29684. fragmentDepthSupported: boolean;
  29685. /** Defines if float texture linear filtering is supported*/
  29686. textureFloatLinearFiltering: boolean;
  29687. /** Defines if rendering to float textures is supported */
  29688. textureFloatRender: boolean;
  29689. /** Defines if half float textures are supported*/
  29690. textureHalfFloat: boolean;
  29691. /** Defines if half float texture linear filtering is supported*/
  29692. textureHalfFloatLinearFiltering: boolean;
  29693. /** Defines if rendering to half float textures is supported */
  29694. textureHalfFloatRender: boolean;
  29695. /** Defines if textureLOD shader command is supported */
  29696. textureLOD: boolean;
  29697. /** Defines if draw buffers extension is supported */
  29698. drawBuffersExtension: boolean;
  29699. /** Defines if depth textures are supported */
  29700. depthTextureExtension: boolean;
  29701. /** Defines if float color buffer are supported */
  29702. colorBufferFloat: boolean;
  29703. /** Gets disjoint timer query extension (null if not supported) */
  29704. timerQuery: EXT_disjoint_timer_query;
  29705. /** Defines if timestamp can be used with timer query */
  29706. canUseTimestampForTimerQuery: boolean;
  29707. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29708. multiview: any;
  29709. /** Function used to let the system compiles shaders in background */
  29710. parallelShaderCompile: {
  29711. COMPLETION_STATUS_KHR: number;
  29712. };
  29713. /** Max number of texture samples for MSAA */
  29714. maxMSAASamples: number;
  29715. }
  29716. /** Interface defining initialization parameters for Engine class */
  29717. export interface EngineOptions extends WebGLContextAttributes {
  29718. /**
  29719. * Defines if the engine should no exceed a specified device ratio
  29720. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29721. */
  29722. limitDeviceRatio?: number;
  29723. /**
  29724. * Defines if webvr should be enabled automatically
  29725. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29726. */
  29727. autoEnableWebVR?: boolean;
  29728. /**
  29729. * Defines if webgl2 should be turned off even if supported
  29730. * @see http://doc.babylonjs.com/features/webgl2
  29731. */
  29732. disableWebGL2Support?: boolean;
  29733. /**
  29734. * Defines if webaudio should be initialized as well
  29735. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29736. */
  29737. audioEngine?: boolean;
  29738. /**
  29739. * Defines if animations should run using a deterministic lock step
  29740. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29741. */
  29742. deterministicLockstep?: boolean;
  29743. /** Defines the maximum steps to use with deterministic lock step mode */
  29744. lockstepMaxSteps?: number;
  29745. /**
  29746. * Defines that engine should ignore context lost events
  29747. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29748. */
  29749. doNotHandleContextLost?: boolean;
  29750. /**
  29751. * Defines that engine should ignore modifying touch action attribute and style
  29752. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29753. */
  29754. doNotHandleTouchAction?: boolean;
  29755. /**
  29756. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29757. */
  29758. useHighPrecisionFloats?: boolean;
  29759. }
  29760. /**
  29761. * Defines the interface used by display changed events
  29762. */
  29763. export interface IDisplayChangedEventArgs {
  29764. /** Gets the vrDisplay object (if any) */
  29765. vrDisplay: Nullable<any>;
  29766. /** Gets a boolean indicating if webVR is supported */
  29767. vrSupported: boolean;
  29768. }
  29769. /**
  29770. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  29771. */
  29772. export class Engine {
  29773. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29774. static ExceptionList: ({
  29775. key: string;
  29776. capture: string;
  29777. captureConstraint: number;
  29778. targets: string[];
  29779. } | {
  29780. key: string;
  29781. capture: null;
  29782. captureConstraint: null;
  29783. targets: string[];
  29784. })[];
  29785. /** Gets the list of created engines */
  29786. static readonly Instances: Engine[];
  29787. /**
  29788. * Gets the latest created engine
  29789. */
  29790. static readonly LastCreatedEngine: Nullable<Engine>;
  29791. /**
  29792. * Gets the latest created scene
  29793. */
  29794. static readonly LastCreatedScene: Nullable<Scene>;
  29795. /**
  29796. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  29797. * @param flag defines which part of the materials must be marked as dirty
  29798. * @param predicate defines a predicate used to filter which materials should be affected
  29799. */
  29800. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  29801. /** @hidden */
  29802. static _TextureLoaders: IInternalTextureLoader[];
  29803. /** Defines that alpha blending is disabled */
  29804. static readonly ALPHA_DISABLE: number;
  29805. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  29806. static readonly ALPHA_ADD: number;
  29807. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  29808. static readonly ALPHA_COMBINE: number;
  29809. /** Defines that alpha blending to DEST - SRC * DEST */
  29810. static readonly ALPHA_SUBTRACT: number;
  29811. /** Defines that alpha blending to SRC * DEST */
  29812. static readonly ALPHA_MULTIPLY: number;
  29813. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  29814. static readonly ALPHA_MAXIMIZED: number;
  29815. /** Defines that alpha blending to SRC + DEST */
  29816. static readonly ALPHA_ONEONE: number;
  29817. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  29818. static readonly ALPHA_PREMULTIPLIED: number;
  29819. /**
  29820. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  29821. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  29822. */
  29823. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  29824. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  29825. static readonly ALPHA_INTERPOLATE: number;
  29826. /**
  29827. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  29828. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  29829. */
  29830. static readonly ALPHA_SCREENMODE: number;
  29831. /** Defines that the ressource is not delayed*/
  29832. static readonly DELAYLOADSTATE_NONE: number;
  29833. /** Defines that the ressource was successfully delay loaded */
  29834. static readonly DELAYLOADSTATE_LOADED: number;
  29835. /** Defines that the ressource is currently delay loading */
  29836. static readonly DELAYLOADSTATE_LOADING: number;
  29837. /** Defines that the ressource is delayed and has not started loading */
  29838. static readonly DELAYLOADSTATE_NOTLOADED: number;
  29839. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  29840. static readonly NEVER: number;
  29841. /** 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 */
  29842. static readonly ALWAYS: number;
  29843. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  29844. static readonly LESS: number;
  29845. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  29846. static readonly EQUAL: number;
  29847. /** 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 */
  29848. static readonly LEQUAL: number;
  29849. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  29850. static readonly GREATER: number;
  29851. /** 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 */
  29852. static readonly GEQUAL: number;
  29853. /** 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 */
  29854. static readonly NOTEQUAL: number;
  29855. /** Passed to stencilOperation to specify that stencil value must be kept */
  29856. static readonly KEEP: number;
  29857. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29858. static readonly REPLACE: number;
  29859. /** Passed to stencilOperation to specify that stencil value must be incremented */
  29860. static readonly INCR: number;
  29861. /** Passed to stencilOperation to specify that stencil value must be decremented */
  29862. static readonly DECR: number;
  29863. /** Passed to stencilOperation to specify that stencil value must be inverted */
  29864. static readonly INVERT: number;
  29865. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  29866. static readonly INCR_WRAP: number;
  29867. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  29868. static readonly DECR_WRAP: number;
  29869. /** Texture is not repeating outside of 0..1 UVs */
  29870. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  29871. /** Texture is repeating outside of 0..1 UVs */
  29872. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  29873. /** Texture is repeating and mirrored */
  29874. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  29875. /** ALPHA */
  29876. static readonly TEXTUREFORMAT_ALPHA: number;
  29877. /** LUMINANCE */
  29878. static readonly TEXTUREFORMAT_LUMINANCE: number;
  29879. /** LUMINANCE_ALPHA */
  29880. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  29881. /** RGB */
  29882. static readonly TEXTUREFORMAT_RGB: number;
  29883. /** RGBA */
  29884. static readonly TEXTUREFORMAT_RGBA: number;
  29885. /** RED */
  29886. static readonly TEXTUREFORMAT_RED: number;
  29887. /** RED (2nd reference) */
  29888. static readonly TEXTUREFORMAT_R: number;
  29889. /** RG */
  29890. static readonly TEXTUREFORMAT_RG: number;
  29891. /** RED_INTEGER */
  29892. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  29893. /** RED_INTEGER (2nd reference) */
  29894. static readonly TEXTUREFORMAT_R_INTEGER: number;
  29895. /** RG_INTEGER */
  29896. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  29897. /** RGB_INTEGER */
  29898. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  29899. /** RGBA_INTEGER */
  29900. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  29901. /** UNSIGNED_BYTE */
  29902. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  29903. /** UNSIGNED_BYTE (2nd reference) */
  29904. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  29905. /** FLOAT */
  29906. static readonly TEXTURETYPE_FLOAT: number;
  29907. /** HALF_FLOAT */
  29908. static readonly TEXTURETYPE_HALF_FLOAT: number;
  29909. /** BYTE */
  29910. static readonly TEXTURETYPE_BYTE: number;
  29911. /** SHORT */
  29912. static readonly TEXTURETYPE_SHORT: number;
  29913. /** UNSIGNED_SHORT */
  29914. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  29915. /** INT */
  29916. static readonly TEXTURETYPE_INT: number;
  29917. /** UNSIGNED_INT */
  29918. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  29919. /** UNSIGNED_SHORT_4_4_4_4 */
  29920. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  29921. /** UNSIGNED_SHORT_5_5_5_1 */
  29922. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  29923. /** UNSIGNED_SHORT_5_6_5 */
  29924. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  29925. /** UNSIGNED_INT_2_10_10_10_REV */
  29926. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  29927. /** UNSIGNED_INT_24_8 */
  29928. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  29929. /** UNSIGNED_INT_10F_11F_11F_REV */
  29930. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  29931. /** UNSIGNED_INT_5_9_9_9_REV */
  29932. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  29933. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  29934. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  29935. /** nearest is mag = nearest and min = nearest and mip = linear */
  29936. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  29937. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29938. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  29939. /** Trilinear is mag = linear and min = linear and mip = linear */
  29940. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  29941. /** nearest is mag = nearest and min = nearest and mip = linear */
  29942. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  29943. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29944. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  29945. /** Trilinear is mag = linear and min = linear and mip = linear */
  29946. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  29947. /** mag = nearest and min = nearest and mip = nearest */
  29948. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  29949. /** mag = nearest and min = linear and mip = nearest */
  29950. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  29951. /** mag = nearest and min = linear and mip = linear */
  29952. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  29953. /** mag = nearest and min = linear and mip = none */
  29954. static readonly TEXTURE_NEAREST_LINEAR: number;
  29955. /** mag = nearest and min = nearest and mip = none */
  29956. static readonly TEXTURE_NEAREST_NEAREST: number;
  29957. /** mag = linear and min = nearest and mip = nearest */
  29958. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  29959. /** mag = linear and min = nearest and mip = linear */
  29960. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  29961. /** mag = linear and min = linear and mip = none */
  29962. static readonly TEXTURE_LINEAR_LINEAR: number;
  29963. /** mag = linear and min = nearest and mip = none */
  29964. static readonly TEXTURE_LINEAR_NEAREST: number;
  29965. /** Explicit coordinates mode */
  29966. static readonly TEXTURE_EXPLICIT_MODE: number;
  29967. /** Spherical coordinates mode */
  29968. static readonly TEXTURE_SPHERICAL_MODE: number;
  29969. /** Planar coordinates mode */
  29970. static readonly TEXTURE_PLANAR_MODE: number;
  29971. /** Cubic coordinates mode */
  29972. static readonly TEXTURE_CUBIC_MODE: number;
  29973. /** Projection coordinates mode */
  29974. static readonly TEXTURE_PROJECTION_MODE: number;
  29975. /** Skybox coordinates mode */
  29976. static readonly TEXTURE_SKYBOX_MODE: number;
  29977. /** Inverse Cubic coordinates mode */
  29978. static readonly TEXTURE_INVCUBIC_MODE: number;
  29979. /** Equirectangular coordinates mode */
  29980. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  29981. /** Equirectangular Fixed coordinates mode */
  29982. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  29983. /** Equirectangular Fixed Mirrored coordinates mode */
  29984. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  29985. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  29986. static readonly SCALEMODE_FLOOR: number;
  29987. /** Defines that texture rescaling will look for the nearest power of 2 size */
  29988. static readonly SCALEMODE_NEAREST: number;
  29989. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  29990. static readonly SCALEMODE_CEILING: number;
  29991. /**
  29992. * Returns the current npm package of the sdk
  29993. */
  29994. static readonly NpmPackage: string;
  29995. /**
  29996. * Returns the current version of the framework
  29997. */
  29998. static readonly Version: string;
  29999. /**
  30000. * Returns a string describing the current engine
  30001. */
  30002. readonly description: string;
  30003. /**
  30004. * Gets or sets the epsilon value used by collision engine
  30005. */
  30006. static CollisionsEpsilon: number;
  30007. /**
  30008. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30009. */
  30010. static ShadersRepository: string;
  30011. /**
  30012. * Method called to create the default loading screen.
  30013. * This can be overriden in your own app.
  30014. * @param canvas The rendering canvas element
  30015. * @returns The loading screen
  30016. */
  30017. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  30018. /**
  30019. * Method called to create the default rescale post process on each engine.
  30020. */
  30021. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  30022. /** @hidden */
  30023. _shaderProcessor: IShaderProcessor;
  30024. /**
  30025. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30026. */
  30027. forcePOTTextures: boolean;
  30028. /**
  30029. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30030. */
  30031. isFullscreen: boolean;
  30032. /**
  30033. * Gets a boolean indicating if the pointer is currently locked
  30034. */
  30035. isPointerLock: boolean;
  30036. /**
  30037. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30038. */
  30039. cullBackFaces: boolean;
  30040. /**
  30041. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30042. */
  30043. renderEvenInBackground: boolean;
  30044. /**
  30045. * Gets or sets a boolean indicating that cache can be kept between frames
  30046. */
  30047. preventCacheWipeBetweenFrames: boolean;
  30048. /**
  30049. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  30050. **/
  30051. enableOfflineSupport: boolean;
  30052. /**
  30053. * 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)
  30054. **/
  30055. disableManifestCheck: boolean;
  30056. /**
  30057. * Gets the list of created scenes
  30058. */
  30059. scenes: Scene[];
  30060. /**
  30061. * Event raised when a new scene is created
  30062. */
  30063. onNewSceneAddedObservable: Observable<Scene>;
  30064. /**
  30065. * Gets the list of created postprocesses
  30066. */
  30067. postProcesses: PostProcess[];
  30068. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30069. validateShaderPrograms: boolean;
  30070. /**
  30071. * Observable event triggered each time the rendering canvas is resized
  30072. */
  30073. onResizeObservable: Observable<Engine>;
  30074. /**
  30075. * Observable event triggered each time the canvas loses focus
  30076. */
  30077. onCanvasBlurObservable: Observable<Engine>;
  30078. /**
  30079. * Observable event triggered each time the canvas gains focus
  30080. */
  30081. onCanvasFocusObservable: Observable<Engine>;
  30082. /**
  30083. * Observable event triggered each time the canvas receives pointerout event
  30084. */
  30085. onCanvasPointerOutObservable: Observable<PointerEvent>;
  30086. /**
  30087. * Observable event triggered before each texture is initialized
  30088. */
  30089. onBeforeTextureInitObservable: Observable<Texture>;
  30090. /**
  30091. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30092. */
  30093. disableUniformBuffers: boolean;
  30094. /** @hidden */
  30095. _uniformBuffers: UniformBuffer[];
  30096. /**
  30097. * Gets a boolean indicating that the engine supports uniform buffers
  30098. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30099. */
  30100. readonly supportsUniformBuffers: boolean;
  30101. /**
  30102. * Observable raised when the engine begins a new frame
  30103. */
  30104. onBeginFrameObservable: Observable<Engine>;
  30105. /**
  30106. * If set, will be used to request the next animation frame for the render loop
  30107. */
  30108. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  30109. /**
  30110. * Observable raised when the engine ends the current frame
  30111. */
  30112. onEndFrameObservable: Observable<Engine>;
  30113. /**
  30114. * Observable raised when the engine is about to compile a shader
  30115. */
  30116. onBeforeShaderCompilationObservable: Observable<Engine>;
  30117. /**
  30118. * Observable raised when the engine has jsut compiled a shader
  30119. */
  30120. onAfterShaderCompilationObservable: Observable<Engine>;
  30121. /** @hidden */
  30122. _gl: WebGLRenderingContext;
  30123. private _renderingCanvas;
  30124. private _windowIsBackground;
  30125. protected _webGLVersion: number;
  30126. protected _highPrecisionShadersAllowed: boolean;
  30127. /** @hidden */
  30128. readonly _shouldUseHighPrecisionShader: boolean;
  30129. /**
  30130. * Gets a boolean indicating that only power of 2 textures are supported
  30131. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30132. */
  30133. readonly needPOTTextures: boolean;
  30134. /** @hidden */
  30135. _badOS: boolean;
  30136. /** @hidden */
  30137. _badDesktopOS: boolean;
  30138. /**
  30139. * Gets the audio engine
  30140. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30141. * @ignorenaming
  30142. */
  30143. static audioEngine: IAudioEngine;
  30144. /**
  30145. * Default AudioEngine factory responsible of creating the Audio Engine.
  30146. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  30147. */
  30148. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  30149. /**
  30150. * Default offline support factory responsible of creating a tool used to store data locally.
  30151. * By default, this will create a Database object if the workload has been embedded.
  30152. */
  30153. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  30154. private _onFocus;
  30155. private _onBlur;
  30156. private _onCanvasPointerOut;
  30157. private _onCanvasBlur;
  30158. private _onCanvasFocus;
  30159. private _onFullscreenChange;
  30160. private _onPointerLockChange;
  30161. private _hardwareScalingLevel;
  30162. /** @hidden */
  30163. _caps: EngineCapabilities;
  30164. private _pointerLockRequested;
  30165. private _isStencilEnable;
  30166. protected _colorWrite: boolean;
  30167. private _loadingScreen;
  30168. /** @hidden */
  30169. _drawCalls: PerfCounter;
  30170. private _glVersion;
  30171. private _glRenderer;
  30172. private _glVendor;
  30173. private _videoTextureSupported;
  30174. private _renderingQueueLaunched;
  30175. private _activeRenderLoops;
  30176. private _deterministicLockstep;
  30177. private _lockstepMaxSteps;
  30178. /**
  30179. * Observable signaled when a context lost event is raised
  30180. */
  30181. onContextLostObservable: Observable<Engine>;
  30182. /**
  30183. * Observable signaled when a context restored event is raised
  30184. */
  30185. onContextRestoredObservable: Observable<Engine>;
  30186. private _onContextLost;
  30187. private _onContextRestored;
  30188. private _contextWasLost;
  30189. /** @hidden */
  30190. _doNotHandleContextLost: boolean;
  30191. /**
  30192. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30193. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30194. */
  30195. doNotHandleContextLost: boolean;
  30196. private _performanceMonitor;
  30197. private _fps;
  30198. private _deltaTime;
  30199. /**
  30200. * Turn this value on if you want to pause FPS computation when in background
  30201. */
  30202. disablePerformanceMonitorInBackground: boolean;
  30203. /**
  30204. * Gets the performance monitor attached to this engine
  30205. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  30206. */
  30207. readonly performanceMonitor: PerformanceMonitor;
  30208. /**
  30209. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30210. */
  30211. disableVertexArrayObjects: boolean;
  30212. /** @hidden */
  30213. protected _depthCullingState: _DepthCullingState;
  30214. /** @hidden */
  30215. protected _stencilState: _StencilState;
  30216. /** @hidden */
  30217. protected _alphaState: _AlphaState;
  30218. /** @hidden */
  30219. protected _alphaMode: number;
  30220. /** @hidden */
  30221. _internalTexturesCache: InternalTexture[];
  30222. /** @hidden */
  30223. protected _activeChannel: number;
  30224. private _currentTextureChannel;
  30225. /** @hidden */
  30226. protected _boundTexturesCache: {
  30227. [key: string]: Nullable<InternalTexture>;
  30228. };
  30229. /** @hidden */
  30230. protected _currentEffect: Nullable<Effect>;
  30231. /** @hidden */
  30232. protected _currentProgram: Nullable<WebGLProgram>;
  30233. private _compiledEffects;
  30234. private _vertexAttribArraysEnabled;
  30235. /** @hidden */
  30236. protected _cachedViewport: Nullable<IViewportLike>;
  30237. private _cachedVertexArrayObject;
  30238. /** @hidden */
  30239. protected _cachedVertexBuffers: any;
  30240. /** @hidden */
  30241. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30242. /** @hidden */
  30243. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30244. /** @hidden */
  30245. _currentRenderTarget: Nullable<InternalTexture>;
  30246. private _uintIndicesCurrentlySet;
  30247. private _currentBoundBuffer;
  30248. /** @hidden */
  30249. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30250. private _currentBufferPointers;
  30251. private _currentInstanceLocations;
  30252. private _currentInstanceBuffers;
  30253. private _textureUnits;
  30254. /** @hidden */
  30255. _workingCanvas: Nullable<HTMLCanvasElement>;
  30256. /** @hidden */
  30257. _workingContext: Nullable<CanvasRenderingContext2D>;
  30258. private _rescalePostProcess;
  30259. private _dummyFramebuffer;
  30260. private _externalData;
  30261. /** @hidden */
  30262. _bindedRenderFunction: any;
  30263. private _vaoRecordInProgress;
  30264. private _mustWipeVertexAttributes;
  30265. private _emptyTexture;
  30266. private _emptyCubeTexture;
  30267. private _emptyTexture3D;
  30268. /** @hidden */
  30269. _frameHandler: number;
  30270. private _nextFreeTextureSlots;
  30271. private _maxSimultaneousTextures;
  30272. private _activeRequests;
  30273. private _texturesSupported;
  30274. /** @hidden */
  30275. _textureFormatInUse: Nullable<string>;
  30276. /**
  30277. * Gets the list of texture formats supported
  30278. */
  30279. readonly texturesSupported: Array<string>;
  30280. /**
  30281. * Gets the list of texture formats in use
  30282. */
  30283. readonly textureFormatInUse: Nullable<string>;
  30284. /**
  30285. * Gets the current viewport
  30286. */
  30287. readonly currentViewport: Nullable<IViewportLike>;
  30288. /**
  30289. * Gets the default empty texture
  30290. */
  30291. readonly emptyTexture: InternalTexture;
  30292. /**
  30293. * Gets the default empty 3D texture
  30294. */
  30295. readonly emptyTexture3D: InternalTexture;
  30296. /**
  30297. * Gets the default empty cube texture
  30298. */
  30299. readonly emptyCubeTexture: InternalTexture;
  30300. /**
  30301. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30302. */
  30303. readonly premultipliedAlpha: boolean;
  30304. /**
  30305. * Creates a new engine
  30306. * @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
  30307. * @param antialias defines enable antialiasing (default: false)
  30308. * @param options defines further options to be sent to the getContext() function
  30309. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30310. */
  30311. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30312. /**
  30313. * Initializes a webVR display and starts listening to display change events
  30314. * The onVRDisplayChangedObservable will be notified upon these changes
  30315. * @returns The onVRDisplayChangedObservable
  30316. */
  30317. initWebVR(): Observable<IDisplayChangedEventArgs>;
  30318. /** @hidden */
  30319. _prepareVRComponent(): void;
  30320. /** @hidden */
  30321. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  30322. /** @hidden */
  30323. _submitVRFrame(): void;
  30324. /**
  30325. * Call this function to leave webVR mode
  30326. * Will do nothing if webVR is not supported or if there is no webVR device
  30327. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30328. */
  30329. disableVR(): void;
  30330. /**
  30331. * Gets a boolean indicating that the system is in VR mode and is presenting
  30332. * @returns true if VR mode is engaged
  30333. */
  30334. isVRPresenting(): boolean;
  30335. /** @hidden */
  30336. _requestVRFrame(): void;
  30337. private _disableTouchAction;
  30338. private _rebuildInternalTextures;
  30339. private _rebuildEffects;
  30340. /**
  30341. * Gets a boolean indicating if all created effects are ready
  30342. * @returns true if all effects are ready
  30343. */
  30344. areAllEffectsReady(): boolean;
  30345. private _rebuildBuffers;
  30346. private _initGLContext;
  30347. /**
  30348. * Gets version of the current webGL context
  30349. */
  30350. readonly webGLVersion: number;
  30351. /**
  30352. * Gets a string idenfifying the name of the class
  30353. * @returns "Engine" string
  30354. */
  30355. getClassName(): string;
  30356. /**
  30357. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30358. */
  30359. readonly isStencilEnable: boolean;
  30360. /** @hidden */
  30361. _prepareWorkingCanvas(): void;
  30362. /**
  30363. * Reset the texture cache to empty state
  30364. */
  30365. resetTextureCache(): void;
  30366. /**
  30367. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  30368. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30369. * @returns true if engine is in deterministic lock step mode
  30370. */
  30371. isDeterministicLockStep(): boolean;
  30372. /**
  30373. * Gets the max steps when engine is running in deterministic lock step
  30374. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30375. * @returns the max steps
  30376. */
  30377. getLockstepMaxSteps(): number;
  30378. /**
  30379. * Gets an object containing information about the current webGL context
  30380. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30381. */
  30382. getGlInfo(): {
  30383. vendor: string;
  30384. renderer: string;
  30385. version: string;
  30386. };
  30387. /**
  30388. * Gets current aspect ratio
  30389. * @param viewportOwner defines the camera to use to get the aspect ratio
  30390. * @param useScreen defines if screen size must be used (or the current render target if any)
  30391. * @returns a number defining the aspect ratio
  30392. */
  30393. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  30394. /**
  30395. * Gets current screen aspect ratio
  30396. * @returns a number defining the aspect ratio
  30397. */
  30398. getScreenAspectRatio(): number;
  30399. /**
  30400. * Gets the current render width
  30401. * @param useScreen defines if screen size must be used (or the current render target if any)
  30402. * @returns a number defining the current render width
  30403. */
  30404. getRenderWidth(useScreen?: boolean): number;
  30405. /**
  30406. * Gets the current render height
  30407. * @param useScreen defines if screen size must be used (or the current render target if any)
  30408. * @returns a number defining the current render height
  30409. */
  30410. getRenderHeight(useScreen?: boolean): number;
  30411. /**
  30412. * Gets the HTML canvas attached with the current webGL context
  30413. * @returns a HTML canvas
  30414. */
  30415. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30416. /**
  30417. * Gets host window
  30418. * @returns the host window object
  30419. */
  30420. getHostWindow(): Window;
  30421. /**
  30422. * Gets host document
  30423. * @returns the host document object
  30424. */
  30425. getHostDocument(): Document;
  30426. /**
  30427. * Gets the client rect of the HTML canvas attached with the current webGL context
  30428. * @returns a client rectanglee
  30429. */
  30430. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  30431. /**
  30432. * Defines the hardware scaling level.
  30433. * By default the hardware scaling level is computed from the window device ratio.
  30434. * 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.
  30435. * @param level defines the level to use
  30436. */
  30437. setHardwareScalingLevel(level: number): void;
  30438. /**
  30439. * Gets the current hardware scaling level.
  30440. * By default the hardware scaling level is computed from the window device ratio.
  30441. * 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.
  30442. * @returns a number indicating the current hardware scaling level
  30443. */
  30444. getHardwareScalingLevel(): number;
  30445. /**
  30446. * Gets the list of loaded textures
  30447. * @returns an array containing all loaded textures
  30448. */
  30449. getLoadedTexturesCache(): InternalTexture[];
  30450. /**
  30451. * Gets the object containing all engine capabilities
  30452. * @returns the EngineCapabilities object
  30453. */
  30454. getCaps(): EngineCapabilities;
  30455. /**
  30456. * Gets the current depth function
  30457. * @returns a number defining the depth function
  30458. */
  30459. getDepthFunction(): Nullable<number>;
  30460. /**
  30461. * Sets the current depth function
  30462. * @param depthFunc defines the function to use
  30463. */
  30464. setDepthFunction(depthFunc: number): void;
  30465. /**
  30466. * Sets the current depth function to GREATER
  30467. */
  30468. setDepthFunctionToGreater(): void;
  30469. /**
  30470. * Sets the current depth function to GEQUAL
  30471. */
  30472. setDepthFunctionToGreaterOrEqual(): void;
  30473. /**
  30474. * Sets the current depth function to LESS
  30475. */
  30476. setDepthFunctionToLess(): void;
  30477. private _cachedStencilBuffer;
  30478. private _cachedStencilFunction;
  30479. private _cachedStencilMask;
  30480. private _cachedStencilOperationPass;
  30481. private _cachedStencilOperationFail;
  30482. private _cachedStencilOperationDepthFail;
  30483. private _cachedStencilReference;
  30484. /**
  30485. * Caches the the state of the stencil buffer
  30486. */
  30487. cacheStencilState(): void;
  30488. /**
  30489. * Restores the state of the stencil buffer
  30490. */
  30491. restoreStencilState(): void;
  30492. /**
  30493. * Sets the current depth function to LEQUAL
  30494. */
  30495. setDepthFunctionToLessOrEqual(): void;
  30496. /**
  30497. * Gets a boolean indicating if stencil buffer is enabled
  30498. * @returns the current stencil buffer state
  30499. */
  30500. getStencilBuffer(): boolean;
  30501. /**
  30502. * Enable or disable the stencil buffer
  30503. * @param enable defines if the stencil buffer must be enabled or disabled
  30504. */
  30505. setStencilBuffer(enable: boolean): void;
  30506. /**
  30507. * Gets the current stencil mask
  30508. * @returns a number defining the new stencil mask to use
  30509. */
  30510. getStencilMask(): number;
  30511. /**
  30512. * Sets the current stencil mask
  30513. * @param mask defines the new stencil mask to use
  30514. */
  30515. setStencilMask(mask: number): void;
  30516. /**
  30517. * Gets the current stencil function
  30518. * @returns a number defining the stencil function to use
  30519. */
  30520. getStencilFunction(): number;
  30521. /**
  30522. * Gets the current stencil reference value
  30523. * @returns a number defining the stencil reference value to use
  30524. */
  30525. getStencilFunctionReference(): number;
  30526. /**
  30527. * Gets the current stencil mask
  30528. * @returns a number defining the stencil mask to use
  30529. */
  30530. getStencilFunctionMask(): number;
  30531. /**
  30532. * Sets the current stencil function
  30533. * @param stencilFunc defines the new stencil function to use
  30534. */
  30535. setStencilFunction(stencilFunc: number): void;
  30536. /**
  30537. * Sets the current stencil reference
  30538. * @param reference defines the new stencil reference to use
  30539. */
  30540. setStencilFunctionReference(reference: number): void;
  30541. /**
  30542. * Sets the current stencil mask
  30543. * @param mask defines the new stencil mask to use
  30544. */
  30545. setStencilFunctionMask(mask: number): void;
  30546. /**
  30547. * Gets the current stencil operation when stencil fails
  30548. * @returns a number defining stencil operation to use when stencil fails
  30549. */
  30550. getStencilOperationFail(): number;
  30551. /**
  30552. * Gets the current stencil operation when depth fails
  30553. * @returns a number defining stencil operation to use when depth fails
  30554. */
  30555. getStencilOperationDepthFail(): number;
  30556. /**
  30557. * Gets the current stencil operation when stencil passes
  30558. * @returns a number defining stencil operation to use when stencil passes
  30559. */
  30560. getStencilOperationPass(): number;
  30561. /**
  30562. * Sets the stencil operation to use when stencil fails
  30563. * @param operation defines the stencil operation to use when stencil fails
  30564. */
  30565. setStencilOperationFail(operation: number): void;
  30566. /**
  30567. * Sets the stencil operation to use when depth fails
  30568. * @param operation defines the stencil operation to use when depth fails
  30569. */
  30570. setStencilOperationDepthFail(operation: number): void;
  30571. /**
  30572. * Sets the stencil operation to use when stencil passes
  30573. * @param operation defines the stencil operation to use when stencil passes
  30574. */
  30575. setStencilOperationPass(operation: number): void;
  30576. /**
  30577. * Sets a boolean indicating if the dithering state is enabled or disabled
  30578. * @param value defines the dithering state
  30579. */
  30580. setDitheringState(value: boolean): void;
  30581. /**
  30582. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  30583. * @param value defines the rasterizer state
  30584. */
  30585. setRasterizerState(value: boolean): void;
  30586. /**
  30587. * stop executing a render loop function and remove it from the execution array
  30588. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30589. */
  30590. stopRenderLoop(renderFunction?: () => void): void;
  30591. /** @hidden */
  30592. _renderLoop(): void;
  30593. /**
  30594. * Can be used to override the current requestAnimationFrame requester.
  30595. * @hidden
  30596. */
  30597. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30598. /**
  30599. * Register and execute a render loop. The engine can have more than one render function
  30600. * @param renderFunction defines the function to continuously execute
  30601. */
  30602. runRenderLoop(renderFunction: () => void): void;
  30603. /**
  30604. * Toggle full screen mode
  30605. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30606. */
  30607. switchFullscreen(requestPointerLock: boolean): void;
  30608. /**
  30609. * Enters full screen mode
  30610. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30611. */
  30612. enterFullscreen(requestPointerLock: boolean): void;
  30613. /**
  30614. * Exits full screen mode
  30615. */
  30616. exitFullscreen(): void;
  30617. /**
  30618. * Enters Pointerlock mode
  30619. */
  30620. enterPointerlock(): void;
  30621. /**
  30622. * Exits Pointerlock mode
  30623. */
  30624. exitPointerlock(): void;
  30625. /**
  30626. * Clear the current render buffer or the current render target (if any is set up)
  30627. * @param color defines the color to use
  30628. * @param backBuffer defines if the back buffer must be cleared
  30629. * @param depth defines if the depth buffer must be cleared
  30630. * @param stencil defines if the stencil buffer must be cleared
  30631. */
  30632. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30633. /**
  30634. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  30635. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30636. * @param y defines the y-coordinate of the corner of the clear rectangle
  30637. * @param width defines the width of the clear rectangle
  30638. * @param height defines the height of the clear rectangle
  30639. * @param clearColor defines the clear color
  30640. */
  30641. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  30642. /**
  30643. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  30644. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30645. * @param y defines the y-coordinate of the corner of the clear rectangle
  30646. * @param width defines the width of the clear rectangle
  30647. * @param height defines the height of the clear rectangle
  30648. */
  30649. enableScissor(x: number, y: number, width: number, height: number): void;
  30650. /**
  30651. * Disable previously set scissor test rectangle
  30652. */
  30653. disableScissor(): void;
  30654. private _viewportCached;
  30655. /** @hidden */
  30656. _viewport(x: number, y: number, width: number, height: number): void;
  30657. /**
  30658. * Set the WebGL's viewport
  30659. * @param viewport defines the viewport element to be used
  30660. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30661. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30662. */
  30663. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30664. /**
  30665. * Directly set the WebGL Viewport
  30666. * @param x defines the x coordinate of the viewport (in screen space)
  30667. * @param y defines the y coordinate of the viewport (in screen space)
  30668. * @param width defines the width of the viewport (in screen space)
  30669. * @param height defines the height of the viewport (in screen space)
  30670. * @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
  30671. */
  30672. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  30673. /**
  30674. * Begin a new frame
  30675. */
  30676. beginFrame(): void;
  30677. /**
  30678. * Enf the current frame
  30679. */
  30680. endFrame(): void;
  30681. /**
  30682. * Resize the view according to the canvas' size
  30683. */
  30684. resize(): void;
  30685. /**
  30686. * Force a specific size of the canvas
  30687. * @param width defines the new canvas' width
  30688. * @param height defines the new canvas' height
  30689. */
  30690. setSize(width: number, height: number): void;
  30691. /**
  30692. * Binds the frame buffer to the specified texture.
  30693. * @param texture The texture to render to or null for the default canvas
  30694. * @param faceIndex The face of the texture to render to in case of cube texture
  30695. * @param requiredWidth The width of the target to render to
  30696. * @param requiredHeight The height of the target to render to
  30697. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30698. * @param depthStencilTexture The depth stencil texture to use to render
  30699. * @param lodLevel defines le lod level to bind to the frame buffer
  30700. */
  30701. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30702. /** @hidden */
  30703. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30704. /**
  30705. * Unbind the current render target texture from the webGL context
  30706. * @param texture defines the render target texture to unbind
  30707. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30708. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30709. */
  30710. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30711. /**
  30712. * Force the mipmap generation for the given render target texture
  30713. * @param texture defines the render target texture to use
  30714. */
  30715. generateMipMapsForCubemap(texture: InternalTexture): void;
  30716. /**
  30717. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30718. */
  30719. flushFramebuffer(): void;
  30720. /**
  30721. * Unbind the current render target and bind the default framebuffer
  30722. */
  30723. restoreDefaultFramebuffer(): void;
  30724. /**
  30725. * Create an uniform buffer
  30726. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30727. * @param elements defines the content of the uniform buffer
  30728. * @returns the webGL uniform buffer
  30729. */
  30730. createUniformBuffer(elements: FloatArray): DataBuffer;
  30731. /**
  30732. * Create a dynamic uniform buffer
  30733. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30734. * @param elements defines the content of the uniform buffer
  30735. * @returns the webGL uniform buffer
  30736. */
  30737. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  30738. /**
  30739. * Update an existing uniform buffer
  30740. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30741. * @param uniformBuffer defines the target uniform buffer
  30742. * @param elements defines the content to update
  30743. * @param offset defines the offset in the uniform buffer where update should start
  30744. * @param count defines the size of the data to update
  30745. */
  30746. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  30747. private _resetVertexBufferBinding;
  30748. /**
  30749. * Creates a vertex buffer
  30750. * @param data the data for the vertex buffer
  30751. * @returns the new WebGL static buffer
  30752. */
  30753. createVertexBuffer(data: DataArray): DataBuffer;
  30754. /**
  30755. * Creates a dynamic vertex buffer
  30756. * @param data the data for the dynamic vertex buffer
  30757. * @returns the new WebGL dynamic buffer
  30758. */
  30759. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30760. /**
  30761. * Update a dynamic index buffer
  30762. * @param indexBuffer defines the target index buffer
  30763. * @param indices defines the data to update
  30764. * @param offset defines the offset in the target index buffer where update should start
  30765. */
  30766. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  30767. /**
  30768. * Updates a dynamic vertex buffer.
  30769. * @param vertexBuffer the vertex buffer to update
  30770. * @param data the data used to update the vertex buffer
  30771. * @param byteOffset the byte offset of the data
  30772. * @param byteLength the byte length of the data
  30773. */
  30774. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  30775. private _resetIndexBufferBinding;
  30776. /**
  30777. * Creates a new index buffer
  30778. * @param indices defines the content of the index buffer
  30779. * @param updatable defines if the index buffer must be updatable
  30780. * @returns a new webGL buffer
  30781. */
  30782. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30783. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30784. /**
  30785. * Bind a webGL buffer to the webGL context
  30786. * @param buffer defines the buffer to bind
  30787. */
  30788. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30789. /**
  30790. * Bind an uniform buffer to the current webGL context
  30791. * @param buffer defines the buffer to bind
  30792. */
  30793. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  30794. /**
  30795. * Bind a buffer to the current webGL context at a given location
  30796. * @param buffer defines the buffer to bind
  30797. * @param location defines the index where to bind the buffer
  30798. */
  30799. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  30800. /**
  30801. * Bind a specific block at a given index in a specific shader program
  30802. * @param pipelineContext defines the pipeline context to use
  30803. * @param blockName defines the block name
  30804. * @param index defines the index where to bind the block
  30805. */
  30806. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  30807. private bindIndexBuffer;
  30808. private bindBuffer;
  30809. /**
  30810. * update the bound buffer with the given data
  30811. * @param data defines the data to update
  30812. */
  30813. updateArrayBuffer(data: Float32Array): void;
  30814. private _vertexAttribPointer;
  30815. private _bindIndexBufferWithCache;
  30816. private _bindVertexBuffersAttributes;
  30817. /**
  30818. * Records a vertex array object
  30819. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30820. * @param vertexBuffers defines the list of vertex buffers to store
  30821. * @param indexBuffer defines the index buffer to store
  30822. * @param effect defines the effect to store
  30823. * @returns the new vertex array object
  30824. */
  30825. recordVertexArrayObject(vertexBuffers: {
  30826. [key: string]: VertexBuffer;
  30827. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30828. /**
  30829. * Bind a specific vertex array object
  30830. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30831. * @param vertexArrayObject defines the vertex array object to bind
  30832. * @param indexBuffer defines the index buffer to bind
  30833. */
  30834. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30835. /**
  30836. * Bind webGl buffers directly to the webGL context
  30837. * @param vertexBuffer defines the vertex buffer to bind
  30838. * @param indexBuffer defines the index buffer to bind
  30839. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30840. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30841. * @param effect defines the effect associated with the vertex buffer
  30842. */
  30843. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30844. private _unbindVertexArrayObject;
  30845. /**
  30846. * Bind a list of vertex buffers to the webGL context
  30847. * @param vertexBuffers defines the list of vertex buffers to bind
  30848. * @param indexBuffer defines the index buffer to bind
  30849. * @param effect defines the effect associated with the vertex buffers
  30850. */
  30851. bindBuffers(vertexBuffers: {
  30852. [key: string]: Nullable<VertexBuffer>;
  30853. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30854. /**
  30855. * Unbind all instance attributes
  30856. */
  30857. unbindInstanceAttributes(): void;
  30858. /**
  30859. * Release and free the memory of a vertex array object
  30860. * @param vao defines the vertex array object to delete
  30861. */
  30862. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30863. /** @hidden */
  30864. _releaseBuffer(buffer: DataBuffer): boolean;
  30865. protected _deleteBuffer(buffer: DataBuffer): void;
  30866. /**
  30867. * Creates a webGL buffer to use with instanciation
  30868. * @param capacity defines the size of the buffer
  30869. * @returns the webGL buffer
  30870. */
  30871. createInstancesBuffer(capacity: number): DataBuffer;
  30872. /**
  30873. * Delete a webGL buffer used with instanciation
  30874. * @param buffer defines the webGL buffer to delete
  30875. */
  30876. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  30877. /**
  30878. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30879. * @param instancesBuffer defines the webGL buffer to update and bind
  30880. * @param data defines the data to store in the buffer
  30881. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30882. */
  30883. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30884. /**
  30885. * Apply all cached states (depth, culling, stencil and alpha)
  30886. */
  30887. applyStates(): void;
  30888. /**
  30889. * Send a draw order
  30890. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30891. * @param indexStart defines the starting index
  30892. * @param indexCount defines the number of index to draw
  30893. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30894. */
  30895. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30896. /**
  30897. * Draw a list of points
  30898. * @param verticesStart defines the index of first vertex to draw
  30899. * @param verticesCount defines the count of vertices to draw
  30900. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30901. */
  30902. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30903. /**
  30904. * Draw a list of unindexed primitives
  30905. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30906. * @param verticesStart defines the index of first vertex to draw
  30907. * @param verticesCount defines the count of vertices to draw
  30908. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30909. */
  30910. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30911. /**
  30912. * Draw a list of indexed primitives
  30913. * @param fillMode defines the primitive to use
  30914. * @param indexStart defines the starting index
  30915. * @param indexCount defines the number of index to draw
  30916. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30917. */
  30918. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30919. /**
  30920. * Draw a list of unindexed primitives
  30921. * @param fillMode defines the primitive to use
  30922. * @param verticesStart defines the index of first vertex to draw
  30923. * @param verticesCount defines the count of vertices to draw
  30924. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30925. */
  30926. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30927. private _drawMode;
  30928. /** @hidden */
  30929. _releaseEffect(effect: Effect): void;
  30930. /** @hidden */
  30931. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30932. /**
  30933. * Create a new effect (used to store vertex/fragment shaders)
  30934. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30935. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  30936. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30937. * @param samplers defines an array of string used to represent textures
  30938. * @param defines defines the string containing the defines to use to compile the shaders
  30939. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30940. * @param onCompiled defines a function to call when the effect creation is successful
  30941. * @param onError defines a function to call when the effect creation has failed
  30942. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30943. * @returns the new Effect
  30944. */
  30945. 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;
  30946. protected static _concatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30947. private _compileShader;
  30948. private _compileRawShader;
  30949. /**
  30950. * Directly creates a webGL program
  30951. * @param pipelineContext defines the pipeline context to attach to
  30952. * @param vertexCode defines the vertex shader code to use
  30953. * @param fragmentCode defines the fragment shader code to use
  30954. * @param context defines the webGL context to use (if not set, the current one will be used)
  30955. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30956. * @returns the new webGL program
  30957. */
  30958. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30959. /**
  30960. * Creates a webGL program
  30961. * @param pipelineContext defines the pipeline context to attach to
  30962. * @param vertexCode defines the vertex shader code to use
  30963. * @param fragmentCode defines the fragment shader code to use
  30964. * @param defines defines the string containing the defines to use to compile the shaders
  30965. * @param context defines the webGL context to use (if not set, the current one will be used)
  30966. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30967. * @returns the new webGL program
  30968. */
  30969. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30970. /**
  30971. * Creates a new pipeline context
  30972. * @returns the new pipeline
  30973. */
  30974. createPipelineContext(): IPipelineContext;
  30975. private _createShaderProgram;
  30976. private _finalizePipelineContext;
  30977. /** @hidden */
  30978. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30979. /** @hidden */
  30980. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30981. /** @hidden */
  30982. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30983. /**
  30984. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30985. * @param pipelineContext defines the pipeline context to use
  30986. * @param uniformsNames defines the list of uniform names
  30987. * @returns an array of webGL uniform locations
  30988. */
  30989. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30990. /**
  30991. * Gets the lsit of active attributes for a given webGL program
  30992. * @param pipelineContext defines the pipeline context to use
  30993. * @param attributesNames defines the list of attribute names to get
  30994. * @returns an array of indices indicating the offset of each attribute
  30995. */
  30996. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30997. /**
  30998. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30999. * @param effect defines the effect to activate
  31000. */
  31001. enableEffect(effect: Nullable<Effect>): void;
  31002. /**
  31003. * Set the value of an uniform to an array of int32
  31004. * @param uniform defines the webGL uniform location where to store the value
  31005. * @param array defines the array of int32 to store
  31006. */
  31007. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31008. /**
  31009. * Set the value of an uniform to an array of int32 (stored as vec2)
  31010. * @param uniform defines the webGL uniform location where to store the value
  31011. * @param array defines the array of int32 to store
  31012. */
  31013. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31014. /**
  31015. * Set the value of an uniform to an array of int32 (stored as vec3)
  31016. * @param uniform defines the webGL uniform location where to store the value
  31017. * @param array defines the array of int32 to store
  31018. */
  31019. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31020. /**
  31021. * Set the value of an uniform to an array of int32 (stored as vec4)
  31022. * @param uniform defines the webGL uniform location where to store the value
  31023. * @param array defines the array of int32 to store
  31024. */
  31025. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31026. /**
  31027. * Set the value of an uniform to an array of float32
  31028. * @param uniform defines the webGL uniform location where to store the value
  31029. * @param array defines the array of float32 to store
  31030. */
  31031. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31032. /**
  31033. * Set the value of an uniform to an array of float32 (stored as vec2)
  31034. * @param uniform defines the webGL uniform location where to store the value
  31035. * @param array defines the array of float32 to store
  31036. */
  31037. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31038. /**
  31039. * Set the value of an uniform to an array of float32 (stored as vec3)
  31040. * @param uniform defines the webGL uniform location where to store the value
  31041. * @param array defines the array of float32 to store
  31042. */
  31043. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31044. /**
  31045. * Set the value of an uniform to an array of float32 (stored as vec4)
  31046. * @param uniform defines the webGL uniform location where to store the value
  31047. * @param array defines the array of float32 to store
  31048. */
  31049. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31050. /**
  31051. * Set the value of an uniform to an array of number
  31052. * @param uniform defines the webGL uniform location where to store the value
  31053. * @param array defines the array of number to store
  31054. */
  31055. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31056. /**
  31057. * Set the value of an uniform to an array of number (stored as vec2)
  31058. * @param uniform defines the webGL uniform location where to store the value
  31059. * @param array defines the array of number to store
  31060. */
  31061. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31062. /**
  31063. * Set the value of an uniform to an array of number (stored as vec3)
  31064. * @param uniform defines the webGL uniform location where to store the value
  31065. * @param array defines the array of number to store
  31066. */
  31067. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31068. /**
  31069. * Set the value of an uniform to an array of number (stored as vec4)
  31070. * @param uniform defines the webGL uniform location where to store the value
  31071. * @param array defines the array of number to store
  31072. */
  31073. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31074. /**
  31075. * Set the value of an uniform to an array of float32 (stored as matrices)
  31076. * @param uniform defines the webGL uniform location where to store the value
  31077. * @param matrices defines the array of float32 to store
  31078. */
  31079. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31080. /**
  31081. * Set the value of an uniform to a matrix (3x3)
  31082. * @param uniform defines the webGL uniform location where to store the value
  31083. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31084. */
  31085. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31086. /**
  31087. * Set the value of an uniform to a matrix (2x2)
  31088. * @param uniform defines the webGL uniform location where to store the value
  31089. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31090. */
  31091. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31092. /**
  31093. * Set the value of an uniform to a number (int)
  31094. * @param uniform defines the webGL uniform location where to store the value
  31095. * @param value defines the int number to store
  31096. */
  31097. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31098. /**
  31099. * Set the value of an uniform to a number (float)
  31100. * @param uniform defines the webGL uniform location where to store the value
  31101. * @param value defines the float number to store
  31102. */
  31103. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31104. /**
  31105. * Set the value of an uniform to a vec2
  31106. * @param uniform defines the webGL uniform location where to store the value
  31107. * @param x defines the 1st component of the value
  31108. * @param y defines the 2nd component of the value
  31109. */
  31110. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31111. /**
  31112. * Set the value of an uniform to a vec3
  31113. * @param uniform defines the webGL uniform location where to store the value
  31114. * @param x defines the 1st component of the value
  31115. * @param y defines the 2nd component of the value
  31116. * @param z defines the 3rd component of the value
  31117. */
  31118. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31119. /**
  31120. * Set the value of an uniform to a boolean
  31121. * @param uniform defines the webGL uniform location where to store the value
  31122. * @param bool defines the boolean to store
  31123. */
  31124. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  31125. /**
  31126. * Set the value of an uniform to a vec4
  31127. * @param uniform defines the webGL uniform location where to store the value
  31128. * @param x defines the 1st component of the value
  31129. * @param y defines the 2nd component of the value
  31130. * @param z defines the 3rd component of the value
  31131. * @param w defines the 4th component of the value
  31132. */
  31133. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31134. /**
  31135. * Sets a Color4 on a uniform variable
  31136. * @param uniform defines the uniform location
  31137. * @param color4 defines the value to be set
  31138. */
  31139. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  31140. /**
  31141. * Set various states to the webGL context
  31142. * @param culling defines backface culling state
  31143. * @param zOffset defines the value to apply to zOffset (0 by default)
  31144. * @param force defines if states must be applied even if cache is up to date
  31145. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31146. */
  31147. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31148. /**
  31149. * Set the z offset to apply to current rendering
  31150. * @param value defines the offset to apply
  31151. */
  31152. setZOffset(value: number): void;
  31153. /**
  31154. * Gets the current value of the zOffset
  31155. * @returns the current zOffset state
  31156. */
  31157. getZOffset(): number;
  31158. /**
  31159. * Enable or disable depth buffering
  31160. * @param enable defines the state to set
  31161. */
  31162. setDepthBuffer(enable: boolean): void;
  31163. /**
  31164. * Gets a boolean indicating if depth writing is enabled
  31165. * @returns the current depth writing state
  31166. */
  31167. getDepthWrite(): boolean;
  31168. /**
  31169. * Enable or disable depth writing
  31170. * @param enable defines the state to set
  31171. */
  31172. setDepthWrite(enable: boolean): void;
  31173. /**
  31174. * Enable or disable color writing
  31175. * @param enable defines the state to set
  31176. */
  31177. setColorWrite(enable: boolean): void;
  31178. /**
  31179. * Gets a boolean indicating if color writing is enabled
  31180. * @returns the current color writing state
  31181. */
  31182. getColorWrite(): boolean;
  31183. /**
  31184. * Sets alpha constants used by some alpha blending modes
  31185. * @param r defines the red component
  31186. * @param g defines the green component
  31187. * @param b defines the blue component
  31188. * @param a defines the alpha component
  31189. */
  31190. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31191. /**
  31192. * Sets the current alpha mode
  31193. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31194. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31195. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31196. */
  31197. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31198. /**
  31199. * Gets the current alpha mode
  31200. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31201. * @returns the current alpha mode
  31202. */
  31203. getAlphaMode(): number;
  31204. /**
  31205. * Clears the list of texture accessible through engine.
  31206. * This can help preventing texture load conflict due to name collision.
  31207. */
  31208. clearInternalTexturesCache(): void;
  31209. /**
  31210. * Force the entire cache to be cleared
  31211. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31212. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31213. */
  31214. wipeCaches(bruteForce?: boolean): void;
  31215. /**
  31216. * Set the compressed texture format to use, based on the formats you have, and the formats
  31217. * supported by the hardware / browser.
  31218. *
  31219. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31220. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31221. * to API arguments needed to compressed textures. This puts the burden on the container
  31222. * generator to house the arcane code for determining these for current & future formats.
  31223. *
  31224. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31225. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31226. *
  31227. * Note: The result of this call is not taken into account when a texture is base64.
  31228. *
  31229. * @param formatsAvailable defines the list of those format families you have created
  31230. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31231. *
  31232. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31233. * @returns The extension selected.
  31234. */
  31235. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31236. /** @hidden */
  31237. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31238. min: number;
  31239. mag: number;
  31240. };
  31241. /** @hidden */
  31242. _createTexture(): WebGLTexture;
  31243. /**
  31244. * Usually called from Texture.ts.
  31245. * Passed information to create a WebGLTexture
  31246. * @param urlArg defines a value which contains one of the following:
  31247. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31248. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31249. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31250. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31251. * @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)
  31252. * @param scene needed for loading to the correct scene
  31253. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31254. * @param onLoad optional callback to be called upon successful completion
  31255. * @param onError optional callback to be called upon failure
  31256. * @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
  31257. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31258. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31259. * @param forcedExtension defines the extension to use to pick the right loader
  31260. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31261. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31262. */
  31263. 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 | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  31264. /**
  31265. * @hidden
  31266. * Rescales a texture
  31267. * @param source input texutre
  31268. * @param destination destination texture
  31269. * @param scene scene to use to render the resize
  31270. * @param internalFormat format to use when resizing
  31271. * @param onComplete callback to be called when resize has completed
  31272. */
  31273. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  31274. private _unpackFlipYCached;
  31275. /**
  31276. * In case you are sharing the context with other applications, it might
  31277. * be interested to not cache the unpack flip y state to ensure a consistent
  31278. * value would be set.
  31279. */
  31280. enableUnpackFlipYCached: boolean;
  31281. /** @hidden */
  31282. _unpackFlipY(value: boolean): void;
  31283. /** @hidden */
  31284. _getUnpackAlignement(): number;
  31285. /**
  31286. * Creates a dynamic texture
  31287. * @param width defines the width of the texture
  31288. * @param height defines the height of the texture
  31289. * @param generateMipMaps defines if the engine should generate the mip levels
  31290. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31291. * @returns the dynamic texture inside an InternalTexture
  31292. */
  31293. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  31294. /**
  31295. * Update the sampling mode of a given texture
  31296. * @param samplingMode defines the required sampling mode
  31297. * @param texture defines the texture to update
  31298. */
  31299. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  31300. /**
  31301. * Update the content of a dynamic texture
  31302. * @param texture defines the texture to update
  31303. * @param canvas defines the canvas containing the source
  31304. * @param invertY defines if data must be stored with Y axis inverted
  31305. * @param premulAlpha defines if alpha is stored as premultiplied
  31306. * @param format defines the format of the data
  31307. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  31308. */
  31309. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  31310. /**
  31311. * Update a video texture
  31312. * @param texture defines the texture to update
  31313. * @param video defines the video element to use
  31314. * @param invertY defines if data must be stored with Y axis inverted
  31315. */
  31316. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31317. /**
  31318. * Updates a depth texture Comparison Mode and Function.
  31319. * If the comparison Function is equal to 0, the mode will be set to none.
  31320. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  31321. * @param texture The texture to set the comparison function for
  31322. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  31323. */
  31324. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  31325. /** @hidden */
  31326. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31327. width: number;
  31328. height: number;
  31329. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31330. /**
  31331. * Creates a depth stencil texture.
  31332. * This is only available in WebGL 2 or with the depth texture extension available.
  31333. * @param size The size of face edge in the texture.
  31334. * @param options The options defining the texture.
  31335. * @returns The texture
  31336. */
  31337. createDepthStencilTexture(size: number | {
  31338. width: number;
  31339. height: number;
  31340. }, options: DepthTextureCreationOptions): InternalTexture;
  31341. /**
  31342. * Creates a depth stencil texture.
  31343. * This is only available in WebGL 2 or with the depth texture extension available.
  31344. * @param size The size of face edge in the texture.
  31345. * @param options The options defining the texture.
  31346. * @returns The texture
  31347. */
  31348. private _createDepthStencilTexture;
  31349. /**
  31350. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31351. * @param renderTarget The render target to set the frame buffer for
  31352. */
  31353. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  31354. /**
  31355. * Creates a new render target texture
  31356. * @param size defines the size of the texture
  31357. * @param options defines the options used to create the texture
  31358. * @returns a new render target texture stored in an InternalTexture
  31359. */
  31360. createRenderTargetTexture(size: number | {
  31361. width: number;
  31362. height: number;
  31363. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  31364. /** @hidden */
  31365. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31366. /**
  31367. * Updates the sample count of a render target texture
  31368. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31369. * @param texture defines the texture to update
  31370. * @param samples defines the sample count to set
  31371. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31372. */
  31373. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  31374. /** @hidden */
  31375. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31376. /** @hidden */
  31377. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31378. /** @hidden */
  31379. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31380. /** @hidden */
  31381. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  31382. /**
  31383. * @hidden
  31384. */
  31385. _setCubeMapTextureParams(loadMipmap: boolean): void;
  31386. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<Scene>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31387. private _prepareWebGLTexture;
  31388. /** @hidden */
  31389. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  31390. /** @hidden */
  31391. _releaseFramebufferObjects(texture: InternalTexture): void;
  31392. /** @hidden */
  31393. _releaseTexture(texture: InternalTexture): void;
  31394. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31395. protected _setProgram(program: WebGLProgram): void;
  31396. protected _boundUniforms: {
  31397. [key: number]: WebGLUniformLocation;
  31398. };
  31399. /**
  31400. * Binds an effect to the webGL context
  31401. * @param effect defines the effect to bind
  31402. */
  31403. bindSamplers(effect: Effect): void;
  31404. private _activateCurrentTexture;
  31405. /** @hidden */
  31406. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31407. /** @hidden */
  31408. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31409. /**
  31410. * Sets a texture to the webGL context from a postprocess
  31411. * @param channel defines the channel to use
  31412. * @param postProcess defines the source postprocess
  31413. */
  31414. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  31415. /**
  31416. * Binds the output of the passed in post process to the texture channel specified
  31417. * @param channel The channel the texture should be bound to
  31418. * @param postProcess The post process which's output should be bound
  31419. */
  31420. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  31421. /**
  31422. * Unbind all textures from the webGL context
  31423. */
  31424. unbindAllTextures(): void;
  31425. /**
  31426. * Sets a texture to the according uniform.
  31427. * @param channel The texture channel
  31428. * @param uniform The uniform to set
  31429. * @param texture The texture to apply
  31430. */
  31431. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31432. /**
  31433. * Sets a depth stencil texture from a render target to the according uniform.
  31434. * @param channel The texture channel
  31435. * @param uniform The uniform to set
  31436. * @param texture The render target texture containing the depth stencil texture to apply
  31437. */
  31438. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  31439. private _bindSamplerUniformToChannel;
  31440. private _getTextureWrapMode;
  31441. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31442. /**
  31443. * Sets an array of texture to the webGL context
  31444. * @param channel defines the channel where the texture array must be set
  31445. * @param uniform defines the associated uniform location
  31446. * @param textures defines the array of textures to bind
  31447. */
  31448. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31449. /** @hidden */
  31450. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31451. private _setTextureParameterFloat;
  31452. private _setTextureParameterInteger;
  31453. /**
  31454. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31455. * @param x defines the x coordinate of the rectangle where pixels must be read
  31456. * @param y defines the y coordinate of the rectangle where pixels must be read
  31457. * @param width defines the width of the rectangle where pixels must be read
  31458. * @param height defines the height of the rectangle where pixels must be read
  31459. * @returns a Uint8Array containing RGBA colors
  31460. */
  31461. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  31462. /**
  31463. * Add an externaly attached data from its key.
  31464. * This method call will fail and return false, if such key already exists.
  31465. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  31466. * @param key the unique key that identifies the data
  31467. * @param data the data object to associate to the key for this Engine instance
  31468. * @return true if no such key were already present and the data was added successfully, false otherwise
  31469. */
  31470. addExternalData<T>(key: string, data: T): boolean;
  31471. /**
  31472. * Get an externaly attached data from its key
  31473. * @param key the unique key that identifies the data
  31474. * @return the associated data, if present (can be null), or undefined if not present
  31475. */
  31476. getExternalData<T>(key: string): T;
  31477. /**
  31478. * Get an externaly attached data from its key, create it using a factory if it's not already present
  31479. * @param key the unique key that identifies the data
  31480. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  31481. * @return the associated data, can be null if the factory returned null.
  31482. */
  31483. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  31484. /**
  31485. * Remove an externaly attached data from the Engine instance
  31486. * @param key the unique key that identifies the data
  31487. * @return true if the data was successfully removed, false if it doesn't exist
  31488. */
  31489. removeExternalData(key: string): boolean;
  31490. /**
  31491. * Unbind all vertex attributes from the webGL context
  31492. */
  31493. unbindAllAttributes(): void;
  31494. /**
  31495. * 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
  31496. */
  31497. releaseEffects(): void;
  31498. /**
  31499. * Dispose and release all associated resources
  31500. */
  31501. dispose(): void;
  31502. /**
  31503. * Display the loading screen
  31504. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31505. */
  31506. displayLoadingUI(): void;
  31507. /**
  31508. * Hide the loading screen
  31509. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31510. */
  31511. hideLoadingUI(): void;
  31512. /**
  31513. * Gets the current loading screen object
  31514. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31515. */
  31516. /**
  31517. * Sets the current loading screen object
  31518. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31519. */
  31520. loadingScreen: ILoadingScreen;
  31521. /**
  31522. * Sets the current loading screen text
  31523. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31524. */
  31525. loadingUIText: string;
  31526. /**
  31527. * Sets the current loading screen background color
  31528. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31529. */
  31530. loadingUIBackgroundColor: string;
  31531. /**
  31532. * Attach a new callback raised when context lost event is fired
  31533. * @param callback defines the callback to call
  31534. */
  31535. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31536. /**
  31537. * Attach a new callback raised when context restored event is fired
  31538. * @param callback defines the callback to call
  31539. */
  31540. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31541. /**
  31542. * Gets the source code of the vertex shader associated with a specific webGL program
  31543. * @param program defines the program to use
  31544. * @returns a string containing the source code of the vertex shader associated with the program
  31545. */
  31546. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  31547. /**
  31548. * Gets the source code of the fragment shader associated with a specific webGL program
  31549. * @param program defines the program to use
  31550. * @returns a string containing the source code of the fragment shader associated with the program
  31551. */
  31552. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  31553. /**
  31554. * Get the current error code of the webGL context
  31555. * @returns the error code
  31556. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31557. */
  31558. getError(): number;
  31559. /**
  31560. * Gets the current framerate
  31561. * @returns a number representing the framerate
  31562. */
  31563. getFps(): number;
  31564. /**
  31565. * Gets the time spent between current and previous frame
  31566. * @returns a number representing the delta time in ms
  31567. */
  31568. getDeltaTime(): number;
  31569. private _measureFps;
  31570. /** @hidden */
  31571. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  31572. private _canRenderToFloatFramebuffer;
  31573. private _canRenderToHalfFloatFramebuffer;
  31574. private _canRenderToFramebuffer;
  31575. /** @hidden */
  31576. _getWebGLTextureType(type: number): number;
  31577. /** @hidden */
  31578. _getInternalFormat(format: number): number;
  31579. /** @hidden */
  31580. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31581. /** @hidden */
  31582. _getRGBAMultiSampleBufferFormat(type: number): number;
  31583. /** @hidden */
  31584. _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;
  31585. /** @hidden */
  31586. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  31587. /**
  31588. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31589. * @returns true if the engine can be created
  31590. * @ignorenaming
  31591. */
  31592. static isSupported(): boolean;
  31593. /**
  31594. * Find the next highest power of two.
  31595. * @param x Number to start search from.
  31596. * @return Next highest power of two.
  31597. */
  31598. static CeilingPOT(x: number): number;
  31599. /**
  31600. * Find the next lowest power of two.
  31601. * @param x Number to start search from.
  31602. * @return Next lowest power of two.
  31603. */
  31604. static FloorPOT(x: number): number;
  31605. /**
  31606. * Find the nearest power of two.
  31607. * @param x Number to start search from.
  31608. * @return Next nearest power of two.
  31609. */
  31610. static NearestPOT(x: number): number;
  31611. /**
  31612. * Get the closest exponent of two
  31613. * @param value defines the value to approximate
  31614. * @param max defines the maximum value to return
  31615. * @param mode defines how to define the closest value
  31616. * @returns closest exponent of two of the given value
  31617. */
  31618. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31619. /**
  31620. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31621. * @param func - the function to be called
  31622. * @param requester - the object that will request the next frame. Falls back to window.
  31623. * @returns frame number
  31624. */
  31625. static QueueNewFrame(func: () => void, requester?: any): number;
  31626. /**
  31627. * Ask the browser to promote the current element to pointerlock mode
  31628. * @param element defines the DOM element to promote
  31629. */
  31630. static _RequestPointerlock(element: HTMLElement): void;
  31631. /**
  31632. * Asks the browser to exit pointerlock mode
  31633. */
  31634. static _ExitPointerlock(): void;
  31635. /**
  31636. * Ask the browser to promote the current element to fullscreen rendering mode
  31637. * @param element defines the DOM element to promote
  31638. */
  31639. static _RequestFullscreen(element: HTMLElement): void;
  31640. /**
  31641. * Asks the browser to exit fullscreen mode
  31642. */
  31643. static _ExitFullscreen(): void;
  31644. }
  31645. }
  31646. declare module BABYLON {
  31647. /**
  31648. * The engine store class is responsible to hold all the instances of Engine and Scene created
  31649. * during the life time of the application.
  31650. */
  31651. export class EngineStore {
  31652. /** Gets the list of created engines */
  31653. static Instances: Engine[];
  31654. /** @hidden */
  31655. static _LastCreatedScene: Nullable<Scene>;
  31656. /**
  31657. * Gets the latest created engine
  31658. */
  31659. static readonly LastCreatedEngine: Nullable<Engine>;
  31660. /**
  31661. * Gets the latest created scene
  31662. */
  31663. static readonly LastCreatedScene: Nullable<Scene>;
  31664. /**
  31665. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31666. * @ignorenaming
  31667. */
  31668. static UseFallbackTexture: boolean;
  31669. /**
  31670. * Texture content used if a texture cannot loaded
  31671. * @ignorenaming
  31672. */
  31673. static FallbackTexture: string;
  31674. }
  31675. }
  31676. declare module BABYLON {
  31677. /**
  31678. * Helper class that provides a small promise polyfill
  31679. */
  31680. export class PromisePolyfill {
  31681. /**
  31682. * Static function used to check if the polyfill is required
  31683. * If this is the case then the function will inject the polyfill to window.Promise
  31684. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31685. */
  31686. static Apply(force?: boolean): void;
  31687. }
  31688. }
  31689. declare module BABYLON {
  31690. /**
  31691. * Interface for screenshot methods with describe argument called `size` as object with options
  31692. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  31693. */
  31694. export interface IScreenshotSize {
  31695. /**
  31696. * number in pixels for canvas height
  31697. */
  31698. height?: number;
  31699. /**
  31700. * multiplier allowing render at a higher or lower resolution
  31701. * If value is defined then height and width will be ignored and taken from camera
  31702. */
  31703. precision?: number;
  31704. /**
  31705. * number in pixels for canvas width
  31706. */
  31707. width?: number;
  31708. }
  31709. }
  31710. declare module BABYLON {
  31711. interface IColor4Like {
  31712. r: float;
  31713. g: float;
  31714. b: float;
  31715. a: float;
  31716. }
  31717. /**
  31718. * Class containing a set of static utilities functions
  31719. */
  31720. export class Tools {
  31721. /**
  31722. * Gets or sets the base URL to use to load assets
  31723. */
  31724. static BaseUrl: string;
  31725. /**
  31726. * Enable/Disable Custom HTTP Request Headers globally.
  31727. * default = false
  31728. * @see CustomRequestHeaders
  31729. */
  31730. static UseCustomRequestHeaders: boolean;
  31731. /**
  31732. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31733. * i.e. when loading files, where the server/service expects an Authorization header
  31734. */
  31735. static CustomRequestHeaders: {
  31736. [key: string]: string;
  31737. };
  31738. /**
  31739. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31740. */
  31741. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31742. /**
  31743. * Default behaviour for cors in the application.
  31744. * It can be a string if the expected behavior is identical in the entire app.
  31745. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31746. */
  31747. static CorsBehavior: string | ((url: string | string[]) => string);
  31748. /**
  31749. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31750. * @ignorenaming
  31751. */
  31752. static UseFallbackTexture: boolean;
  31753. /**
  31754. * Use this object to register external classes like custom textures or material
  31755. * to allow the laoders to instantiate them
  31756. */
  31757. static RegisteredExternalClasses: {
  31758. [key: string]: Object;
  31759. };
  31760. /**
  31761. * Texture content used if a texture cannot loaded
  31762. * @ignorenaming
  31763. */
  31764. static fallbackTexture: string;
  31765. /**
  31766. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31767. * @param u defines the coordinate on X axis
  31768. * @param v defines the coordinate on Y axis
  31769. * @param width defines the width of the source data
  31770. * @param height defines the height of the source data
  31771. * @param pixels defines the source byte array
  31772. * @param color defines the output color
  31773. */
  31774. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  31775. /**
  31776. * Interpolates between a and b via alpha
  31777. * @param a The lower value (returned when alpha = 0)
  31778. * @param b The upper value (returned when alpha = 1)
  31779. * @param alpha The interpolation-factor
  31780. * @return The mixed value
  31781. */
  31782. static Mix(a: number, b: number, alpha: number): number;
  31783. /**
  31784. * Tries to instantiate a new object from a given class name
  31785. * @param className defines the class name to instantiate
  31786. * @returns the new object or null if the system was not able to do the instantiation
  31787. */
  31788. static Instantiate(className: string): any;
  31789. /**
  31790. * Provides a slice function that will work even on IE
  31791. * @param data defines the array to slice
  31792. * @param start defines the start of the data (optional)
  31793. * @param end defines the end of the data (optional)
  31794. * @returns the new sliced array
  31795. */
  31796. static Slice<T>(data: T, start?: number, end?: number): T;
  31797. /**
  31798. * Polyfill for setImmediate
  31799. * @param action defines the action to execute after the current execution block
  31800. */
  31801. static SetImmediate(action: () => void): void;
  31802. /**
  31803. * Function indicating if a number is an exponent of 2
  31804. * @param value defines the value to test
  31805. * @returns true if the value is an exponent of 2
  31806. */
  31807. static IsExponentOfTwo(value: number): boolean;
  31808. private static _tmpFloatArray;
  31809. /**
  31810. * Returns the nearest 32-bit single precision float representation of a Number
  31811. * @param value A Number. If the parameter is of a different type, it will get converted
  31812. * to a number or to NaN if it cannot be converted
  31813. * @returns number
  31814. */
  31815. static FloatRound(value: number): number;
  31816. /**
  31817. * Extracts the filename from a path
  31818. * @param path defines the path to use
  31819. * @returns the filename
  31820. */
  31821. static GetFilename(path: string): string;
  31822. /**
  31823. * Extracts the "folder" part of a path (everything before the filename).
  31824. * @param uri The URI to extract the info from
  31825. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31826. * @returns The "folder" part of the path
  31827. */
  31828. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31829. /**
  31830. * Extracts text content from a DOM element hierarchy
  31831. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31832. */
  31833. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31834. /**
  31835. * Convert an angle in radians to degrees
  31836. * @param angle defines the angle to convert
  31837. * @returns the angle in degrees
  31838. */
  31839. static ToDegrees(angle: number): number;
  31840. /**
  31841. * Convert an angle in degrees to radians
  31842. * @param angle defines the angle to convert
  31843. * @returns the angle in radians
  31844. */
  31845. static ToRadians(angle: number): number;
  31846. /**
  31847. * Encode a buffer to a base64 string
  31848. * @param buffer defines the buffer to encode
  31849. * @returns the encoded string
  31850. */
  31851. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31852. /**
  31853. * Returns an array if obj is not an array
  31854. * @param obj defines the object to evaluate as an array
  31855. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31856. * @returns either obj directly if obj is an array or a new array containing obj
  31857. */
  31858. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31859. /**
  31860. * Gets the pointer prefix to use
  31861. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31862. */
  31863. static GetPointerPrefix(): string;
  31864. /**
  31865. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31866. * @param url define the url we are trying
  31867. * @param element define the dom element where to configure the cors policy
  31868. */
  31869. static SetCorsBehavior(url: string | string[], element: {
  31870. crossOrigin: string | null;
  31871. }): void;
  31872. /**
  31873. * Removes unwanted characters from an url
  31874. * @param url defines the url to clean
  31875. * @returns the cleaned url
  31876. */
  31877. static CleanUrl(url: string): string;
  31878. /**
  31879. * Gets or sets a function used to pre-process url before using them to load assets
  31880. */
  31881. static PreprocessUrl: (url: string) => string;
  31882. /**
  31883. * Loads an image as an HTMLImageElement.
  31884. * @param input url string, ArrayBuffer, or Blob to load
  31885. * @param onLoad callback called when the image successfully loads
  31886. * @param onError callback called when the image fails to load
  31887. * @param offlineProvider offline provider for caching
  31888. * @returns the HTMLImageElement of the loaded image
  31889. */
  31890. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31891. /**
  31892. * Loads a file
  31893. * @param url url string, ArrayBuffer, or Blob to load
  31894. * @param onSuccess callback called when the file successfully loads
  31895. * @param onProgress callback called while file is loading (if the server supports this mode)
  31896. * @param offlineProvider defines the offline provider for caching
  31897. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31898. * @param onError callback called when the file fails to load
  31899. * @returns a file request object
  31900. */
  31901. 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;
  31902. /**
  31903. * Loads a file from a url
  31904. * @param url the file url to load
  31905. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  31906. */
  31907. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  31908. /**
  31909. * Load a script (identified by an url). When the url returns, the
  31910. * content of this file is added into a new script element, attached to the DOM (body element)
  31911. * @param scriptUrl defines the url of the script to laod
  31912. * @param onSuccess defines the callback called when the script is loaded
  31913. * @param onError defines the callback to call if an error occurs
  31914. * @param scriptId defines the id of the script element
  31915. */
  31916. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31917. /**
  31918. * Load an asynchronous script (identified by an url). When the url returns, the
  31919. * content of this file is added into a new script element, attached to the DOM (body element)
  31920. * @param scriptUrl defines the url of the script to laod
  31921. * @param scriptId defines the id of the script element
  31922. * @returns a promise request object
  31923. */
  31924. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  31925. /**
  31926. * Loads a file from a blob
  31927. * @param fileToLoad defines the blob to use
  31928. * @param callback defines the callback to call when data is loaded
  31929. * @param progressCallback defines the callback to call during loading process
  31930. * @returns a file request object
  31931. */
  31932. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31933. /**
  31934. * Loads a file
  31935. * @param fileToLoad defines the file to load
  31936. * @param callback defines the callback to call when data is loaded
  31937. * @param progressCallBack defines the callback to call during loading process
  31938. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31939. * @returns a file request object
  31940. */
  31941. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31942. /**
  31943. * Creates a data url from a given string content
  31944. * @param content defines the content to convert
  31945. * @returns the new data url link
  31946. */
  31947. static FileAsURL(content: string): string;
  31948. /**
  31949. * Format the given number to a specific decimal format
  31950. * @param value defines the number to format
  31951. * @param decimals defines the number of decimals to use
  31952. * @returns the formatted string
  31953. */
  31954. static Format(value: number, decimals?: number): string;
  31955. /**
  31956. * Tries to copy an object by duplicating every property
  31957. * @param source defines the source object
  31958. * @param destination defines the target object
  31959. * @param doNotCopyList defines a list of properties to avoid
  31960. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31961. */
  31962. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31963. /**
  31964. * Gets a boolean indicating if the given object has no own property
  31965. * @param obj defines the object to test
  31966. * @returns true if object has no own property
  31967. */
  31968. static IsEmpty(obj: any): boolean;
  31969. /**
  31970. * Function used to register events at window level
  31971. * @param windowElement defines the Window object to use
  31972. * @param events defines the events to register
  31973. */
  31974. static RegisterTopRootEvents(windowElement: Window, events: {
  31975. name: string;
  31976. handler: Nullable<(e: FocusEvent) => any>;
  31977. }[]): void;
  31978. /**
  31979. * Function used to unregister events from window level
  31980. * @param windowElement defines the Window object to use
  31981. * @param events defines the events to unregister
  31982. */
  31983. static UnregisterTopRootEvents(windowElement: Window, events: {
  31984. name: string;
  31985. handler: Nullable<(e: FocusEvent) => any>;
  31986. }[]): void;
  31987. /**
  31988. * @ignore
  31989. */
  31990. static _ScreenshotCanvas: HTMLCanvasElement;
  31991. /**
  31992. * Dumps the current bound framebuffer
  31993. * @param width defines the rendering width
  31994. * @param height defines the rendering height
  31995. * @param engine defines the hosting engine
  31996. * @param successCallback defines the callback triggered once the data are available
  31997. * @param mimeType defines the mime type of the result
  31998. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31999. */
  32000. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32001. /**
  32002. * Converts the canvas data to blob.
  32003. * This acts as a polyfill for browsers not supporting the to blob function.
  32004. * @param canvas Defines the canvas to extract the data from
  32005. * @param successCallback Defines the callback triggered once the data are available
  32006. * @param mimeType Defines the mime type of the result
  32007. */
  32008. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32009. /**
  32010. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32011. * @param successCallback defines the callback triggered once the data are available
  32012. * @param mimeType defines the mime type of the result
  32013. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32014. */
  32015. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32016. /**
  32017. * Downloads a blob in the browser
  32018. * @param blob defines the blob to download
  32019. * @param fileName defines the name of the downloaded file
  32020. */
  32021. static Download(blob: Blob, fileName: string): void;
  32022. /**
  32023. * Captures a screenshot of the current rendering
  32024. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32025. * @param engine defines the rendering engine
  32026. * @param camera defines the source camera
  32027. * @param size This parameter can be set to a single number or to an object with the
  32028. * following (optional) properties: precision, width, height. If a single number is passed,
  32029. * it will be used for both width and height. If an object is passed, the screenshot size
  32030. * will be derived from the parameters. The precision property is a multiplier allowing
  32031. * rendering at a higher or lower resolution
  32032. * @param successCallback defines the callback receives a single parameter which contains the
  32033. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32034. * src parameter of an <img> to display it
  32035. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32036. * Check your browser for supported MIME types
  32037. */
  32038. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32039. /**
  32040. * Captures a screenshot of the current rendering
  32041. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32042. * @param engine defines the rendering engine
  32043. * @param camera defines the source camera
  32044. * @param size This parameter can be set to a single number or to an object with the
  32045. * following (optional) properties: precision, width, height. If a single number is passed,
  32046. * it will be used for both width and height. If an object is passed, the screenshot size
  32047. * will be derived from the parameters. The precision property is a multiplier allowing
  32048. * rendering at a higher or lower resolution
  32049. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32050. * Check your browser for supported MIME types
  32051. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32052. * to the src parameter of an <img> to display it
  32053. */
  32054. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32055. /**
  32056. * Generates an image screenshot from the specified camera.
  32057. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32058. * @param engine The engine to use for rendering
  32059. * @param camera The camera to use for rendering
  32060. * @param size This parameter can be set to a single number or to an object with the
  32061. * following (optional) properties: precision, width, height. If a single number is passed,
  32062. * it will be used for both width and height. If an object is passed, the screenshot size
  32063. * will be derived from the parameters. The precision property is a multiplier allowing
  32064. * rendering at a higher or lower resolution
  32065. * @param successCallback The callback receives a single parameter which contains the
  32066. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32067. * src parameter of an <img> to display it
  32068. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32069. * Check your browser for supported MIME types
  32070. * @param samples Texture samples (default: 1)
  32071. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32072. * @param fileName A name for for the downloaded file.
  32073. */
  32074. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32075. /**
  32076. * Generates an image screenshot from the specified camera.
  32077. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32078. * @param engine The engine to use for rendering
  32079. * @param camera The camera to use for rendering
  32080. * @param size This parameter can be set to a single number or to an object with the
  32081. * following (optional) properties: precision, width, height. If a single number is passed,
  32082. * it will be used for both width and height. If an object is passed, the screenshot size
  32083. * will be derived from the parameters. The precision property is a multiplier allowing
  32084. * rendering at a higher or lower resolution
  32085. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32086. * Check your browser for supported MIME types
  32087. * @param samples Texture samples (default: 1)
  32088. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32089. * @param fileName A name for for the downloaded file.
  32090. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32091. * to the src parameter of an <img> to display it
  32092. */
  32093. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32094. /**
  32095. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32096. * Be aware Math.random() could cause collisions, but:
  32097. * "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"
  32098. * @returns a pseudo random id
  32099. */
  32100. static RandomId(): string;
  32101. /**
  32102. * Test if the given uri is a base64 string
  32103. * @param uri The uri to test
  32104. * @return True if the uri is a base64 string or false otherwise
  32105. */
  32106. static IsBase64(uri: string): boolean;
  32107. /**
  32108. * Decode the given base64 uri.
  32109. * @param uri The uri to decode
  32110. * @return The decoded base64 data.
  32111. */
  32112. static DecodeBase64(uri: string): ArrayBuffer;
  32113. /**
  32114. * Gets the absolute url.
  32115. * @param url the input url
  32116. * @return the absolute url
  32117. */
  32118. static GetAbsoluteUrl(url: string): string;
  32119. /**
  32120. * No log
  32121. */
  32122. static readonly NoneLogLevel: number;
  32123. /**
  32124. * Only message logs
  32125. */
  32126. static readonly MessageLogLevel: number;
  32127. /**
  32128. * Only warning logs
  32129. */
  32130. static readonly WarningLogLevel: number;
  32131. /**
  32132. * Only error logs
  32133. */
  32134. static readonly ErrorLogLevel: number;
  32135. /**
  32136. * All logs
  32137. */
  32138. static readonly AllLogLevel: number;
  32139. /**
  32140. * Gets a value indicating the number of loading errors
  32141. * @ignorenaming
  32142. */
  32143. static readonly errorsCount: number;
  32144. /**
  32145. * Callback called when a new log is added
  32146. */
  32147. static OnNewCacheEntry: (entry: string) => void;
  32148. /**
  32149. * Log a message to the console
  32150. * @param message defines the message to log
  32151. */
  32152. static Log(message: string): void;
  32153. /**
  32154. * Write a warning message to the console
  32155. * @param message defines the message to log
  32156. */
  32157. static Warn(message: string): void;
  32158. /**
  32159. * Write an error message to the console
  32160. * @param message defines the message to log
  32161. */
  32162. static Error(message: string): void;
  32163. /**
  32164. * Gets current log cache (list of logs)
  32165. */
  32166. static readonly LogCache: string;
  32167. /**
  32168. * Clears the log cache
  32169. */
  32170. static ClearLogCache(): void;
  32171. /**
  32172. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32173. */
  32174. static LogLevels: number;
  32175. /**
  32176. * Checks if the window object exists
  32177. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32178. */
  32179. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32180. /**
  32181. * No performance log
  32182. */
  32183. static readonly PerformanceNoneLogLevel: number;
  32184. /**
  32185. * Use user marks to log performance
  32186. */
  32187. static readonly PerformanceUserMarkLogLevel: number;
  32188. /**
  32189. * Log performance to the console
  32190. */
  32191. static readonly PerformanceConsoleLogLevel: number;
  32192. private static _performance;
  32193. /**
  32194. * Sets the current performance log level
  32195. */
  32196. static PerformanceLogLevel: number;
  32197. private static _StartPerformanceCounterDisabled;
  32198. private static _EndPerformanceCounterDisabled;
  32199. private static _StartUserMark;
  32200. private static _EndUserMark;
  32201. private static _StartPerformanceConsole;
  32202. private static _EndPerformanceConsole;
  32203. /**
  32204. * Starts a performance counter
  32205. */
  32206. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32207. /**
  32208. * Ends a specific performance coutner
  32209. */
  32210. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32211. /**
  32212. * Gets either window.performance.now() if supported or Date.now() else
  32213. */
  32214. static readonly Now: number;
  32215. /**
  32216. * This method will return the name of the class used to create the instance of the given object.
  32217. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32218. * @param object the object to get the class name from
  32219. * @param isType defines if the object is actually a type
  32220. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32221. */
  32222. static GetClassName(object: any, isType?: boolean): string;
  32223. /**
  32224. * Gets the first element of an array satisfying a given predicate
  32225. * @param array defines the array to browse
  32226. * @param predicate defines the predicate to use
  32227. * @returns null if not found or the element
  32228. */
  32229. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32230. /**
  32231. * This method will return the name of the full name of the class, including its owning module (if any).
  32232. * 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).
  32233. * @param object the object to get the class name from
  32234. * @param isType defines if the object is actually a type
  32235. * @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.
  32236. * @ignorenaming
  32237. */
  32238. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32239. /**
  32240. * Returns a promise that resolves after the given amount of time.
  32241. * @param delay Number of milliseconds to delay
  32242. * @returns Promise that resolves after the given amount of time
  32243. */
  32244. static DelayAsync(delay: number): Promise<void>;
  32245. }
  32246. /**
  32247. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32248. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32249. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32250. * @param name The name of the class, case should be preserved
  32251. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32252. */
  32253. export function className(name: string, module?: string): (target: Object) => void;
  32254. /**
  32255. * An implementation of a loop for asynchronous functions.
  32256. */
  32257. export class AsyncLoop {
  32258. /**
  32259. * Defines the number of iterations for the loop
  32260. */
  32261. iterations: number;
  32262. /**
  32263. * Defines the current index of the loop.
  32264. */
  32265. index: number;
  32266. private _done;
  32267. private _fn;
  32268. private _successCallback;
  32269. /**
  32270. * Constructor.
  32271. * @param iterations the number of iterations.
  32272. * @param func the function to run each iteration
  32273. * @param successCallback the callback that will be called upon succesful execution
  32274. * @param offset starting offset.
  32275. */
  32276. constructor(
  32277. /**
  32278. * Defines the number of iterations for the loop
  32279. */
  32280. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32281. /**
  32282. * Execute the next iteration. Must be called after the last iteration was finished.
  32283. */
  32284. executeNext(): void;
  32285. /**
  32286. * Break the loop and run the success callback.
  32287. */
  32288. breakLoop(): void;
  32289. /**
  32290. * Create and run an async loop.
  32291. * @param iterations the number of iterations.
  32292. * @param fn the function to run each iteration
  32293. * @param successCallback the callback that will be called upon succesful execution
  32294. * @param offset starting offset.
  32295. * @returns the created async loop object
  32296. */
  32297. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32298. /**
  32299. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32300. * @param iterations total number of iterations
  32301. * @param syncedIterations number of synchronous iterations in each async iteration.
  32302. * @param fn the function to call each iteration.
  32303. * @param callback a success call back that will be called when iterating stops.
  32304. * @param breakFunction a break condition (optional)
  32305. * @param timeout timeout settings for the setTimeout function. default - 0.
  32306. * @returns the created async loop object
  32307. */
  32308. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32309. }
  32310. }
  32311. declare module BABYLON {
  32312. /** @hidden */
  32313. export interface ICollisionCoordinator {
  32314. createCollider(): Collider;
  32315. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32316. init(scene: Scene): void;
  32317. }
  32318. /** @hidden */
  32319. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32320. private _scene;
  32321. private _scaledPosition;
  32322. private _scaledVelocity;
  32323. private _finalPosition;
  32324. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32325. createCollider(): Collider;
  32326. init(scene: Scene): void;
  32327. private _collideWithWorld;
  32328. }
  32329. }
  32330. declare module BABYLON {
  32331. /**
  32332. * Class used to manage all inputs for the scene.
  32333. */
  32334. export class InputManager {
  32335. /** The distance in pixel that you have to move to prevent some events */
  32336. static DragMovementThreshold: number;
  32337. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32338. static LongPressDelay: number;
  32339. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32340. static DoubleClickDelay: number;
  32341. /** If you need to check double click without raising a single click at first click, enable this flag */
  32342. static ExclusiveDoubleClickMode: boolean;
  32343. private _wheelEventName;
  32344. private _onPointerMove;
  32345. private _onPointerDown;
  32346. private _onPointerUp;
  32347. private _initClickEvent;
  32348. private _initActionManager;
  32349. private _delayedSimpleClick;
  32350. private _delayedSimpleClickTimeout;
  32351. private _previousDelayedSimpleClickTimeout;
  32352. private _meshPickProceed;
  32353. private _previousButtonPressed;
  32354. private _currentPickResult;
  32355. private _previousPickResult;
  32356. private _totalPointersPressed;
  32357. private _doubleClickOccured;
  32358. private _pointerOverMesh;
  32359. private _pickedDownMesh;
  32360. private _pickedUpMesh;
  32361. private _pointerX;
  32362. private _pointerY;
  32363. private _unTranslatedPointerX;
  32364. private _unTranslatedPointerY;
  32365. private _startingPointerPosition;
  32366. private _previousStartingPointerPosition;
  32367. private _startingPointerTime;
  32368. private _previousStartingPointerTime;
  32369. private _pointerCaptures;
  32370. private _onKeyDown;
  32371. private _onKeyUp;
  32372. private _onCanvasFocusObserver;
  32373. private _onCanvasBlurObserver;
  32374. private _scene;
  32375. /**
  32376. * Creates a new InputManager
  32377. * @param scene defines the hosting scene
  32378. */
  32379. constructor(scene: Scene);
  32380. /**
  32381. * Gets the mesh that is currently under the pointer
  32382. */
  32383. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32384. /**
  32385. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32386. */
  32387. readonly unTranslatedPointer: Vector2;
  32388. /**
  32389. * Gets or sets the current on-screen X position of the pointer
  32390. */
  32391. pointerX: number;
  32392. /**
  32393. * Gets or sets the current on-screen Y position of the pointer
  32394. */
  32395. pointerY: number;
  32396. private _updatePointerPosition;
  32397. private _processPointerMove;
  32398. private _setRayOnPointerInfo;
  32399. private _checkPrePointerObservable;
  32400. /**
  32401. * Use this method to simulate a pointer move on a mesh
  32402. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32403. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32404. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32405. */
  32406. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32407. /**
  32408. * Use this method to simulate a pointer down on a mesh
  32409. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32410. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32411. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32412. */
  32413. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32414. private _processPointerDown;
  32415. /** @hidden */
  32416. _isPointerSwiping(): boolean;
  32417. /**
  32418. * Use this method to simulate a pointer up on a mesh
  32419. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32420. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32421. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32422. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32423. */
  32424. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32425. private _processPointerUp;
  32426. /**
  32427. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32428. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32429. * @returns true if the pointer was captured
  32430. */
  32431. isPointerCaptured(pointerId?: number): boolean;
  32432. /**
  32433. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32434. * @param attachUp defines if you want to attach events to pointerup
  32435. * @param attachDown defines if you want to attach events to pointerdown
  32436. * @param attachMove defines if you want to attach events to pointermove
  32437. */
  32438. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32439. /**
  32440. * Detaches all event handlers
  32441. */
  32442. detachControl(): void;
  32443. /**
  32444. * Force the value of meshUnderPointer
  32445. * @param mesh defines the mesh to use
  32446. */
  32447. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32448. /**
  32449. * Gets the mesh under the pointer
  32450. * @returns a Mesh or null if no mesh is under the pointer
  32451. */
  32452. getPointerOverMesh(): Nullable<AbstractMesh>;
  32453. }
  32454. }
  32455. declare module BABYLON {
  32456. /**
  32457. * Helper class used to generate session unique ID
  32458. */
  32459. export class UniqueIdGenerator {
  32460. private static _UniqueIdCounter;
  32461. /**
  32462. * Gets an unique (relatively to the current scene) Id
  32463. */
  32464. static readonly UniqueId: number;
  32465. }
  32466. }
  32467. declare module BABYLON {
  32468. /**
  32469. * This class defines the direct association between an animation and a target
  32470. */
  32471. export class TargetedAnimation {
  32472. /**
  32473. * Animation to perform
  32474. */
  32475. animation: Animation;
  32476. /**
  32477. * Target to animate
  32478. */
  32479. target: any;
  32480. /**
  32481. * Serialize the object
  32482. * @returns the JSON object representing the current entity
  32483. */
  32484. serialize(): any;
  32485. }
  32486. /**
  32487. * Use this class to create coordinated animations on multiple targets
  32488. */
  32489. export class AnimationGroup implements IDisposable {
  32490. /** The name of the animation group */
  32491. name: string;
  32492. private _scene;
  32493. private _targetedAnimations;
  32494. private _animatables;
  32495. private _from;
  32496. private _to;
  32497. private _isStarted;
  32498. private _isPaused;
  32499. private _speedRatio;
  32500. private _loopAnimation;
  32501. /**
  32502. * Gets or sets the unique id of the node
  32503. */
  32504. uniqueId: number;
  32505. /**
  32506. * This observable will notify when one animation have ended
  32507. */
  32508. onAnimationEndObservable: Observable<TargetedAnimation>;
  32509. /**
  32510. * Observer raised when one animation loops
  32511. */
  32512. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32513. /**
  32514. * This observable will notify when all animations have ended.
  32515. */
  32516. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32517. /**
  32518. * This observable will notify when all animations have paused.
  32519. */
  32520. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32521. /**
  32522. * This observable will notify when all animations are playing.
  32523. */
  32524. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32525. /**
  32526. * Gets the first frame
  32527. */
  32528. readonly from: number;
  32529. /**
  32530. * Gets the last frame
  32531. */
  32532. readonly to: number;
  32533. /**
  32534. * Define if the animations are started
  32535. */
  32536. readonly isStarted: boolean;
  32537. /**
  32538. * Gets a value indicating that the current group is playing
  32539. */
  32540. readonly isPlaying: boolean;
  32541. /**
  32542. * Gets or sets the speed ratio to use for all animations
  32543. */
  32544. /**
  32545. * Gets or sets the speed ratio to use for all animations
  32546. */
  32547. speedRatio: number;
  32548. /**
  32549. * Gets or sets if all animations should loop or not
  32550. */
  32551. loopAnimation: boolean;
  32552. /**
  32553. * Gets the targeted animations for this animation group
  32554. */
  32555. readonly targetedAnimations: Array<TargetedAnimation>;
  32556. /**
  32557. * returning the list of animatables controlled by this animation group.
  32558. */
  32559. readonly animatables: Array<Animatable>;
  32560. /**
  32561. * Instantiates a new Animation Group.
  32562. * This helps managing several animations at once.
  32563. * @see http://doc.babylonjs.com/how_to/group
  32564. * @param name Defines the name of the group
  32565. * @param scene Defines the scene the group belongs to
  32566. */
  32567. constructor(
  32568. /** The name of the animation group */
  32569. name: string, scene?: Nullable<Scene>);
  32570. /**
  32571. * Add an animation (with its target) in the group
  32572. * @param animation defines the animation we want to add
  32573. * @param target defines the target of the animation
  32574. * @returns the TargetedAnimation object
  32575. */
  32576. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32577. /**
  32578. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32579. * It can add constant keys at begin or end
  32580. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32581. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32582. * @returns the animation group
  32583. */
  32584. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32585. /**
  32586. * Start all animations on given targets
  32587. * @param loop defines if animations must loop
  32588. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32589. * @param from defines the from key (optional)
  32590. * @param to defines the to key (optional)
  32591. * @returns the current animation group
  32592. */
  32593. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32594. /**
  32595. * Pause all animations
  32596. * @returns the animation group
  32597. */
  32598. pause(): AnimationGroup;
  32599. /**
  32600. * Play all animations to initial state
  32601. * This function will start() the animations if they were not started or will restart() them if they were paused
  32602. * @param loop defines if animations must loop
  32603. * @returns the animation group
  32604. */
  32605. play(loop?: boolean): AnimationGroup;
  32606. /**
  32607. * Reset all animations to initial state
  32608. * @returns the animation group
  32609. */
  32610. reset(): AnimationGroup;
  32611. /**
  32612. * Restart animations from key 0
  32613. * @returns the animation group
  32614. */
  32615. restart(): AnimationGroup;
  32616. /**
  32617. * Stop all animations
  32618. * @returns the animation group
  32619. */
  32620. stop(): AnimationGroup;
  32621. /**
  32622. * Set animation weight for all animatables
  32623. * @param weight defines the weight to use
  32624. * @return the animationGroup
  32625. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32626. */
  32627. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32628. /**
  32629. * Synchronize and normalize all animatables with a source animatable
  32630. * @param root defines the root animatable to synchronize with
  32631. * @return the animationGroup
  32632. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32633. */
  32634. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32635. /**
  32636. * Goes to a specific frame in this animation group
  32637. * @param frame the frame number to go to
  32638. * @return the animationGroup
  32639. */
  32640. goToFrame(frame: number): AnimationGroup;
  32641. /**
  32642. * Dispose all associated resources
  32643. */
  32644. dispose(): void;
  32645. private _checkAnimationGroupEnded;
  32646. /**
  32647. * Clone the current animation group and returns a copy
  32648. * @param newName defines the name of the new group
  32649. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32650. * @returns the new aniamtion group
  32651. */
  32652. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32653. /**
  32654. * Serializes the animationGroup to an object
  32655. * @returns Serialized object
  32656. */
  32657. serialize(): any;
  32658. /**
  32659. * Returns a new AnimationGroup object parsed from the source provided.
  32660. * @param parsedAnimationGroup defines the source
  32661. * @param scene defines the scene that will receive the animationGroup
  32662. * @returns a new AnimationGroup
  32663. */
  32664. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32665. /**
  32666. * Returns the string "AnimationGroup"
  32667. * @returns "AnimationGroup"
  32668. */
  32669. getClassName(): string;
  32670. /**
  32671. * Creates a detailled string about the object
  32672. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32673. * @returns a string representing the object
  32674. */
  32675. toString(fullDetails?: boolean): string;
  32676. }
  32677. }
  32678. declare module BABYLON {
  32679. /**
  32680. * Define an interface for all classes that will hold resources
  32681. */
  32682. export interface IDisposable {
  32683. /**
  32684. * Releases all held resources
  32685. */
  32686. dispose(): void;
  32687. }
  32688. /** Interface defining initialization parameters for Scene class */
  32689. export interface SceneOptions {
  32690. /**
  32691. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32692. * It will improve performance when the number of geometries becomes important.
  32693. */
  32694. useGeometryUniqueIdsMap?: boolean;
  32695. /**
  32696. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32697. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32698. */
  32699. useMaterialMeshMap?: boolean;
  32700. /**
  32701. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32702. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32703. */
  32704. useClonedMeshhMap?: boolean;
  32705. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32706. virtual?: boolean;
  32707. }
  32708. /**
  32709. * Represents a scene to be rendered by the engine.
  32710. * @see http://doc.babylonjs.com/features/scene
  32711. */
  32712. export class Scene extends AbstractScene implements IAnimatable {
  32713. /** The fog is deactivated */
  32714. static readonly FOGMODE_NONE: number;
  32715. /** The fog density is following an exponential function */
  32716. static readonly FOGMODE_EXP: number;
  32717. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32718. static readonly FOGMODE_EXP2: number;
  32719. /** The fog density is following a linear function. */
  32720. static readonly FOGMODE_LINEAR: number;
  32721. /**
  32722. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32723. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32724. */
  32725. static MinDeltaTime: number;
  32726. /**
  32727. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32728. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32729. */
  32730. static MaxDeltaTime: number;
  32731. /**
  32732. * Factory used to create the default material.
  32733. * @param name The name of the material to create
  32734. * @param scene The scene to create the material for
  32735. * @returns The default material
  32736. */
  32737. static DefaultMaterialFactory(scene: Scene): Material;
  32738. /**
  32739. * Factory used to create the a collision coordinator.
  32740. * @returns The collision coordinator
  32741. */
  32742. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32743. /** @hidden */
  32744. _inputManager: InputManager;
  32745. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32746. cameraToUseForPointers: Nullable<Camera>;
  32747. /** @hidden */
  32748. readonly _isScene: boolean;
  32749. /**
  32750. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32751. */
  32752. autoClear: boolean;
  32753. /**
  32754. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32755. */
  32756. autoClearDepthAndStencil: boolean;
  32757. /**
  32758. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32759. */
  32760. clearColor: Color4;
  32761. /**
  32762. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32763. */
  32764. ambientColor: Color3;
  32765. /**
  32766. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32767. * It should only be one of the following (if not the default embedded one):
  32768. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32769. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32770. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32771. * The material properties need to be setup according to the type of texture in use.
  32772. */
  32773. environmentBRDFTexture: BaseTexture;
  32774. /** @hidden */
  32775. protected _environmentTexture: Nullable<BaseTexture>;
  32776. /**
  32777. * Texture used in all pbr material as the reflection texture.
  32778. * As in the majority of the scene they are the same (exception for multi room and so on),
  32779. * this is easier to reference from here than from all the materials.
  32780. */
  32781. /**
  32782. * Texture used in all pbr material as the reflection texture.
  32783. * As in the majority of the scene they are the same (exception for multi room and so on),
  32784. * this is easier to set here than in all the materials.
  32785. */
  32786. environmentTexture: Nullable<BaseTexture>;
  32787. /** @hidden */
  32788. protected _environmentIntensity: number;
  32789. /**
  32790. * Intensity of the environment in all pbr material.
  32791. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32792. * As in the majority of the scene they are the same (exception for multi room and so on),
  32793. * this is easier to reference from here than from all the materials.
  32794. */
  32795. /**
  32796. * Intensity of the environment in all pbr material.
  32797. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32798. * As in the majority of the scene they are the same (exception for multi room and so on),
  32799. * this is easier to set here than in all the materials.
  32800. */
  32801. environmentIntensity: number;
  32802. /** @hidden */
  32803. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32804. /**
  32805. * Default image processing configuration used either in the rendering
  32806. * Forward main pass or through the imageProcessingPostProcess if present.
  32807. * As in the majority of the scene they are the same (exception for multi camera),
  32808. * this is easier to reference from here than from all the materials and post process.
  32809. *
  32810. * No setter as we it is a shared configuration, you can set the values instead.
  32811. */
  32812. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32813. private _forceWireframe;
  32814. /**
  32815. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32816. */
  32817. forceWireframe: boolean;
  32818. private _forcePointsCloud;
  32819. /**
  32820. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32821. */
  32822. forcePointsCloud: boolean;
  32823. /**
  32824. * Gets or sets the active clipplane 1
  32825. */
  32826. clipPlane: Nullable<Plane>;
  32827. /**
  32828. * Gets or sets the active clipplane 2
  32829. */
  32830. clipPlane2: Nullable<Plane>;
  32831. /**
  32832. * Gets or sets the active clipplane 3
  32833. */
  32834. clipPlane3: Nullable<Plane>;
  32835. /**
  32836. * Gets or sets the active clipplane 4
  32837. */
  32838. clipPlane4: Nullable<Plane>;
  32839. /**
  32840. * Gets or sets a boolean indicating if animations are enabled
  32841. */
  32842. animationsEnabled: boolean;
  32843. private _animationPropertiesOverride;
  32844. /**
  32845. * Gets or sets the animation properties override
  32846. */
  32847. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32848. /**
  32849. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32850. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32851. */
  32852. useConstantAnimationDeltaTime: boolean;
  32853. /**
  32854. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32855. * Please note that it requires to run a ray cast through the scene on every frame
  32856. */
  32857. constantlyUpdateMeshUnderPointer: boolean;
  32858. /**
  32859. * Defines the HTML cursor to use when hovering over interactive elements
  32860. */
  32861. hoverCursor: string;
  32862. /**
  32863. * Defines the HTML default cursor to use (empty by default)
  32864. */
  32865. defaultCursor: string;
  32866. /**
  32867. * This is used to call preventDefault() on pointer down
  32868. * in order to block unwanted artifacts like system double clicks
  32869. */
  32870. preventDefaultOnPointerDown: boolean;
  32871. /**
  32872. * This is used to call preventDefault() on pointer up
  32873. * in order to block unwanted artifacts like system double clicks
  32874. */
  32875. preventDefaultOnPointerUp: boolean;
  32876. /**
  32877. * Gets or sets user defined metadata
  32878. */
  32879. metadata: any;
  32880. /**
  32881. * For internal use only. Please do not use.
  32882. */
  32883. reservedDataStore: any;
  32884. /**
  32885. * Gets the name of the plugin used to load this scene (null by default)
  32886. */
  32887. loadingPluginName: string;
  32888. /**
  32889. * Use this array to add regular expressions used to disable offline support for specific urls
  32890. */
  32891. disableOfflineSupportExceptionRules: RegExp[];
  32892. /**
  32893. * An event triggered when the scene is disposed.
  32894. */
  32895. onDisposeObservable: Observable<Scene>;
  32896. private _onDisposeObserver;
  32897. /** Sets a function to be executed when this scene is disposed. */
  32898. onDispose: () => void;
  32899. /**
  32900. * An event triggered before rendering the scene (right after animations and physics)
  32901. */
  32902. onBeforeRenderObservable: Observable<Scene>;
  32903. private _onBeforeRenderObserver;
  32904. /** Sets a function to be executed before rendering this scene */
  32905. beforeRender: Nullable<() => void>;
  32906. /**
  32907. * An event triggered after rendering the scene
  32908. */
  32909. onAfterRenderObservable: Observable<Scene>;
  32910. /**
  32911. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  32912. */
  32913. onAfterRenderCameraObservable: Observable<Camera>;
  32914. private _onAfterRenderObserver;
  32915. /** Sets a function to be executed after rendering this scene */
  32916. afterRender: Nullable<() => void>;
  32917. /**
  32918. * An event triggered before animating the scene
  32919. */
  32920. onBeforeAnimationsObservable: Observable<Scene>;
  32921. /**
  32922. * An event triggered after animations processing
  32923. */
  32924. onAfterAnimationsObservable: Observable<Scene>;
  32925. /**
  32926. * An event triggered before draw calls are ready to be sent
  32927. */
  32928. onBeforeDrawPhaseObservable: Observable<Scene>;
  32929. /**
  32930. * An event triggered after draw calls have been sent
  32931. */
  32932. onAfterDrawPhaseObservable: Observable<Scene>;
  32933. /**
  32934. * An event triggered when the scene is ready
  32935. */
  32936. onReadyObservable: Observable<Scene>;
  32937. /**
  32938. * An event triggered before rendering a camera
  32939. */
  32940. onBeforeCameraRenderObservable: Observable<Camera>;
  32941. private _onBeforeCameraRenderObserver;
  32942. /** Sets a function to be executed before rendering a camera*/
  32943. beforeCameraRender: () => void;
  32944. /**
  32945. * An event triggered after rendering a camera
  32946. */
  32947. onAfterCameraRenderObservable: Observable<Camera>;
  32948. private _onAfterCameraRenderObserver;
  32949. /** Sets a function to be executed after rendering a camera*/
  32950. afterCameraRender: () => void;
  32951. /**
  32952. * An event triggered when active meshes evaluation is about to start
  32953. */
  32954. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32955. /**
  32956. * An event triggered when active meshes evaluation is done
  32957. */
  32958. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32959. /**
  32960. * An event triggered when particles rendering is about to start
  32961. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32962. */
  32963. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32964. /**
  32965. * An event triggered when particles rendering is done
  32966. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32967. */
  32968. onAfterParticlesRenderingObservable: Observable<Scene>;
  32969. /**
  32970. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32971. */
  32972. onDataLoadedObservable: Observable<Scene>;
  32973. /**
  32974. * An event triggered when a camera is created
  32975. */
  32976. onNewCameraAddedObservable: Observable<Camera>;
  32977. /**
  32978. * An event triggered when a camera is removed
  32979. */
  32980. onCameraRemovedObservable: Observable<Camera>;
  32981. /**
  32982. * An event triggered when a light is created
  32983. */
  32984. onNewLightAddedObservable: Observable<Light>;
  32985. /**
  32986. * An event triggered when a light is removed
  32987. */
  32988. onLightRemovedObservable: Observable<Light>;
  32989. /**
  32990. * An event triggered when a geometry is created
  32991. */
  32992. onNewGeometryAddedObservable: Observable<Geometry>;
  32993. /**
  32994. * An event triggered when a geometry is removed
  32995. */
  32996. onGeometryRemovedObservable: Observable<Geometry>;
  32997. /**
  32998. * An event triggered when a transform node is created
  32999. */
  33000. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33001. /**
  33002. * An event triggered when a transform node is removed
  33003. */
  33004. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33005. /**
  33006. * An event triggered when a mesh is created
  33007. */
  33008. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33009. /**
  33010. * An event triggered when a mesh is removed
  33011. */
  33012. onMeshRemovedObservable: Observable<AbstractMesh>;
  33013. /**
  33014. * An event triggered when a skeleton is created
  33015. */
  33016. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33017. /**
  33018. * An event triggered when a skeleton is removed
  33019. */
  33020. onSkeletonRemovedObservable: Observable<Skeleton>;
  33021. /**
  33022. * An event triggered when a material is created
  33023. */
  33024. onNewMaterialAddedObservable: Observable<Material>;
  33025. /**
  33026. * An event triggered when a material is removed
  33027. */
  33028. onMaterialRemovedObservable: Observable<Material>;
  33029. /**
  33030. * An event triggered when a texture is created
  33031. */
  33032. onNewTextureAddedObservable: Observable<BaseTexture>;
  33033. /**
  33034. * An event triggered when a texture is removed
  33035. */
  33036. onTextureRemovedObservable: Observable<BaseTexture>;
  33037. /**
  33038. * An event triggered when render targets are about to be rendered
  33039. * Can happen multiple times per frame.
  33040. */
  33041. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33042. /**
  33043. * An event triggered when render targets were rendered.
  33044. * Can happen multiple times per frame.
  33045. */
  33046. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33047. /**
  33048. * An event triggered before calculating deterministic simulation step
  33049. */
  33050. onBeforeStepObservable: Observable<Scene>;
  33051. /**
  33052. * An event triggered after calculating deterministic simulation step
  33053. */
  33054. onAfterStepObservable: Observable<Scene>;
  33055. /**
  33056. * An event triggered when the activeCamera property is updated
  33057. */
  33058. onActiveCameraChanged: Observable<Scene>;
  33059. /**
  33060. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33061. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33062. * 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)
  33063. */
  33064. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33065. /**
  33066. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33067. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33068. * 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)
  33069. */
  33070. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33071. /**
  33072. * This Observable will when a mesh has been imported into the scene.
  33073. */
  33074. onMeshImportedObservable: Observable<AbstractMesh>;
  33075. /**
  33076. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33077. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33078. */
  33079. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33080. /** @hidden */
  33081. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33082. /**
  33083. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33084. */
  33085. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33086. /**
  33087. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33088. */
  33089. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33090. /**
  33091. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33092. */
  33093. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33094. /** Callback called when a pointer move is detected */
  33095. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33096. /** Callback called when a pointer down is detected */
  33097. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33098. /** Callback called when a pointer up is detected */
  33099. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33100. /** Callback called when a pointer pick is detected */
  33101. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33102. /**
  33103. * 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).
  33104. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33105. */
  33106. onPrePointerObservable: Observable<PointerInfoPre>;
  33107. /**
  33108. * Observable event triggered each time an input event is received from the rendering canvas
  33109. */
  33110. onPointerObservable: Observable<PointerInfo>;
  33111. /**
  33112. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33113. */
  33114. readonly unTranslatedPointer: Vector2;
  33115. /**
  33116. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33117. */
  33118. static DragMovementThreshold: number;
  33119. /**
  33120. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33121. */
  33122. static LongPressDelay: number;
  33123. /**
  33124. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33125. */
  33126. static DoubleClickDelay: number;
  33127. /** If you need to check double click without raising a single click at first click, enable this flag */
  33128. static ExclusiveDoubleClickMode: boolean;
  33129. /** @hidden */
  33130. _mirroredCameraPosition: Nullable<Vector3>;
  33131. /**
  33132. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33133. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33134. */
  33135. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33136. /**
  33137. * Observable event triggered each time an keyboard event is received from the hosting window
  33138. */
  33139. onKeyboardObservable: Observable<KeyboardInfo>;
  33140. private _useRightHandedSystem;
  33141. /**
  33142. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33143. */
  33144. useRightHandedSystem: boolean;
  33145. private _timeAccumulator;
  33146. private _currentStepId;
  33147. private _currentInternalStep;
  33148. /**
  33149. * Sets the step Id used by deterministic lock step
  33150. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33151. * @param newStepId defines the step Id
  33152. */
  33153. setStepId(newStepId: number): void;
  33154. /**
  33155. * Gets the step Id used by deterministic lock step
  33156. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33157. * @returns the step Id
  33158. */
  33159. getStepId(): number;
  33160. /**
  33161. * Gets the internal step used by deterministic lock step
  33162. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33163. * @returns the internal step
  33164. */
  33165. getInternalStep(): number;
  33166. private _fogEnabled;
  33167. /**
  33168. * Gets or sets a boolean indicating if fog is enabled on this scene
  33169. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33170. * (Default is true)
  33171. */
  33172. fogEnabled: boolean;
  33173. private _fogMode;
  33174. /**
  33175. * Gets or sets the fog mode to use
  33176. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33177. * | mode | value |
  33178. * | --- | --- |
  33179. * | FOGMODE_NONE | 0 |
  33180. * | FOGMODE_EXP | 1 |
  33181. * | FOGMODE_EXP2 | 2 |
  33182. * | FOGMODE_LINEAR | 3 |
  33183. */
  33184. fogMode: number;
  33185. /**
  33186. * Gets or sets the fog color to use
  33187. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33188. * (Default is Color3(0.2, 0.2, 0.3))
  33189. */
  33190. fogColor: Color3;
  33191. /**
  33192. * Gets or sets the fog density to use
  33193. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33194. * (Default is 0.1)
  33195. */
  33196. fogDensity: number;
  33197. /**
  33198. * Gets or sets the fog start distance to use
  33199. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33200. * (Default is 0)
  33201. */
  33202. fogStart: number;
  33203. /**
  33204. * Gets or sets the fog end distance to use
  33205. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33206. * (Default is 1000)
  33207. */
  33208. fogEnd: number;
  33209. private _shadowsEnabled;
  33210. /**
  33211. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33212. */
  33213. shadowsEnabled: boolean;
  33214. private _lightsEnabled;
  33215. /**
  33216. * Gets or sets a boolean indicating if lights are enabled on this scene
  33217. */
  33218. lightsEnabled: boolean;
  33219. /** All of the active cameras added to this scene. */
  33220. activeCameras: Camera[];
  33221. /** @hidden */
  33222. _activeCamera: Nullable<Camera>;
  33223. /** Gets or sets the current active camera */
  33224. activeCamera: Nullable<Camera>;
  33225. private _defaultMaterial;
  33226. /** The default material used on meshes when no material is affected */
  33227. /** The default material used on meshes when no material is affected */
  33228. defaultMaterial: Material;
  33229. private _texturesEnabled;
  33230. /**
  33231. * Gets or sets a boolean indicating if textures are enabled on this scene
  33232. */
  33233. texturesEnabled: boolean;
  33234. /**
  33235. * Gets or sets a boolean indicating if particles are enabled on this scene
  33236. */
  33237. particlesEnabled: boolean;
  33238. /**
  33239. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33240. */
  33241. spritesEnabled: boolean;
  33242. private _skeletonsEnabled;
  33243. /**
  33244. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33245. */
  33246. skeletonsEnabled: boolean;
  33247. /**
  33248. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33249. */
  33250. lensFlaresEnabled: boolean;
  33251. /**
  33252. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33253. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33254. */
  33255. collisionsEnabled: boolean;
  33256. private _collisionCoordinator;
  33257. /** @hidden */
  33258. readonly collisionCoordinator: ICollisionCoordinator;
  33259. /**
  33260. * Defines the gravity applied to this scene (used only for collisions)
  33261. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33262. */
  33263. gravity: Vector3;
  33264. /**
  33265. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33266. */
  33267. postProcessesEnabled: boolean;
  33268. /**
  33269. * The list of postprocesses added to the scene
  33270. */
  33271. postProcesses: PostProcess[];
  33272. /**
  33273. * Gets the current postprocess manager
  33274. */
  33275. postProcessManager: PostProcessManager;
  33276. /**
  33277. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33278. */
  33279. renderTargetsEnabled: boolean;
  33280. /**
  33281. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33282. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33283. */
  33284. dumpNextRenderTargets: boolean;
  33285. /**
  33286. * The list of user defined render targets added to the scene
  33287. */
  33288. customRenderTargets: RenderTargetTexture[];
  33289. /**
  33290. * Defines if texture loading must be delayed
  33291. * If true, textures will only be loaded when they need to be rendered
  33292. */
  33293. useDelayedTextureLoading: boolean;
  33294. /**
  33295. * Gets the list of meshes imported to the scene through SceneLoader
  33296. */
  33297. importedMeshesFiles: String[];
  33298. /**
  33299. * Gets or sets a boolean indicating if probes are enabled on this scene
  33300. */
  33301. probesEnabled: boolean;
  33302. /**
  33303. * Gets or sets the current offline provider to use to store scene data
  33304. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33305. */
  33306. offlineProvider: IOfflineProvider;
  33307. /**
  33308. * Gets or sets the action manager associated with the scene
  33309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33310. */
  33311. actionManager: AbstractActionManager;
  33312. private _meshesForIntersections;
  33313. /**
  33314. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33315. */
  33316. proceduralTexturesEnabled: boolean;
  33317. private _engine;
  33318. private _totalVertices;
  33319. /** @hidden */
  33320. _activeIndices: PerfCounter;
  33321. /** @hidden */
  33322. _activeParticles: PerfCounter;
  33323. /** @hidden */
  33324. _activeBones: PerfCounter;
  33325. private _animationRatio;
  33326. /** @hidden */
  33327. _animationTimeLast: number;
  33328. /** @hidden */
  33329. _animationTime: number;
  33330. /**
  33331. * Gets or sets a general scale for animation speed
  33332. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33333. */
  33334. animationTimeScale: number;
  33335. /** @hidden */
  33336. _cachedMaterial: Nullable<Material>;
  33337. /** @hidden */
  33338. _cachedEffect: Nullable<Effect>;
  33339. /** @hidden */
  33340. _cachedVisibility: Nullable<number>;
  33341. private _renderId;
  33342. private _frameId;
  33343. private _executeWhenReadyTimeoutId;
  33344. private _intermediateRendering;
  33345. private _viewUpdateFlag;
  33346. private _projectionUpdateFlag;
  33347. /** @hidden */
  33348. _toBeDisposed: Nullable<IDisposable>[];
  33349. private _activeRequests;
  33350. /** @hidden */
  33351. _pendingData: any[];
  33352. private _isDisposed;
  33353. /**
  33354. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33355. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33356. */
  33357. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33358. private _activeMeshes;
  33359. private _processedMaterials;
  33360. private _renderTargets;
  33361. /** @hidden */
  33362. _activeParticleSystems: SmartArray<IParticleSystem>;
  33363. private _activeSkeletons;
  33364. private _softwareSkinnedMeshes;
  33365. private _renderingManager;
  33366. /** @hidden */
  33367. _activeAnimatables: Animatable[];
  33368. private _transformMatrix;
  33369. private _sceneUbo;
  33370. /** @hidden */
  33371. _viewMatrix: Matrix;
  33372. private _projectionMatrix;
  33373. /** @hidden */
  33374. _forcedViewPosition: Nullable<Vector3>;
  33375. /** @hidden */
  33376. _frustumPlanes: Plane[];
  33377. /**
  33378. * Gets the list of frustum planes (built from the active camera)
  33379. */
  33380. readonly frustumPlanes: Plane[];
  33381. /**
  33382. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33383. * This is useful if there are more lights that the maximum simulteanous authorized
  33384. */
  33385. requireLightSorting: boolean;
  33386. /** @hidden */
  33387. readonly useMaterialMeshMap: boolean;
  33388. /** @hidden */
  33389. readonly useClonedMeshhMap: boolean;
  33390. private _externalData;
  33391. private _uid;
  33392. /**
  33393. * @hidden
  33394. * Backing store of defined scene components.
  33395. */
  33396. _components: ISceneComponent[];
  33397. /**
  33398. * @hidden
  33399. * Backing store of defined scene components.
  33400. */
  33401. _serializableComponents: ISceneSerializableComponent[];
  33402. /**
  33403. * List of components to register on the next registration step.
  33404. */
  33405. private _transientComponents;
  33406. /**
  33407. * Registers the transient components if needed.
  33408. */
  33409. private _registerTransientComponents;
  33410. /**
  33411. * @hidden
  33412. * Add a component to the scene.
  33413. * Note that the ccomponent could be registered on th next frame if this is called after
  33414. * the register component stage.
  33415. * @param component Defines the component to add to the scene
  33416. */
  33417. _addComponent(component: ISceneComponent): void;
  33418. /**
  33419. * @hidden
  33420. * Gets a component from the scene.
  33421. * @param name defines the name of the component to retrieve
  33422. * @returns the component or null if not present
  33423. */
  33424. _getComponent(name: string): Nullable<ISceneComponent>;
  33425. /**
  33426. * @hidden
  33427. * Defines the actions happening before camera updates.
  33428. */
  33429. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33430. /**
  33431. * @hidden
  33432. * Defines the actions happening before clear the canvas.
  33433. */
  33434. _beforeClearStage: Stage<SimpleStageAction>;
  33435. /**
  33436. * @hidden
  33437. * Defines the actions when collecting render targets for the frame.
  33438. */
  33439. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33440. /**
  33441. * @hidden
  33442. * Defines the actions happening for one camera in the frame.
  33443. */
  33444. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33445. /**
  33446. * @hidden
  33447. * Defines the actions happening during the per mesh ready checks.
  33448. */
  33449. _isReadyForMeshStage: Stage<MeshStageAction>;
  33450. /**
  33451. * @hidden
  33452. * Defines the actions happening before evaluate active mesh checks.
  33453. */
  33454. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33455. /**
  33456. * @hidden
  33457. * Defines the actions happening during the evaluate sub mesh checks.
  33458. */
  33459. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33460. /**
  33461. * @hidden
  33462. * Defines the actions happening during the active mesh stage.
  33463. */
  33464. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33465. /**
  33466. * @hidden
  33467. * Defines the actions happening during the per camera render target step.
  33468. */
  33469. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33470. /**
  33471. * @hidden
  33472. * Defines the actions happening just before the active camera is drawing.
  33473. */
  33474. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33475. /**
  33476. * @hidden
  33477. * Defines the actions happening just before a render target is drawing.
  33478. */
  33479. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33480. /**
  33481. * @hidden
  33482. * Defines the actions happening just before a rendering group is drawing.
  33483. */
  33484. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33485. /**
  33486. * @hidden
  33487. * Defines the actions happening just before a mesh is drawing.
  33488. */
  33489. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33490. /**
  33491. * @hidden
  33492. * Defines the actions happening just after a mesh has been drawn.
  33493. */
  33494. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33495. /**
  33496. * @hidden
  33497. * Defines the actions happening just after a rendering group has been drawn.
  33498. */
  33499. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33500. /**
  33501. * @hidden
  33502. * Defines the actions happening just after the active camera has been drawn.
  33503. */
  33504. _afterCameraDrawStage: Stage<CameraStageAction>;
  33505. /**
  33506. * @hidden
  33507. * Defines the actions happening just after a render target has been drawn.
  33508. */
  33509. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33510. /**
  33511. * @hidden
  33512. * Defines the actions happening just after rendering all cameras and computing intersections.
  33513. */
  33514. _afterRenderStage: Stage<SimpleStageAction>;
  33515. /**
  33516. * @hidden
  33517. * Defines the actions happening when a pointer move event happens.
  33518. */
  33519. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33520. /**
  33521. * @hidden
  33522. * Defines the actions happening when a pointer down event happens.
  33523. */
  33524. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33525. /**
  33526. * @hidden
  33527. * Defines the actions happening when a pointer up event happens.
  33528. */
  33529. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33530. /**
  33531. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33532. */
  33533. private geometriesByUniqueId;
  33534. /**
  33535. * Creates a new Scene
  33536. * @param engine defines the engine to use to render this scene
  33537. * @param options defines the scene options
  33538. */
  33539. constructor(engine: Engine, options?: SceneOptions);
  33540. /**
  33541. * Gets a string idenfifying the name of the class
  33542. * @returns "Scene" string
  33543. */
  33544. getClassName(): string;
  33545. private _defaultMeshCandidates;
  33546. /**
  33547. * @hidden
  33548. */
  33549. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33550. private _defaultSubMeshCandidates;
  33551. /**
  33552. * @hidden
  33553. */
  33554. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33555. /**
  33556. * Sets the default candidate providers for the scene.
  33557. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33558. * and getCollidingSubMeshCandidates to their default function
  33559. */
  33560. setDefaultCandidateProviders(): void;
  33561. /**
  33562. * Gets the mesh that is currently under the pointer
  33563. */
  33564. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33565. /**
  33566. * Gets or sets the current on-screen X position of the pointer
  33567. */
  33568. pointerX: number;
  33569. /**
  33570. * Gets or sets the current on-screen Y position of the pointer
  33571. */
  33572. pointerY: number;
  33573. /**
  33574. * Gets the cached material (ie. the latest rendered one)
  33575. * @returns the cached material
  33576. */
  33577. getCachedMaterial(): Nullable<Material>;
  33578. /**
  33579. * Gets the cached effect (ie. the latest rendered one)
  33580. * @returns the cached effect
  33581. */
  33582. getCachedEffect(): Nullable<Effect>;
  33583. /**
  33584. * Gets the cached visibility state (ie. the latest rendered one)
  33585. * @returns the cached visibility state
  33586. */
  33587. getCachedVisibility(): Nullable<number>;
  33588. /**
  33589. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33590. * @param material defines the current material
  33591. * @param effect defines the current effect
  33592. * @param visibility defines the current visibility state
  33593. * @returns true if one parameter is not cached
  33594. */
  33595. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33596. /**
  33597. * Gets the engine associated with the scene
  33598. * @returns an Engine
  33599. */
  33600. getEngine(): Engine;
  33601. /**
  33602. * Gets the total number of vertices rendered per frame
  33603. * @returns the total number of vertices rendered per frame
  33604. */
  33605. getTotalVertices(): number;
  33606. /**
  33607. * Gets the performance counter for total vertices
  33608. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33609. */
  33610. readonly totalVerticesPerfCounter: PerfCounter;
  33611. /**
  33612. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33613. * @returns the total number of active indices rendered per frame
  33614. */
  33615. getActiveIndices(): number;
  33616. /**
  33617. * Gets the performance counter for active indices
  33618. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33619. */
  33620. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33621. /**
  33622. * Gets the total number of active particles rendered per frame
  33623. * @returns the total number of active particles rendered per frame
  33624. */
  33625. getActiveParticles(): number;
  33626. /**
  33627. * Gets the performance counter for active particles
  33628. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33629. */
  33630. readonly activeParticlesPerfCounter: PerfCounter;
  33631. /**
  33632. * Gets the total number of active bones rendered per frame
  33633. * @returns the total number of active bones rendered per frame
  33634. */
  33635. getActiveBones(): number;
  33636. /**
  33637. * Gets the performance counter for active bones
  33638. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33639. */
  33640. readonly activeBonesPerfCounter: PerfCounter;
  33641. /**
  33642. * Gets the array of active meshes
  33643. * @returns an array of AbstractMesh
  33644. */
  33645. getActiveMeshes(): SmartArray<AbstractMesh>;
  33646. /**
  33647. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33648. * @returns a number
  33649. */
  33650. getAnimationRatio(): number;
  33651. /**
  33652. * Gets an unique Id for the current render phase
  33653. * @returns a number
  33654. */
  33655. getRenderId(): number;
  33656. /**
  33657. * Gets an unique Id for the current frame
  33658. * @returns a number
  33659. */
  33660. getFrameId(): number;
  33661. /** Call this function if you want to manually increment the render Id*/
  33662. incrementRenderId(): void;
  33663. private _createUbo;
  33664. /**
  33665. * Use this method to simulate a pointer move on a mesh
  33666. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33667. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33668. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33669. * @returns the current scene
  33670. */
  33671. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33672. /**
  33673. * Use this method to simulate a pointer down on a mesh
  33674. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33675. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33676. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33677. * @returns the current scene
  33678. */
  33679. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33680. /**
  33681. * Use this method to simulate a pointer up on a mesh
  33682. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33683. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33684. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33685. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33686. * @returns the current scene
  33687. */
  33688. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33689. /**
  33690. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33691. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33692. * @returns true if the pointer was captured
  33693. */
  33694. isPointerCaptured(pointerId?: number): boolean;
  33695. /**
  33696. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33697. * @param attachUp defines if you want to attach events to pointerup
  33698. * @param attachDown defines if you want to attach events to pointerdown
  33699. * @param attachMove defines if you want to attach events to pointermove
  33700. */
  33701. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33702. /** Detaches all event handlers*/
  33703. detachControl(): void;
  33704. /**
  33705. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33706. * Delay loaded resources are not taking in account
  33707. * @return true if all required resources are ready
  33708. */
  33709. isReady(): boolean;
  33710. /** Resets all cached information relative to material (including effect and visibility) */
  33711. resetCachedMaterial(): void;
  33712. /**
  33713. * Registers a function to be called before every frame render
  33714. * @param func defines the function to register
  33715. */
  33716. registerBeforeRender(func: () => void): void;
  33717. /**
  33718. * Unregisters a function called before every frame render
  33719. * @param func defines the function to unregister
  33720. */
  33721. unregisterBeforeRender(func: () => void): void;
  33722. /**
  33723. * Registers a function to be called after every frame render
  33724. * @param func defines the function to register
  33725. */
  33726. registerAfterRender(func: () => void): void;
  33727. /**
  33728. * Unregisters a function called after every frame render
  33729. * @param func defines the function to unregister
  33730. */
  33731. unregisterAfterRender(func: () => void): void;
  33732. private _executeOnceBeforeRender;
  33733. /**
  33734. * The provided function will run before render once and will be disposed afterwards.
  33735. * A timeout delay can be provided so that the function will be executed in N ms.
  33736. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33737. * @param func The function to be executed.
  33738. * @param timeout optional delay in ms
  33739. */
  33740. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33741. /** @hidden */
  33742. _addPendingData(data: any): void;
  33743. /** @hidden */
  33744. _removePendingData(data: any): void;
  33745. /**
  33746. * Returns the number of items waiting to be loaded
  33747. * @returns the number of items waiting to be loaded
  33748. */
  33749. getWaitingItemsCount(): number;
  33750. /**
  33751. * Returns a boolean indicating if the scene is still loading data
  33752. */
  33753. readonly isLoading: boolean;
  33754. /**
  33755. * Registers a function to be executed when the scene is ready
  33756. * @param {Function} func - the function to be executed
  33757. */
  33758. executeWhenReady(func: () => void): void;
  33759. /**
  33760. * Returns a promise that resolves when the scene is ready
  33761. * @returns A promise that resolves when the scene is ready
  33762. */
  33763. whenReadyAsync(): Promise<void>;
  33764. /** @hidden */
  33765. _checkIsReady(): void;
  33766. /**
  33767. * Gets all animatable attached to the scene
  33768. */
  33769. readonly animatables: Animatable[];
  33770. /**
  33771. * Resets the last animation time frame.
  33772. * Useful to override when animations start running when loading a scene for the first time.
  33773. */
  33774. resetLastAnimationTimeFrame(): void;
  33775. /**
  33776. * Gets the current view matrix
  33777. * @returns a Matrix
  33778. */
  33779. getViewMatrix(): Matrix;
  33780. /**
  33781. * Gets the current projection matrix
  33782. * @returns a Matrix
  33783. */
  33784. getProjectionMatrix(): Matrix;
  33785. /**
  33786. * Gets the current transform matrix
  33787. * @returns a Matrix made of View * Projection
  33788. */
  33789. getTransformMatrix(): Matrix;
  33790. /**
  33791. * Sets the current transform matrix
  33792. * @param viewL defines the View matrix to use
  33793. * @param projectionL defines the Projection matrix to use
  33794. * @param viewR defines the right View matrix to use (if provided)
  33795. * @param projectionR defines the right Projection matrix to use (if provided)
  33796. */
  33797. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33798. /**
  33799. * Gets the uniform buffer used to store scene data
  33800. * @returns a UniformBuffer
  33801. */
  33802. getSceneUniformBuffer(): UniformBuffer;
  33803. /**
  33804. * Gets an unique (relatively to the current scene) Id
  33805. * @returns an unique number for the scene
  33806. */
  33807. getUniqueId(): number;
  33808. /**
  33809. * Add a mesh to the list of scene's meshes
  33810. * @param newMesh defines the mesh to add
  33811. * @param recursive if all child meshes should also be added to the scene
  33812. */
  33813. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33814. /**
  33815. * Remove a mesh for the list of scene's meshes
  33816. * @param toRemove defines the mesh to remove
  33817. * @param recursive if all child meshes should also be removed from the scene
  33818. * @returns the index where the mesh was in the mesh list
  33819. */
  33820. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33821. /**
  33822. * Add a transform node to the list of scene's transform nodes
  33823. * @param newTransformNode defines the transform node to add
  33824. */
  33825. addTransformNode(newTransformNode: TransformNode): void;
  33826. /**
  33827. * Remove a transform node for the list of scene's transform nodes
  33828. * @param toRemove defines the transform node to remove
  33829. * @returns the index where the transform node was in the transform node list
  33830. */
  33831. removeTransformNode(toRemove: TransformNode): number;
  33832. /**
  33833. * Remove a skeleton for the list of scene's skeletons
  33834. * @param toRemove defines the skeleton to remove
  33835. * @returns the index where the skeleton was in the skeleton list
  33836. */
  33837. removeSkeleton(toRemove: Skeleton): number;
  33838. /**
  33839. * Remove a morph target for the list of scene's morph targets
  33840. * @param toRemove defines the morph target to remove
  33841. * @returns the index where the morph target was in the morph target list
  33842. */
  33843. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33844. /**
  33845. * Remove a light for the list of scene's lights
  33846. * @param toRemove defines the light to remove
  33847. * @returns the index where the light was in the light list
  33848. */
  33849. removeLight(toRemove: Light): number;
  33850. /**
  33851. * Remove a camera for the list of scene's cameras
  33852. * @param toRemove defines the camera to remove
  33853. * @returns the index where the camera was in the camera list
  33854. */
  33855. removeCamera(toRemove: Camera): number;
  33856. /**
  33857. * Remove a particle system for the list of scene's particle systems
  33858. * @param toRemove defines the particle system to remove
  33859. * @returns the index where the particle system was in the particle system list
  33860. */
  33861. removeParticleSystem(toRemove: IParticleSystem): number;
  33862. /**
  33863. * Remove a animation for the list of scene's animations
  33864. * @param toRemove defines the animation to remove
  33865. * @returns the index where the animation was in the animation list
  33866. */
  33867. removeAnimation(toRemove: Animation): number;
  33868. /**
  33869. * Will stop the animation of the given target
  33870. * @param target - the target
  33871. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33872. * @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)
  33873. */
  33874. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33875. /**
  33876. * Removes the given animation group from this scene.
  33877. * @param toRemove The animation group to remove
  33878. * @returns The index of the removed animation group
  33879. */
  33880. removeAnimationGroup(toRemove: AnimationGroup): number;
  33881. /**
  33882. * Removes the given multi-material from this scene.
  33883. * @param toRemove The multi-material to remove
  33884. * @returns The index of the removed multi-material
  33885. */
  33886. removeMultiMaterial(toRemove: MultiMaterial): number;
  33887. /**
  33888. * Removes the given material from this scene.
  33889. * @param toRemove The material to remove
  33890. * @returns The index of the removed material
  33891. */
  33892. removeMaterial(toRemove: Material): number;
  33893. /**
  33894. * Removes the given action manager from this scene.
  33895. * @param toRemove The action manager to remove
  33896. * @returns The index of the removed action manager
  33897. */
  33898. removeActionManager(toRemove: AbstractActionManager): number;
  33899. /**
  33900. * Removes the given texture from this scene.
  33901. * @param toRemove The texture to remove
  33902. * @returns The index of the removed texture
  33903. */
  33904. removeTexture(toRemove: BaseTexture): number;
  33905. /**
  33906. * Adds the given light to this scene
  33907. * @param newLight The light to add
  33908. */
  33909. addLight(newLight: Light): void;
  33910. /**
  33911. * Sorts the list list based on light priorities
  33912. */
  33913. sortLightsByPriority(): void;
  33914. /**
  33915. * Adds the given camera to this scene
  33916. * @param newCamera The camera to add
  33917. */
  33918. addCamera(newCamera: Camera): void;
  33919. /**
  33920. * Adds the given skeleton to this scene
  33921. * @param newSkeleton The skeleton to add
  33922. */
  33923. addSkeleton(newSkeleton: Skeleton): void;
  33924. /**
  33925. * Adds the given particle system to this scene
  33926. * @param newParticleSystem The particle system to add
  33927. */
  33928. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33929. /**
  33930. * Adds the given animation to this scene
  33931. * @param newAnimation The animation to add
  33932. */
  33933. addAnimation(newAnimation: Animation): void;
  33934. /**
  33935. * Adds the given animation group to this scene.
  33936. * @param newAnimationGroup The animation group to add
  33937. */
  33938. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33939. /**
  33940. * Adds the given multi-material to this scene
  33941. * @param newMultiMaterial The multi-material to add
  33942. */
  33943. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33944. /**
  33945. * Adds the given material to this scene
  33946. * @param newMaterial The material to add
  33947. */
  33948. addMaterial(newMaterial: Material): void;
  33949. /**
  33950. * Adds the given morph target to this scene
  33951. * @param newMorphTargetManager The morph target to add
  33952. */
  33953. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33954. /**
  33955. * Adds the given geometry to this scene
  33956. * @param newGeometry The geometry to add
  33957. */
  33958. addGeometry(newGeometry: Geometry): void;
  33959. /**
  33960. * Adds the given action manager to this scene
  33961. * @param newActionManager The action manager to add
  33962. */
  33963. addActionManager(newActionManager: AbstractActionManager): void;
  33964. /**
  33965. * Adds the given texture to this scene.
  33966. * @param newTexture The texture to add
  33967. */
  33968. addTexture(newTexture: BaseTexture): void;
  33969. /**
  33970. * Switch active camera
  33971. * @param newCamera defines the new active camera
  33972. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33973. */
  33974. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33975. /**
  33976. * sets the active camera of the scene using its ID
  33977. * @param id defines the camera's ID
  33978. * @return the new active camera or null if none found.
  33979. */
  33980. setActiveCameraByID(id: string): Nullable<Camera>;
  33981. /**
  33982. * sets the active camera of the scene using its name
  33983. * @param name defines the camera's name
  33984. * @returns the new active camera or null if none found.
  33985. */
  33986. setActiveCameraByName(name: string): Nullable<Camera>;
  33987. /**
  33988. * get an animation group using its name
  33989. * @param name defines the material's name
  33990. * @return the animation group or null if none found.
  33991. */
  33992. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33993. /**
  33994. * Get a material using its unique id
  33995. * @param uniqueId defines the material's unique id
  33996. * @return the material or null if none found.
  33997. */
  33998. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33999. /**
  34000. * get a material using its id
  34001. * @param id defines the material's ID
  34002. * @return the material or null if none found.
  34003. */
  34004. getMaterialByID(id: string): Nullable<Material>;
  34005. /**
  34006. * Gets a the last added material using a given id
  34007. * @param id defines the material's ID
  34008. * @return the last material with the given id or null if none found.
  34009. */
  34010. getLastMaterialByID(id: string): Nullable<Material>;
  34011. /**
  34012. * Gets a material using its name
  34013. * @param name defines the material's name
  34014. * @return the material or null if none found.
  34015. */
  34016. getMaterialByName(name: string): Nullable<Material>;
  34017. /**
  34018. * Get a texture using its unique id
  34019. * @param uniqueId defines the texture's unique id
  34020. * @return the texture or null if none found.
  34021. */
  34022. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  34023. /**
  34024. * Gets a camera using its id
  34025. * @param id defines the id to look for
  34026. * @returns the camera or null if not found
  34027. */
  34028. getCameraByID(id: string): Nullable<Camera>;
  34029. /**
  34030. * Gets a camera using its unique id
  34031. * @param uniqueId defines the unique id to look for
  34032. * @returns the camera or null if not found
  34033. */
  34034. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34035. /**
  34036. * Gets a camera using its name
  34037. * @param name defines the camera's name
  34038. * @return the camera or null if none found.
  34039. */
  34040. getCameraByName(name: string): Nullable<Camera>;
  34041. /**
  34042. * Gets a bone using its id
  34043. * @param id defines the bone's id
  34044. * @return the bone or null if not found
  34045. */
  34046. getBoneByID(id: string): Nullable<Bone>;
  34047. /**
  34048. * Gets a bone using its id
  34049. * @param name defines the bone's name
  34050. * @return the bone or null if not found
  34051. */
  34052. getBoneByName(name: string): Nullable<Bone>;
  34053. /**
  34054. * Gets a light node using its name
  34055. * @param name defines the the light's name
  34056. * @return the light or null if none found.
  34057. */
  34058. getLightByName(name: string): Nullable<Light>;
  34059. /**
  34060. * Gets a light node using its id
  34061. * @param id defines the light's id
  34062. * @return the light or null if none found.
  34063. */
  34064. getLightByID(id: string): Nullable<Light>;
  34065. /**
  34066. * Gets a light node using its scene-generated unique ID
  34067. * @param uniqueId defines the light's unique id
  34068. * @return the light or null if none found.
  34069. */
  34070. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34071. /**
  34072. * Gets a particle system by id
  34073. * @param id defines the particle system id
  34074. * @return the corresponding system or null if none found
  34075. */
  34076. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34077. /**
  34078. * Gets a geometry using its ID
  34079. * @param id defines the geometry's id
  34080. * @return the geometry or null if none found.
  34081. */
  34082. getGeometryByID(id: string): Nullable<Geometry>;
  34083. private _getGeometryByUniqueID;
  34084. /**
  34085. * Add a new geometry to this scene
  34086. * @param geometry defines the geometry to be added to the scene.
  34087. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34088. * @return a boolean defining if the geometry was added or not
  34089. */
  34090. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34091. /**
  34092. * Removes an existing geometry
  34093. * @param geometry defines the geometry to be removed from the scene
  34094. * @return a boolean defining if the geometry was removed or not
  34095. */
  34096. removeGeometry(geometry: Geometry): boolean;
  34097. /**
  34098. * Gets the list of geometries attached to the scene
  34099. * @returns an array of Geometry
  34100. */
  34101. getGeometries(): Geometry[];
  34102. /**
  34103. * Gets the first added mesh found of a given ID
  34104. * @param id defines the id to search for
  34105. * @return the mesh found or null if not found at all
  34106. */
  34107. getMeshByID(id: string): Nullable<AbstractMesh>;
  34108. /**
  34109. * Gets a list of meshes using their id
  34110. * @param id defines the id to search for
  34111. * @returns a list of meshes
  34112. */
  34113. getMeshesByID(id: string): Array<AbstractMesh>;
  34114. /**
  34115. * Gets the first added transform node found of a given ID
  34116. * @param id defines the id to search for
  34117. * @return the found transform node or null if not found at all.
  34118. */
  34119. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34120. /**
  34121. * Gets a transform node with its auto-generated unique id
  34122. * @param uniqueId efines the unique id to search for
  34123. * @return the found transform node or null if not found at all.
  34124. */
  34125. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34126. /**
  34127. * Gets a list of transform nodes using their id
  34128. * @param id defines the id to search for
  34129. * @returns a list of transform nodes
  34130. */
  34131. getTransformNodesByID(id: string): Array<TransformNode>;
  34132. /**
  34133. * Gets a mesh with its auto-generated unique id
  34134. * @param uniqueId defines the unique id to search for
  34135. * @return the found mesh or null if not found at all.
  34136. */
  34137. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34138. /**
  34139. * Gets a the last added mesh using a given id
  34140. * @param id defines the id to search for
  34141. * @return the found mesh or null if not found at all.
  34142. */
  34143. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34144. /**
  34145. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34146. * @param id defines the id to search for
  34147. * @return the found node or null if not found at all
  34148. */
  34149. getLastEntryByID(id: string): Nullable<Node>;
  34150. /**
  34151. * Gets a node (Mesh, Camera, Light) using a given id
  34152. * @param id defines the id to search for
  34153. * @return the found node or null if not found at all
  34154. */
  34155. getNodeByID(id: string): Nullable<Node>;
  34156. /**
  34157. * Gets a node (Mesh, Camera, Light) using a given name
  34158. * @param name defines the name to search for
  34159. * @return the found node or null if not found at all.
  34160. */
  34161. getNodeByName(name: string): Nullable<Node>;
  34162. /**
  34163. * Gets a mesh using a given name
  34164. * @param name defines the name to search for
  34165. * @return the found mesh or null if not found at all.
  34166. */
  34167. getMeshByName(name: string): Nullable<AbstractMesh>;
  34168. /**
  34169. * Gets a transform node using a given name
  34170. * @param name defines the name to search for
  34171. * @return the found transform node or null if not found at all.
  34172. */
  34173. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34174. /**
  34175. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34176. * @param id defines the id to search for
  34177. * @return the found skeleton or null if not found at all.
  34178. */
  34179. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34180. /**
  34181. * Gets a skeleton using a given auto generated unique id
  34182. * @param uniqueId defines the unique id to search for
  34183. * @return the found skeleton or null if not found at all.
  34184. */
  34185. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34186. /**
  34187. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34188. * @param id defines the id to search for
  34189. * @return the found skeleton or null if not found at all.
  34190. */
  34191. getSkeletonById(id: string): Nullable<Skeleton>;
  34192. /**
  34193. * Gets a skeleton using a given name
  34194. * @param name defines the name to search for
  34195. * @return the found skeleton or null if not found at all.
  34196. */
  34197. getSkeletonByName(name: string): Nullable<Skeleton>;
  34198. /**
  34199. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34200. * @param id defines the id to search for
  34201. * @return the found morph target manager or null if not found at all.
  34202. */
  34203. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34204. /**
  34205. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34206. * @param id defines the id to search for
  34207. * @return the found morph target or null if not found at all.
  34208. */
  34209. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34210. /**
  34211. * Gets a boolean indicating if the given mesh is active
  34212. * @param mesh defines the mesh to look for
  34213. * @returns true if the mesh is in the active list
  34214. */
  34215. isActiveMesh(mesh: AbstractMesh): boolean;
  34216. /**
  34217. * Return a unique id as a string which can serve as an identifier for the scene
  34218. */
  34219. readonly uid: string;
  34220. /**
  34221. * Add an externaly attached data from its key.
  34222. * This method call will fail and return false, if such key already exists.
  34223. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34224. * @param key the unique key that identifies the data
  34225. * @param data the data object to associate to the key for this Engine instance
  34226. * @return true if no such key were already present and the data was added successfully, false otherwise
  34227. */
  34228. addExternalData<T>(key: string, data: T): boolean;
  34229. /**
  34230. * Get an externaly attached data from its key
  34231. * @param key the unique key that identifies the data
  34232. * @return the associated data, if present (can be null), or undefined if not present
  34233. */
  34234. getExternalData<T>(key: string): Nullable<T>;
  34235. /**
  34236. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34237. * @param key the unique key that identifies the data
  34238. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34239. * @return the associated data, can be null if the factory returned null.
  34240. */
  34241. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34242. /**
  34243. * Remove an externaly attached data from the Engine instance
  34244. * @param key the unique key that identifies the data
  34245. * @return true if the data was successfully removed, false if it doesn't exist
  34246. */
  34247. removeExternalData(key: string): boolean;
  34248. private _evaluateSubMesh;
  34249. /**
  34250. * Clear the processed materials smart array preventing retention point in material dispose.
  34251. */
  34252. freeProcessedMaterials(): void;
  34253. private _preventFreeActiveMeshesAndRenderingGroups;
  34254. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34255. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34256. * when disposing several meshes in a row or a hierarchy of meshes.
  34257. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34258. */
  34259. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34260. /**
  34261. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34262. */
  34263. freeActiveMeshes(): void;
  34264. /**
  34265. * Clear the info related to rendering groups preventing retention points during dispose.
  34266. */
  34267. freeRenderingGroups(): void;
  34268. /** @hidden */
  34269. _isInIntermediateRendering(): boolean;
  34270. /**
  34271. * Lambda returning the list of potentially active meshes.
  34272. */
  34273. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34274. /**
  34275. * Lambda returning the list of potentially active sub meshes.
  34276. */
  34277. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34278. /**
  34279. * Lambda returning the list of potentially intersecting sub meshes.
  34280. */
  34281. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34282. /**
  34283. * Lambda returning the list of potentially colliding sub meshes.
  34284. */
  34285. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34286. private _activeMeshesFrozen;
  34287. /**
  34288. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34289. * @returns the current scene
  34290. */
  34291. freezeActiveMeshes(): Scene;
  34292. /**
  34293. * Use this function to restart evaluating active meshes on every frame
  34294. * @returns the current scene
  34295. */
  34296. unfreezeActiveMeshes(): Scene;
  34297. private _evaluateActiveMeshes;
  34298. private _activeMesh;
  34299. /**
  34300. * Update the transform matrix to update from the current active camera
  34301. * @param force defines a boolean used to force the update even if cache is up to date
  34302. */
  34303. updateTransformMatrix(force?: boolean): void;
  34304. private _bindFrameBuffer;
  34305. /** @hidden */
  34306. _allowPostProcessClearColor: boolean;
  34307. /** @hidden */
  34308. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34309. private _processSubCameras;
  34310. private _checkIntersections;
  34311. /** @hidden */
  34312. _advancePhysicsEngineStep(step: number): void;
  34313. /**
  34314. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34315. */
  34316. getDeterministicFrameTime: () => number;
  34317. /** @hidden */
  34318. _animate(): void;
  34319. /** Execute all animations (for a frame) */
  34320. animate(): void;
  34321. /**
  34322. * Render the scene
  34323. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34324. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34325. */
  34326. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34327. /**
  34328. * Freeze all materials
  34329. * A frozen material will not be updatable but should be faster to render
  34330. */
  34331. freezeMaterials(): void;
  34332. /**
  34333. * Unfreeze all materials
  34334. * A frozen material will not be updatable but should be faster to render
  34335. */
  34336. unfreezeMaterials(): void;
  34337. /**
  34338. * Releases all held ressources
  34339. */
  34340. dispose(): void;
  34341. /**
  34342. * Gets if the scene is already disposed
  34343. */
  34344. readonly isDisposed: boolean;
  34345. /**
  34346. * Call this function to reduce memory footprint of the scene.
  34347. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34348. */
  34349. clearCachedVertexData(): void;
  34350. /**
  34351. * This function will remove the local cached buffer data from texture.
  34352. * It will save memory but will prevent the texture from being rebuilt
  34353. */
  34354. cleanCachedTextureBuffer(): void;
  34355. /**
  34356. * Get the world extend vectors with an optional filter
  34357. *
  34358. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34359. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34360. */
  34361. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34362. min: Vector3;
  34363. max: Vector3;
  34364. };
  34365. /**
  34366. * Creates a ray that can be used to pick in the scene
  34367. * @param x defines the x coordinate of the origin (on-screen)
  34368. * @param y defines the y coordinate of the origin (on-screen)
  34369. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34370. * @param camera defines the camera to use for the picking
  34371. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34372. * @returns a Ray
  34373. */
  34374. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34375. /**
  34376. * Creates a ray that can be used to pick in the scene
  34377. * @param x defines the x coordinate of the origin (on-screen)
  34378. * @param y defines the y coordinate of the origin (on-screen)
  34379. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34380. * @param result defines the ray where to store the picking ray
  34381. * @param camera defines the camera to use for the picking
  34382. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34383. * @returns the current scene
  34384. */
  34385. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34386. /**
  34387. * Creates a ray that can be used to pick in the scene
  34388. * @param x defines the x coordinate of the origin (on-screen)
  34389. * @param y defines the y coordinate of the origin (on-screen)
  34390. * @param camera defines the camera to use for the picking
  34391. * @returns a Ray
  34392. */
  34393. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34394. /**
  34395. * Creates a ray that can be used to pick in the scene
  34396. * @param x defines the x coordinate of the origin (on-screen)
  34397. * @param y defines the y coordinate of the origin (on-screen)
  34398. * @param result defines the ray where to store the picking ray
  34399. * @param camera defines the camera to use for the picking
  34400. * @returns the current scene
  34401. */
  34402. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34403. /** Launch a ray to try to pick a mesh in the scene
  34404. * @param x position on screen
  34405. * @param y position on screen
  34406. * @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
  34407. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34408. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34409. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34410. * @returns a PickingInfo
  34411. */
  34412. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34413. /** Use the given ray to pick a mesh in the scene
  34414. * @param ray The ray to use to pick meshes
  34415. * @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
  34416. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34417. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34418. * @returns a PickingInfo
  34419. */
  34420. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34421. /**
  34422. * Launch a ray to try to pick a mesh in the scene
  34423. * @param x X position on screen
  34424. * @param y Y position on screen
  34425. * @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
  34426. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34427. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34428. * @returns an array of PickingInfo
  34429. */
  34430. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34431. /**
  34432. * Launch a ray to try to pick a mesh in the scene
  34433. * @param ray Ray to use
  34434. * @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
  34435. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34436. * @returns an array of PickingInfo
  34437. */
  34438. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34439. /**
  34440. * Force the value of meshUnderPointer
  34441. * @param mesh defines the mesh to use
  34442. */
  34443. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34444. /**
  34445. * Gets the mesh under the pointer
  34446. * @returns a Mesh or null if no mesh is under the pointer
  34447. */
  34448. getPointerOverMesh(): Nullable<AbstractMesh>;
  34449. /** @hidden */
  34450. _rebuildGeometries(): void;
  34451. /** @hidden */
  34452. _rebuildTextures(): void;
  34453. private _getByTags;
  34454. /**
  34455. * Get a list of meshes by tags
  34456. * @param tagsQuery defines the tags query to use
  34457. * @param forEach defines a predicate used to filter results
  34458. * @returns an array of Mesh
  34459. */
  34460. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34461. /**
  34462. * Get a list of cameras by tags
  34463. * @param tagsQuery defines the tags query to use
  34464. * @param forEach defines a predicate used to filter results
  34465. * @returns an array of Camera
  34466. */
  34467. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34468. /**
  34469. * Get a list of lights by tags
  34470. * @param tagsQuery defines the tags query to use
  34471. * @param forEach defines a predicate used to filter results
  34472. * @returns an array of Light
  34473. */
  34474. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34475. /**
  34476. * Get a list of materials by tags
  34477. * @param tagsQuery defines the tags query to use
  34478. * @param forEach defines a predicate used to filter results
  34479. * @returns an array of Material
  34480. */
  34481. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34482. /**
  34483. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34484. * This allowed control for front to back rendering or reversly depending of the special needs.
  34485. *
  34486. * @param renderingGroupId The rendering group id corresponding to its index
  34487. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34488. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34489. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34490. */
  34491. 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;
  34492. /**
  34493. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34494. *
  34495. * @param renderingGroupId The rendering group id corresponding to its index
  34496. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34497. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34498. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34499. */
  34500. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34501. /**
  34502. * Gets the current auto clear configuration for one rendering group of the rendering
  34503. * manager.
  34504. * @param index the rendering group index to get the information for
  34505. * @returns The auto clear setup for the requested rendering group
  34506. */
  34507. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34508. private _blockMaterialDirtyMechanism;
  34509. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34510. blockMaterialDirtyMechanism: boolean;
  34511. /**
  34512. * Will flag all materials as dirty to trigger new shader compilation
  34513. * @param flag defines the flag used to specify which material part must be marked as dirty
  34514. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34515. */
  34516. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34517. /** @hidden */
  34518. _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;
  34519. /** @hidden */
  34520. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34521. }
  34522. }
  34523. declare module BABYLON {
  34524. /**
  34525. * Set of assets to keep when moving a scene into an asset container.
  34526. */
  34527. export class KeepAssets extends AbstractScene {
  34528. }
  34529. /**
  34530. * Container with a set of assets that can be added or removed from a scene.
  34531. */
  34532. export class AssetContainer extends AbstractScene {
  34533. /**
  34534. * The scene the AssetContainer belongs to.
  34535. */
  34536. scene: Scene;
  34537. /**
  34538. * Instantiates an AssetContainer.
  34539. * @param scene The scene the AssetContainer belongs to.
  34540. */
  34541. constructor(scene: Scene);
  34542. /**
  34543. * Adds all the assets from the container to the scene.
  34544. */
  34545. addAllToScene(): void;
  34546. /**
  34547. * Removes all the assets in the container from the scene
  34548. */
  34549. removeAllFromScene(): void;
  34550. /**
  34551. * Disposes all the assets in the container
  34552. */
  34553. dispose(): void;
  34554. private _moveAssets;
  34555. /**
  34556. * Removes all the assets contained in the scene and adds them to the container.
  34557. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34558. */
  34559. moveAllFromScene(keepAssets?: KeepAssets): void;
  34560. /**
  34561. * 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.
  34562. * @returns the root mesh
  34563. */
  34564. createRootMesh(): Mesh;
  34565. }
  34566. }
  34567. declare module BABYLON {
  34568. /**
  34569. * Defines how the parser contract is defined.
  34570. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34571. */
  34572. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34573. /**
  34574. * Defines how the individual parser contract is defined.
  34575. * These parser can parse an individual asset
  34576. */
  34577. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34578. /**
  34579. * Base class of the scene acting as a container for the different elements composing a scene.
  34580. * This class is dynamically extended by the different components of the scene increasing
  34581. * flexibility and reducing coupling
  34582. */
  34583. export abstract class AbstractScene {
  34584. /**
  34585. * Stores the list of available parsers in the application.
  34586. */
  34587. private static _BabylonFileParsers;
  34588. /**
  34589. * Stores the list of available individual parsers in the application.
  34590. */
  34591. private static _IndividualBabylonFileParsers;
  34592. /**
  34593. * Adds a parser in the list of available ones
  34594. * @param name Defines the name of the parser
  34595. * @param parser Defines the parser to add
  34596. */
  34597. static AddParser(name: string, parser: BabylonFileParser): void;
  34598. /**
  34599. * Gets a general parser from the list of avaialble ones
  34600. * @param name Defines the name of the parser
  34601. * @returns the requested parser or null
  34602. */
  34603. static GetParser(name: string): Nullable<BabylonFileParser>;
  34604. /**
  34605. * Adds n individual parser in the list of available ones
  34606. * @param name Defines the name of the parser
  34607. * @param parser Defines the parser to add
  34608. */
  34609. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34610. /**
  34611. * Gets an individual parser from the list of avaialble ones
  34612. * @param name Defines the name of the parser
  34613. * @returns the requested parser or null
  34614. */
  34615. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34616. /**
  34617. * Parser json data and populate both a scene and its associated container object
  34618. * @param jsonData Defines the data to parse
  34619. * @param scene Defines the scene to parse the data for
  34620. * @param container Defines the container attached to the parsing sequence
  34621. * @param rootUrl Defines the root url of the data
  34622. */
  34623. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34624. /**
  34625. * Gets the list of root nodes (ie. nodes with no parent)
  34626. */
  34627. rootNodes: Node[];
  34628. /** All of the cameras added to this scene
  34629. * @see http://doc.babylonjs.com/babylon101/cameras
  34630. */
  34631. cameras: Camera[];
  34632. /**
  34633. * All of the lights added to this scene
  34634. * @see http://doc.babylonjs.com/babylon101/lights
  34635. */
  34636. lights: Light[];
  34637. /**
  34638. * All of the (abstract) meshes added to this scene
  34639. */
  34640. meshes: AbstractMesh[];
  34641. /**
  34642. * The list of skeletons added to the scene
  34643. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34644. */
  34645. skeletons: Skeleton[];
  34646. /**
  34647. * All of the particle systems added to this scene
  34648. * @see http://doc.babylonjs.com/babylon101/particles
  34649. */
  34650. particleSystems: IParticleSystem[];
  34651. /**
  34652. * Gets a list of Animations associated with the scene
  34653. */
  34654. animations: Animation[];
  34655. /**
  34656. * All of the animation groups added to this scene
  34657. * @see http://doc.babylonjs.com/how_to/group
  34658. */
  34659. animationGroups: AnimationGroup[];
  34660. /**
  34661. * All of the multi-materials added to this scene
  34662. * @see http://doc.babylonjs.com/how_to/multi_materials
  34663. */
  34664. multiMaterials: MultiMaterial[];
  34665. /**
  34666. * All of the materials added to this scene
  34667. * In the context of a Scene, it is not supposed to be modified manually.
  34668. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34669. * Note also that the order of the Material wihin the array is not significant and might change.
  34670. * @see http://doc.babylonjs.com/babylon101/materials
  34671. */
  34672. materials: Material[];
  34673. /**
  34674. * The list of morph target managers added to the scene
  34675. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34676. */
  34677. morphTargetManagers: MorphTargetManager[];
  34678. /**
  34679. * The list of geometries used in the scene.
  34680. */
  34681. geometries: Geometry[];
  34682. /**
  34683. * All of the tranform nodes added to this scene
  34684. * In the context of a Scene, it is not supposed to be modified manually.
  34685. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34686. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34687. * @see http://doc.babylonjs.com/how_to/transformnode
  34688. */
  34689. transformNodes: TransformNode[];
  34690. /**
  34691. * ActionManagers available on the scene.
  34692. */
  34693. actionManagers: AbstractActionManager[];
  34694. /**
  34695. * Textures to keep.
  34696. */
  34697. textures: BaseTexture[];
  34698. /**
  34699. * Environment texture for the scene
  34700. */
  34701. environmentTexture: Nullable<BaseTexture>;
  34702. }
  34703. }
  34704. declare module BABYLON {
  34705. /**
  34706. * Interface used to define options for Sound class
  34707. */
  34708. export interface ISoundOptions {
  34709. /**
  34710. * Does the sound autoplay once loaded.
  34711. */
  34712. autoplay?: boolean;
  34713. /**
  34714. * Does the sound loop after it finishes playing once.
  34715. */
  34716. loop?: boolean;
  34717. /**
  34718. * Sound's volume
  34719. */
  34720. volume?: number;
  34721. /**
  34722. * Is it a spatial sound?
  34723. */
  34724. spatialSound?: boolean;
  34725. /**
  34726. * Maximum distance to hear that sound
  34727. */
  34728. maxDistance?: number;
  34729. /**
  34730. * Uses user defined attenuation function
  34731. */
  34732. useCustomAttenuation?: boolean;
  34733. /**
  34734. * Define the roll off factor of spatial sounds.
  34735. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34736. */
  34737. rolloffFactor?: number;
  34738. /**
  34739. * Define the reference distance the sound should be heard perfectly.
  34740. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34741. */
  34742. refDistance?: number;
  34743. /**
  34744. * Define the distance attenuation model the sound will follow.
  34745. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34746. */
  34747. distanceModel?: string;
  34748. /**
  34749. * Defines the playback speed (1 by default)
  34750. */
  34751. playbackRate?: number;
  34752. /**
  34753. * Defines if the sound is from a streaming source
  34754. */
  34755. streaming?: boolean;
  34756. /**
  34757. * Defines an optional length (in seconds) inside the sound file
  34758. */
  34759. length?: number;
  34760. /**
  34761. * Defines an optional offset (in seconds) inside the sound file
  34762. */
  34763. offset?: number;
  34764. /**
  34765. * If true, URLs will not be required to state the audio file codec to use.
  34766. */
  34767. skipCodecCheck?: boolean;
  34768. }
  34769. /**
  34770. * Defines a sound that can be played in the application.
  34771. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34772. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34773. */
  34774. export class Sound {
  34775. /**
  34776. * The name of the sound in the scene.
  34777. */
  34778. name: string;
  34779. /**
  34780. * Does the sound autoplay once loaded.
  34781. */
  34782. autoplay: boolean;
  34783. /**
  34784. * Does the sound loop after it finishes playing once.
  34785. */
  34786. loop: boolean;
  34787. /**
  34788. * Does the sound use a custom attenuation curve to simulate the falloff
  34789. * happening when the source gets further away from the camera.
  34790. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34791. */
  34792. useCustomAttenuation: boolean;
  34793. /**
  34794. * The sound track id this sound belongs to.
  34795. */
  34796. soundTrackId: number;
  34797. /**
  34798. * Is this sound currently played.
  34799. */
  34800. isPlaying: boolean;
  34801. /**
  34802. * Is this sound currently paused.
  34803. */
  34804. isPaused: boolean;
  34805. /**
  34806. * Does this sound enables spatial sound.
  34807. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34808. */
  34809. spatialSound: boolean;
  34810. /**
  34811. * Define the reference distance the sound should be heard perfectly.
  34812. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34813. */
  34814. refDistance: number;
  34815. /**
  34816. * Define the roll off factor of spatial sounds.
  34817. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34818. */
  34819. rolloffFactor: number;
  34820. /**
  34821. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34822. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34823. */
  34824. maxDistance: number;
  34825. /**
  34826. * Define the distance attenuation model the sound will follow.
  34827. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34828. */
  34829. distanceModel: string;
  34830. /**
  34831. * @hidden
  34832. * Back Compat
  34833. **/
  34834. onended: () => any;
  34835. /**
  34836. * Observable event when the current playing sound finishes.
  34837. */
  34838. onEndedObservable: Observable<Sound>;
  34839. private _panningModel;
  34840. private _playbackRate;
  34841. private _streaming;
  34842. private _startTime;
  34843. private _startOffset;
  34844. private _position;
  34845. /** @hidden */
  34846. _positionInEmitterSpace: boolean;
  34847. private _localDirection;
  34848. private _volume;
  34849. private _isReadyToPlay;
  34850. private _isDirectional;
  34851. private _readyToPlayCallback;
  34852. private _audioBuffer;
  34853. private _soundSource;
  34854. private _streamingSource;
  34855. private _soundPanner;
  34856. private _soundGain;
  34857. private _inputAudioNode;
  34858. private _outputAudioNode;
  34859. private _coneInnerAngle;
  34860. private _coneOuterAngle;
  34861. private _coneOuterGain;
  34862. private _scene;
  34863. private _connectedTransformNode;
  34864. private _customAttenuationFunction;
  34865. private _registerFunc;
  34866. private _isOutputConnected;
  34867. private _htmlAudioElement;
  34868. private _urlType;
  34869. private _length?;
  34870. private _offset?;
  34871. /** @hidden */
  34872. static _SceneComponentInitialization: (scene: Scene) => void;
  34873. /**
  34874. * Create a sound and attach it to a scene
  34875. * @param name Name of your sound
  34876. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34877. * @param scene defines the scene the sound belongs to
  34878. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34879. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34880. */
  34881. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  34882. /**
  34883. * Release the sound and its associated resources
  34884. */
  34885. dispose(): void;
  34886. /**
  34887. * Gets if the sounds is ready to be played or not.
  34888. * @returns true if ready, otherwise false
  34889. */
  34890. isReady(): boolean;
  34891. private _soundLoaded;
  34892. /**
  34893. * Sets the data of the sound from an audiobuffer
  34894. * @param audioBuffer The audioBuffer containing the data
  34895. */
  34896. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34897. /**
  34898. * Updates the current sounds options such as maxdistance, loop...
  34899. * @param options A JSON object containing values named as the object properties
  34900. */
  34901. updateOptions(options: ISoundOptions): void;
  34902. private _createSpatialParameters;
  34903. private _updateSpatialParameters;
  34904. /**
  34905. * Switch the panning model to HRTF:
  34906. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34907. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34908. */
  34909. switchPanningModelToHRTF(): void;
  34910. /**
  34911. * Switch the panning model to Equal Power:
  34912. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34913. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34914. */
  34915. switchPanningModelToEqualPower(): void;
  34916. private _switchPanningModel;
  34917. /**
  34918. * Connect this sound to a sound track audio node like gain...
  34919. * @param soundTrackAudioNode the sound track audio node to connect to
  34920. */
  34921. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34922. /**
  34923. * Transform this sound into a directional source
  34924. * @param coneInnerAngle Size of the inner cone in degree
  34925. * @param coneOuterAngle Size of the outer cone in degree
  34926. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34927. */
  34928. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34929. /**
  34930. * Gets or sets the inner angle for the directional cone.
  34931. */
  34932. /**
  34933. * Gets or sets the inner angle for the directional cone.
  34934. */
  34935. directionalConeInnerAngle: number;
  34936. /**
  34937. * Gets or sets the outer angle for the directional cone.
  34938. */
  34939. /**
  34940. * Gets or sets the outer angle for the directional cone.
  34941. */
  34942. directionalConeOuterAngle: number;
  34943. /**
  34944. * Sets the position of the emitter if spatial sound is enabled
  34945. * @param newPosition Defines the new posisiton
  34946. */
  34947. setPosition(newPosition: Vector3): void;
  34948. /**
  34949. * Sets the local direction of the emitter if spatial sound is enabled
  34950. * @param newLocalDirection Defines the new local direction
  34951. */
  34952. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34953. private _updateDirection;
  34954. /** @hidden */
  34955. updateDistanceFromListener(): void;
  34956. /**
  34957. * Sets a new custom attenuation function for the sound.
  34958. * @param callback Defines the function used for the attenuation
  34959. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34960. */
  34961. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34962. /**
  34963. * Play the sound
  34964. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34965. * @param offset (optional) Start the sound at a specific time in seconds
  34966. * @param length (optional) Sound duration (in seconds)
  34967. */
  34968. play(time?: number, offset?: number, length?: number): void;
  34969. private _onended;
  34970. /**
  34971. * Stop the sound
  34972. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34973. */
  34974. stop(time?: number): void;
  34975. /**
  34976. * Put the sound in pause
  34977. */
  34978. pause(): void;
  34979. /**
  34980. * Sets a dedicated volume for this sounds
  34981. * @param newVolume Define the new volume of the sound
  34982. * @param time Define time for gradual change to new volume
  34983. */
  34984. setVolume(newVolume: number, time?: number): void;
  34985. /**
  34986. * Set the sound play back rate
  34987. * @param newPlaybackRate Define the playback rate the sound should be played at
  34988. */
  34989. setPlaybackRate(newPlaybackRate: number): void;
  34990. /**
  34991. * Gets the volume of the sound.
  34992. * @returns the volume of the sound
  34993. */
  34994. getVolume(): number;
  34995. /**
  34996. * Attach the sound to a dedicated mesh
  34997. * @param transformNode The transform node to connect the sound with
  34998. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34999. */
  35000. attachToMesh(transformNode: TransformNode): void;
  35001. /**
  35002. * Detach the sound from the previously attached mesh
  35003. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35004. */
  35005. detachFromMesh(): void;
  35006. private _onRegisterAfterWorldMatrixUpdate;
  35007. /**
  35008. * Clone the current sound in the scene.
  35009. * @returns the new sound clone
  35010. */
  35011. clone(): Nullable<Sound>;
  35012. /**
  35013. * Gets the current underlying audio buffer containing the data
  35014. * @returns the audio buffer
  35015. */
  35016. getAudioBuffer(): Nullable<AudioBuffer>;
  35017. /**
  35018. * Serializes the Sound in a JSON representation
  35019. * @returns the JSON representation of the sound
  35020. */
  35021. serialize(): any;
  35022. /**
  35023. * Parse a JSON representation of a sound to innstantiate in a given scene
  35024. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35025. * @param scene Define the scene the new parsed sound should be created in
  35026. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35027. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35028. * @returns the newly parsed sound
  35029. */
  35030. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35031. }
  35032. }
  35033. declare module BABYLON {
  35034. /**
  35035. * This defines an action helpful to play a defined sound on a triggered action.
  35036. */
  35037. export class PlaySoundAction extends Action {
  35038. private _sound;
  35039. /**
  35040. * Instantiate the action
  35041. * @param triggerOptions defines the trigger options
  35042. * @param sound defines the sound to play
  35043. * @param condition defines the trigger related conditions
  35044. */
  35045. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35046. /** @hidden */
  35047. _prepare(): void;
  35048. /**
  35049. * Execute the action and play the sound.
  35050. */
  35051. execute(): void;
  35052. /**
  35053. * Serializes the actions and its related information.
  35054. * @param parent defines the object to serialize in
  35055. * @returns the serialized object
  35056. */
  35057. serialize(parent: any): any;
  35058. }
  35059. /**
  35060. * This defines an action helpful to stop a defined sound on a triggered action.
  35061. */
  35062. export class StopSoundAction extends Action {
  35063. private _sound;
  35064. /**
  35065. * Instantiate the action
  35066. * @param triggerOptions defines the trigger options
  35067. * @param sound defines the sound to stop
  35068. * @param condition defines the trigger related conditions
  35069. */
  35070. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35071. /** @hidden */
  35072. _prepare(): void;
  35073. /**
  35074. * Execute the action and stop the sound.
  35075. */
  35076. execute(): void;
  35077. /**
  35078. * Serializes the actions and its related information.
  35079. * @param parent defines the object to serialize in
  35080. * @returns the serialized object
  35081. */
  35082. serialize(parent: any): any;
  35083. }
  35084. }
  35085. declare module BABYLON {
  35086. /**
  35087. * This defines an action responsible to change the value of a property
  35088. * by interpolating between its current value and the newly set one once triggered.
  35089. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35090. */
  35091. export class InterpolateValueAction extends Action {
  35092. /**
  35093. * Defines the path of the property where the value should be interpolated
  35094. */
  35095. propertyPath: string;
  35096. /**
  35097. * Defines the target value at the end of the interpolation.
  35098. */
  35099. value: any;
  35100. /**
  35101. * Defines the time it will take for the property to interpolate to the value.
  35102. */
  35103. duration: number;
  35104. /**
  35105. * Defines if the other scene animations should be stopped when the action has been triggered
  35106. */
  35107. stopOtherAnimations?: boolean;
  35108. /**
  35109. * Defines a callback raised once the interpolation animation has been done.
  35110. */
  35111. onInterpolationDone?: () => void;
  35112. /**
  35113. * Observable triggered once the interpolation animation has been done.
  35114. */
  35115. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35116. private _target;
  35117. private _effectiveTarget;
  35118. private _property;
  35119. /**
  35120. * Instantiate the action
  35121. * @param triggerOptions defines the trigger options
  35122. * @param target defines the object containing the value to interpolate
  35123. * @param propertyPath defines the path to the property in the target object
  35124. * @param value defines the target value at the end of the interpolation
  35125. * @param duration deines the time it will take for the property to interpolate to the value.
  35126. * @param condition defines the trigger related conditions
  35127. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35128. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35129. */
  35130. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35131. /** @hidden */
  35132. _prepare(): void;
  35133. /**
  35134. * Execute the action starts the value interpolation.
  35135. */
  35136. execute(): void;
  35137. /**
  35138. * Serializes the actions and its related information.
  35139. * @param parent defines the object to serialize in
  35140. * @returns the serialized object
  35141. */
  35142. serialize(parent: any): any;
  35143. }
  35144. }
  35145. declare module BABYLON {
  35146. /**
  35147. * Options allowed during the creation of a sound track.
  35148. */
  35149. export interface ISoundTrackOptions {
  35150. /**
  35151. * The volume the sound track should take during creation
  35152. */
  35153. volume?: number;
  35154. /**
  35155. * Define if the sound track is the main sound track of the scene
  35156. */
  35157. mainTrack?: boolean;
  35158. }
  35159. /**
  35160. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35161. * It will be also used in a future release to apply effects on a specific track.
  35162. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35163. */
  35164. export class SoundTrack {
  35165. /**
  35166. * The unique identifier of the sound track in the scene.
  35167. */
  35168. id: number;
  35169. /**
  35170. * The list of sounds included in the sound track.
  35171. */
  35172. soundCollection: Array<Sound>;
  35173. private _outputAudioNode;
  35174. private _scene;
  35175. private _isMainTrack;
  35176. private _connectedAnalyser;
  35177. private _options;
  35178. private _isInitialized;
  35179. /**
  35180. * Creates a new sound track.
  35181. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35182. * @param scene Define the scene the sound track belongs to
  35183. * @param options
  35184. */
  35185. constructor(scene: Scene, options?: ISoundTrackOptions);
  35186. private _initializeSoundTrackAudioGraph;
  35187. /**
  35188. * Release the sound track and its associated resources
  35189. */
  35190. dispose(): void;
  35191. /**
  35192. * Adds a sound to this sound track
  35193. * @param sound define the cound to add
  35194. * @ignoreNaming
  35195. */
  35196. AddSound(sound: Sound): void;
  35197. /**
  35198. * Removes a sound to this sound track
  35199. * @param sound define the cound to remove
  35200. * @ignoreNaming
  35201. */
  35202. RemoveSound(sound: Sound): void;
  35203. /**
  35204. * Set a global volume for the full sound track.
  35205. * @param newVolume Define the new volume of the sound track
  35206. */
  35207. setVolume(newVolume: number): void;
  35208. /**
  35209. * Switch the panning model to HRTF:
  35210. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35211. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35212. */
  35213. switchPanningModelToHRTF(): void;
  35214. /**
  35215. * Switch the panning model to Equal Power:
  35216. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35217. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35218. */
  35219. switchPanningModelToEqualPower(): void;
  35220. /**
  35221. * Connect the sound track to an audio analyser allowing some amazing
  35222. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35223. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35224. * @param analyser The analyser to connect to the engine
  35225. */
  35226. connectToAnalyser(analyser: Analyser): void;
  35227. }
  35228. }
  35229. declare module BABYLON {
  35230. interface AbstractScene {
  35231. /**
  35232. * The list of sounds used in the scene.
  35233. */
  35234. sounds: Nullable<Array<Sound>>;
  35235. }
  35236. interface Scene {
  35237. /**
  35238. * @hidden
  35239. * Backing field
  35240. */
  35241. _mainSoundTrack: SoundTrack;
  35242. /**
  35243. * The main sound track played by the scene.
  35244. * It cotains your primary collection of sounds.
  35245. */
  35246. mainSoundTrack: SoundTrack;
  35247. /**
  35248. * The list of sound tracks added to the scene
  35249. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35250. */
  35251. soundTracks: Nullable<Array<SoundTrack>>;
  35252. /**
  35253. * Gets a sound using a given name
  35254. * @param name defines the name to search for
  35255. * @return the found sound or null if not found at all.
  35256. */
  35257. getSoundByName(name: string): Nullable<Sound>;
  35258. /**
  35259. * Gets or sets if audio support is enabled
  35260. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35261. */
  35262. audioEnabled: boolean;
  35263. /**
  35264. * Gets or sets if audio will be output to headphones
  35265. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35266. */
  35267. headphone: boolean;
  35268. /**
  35269. * Gets or sets custom audio listener position provider
  35270. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35271. */
  35272. audioListenerPositionProvider: Nullable<() => Vector3>;
  35273. }
  35274. /**
  35275. * Defines the sound scene component responsible to manage any sounds
  35276. * in a given scene.
  35277. */
  35278. export class AudioSceneComponent implements ISceneSerializableComponent {
  35279. /**
  35280. * The component name helpfull to identify the component in the list of scene components.
  35281. */
  35282. readonly name: string;
  35283. /**
  35284. * The scene the component belongs to.
  35285. */
  35286. scene: Scene;
  35287. private _audioEnabled;
  35288. /**
  35289. * Gets whether audio is enabled or not.
  35290. * Please use related enable/disable method to switch state.
  35291. */
  35292. readonly audioEnabled: boolean;
  35293. private _headphone;
  35294. /**
  35295. * Gets whether audio is outputing to headphone or not.
  35296. * Please use the according Switch methods to change output.
  35297. */
  35298. readonly headphone: boolean;
  35299. private _audioListenerPositionProvider;
  35300. /**
  35301. * Gets the current audio listener position provider
  35302. */
  35303. /**
  35304. * Sets a custom listener position for all sounds in the scene
  35305. * By default, this is the position of the first active camera
  35306. */
  35307. audioListenerPositionProvider: Nullable<() => Vector3>;
  35308. /**
  35309. * Creates a new instance of the component for the given scene
  35310. * @param scene Defines the scene to register the component in
  35311. */
  35312. constructor(scene: Scene);
  35313. /**
  35314. * Registers the component in a given scene
  35315. */
  35316. register(): void;
  35317. /**
  35318. * Rebuilds the elements related to this component in case of
  35319. * context lost for instance.
  35320. */
  35321. rebuild(): void;
  35322. /**
  35323. * Serializes the component data to the specified json object
  35324. * @param serializationObject The object to serialize to
  35325. */
  35326. serialize(serializationObject: any): void;
  35327. /**
  35328. * Adds all the elements from the container to the scene
  35329. * @param container the container holding the elements
  35330. */
  35331. addFromContainer(container: AbstractScene): void;
  35332. /**
  35333. * Removes all the elements in the container from the scene
  35334. * @param container contains the elements to remove
  35335. * @param dispose if the removed element should be disposed (default: false)
  35336. */
  35337. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35338. /**
  35339. * Disposes the component and the associated ressources.
  35340. */
  35341. dispose(): void;
  35342. /**
  35343. * Disables audio in the associated scene.
  35344. */
  35345. disableAudio(): void;
  35346. /**
  35347. * Enables audio in the associated scene.
  35348. */
  35349. enableAudio(): void;
  35350. /**
  35351. * Switch audio to headphone output.
  35352. */
  35353. switchAudioModeForHeadphones(): void;
  35354. /**
  35355. * Switch audio to normal speakers.
  35356. */
  35357. switchAudioModeForNormalSpeakers(): void;
  35358. private _afterRender;
  35359. }
  35360. }
  35361. declare module BABYLON {
  35362. /**
  35363. * Wraps one or more Sound objects and selects one with random weight for playback.
  35364. */
  35365. export class WeightedSound {
  35366. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35367. loop: boolean;
  35368. private _coneInnerAngle;
  35369. private _coneOuterAngle;
  35370. private _volume;
  35371. /** A Sound is currently playing. */
  35372. isPlaying: boolean;
  35373. /** A Sound is currently paused. */
  35374. isPaused: boolean;
  35375. private _sounds;
  35376. private _weights;
  35377. private _currentIndex?;
  35378. /**
  35379. * Creates a new WeightedSound from the list of sounds given.
  35380. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35381. * @param sounds Array of Sounds that will be selected from.
  35382. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35383. */
  35384. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35385. /**
  35386. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35387. */
  35388. /**
  35389. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35390. */
  35391. directionalConeInnerAngle: number;
  35392. /**
  35393. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35394. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35395. */
  35396. /**
  35397. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35398. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35399. */
  35400. directionalConeOuterAngle: number;
  35401. /**
  35402. * Playback volume.
  35403. */
  35404. /**
  35405. * Playback volume.
  35406. */
  35407. volume: number;
  35408. private _onended;
  35409. /**
  35410. * Suspend playback
  35411. */
  35412. pause(): void;
  35413. /**
  35414. * Stop playback
  35415. */
  35416. stop(): void;
  35417. /**
  35418. * Start playback.
  35419. * @param startOffset Position the clip head at a specific time in seconds.
  35420. */
  35421. play(startOffset?: number): void;
  35422. }
  35423. }
  35424. declare module BABYLON {
  35425. /**
  35426. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35427. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35428. */
  35429. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35430. /**
  35431. * Gets the name of the behavior.
  35432. */
  35433. readonly name: string;
  35434. /**
  35435. * The easing function used by animations
  35436. */
  35437. static EasingFunction: BackEase;
  35438. /**
  35439. * The easing mode used by animations
  35440. */
  35441. static EasingMode: number;
  35442. /**
  35443. * The duration of the animation, in milliseconds
  35444. */
  35445. transitionDuration: number;
  35446. /**
  35447. * Length of the distance animated by the transition when lower radius is reached
  35448. */
  35449. lowerRadiusTransitionRange: number;
  35450. /**
  35451. * Length of the distance animated by the transition when upper radius is reached
  35452. */
  35453. upperRadiusTransitionRange: number;
  35454. private _autoTransitionRange;
  35455. /**
  35456. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35457. */
  35458. /**
  35459. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35460. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35461. */
  35462. autoTransitionRange: boolean;
  35463. private _attachedCamera;
  35464. private _onAfterCheckInputsObserver;
  35465. private _onMeshTargetChangedObserver;
  35466. /**
  35467. * Initializes the behavior.
  35468. */
  35469. init(): void;
  35470. /**
  35471. * Attaches the behavior to its arc rotate camera.
  35472. * @param camera Defines the camera to attach the behavior to
  35473. */
  35474. attach(camera: ArcRotateCamera): void;
  35475. /**
  35476. * Detaches the behavior from its current arc rotate camera.
  35477. */
  35478. detach(): void;
  35479. private _radiusIsAnimating;
  35480. private _radiusBounceTransition;
  35481. private _animatables;
  35482. private _cachedWheelPrecision;
  35483. /**
  35484. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35485. * @param radiusLimit The limit to check against.
  35486. * @return Bool to indicate if at limit.
  35487. */
  35488. private _isRadiusAtLimit;
  35489. /**
  35490. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35491. * @param radiusDelta The delta by which to animate to. Can be negative.
  35492. */
  35493. private _applyBoundRadiusAnimation;
  35494. /**
  35495. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35496. */
  35497. protected _clearAnimationLocks(): void;
  35498. /**
  35499. * Stops and removes all animations that have been applied to the camera
  35500. */
  35501. stopAllAnimations(): void;
  35502. }
  35503. }
  35504. declare module BABYLON {
  35505. /**
  35506. * 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.
  35507. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35508. */
  35509. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35510. /**
  35511. * Gets the name of the behavior.
  35512. */
  35513. readonly name: string;
  35514. private _mode;
  35515. private _radiusScale;
  35516. private _positionScale;
  35517. private _defaultElevation;
  35518. private _elevationReturnTime;
  35519. private _elevationReturnWaitTime;
  35520. private _zoomStopsAnimation;
  35521. private _framingTime;
  35522. /**
  35523. * The easing function used by animations
  35524. */
  35525. static EasingFunction: ExponentialEase;
  35526. /**
  35527. * The easing mode used by animations
  35528. */
  35529. static EasingMode: number;
  35530. /**
  35531. * Sets the current mode used by the behavior
  35532. */
  35533. /**
  35534. * Gets current mode used by the behavior.
  35535. */
  35536. mode: number;
  35537. /**
  35538. * Sets the scale applied to the radius (1 by default)
  35539. */
  35540. /**
  35541. * Gets the scale applied to the radius
  35542. */
  35543. radiusScale: number;
  35544. /**
  35545. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35546. */
  35547. /**
  35548. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35549. */
  35550. positionScale: number;
  35551. /**
  35552. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35553. * behaviour is triggered, in radians.
  35554. */
  35555. /**
  35556. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35557. * behaviour is triggered, in radians.
  35558. */
  35559. defaultElevation: number;
  35560. /**
  35561. * Sets the time (in milliseconds) taken to return to the default beta position.
  35562. * Negative value indicates camera should not return to default.
  35563. */
  35564. /**
  35565. * Gets the time (in milliseconds) taken to return to the default beta position.
  35566. * Negative value indicates camera should not return to default.
  35567. */
  35568. elevationReturnTime: number;
  35569. /**
  35570. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35571. */
  35572. /**
  35573. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35574. */
  35575. elevationReturnWaitTime: number;
  35576. /**
  35577. * Sets the flag that indicates if user zooming should stop animation.
  35578. */
  35579. /**
  35580. * Gets the flag that indicates if user zooming should stop animation.
  35581. */
  35582. zoomStopsAnimation: boolean;
  35583. /**
  35584. * Sets the transition time when framing the mesh, in milliseconds
  35585. */
  35586. /**
  35587. * Gets the transition time when framing the mesh, in milliseconds
  35588. */
  35589. framingTime: number;
  35590. /**
  35591. * Define if the behavior should automatically change the configured
  35592. * camera limits and sensibilities.
  35593. */
  35594. autoCorrectCameraLimitsAndSensibility: boolean;
  35595. private _onPrePointerObservableObserver;
  35596. private _onAfterCheckInputsObserver;
  35597. private _onMeshTargetChangedObserver;
  35598. private _attachedCamera;
  35599. private _isPointerDown;
  35600. private _lastInteractionTime;
  35601. /**
  35602. * Initializes the behavior.
  35603. */
  35604. init(): void;
  35605. /**
  35606. * Attaches the behavior to its arc rotate camera.
  35607. * @param camera Defines the camera to attach the behavior to
  35608. */
  35609. attach(camera: ArcRotateCamera): void;
  35610. /**
  35611. * Detaches the behavior from its current arc rotate camera.
  35612. */
  35613. detach(): void;
  35614. private _animatables;
  35615. private _betaIsAnimating;
  35616. private _betaTransition;
  35617. private _radiusTransition;
  35618. private _vectorTransition;
  35619. /**
  35620. * Targets the given mesh and updates zoom level accordingly.
  35621. * @param mesh The mesh to target.
  35622. * @param radius Optional. If a cached radius position already exists, overrides default.
  35623. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35624. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35625. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35626. */
  35627. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35628. /**
  35629. * Targets the given mesh with its children and updates zoom level accordingly.
  35630. * @param mesh The mesh to target.
  35631. * @param radius Optional. If a cached radius position already exists, overrides default.
  35632. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35633. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35634. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35635. */
  35636. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35637. /**
  35638. * Targets the given meshes with their children and updates zoom level accordingly.
  35639. * @param meshes The mesh to target.
  35640. * @param radius Optional. If a cached radius position already exists, overrides default.
  35641. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35642. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35643. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35644. */
  35645. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35646. /**
  35647. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35648. * @param minimumWorld Determines the smaller position of the bounding box extend
  35649. * @param maximumWorld Determines the bigger position of the bounding box extend
  35650. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35651. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35652. */
  35653. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35654. /**
  35655. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35656. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35657. * frustum width.
  35658. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35659. * to fully enclose the mesh in the viewing frustum.
  35660. */
  35661. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35662. /**
  35663. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35664. * is automatically returned to its default position (expected to be above ground plane).
  35665. */
  35666. private _maintainCameraAboveGround;
  35667. /**
  35668. * Returns the frustum slope based on the canvas ratio and camera FOV
  35669. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35670. */
  35671. private _getFrustumSlope;
  35672. /**
  35673. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35674. */
  35675. private _clearAnimationLocks;
  35676. /**
  35677. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35678. */
  35679. private _applyUserInteraction;
  35680. /**
  35681. * Stops and removes all animations that have been applied to the camera
  35682. */
  35683. stopAllAnimations(): void;
  35684. /**
  35685. * Gets a value indicating if the user is moving the camera
  35686. */
  35687. readonly isUserIsMoving: boolean;
  35688. /**
  35689. * The camera can move all the way towards the mesh.
  35690. */
  35691. static IgnoreBoundsSizeMode: number;
  35692. /**
  35693. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35694. */
  35695. static FitFrustumSidesMode: number;
  35696. }
  35697. }
  35698. declare module BABYLON {
  35699. /**
  35700. * Base class for Camera Pointer Inputs.
  35701. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35702. * for example usage.
  35703. */
  35704. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35705. /**
  35706. * Defines the camera the input is attached to.
  35707. */
  35708. abstract camera: Camera;
  35709. /**
  35710. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35711. */
  35712. protected _altKey: boolean;
  35713. protected _ctrlKey: boolean;
  35714. protected _metaKey: boolean;
  35715. protected _shiftKey: boolean;
  35716. /**
  35717. * Which mouse buttons were pressed at time of last mouse event.
  35718. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35719. */
  35720. protected _buttonsPressed: number;
  35721. /**
  35722. * Defines the buttons associated with the input to handle camera move.
  35723. */
  35724. buttons: number[];
  35725. /**
  35726. * Attach the input controls to a specific dom element to get the input from.
  35727. * @param element Defines the element the controls should be listened from
  35728. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35729. */
  35730. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35731. /**
  35732. * Detach the current controls from the specified dom element.
  35733. * @param element Defines the element to stop listening the inputs from
  35734. */
  35735. detachControl(element: Nullable<HTMLElement>): void;
  35736. /**
  35737. * Gets the class name of the current input.
  35738. * @returns the class name
  35739. */
  35740. getClassName(): string;
  35741. /**
  35742. * Get the friendly name associated with the input class.
  35743. * @returns the input friendly name
  35744. */
  35745. getSimpleName(): string;
  35746. /**
  35747. * Called on pointer POINTERDOUBLETAP event.
  35748. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35749. */
  35750. protected onDoubleTap(type: string): void;
  35751. /**
  35752. * Called on pointer POINTERMOVE event if only a single touch is active.
  35753. * Override this method to provide functionality.
  35754. */
  35755. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35756. /**
  35757. * Called on pointer POINTERMOVE event if multiple touches are active.
  35758. * Override this method to provide functionality.
  35759. */
  35760. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35761. /**
  35762. * Called on JS contextmenu event.
  35763. * Override this method to provide functionality.
  35764. */
  35765. protected onContextMenu(evt: PointerEvent): void;
  35766. /**
  35767. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35768. * press.
  35769. * Override this method to provide functionality.
  35770. */
  35771. protected onButtonDown(evt: PointerEvent): void;
  35772. /**
  35773. * Called each time a new POINTERUP event occurs. Ie, for each button
  35774. * release.
  35775. * Override this method to provide functionality.
  35776. */
  35777. protected onButtonUp(evt: PointerEvent): void;
  35778. /**
  35779. * Called when window becomes inactive.
  35780. * Override this method to provide functionality.
  35781. */
  35782. protected onLostFocus(): void;
  35783. private _pointerInput;
  35784. private _observer;
  35785. private _onLostFocus;
  35786. private pointA;
  35787. private pointB;
  35788. }
  35789. }
  35790. declare module BABYLON {
  35791. /**
  35792. * Manage the pointers inputs to control an arc rotate camera.
  35793. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35794. */
  35795. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35796. /**
  35797. * Defines the camera the input is attached to.
  35798. */
  35799. camera: ArcRotateCamera;
  35800. /**
  35801. * Gets the class name of the current input.
  35802. * @returns the class name
  35803. */
  35804. getClassName(): string;
  35805. /**
  35806. * Defines the buttons associated with the input to handle camera move.
  35807. */
  35808. buttons: number[];
  35809. /**
  35810. * Defines the pointer angular sensibility along the X axis or how fast is
  35811. * the camera rotating.
  35812. */
  35813. angularSensibilityX: number;
  35814. /**
  35815. * Defines the pointer angular sensibility along the Y axis or how fast is
  35816. * the camera rotating.
  35817. */
  35818. angularSensibilityY: number;
  35819. /**
  35820. * Defines the pointer pinch precision or how fast is the camera zooming.
  35821. */
  35822. pinchPrecision: number;
  35823. /**
  35824. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35825. * from 0.
  35826. * It defines the percentage of current camera.radius to use as delta when
  35827. * pinch zoom is used.
  35828. */
  35829. pinchDeltaPercentage: number;
  35830. /**
  35831. * Defines the pointer panning sensibility or how fast is the camera moving.
  35832. */
  35833. panningSensibility: number;
  35834. /**
  35835. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35836. */
  35837. multiTouchPanning: boolean;
  35838. /**
  35839. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35840. * zoom (pinch) through multitouch.
  35841. */
  35842. multiTouchPanAndZoom: boolean;
  35843. /**
  35844. * Revers pinch action direction.
  35845. */
  35846. pinchInwards: boolean;
  35847. private _isPanClick;
  35848. private _twoFingerActivityCount;
  35849. private _isPinching;
  35850. /**
  35851. * Called on pointer POINTERMOVE event if only a single touch is active.
  35852. */
  35853. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35854. /**
  35855. * Called on pointer POINTERDOUBLETAP event.
  35856. */
  35857. protected onDoubleTap(type: string): void;
  35858. /**
  35859. * Called on pointer POINTERMOVE event if multiple touches are active.
  35860. */
  35861. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35862. /**
  35863. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35864. * press.
  35865. */
  35866. protected onButtonDown(evt: PointerEvent): void;
  35867. /**
  35868. * Called each time a new POINTERUP event occurs. Ie, for each button
  35869. * release.
  35870. */
  35871. protected onButtonUp(evt: PointerEvent): void;
  35872. /**
  35873. * Called when window becomes inactive.
  35874. */
  35875. protected onLostFocus(): void;
  35876. }
  35877. }
  35878. declare module BABYLON {
  35879. /**
  35880. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35881. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35882. */
  35883. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35884. /**
  35885. * Defines the camera the input is attached to.
  35886. */
  35887. camera: ArcRotateCamera;
  35888. /**
  35889. * Defines the list of key codes associated with the up action (increase alpha)
  35890. */
  35891. keysUp: number[];
  35892. /**
  35893. * Defines the list of key codes associated with the down action (decrease alpha)
  35894. */
  35895. keysDown: number[];
  35896. /**
  35897. * Defines the list of key codes associated with the left action (increase beta)
  35898. */
  35899. keysLeft: number[];
  35900. /**
  35901. * Defines the list of key codes associated with the right action (decrease beta)
  35902. */
  35903. keysRight: number[];
  35904. /**
  35905. * Defines the list of key codes associated with the reset action.
  35906. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35907. */
  35908. keysReset: number[];
  35909. /**
  35910. * Defines the panning sensibility of the inputs.
  35911. * (How fast is the camera paning)
  35912. */
  35913. panningSensibility: number;
  35914. /**
  35915. * Defines the zooming sensibility of the inputs.
  35916. * (How fast is the camera zooming)
  35917. */
  35918. zoomingSensibility: number;
  35919. /**
  35920. * Defines wether maintaining the alt key down switch the movement mode from
  35921. * orientation to zoom.
  35922. */
  35923. useAltToZoom: boolean;
  35924. /**
  35925. * Rotation speed of the camera
  35926. */
  35927. angularSpeed: number;
  35928. private _keys;
  35929. private _ctrlPressed;
  35930. private _altPressed;
  35931. private _onCanvasBlurObserver;
  35932. private _onKeyboardObserver;
  35933. private _engine;
  35934. private _scene;
  35935. /**
  35936. * Attach the input controls to a specific dom element to get the input from.
  35937. * @param element Defines the element the controls should be listened from
  35938. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35939. */
  35940. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35941. /**
  35942. * Detach the current controls from the specified dom element.
  35943. * @param element Defines the element to stop listening the inputs from
  35944. */
  35945. detachControl(element: Nullable<HTMLElement>): void;
  35946. /**
  35947. * Update the current camera state depending on the inputs that have been used this frame.
  35948. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35949. */
  35950. checkInputs(): void;
  35951. /**
  35952. * Gets the class name of the current intput.
  35953. * @returns the class name
  35954. */
  35955. getClassName(): string;
  35956. /**
  35957. * Get the friendly name associated with the input class.
  35958. * @returns the input friendly name
  35959. */
  35960. getSimpleName(): string;
  35961. }
  35962. }
  35963. declare module BABYLON {
  35964. /**
  35965. * Manage the mouse wheel inputs to control an arc rotate camera.
  35966. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35967. */
  35968. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35969. /**
  35970. * Defines the camera the input is attached to.
  35971. */
  35972. camera: ArcRotateCamera;
  35973. /**
  35974. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35975. */
  35976. wheelPrecision: number;
  35977. /**
  35978. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35979. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35980. */
  35981. wheelDeltaPercentage: number;
  35982. private _wheel;
  35983. private _observer;
  35984. private computeDeltaFromMouseWheelLegacyEvent;
  35985. /**
  35986. * Attach the input controls to a specific dom element to get the input from.
  35987. * @param element Defines the element the controls should be listened from
  35988. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35989. */
  35990. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35991. /**
  35992. * Detach the current controls from the specified dom element.
  35993. * @param element Defines the element to stop listening the inputs from
  35994. */
  35995. detachControl(element: Nullable<HTMLElement>): void;
  35996. /**
  35997. * Gets the class name of the current intput.
  35998. * @returns the class name
  35999. */
  36000. getClassName(): string;
  36001. /**
  36002. * Get the friendly name associated with the input class.
  36003. * @returns the input friendly name
  36004. */
  36005. getSimpleName(): string;
  36006. }
  36007. }
  36008. declare module BABYLON {
  36009. /**
  36010. * Default Inputs manager for the ArcRotateCamera.
  36011. * It groups all the default supported inputs for ease of use.
  36012. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36013. */
  36014. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36015. /**
  36016. * Instantiates a new ArcRotateCameraInputsManager.
  36017. * @param camera Defines the camera the inputs belong to
  36018. */
  36019. constructor(camera: ArcRotateCamera);
  36020. /**
  36021. * Add mouse wheel input support to the input manager.
  36022. * @returns the current input manager
  36023. */
  36024. addMouseWheel(): ArcRotateCameraInputsManager;
  36025. /**
  36026. * Add pointers input support to the input manager.
  36027. * @returns the current input manager
  36028. */
  36029. addPointers(): ArcRotateCameraInputsManager;
  36030. /**
  36031. * Add keyboard input support to the input manager.
  36032. * @returns the current input manager
  36033. */
  36034. addKeyboard(): ArcRotateCameraInputsManager;
  36035. }
  36036. }
  36037. declare module BABYLON {
  36038. /**
  36039. * This represents an orbital type of camera.
  36040. *
  36041. * 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.
  36042. * 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.
  36043. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36044. */
  36045. export class ArcRotateCamera extends TargetCamera {
  36046. /**
  36047. * Defines the rotation angle of the camera along the longitudinal axis.
  36048. */
  36049. alpha: number;
  36050. /**
  36051. * Defines the rotation angle of the camera along the latitudinal axis.
  36052. */
  36053. beta: number;
  36054. /**
  36055. * Defines the radius of the camera from it s target point.
  36056. */
  36057. radius: number;
  36058. protected _target: Vector3;
  36059. protected _targetHost: Nullable<AbstractMesh>;
  36060. /**
  36061. * Defines the target point of the camera.
  36062. * The camera looks towards it form the radius distance.
  36063. */
  36064. target: Vector3;
  36065. /**
  36066. * Define the current local position of the camera in the scene
  36067. */
  36068. position: Vector3;
  36069. protected _upVector: Vector3;
  36070. protected _upToYMatrix: Matrix;
  36071. protected _YToUpMatrix: Matrix;
  36072. /**
  36073. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36074. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36075. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36076. */
  36077. upVector: Vector3;
  36078. /**
  36079. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36080. */
  36081. setMatUp(): void;
  36082. /**
  36083. * Current inertia value on the longitudinal axis.
  36084. * The bigger this number the longer it will take for the camera to stop.
  36085. */
  36086. inertialAlphaOffset: number;
  36087. /**
  36088. * Current inertia value on the latitudinal axis.
  36089. * The bigger this number the longer it will take for the camera to stop.
  36090. */
  36091. inertialBetaOffset: number;
  36092. /**
  36093. * Current inertia value on the radius axis.
  36094. * The bigger this number the longer it will take for the camera to stop.
  36095. */
  36096. inertialRadiusOffset: number;
  36097. /**
  36098. * Minimum allowed angle on the longitudinal axis.
  36099. * This can help limiting how the Camera is able to move in the scene.
  36100. */
  36101. lowerAlphaLimit: Nullable<number>;
  36102. /**
  36103. * Maximum allowed angle on the longitudinal axis.
  36104. * This can help limiting how the Camera is able to move in the scene.
  36105. */
  36106. upperAlphaLimit: Nullable<number>;
  36107. /**
  36108. * Minimum allowed angle on the latitudinal axis.
  36109. * This can help limiting how the Camera is able to move in the scene.
  36110. */
  36111. lowerBetaLimit: number;
  36112. /**
  36113. * Maximum allowed angle on the latitudinal axis.
  36114. * This can help limiting how the Camera is able to move in the scene.
  36115. */
  36116. upperBetaLimit: number;
  36117. /**
  36118. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36119. * This can help limiting how the Camera is able to move in the scene.
  36120. */
  36121. lowerRadiusLimit: Nullable<number>;
  36122. /**
  36123. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36124. * This can help limiting how the Camera is able to move in the scene.
  36125. */
  36126. upperRadiusLimit: Nullable<number>;
  36127. /**
  36128. * Defines the current inertia value used during panning of the camera along the X axis.
  36129. */
  36130. inertialPanningX: number;
  36131. /**
  36132. * Defines the current inertia value used during panning of the camera along the Y axis.
  36133. */
  36134. inertialPanningY: number;
  36135. /**
  36136. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36137. * Basically if your fingers moves away from more than this distance you will be considered
  36138. * in pinch mode.
  36139. */
  36140. pinchToPanMaxDistance: number;
  36141. /**
  36142. * Defines the maximum distance the camera can pan.
  36143. * This could help keeping the cammera always in your scene.
  36144. */
  36145. panningDistanceLimit: Nullable<number>;
  36146. /**
  36147. * Defines the target of the camera before paning.
  36148. */
  36149. panningOriginTarget: Vector3;
  36150. /**
  36151. * Defines the value of the inertia used during panning.
  36152. * 0 would mean stop inertia and one would mean no decelleration at all.
  36153. */
  36154. panningInertia: number;
  36155. /**
  36156. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36157. */
  36158. angularSensibilityX: number;
  36159. /**
  36160. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36161. */
  36162. angularSensibilityY: number;
  36163. /**
  36164. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36165. */
  36166. pinchPrecision: number;
  36167. /**
  36168. * Gets or Set the pointer pinch 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. pinchDeltaPercentage: number;
  36173. /**
  36174. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36175. */
  36176. panningSensibility: number;
  36177. /**
  36178. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36179. */
  36180. keysUp: number[];
  36181. /**
  36182. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36183. */
  36184. keysDown: number[];
  36185. /**
  36186. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36187. */
  36188. keysLeft: number[];
  36189. /**
  36190. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36191. */
  36192. keysRight: number[];
  36193. /**
  36194. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36195. */
  36196. wheelPrecision: number;
  36197. /**
  36198. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36199. * It will be used instead of pinchDeltaPrecision if different from 0.
  36200. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36201. */
  36202. wheelDeltaPercentage: number;
  36203. /**
  36204. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36205. */
  36206. zoomOnFactor: number;
  36207. /**
  36208. * Defines a screen offset for the camera position.
  36209. */
  36210. targetScreenOffset: Vector2;
  36211. /**
  36212. * Allows the camera to be completely reversed.
  36213. * If false the camera can not arrive upside down.
  36214. */
  36215. allowUpsideDown: boolean;
  36216. /**
  36217. * Define if double tap/click is used to restore the previously saved state of the camera.
  36218. */
  36219. useInputToRestoreState: boolean;
  36220. /** @hidden */
  36221. _viewMatrix: Matrix;
  36222. /** @hidden */
  36223. _useCtrlForPanning: boolean;
  36224. /** @hidden */
  36225. _panningMouseButton: number;
  36226. /**
  36227. * Defines the input associated to the camera.
  36228. */
  36229. inputs: ArcRotateCameraInputsManager;
  36230. /** @hidden */
  36231. _reset: () => void;
  36232. /**
  36233. * Defines the allowed panning axis.
  36234. */
  36235. panningAxis: Vector3;
  36236. protected _localDirection: Vector3;
  36237. protected _transformedDirection: Vector3;
  36238. private _bouncingBehavior;
  36239. /**
  36240. * Gets the bouncing behavior of the camera if it has been enabled.
  36241. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36242. */
  36243. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36244. /**
  36245. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36246. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36247. */
  36248. useBouncingBehavior: boolean;
  36249. private _framingBehavior;
  36250. /**
  36251. * Gets the framing behavior of the camera if it has been enabled.
  36252. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36253. */
  36254. readonly framingBehavior: Nullable<FramingBehavior>;
  36255. /**
  36256. * Defines if the framing behavior of the camera is enabled on the camera.
  36257. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36258. */
  36259. useFramingBehavior: boolean;
  36260. private _autoRotationBehavior;
  36261. /**
  36262. * Gets the auto rotation behavior of the camera if it has been enabled.
  36263. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36264. */
  36265. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36266. /**
  36267. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36268. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36269. */
  36270. useAutoRotationBehavior: boolean;
  36271. /**
  36272. * Observable triggered when the mesh target has been changed on the camera.
  36273. */
  36274. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36275. /**
  36276. * Event raised when the camera is colliding with a mesh.
  36277. */
  36278. onCollide: (collidedMesh: AbstractMesh) => void;
  36279. /**
  36280. * Defines whether the camera should check collision with the objects oh the scene.
  36281. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36282. */
  36283. checkCollisions: boolean;
  36284. /**
  36285. * Defines the collision radius of the camera.
  36286. * This simulates a sphere around the camera.
  36287. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36288. */
  36289. collisionRadius: Vector3;
  36290. protected _collider: Collider;
  36291. protected _previousPosition: Vector3;
  36292. protected _collisionVelocity: Vector3;
  36293. protected _newPosition: Vector3;
  36294. protected _previousAlpha: number;
  36295. protected _previousBeta: number;
  36296. protected _previousRadius: number;
  36297. protected _collisionTriggered: boolean;
  36298. protected _targetBoundingCenter: Nullable<Vector3>;
  36299. private _computationVector;
  36300. /**
  36301. * Instantiates a new ArcRotateCamera in a given scene
  36302. * @param name Defines the name of the camera
  36303. * @param alpha Defines the camera rotation along the logitudinal axis
  36304. * @param beta Defines the camera rotation along the latitudinal axis
  36305. * @param radius Defines the camera distance from its target
  36306. * @param target Defines the camera target
  36307. * @param scene Defines the scene the camera belongs to
  36308. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36309. */
  36310. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36311. /** @hidden */
  36312. _initCache(): void;
  36313. /** @hidden */
  36314. _updateCache(ignoreParentClass?: boolean): void;
  36315. protected _getTargetPosition(): Vector3;
  36316. private _storedAlpha;
  36317. private _storedBeta;
  36318. private _storedRadius;
  36319. private _storedTarget;
  36320. private _storedTargetScreenOffset;
  36321. /**
  36322. * Stores the current state of the camera (alpha, beta, radius and target)
  36323. * @returns the camera itself
  36324. */
  36325. storeState(): Camera;
  36326. /**
  36327. * @hidden
  36328. * Restored camera state. You must call storeState() first
  36329. */
  36330. _restoreStateValues(): boolean;
  36331. /** @hidden */
  36332. _isSynchronizedViewMatrix(): boolean;
  36333. /**
  36334. * Attached controls to the current camera.
  36335. * @param element Defines the element the controls should be listened from
  36336. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36337. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36338. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36339. */
  36340. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36341. /**
  36342. * Detach the current controls from the camera.
  36343. * The camera will stop reacting to inputs.
  36344. * @param element Defines the element to stop listening the inputs from
  36345. */
  36346. detachControl(element: HTMLElement): void;
  36347. /** @hidden */
  36348. _checkInputs(): void;
  36349. protected _checkLimits(): void;
  36350. /**
  36351. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36352. */
  36353. rebuildAnglesAndRadius(): void;
  36354. /**
  36355. * Use a position to define the current camera related information like aplha, beta and radius
  36356. * @param position Defines the position to set the camera at
  36357. */
  36358. setPosition(position: Vector3): void;
  36359. /**
  36360. * Defines the target the camera should look at.
  36361. * This will automatically adapt alpha beta and radius to fit within the new target.
  36362. * @param target Defines the new target as a Vector or a mesh
  36363. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36364. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36365. */
  36366. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36367. /** @hidden */
  36368. _getViewMatrix(): Matrix;
  36369. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36370. /**
  36371. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36372. * @param meshes Defines the mesh to zoom on
  36373. * @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)
  36374. */
  36375. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36376. /**
  36377. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36378. * The target will be changed but the radius
  36379. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36380. * @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)
  36381. */
  36382. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36383. min: Vector3;
  36384. max: Vector3;
  36385. distance: number;
  36386. }, doNotUpdateMaxZ?: boolean): void;
  36387. /**
  36388. * @override
  36389. * Override Camera.createRigCamera
  36390. */
  36391. createRigCamera(name: string, cameraIndex: number): Camera;
  36392. /**
  36393. * @hidden
  36394. * @override
  36395. * Override Camera._updateRigCameras
  36396. */
  36397. _updateRigCameras(): void;
  36398. /**
  36399. * Destroy the camera and release the current resources hold by it.
  36400. */
  36401. dispose(): void;
  36402. /**
  36403. * Gets the current object class name.
  36404. * @return the class name
  36405. */
  36406. getClassName(): string;
  36407. }
  36408. }
  36409. declare module BABYLON {
  36410. /**
  36411. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36412. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36413. */
  36414. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36415. /**
  36416. * Gets the name of the behavior.
  36417. */
  36418. readonly name: string;
  36419. private _zoomStopsAnimation;
  36420. private _idleRotationSpeed;
  36421. private _idleRotationWaitTime;
  36422. private _idleRotationSpinupTime;
  36423. /**
  36424. * Sets the flag that indicates if user zooming should stop animation.
  36425. */
  36426. /**
  36427. * Gets the flag that indicates if user zooming should stop animation.
  36428. */
  36429. zoomStopsAnimation: boolean;
  36430. /**
  36431. * Sets the default speed at which the camera rotates around the model.
  36432. */
  36433. /**
  36434. * Gets the default speed at which the camera rotates around the model.
  36435. */
  36436. idleRotationSpeed: number;
  36437. /**
  36438. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36439. */
  36440. /**
  36441. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36442. */
  36443. idleRotationWaitTime: number;
  36444. /**
  36445. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36446. */
  36447. /**
  36448. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36449. */
  36450. idleRotationSpinupTime: number;
  36451. /**
  36452. * Gets a value indicating if the camera is currently rotating because of this behavior
  36453. */
  36454. readonly rotationInProgress: boolean;
  36455. private _onPrePointerObservableObserver;
  36456. private _onAfterCheckInputsObserver;
  36457. private _attachedCamera;
  36458. private _isPointerDown;
  36459. private _lastFrameTime;
  36460. private _lastInteractionTime;
  36461. private _cameraRotationSpeed;
  36462. /**
  36463. * Initializes the behavior.
  36464. */
  36465. init(): void;
  36466. /**
  36467. * Attaches the behavior to its arc rotate camera.
  36468. * @param camera Defines the camera to attach the behavior to
  36469. */
  36470. attach(camera: ArcRotateCamera): void;
  36471. /**
  36472. * Detaches the behavior from its current arc rotate camera.
  36473. */
  36474. detach(): void;
  36475. /**
  36476. * Returns true if user is scrolling.
  36477. * @return true if user is scrolling.
  36478. */
  36479. private _userIsZooming;
  36480. private _lastFrameRadius;
  36481. private _shouldAnimationStopForInteraction;
  36482. /**
  36483. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36484. */
  36485. private _applyUserInteraction;
  36486. private _userIsMoving;
  36487. }
  36488. }
  36489. declare module BABYLON {
  36490. /**
  36491. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36492. */
  36493. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36494. private ui;
  36495. /**
  36496. * The name of the behavior
  36497. */
  36498. name: string;
  36499. /**
  36500. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36501. */
  36502. distanceAwayFromFace: number;
  36503. /**
  36504. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36505. */
  36506. distanceAwayFromBottomOfFace: number;
  36507. private _faceVectors;
  36508. private _target;
  36509. private _scene;
  36510. private _onRenderObserver;
  36511. private _tmpMatrix;
  36512. private _tmpVector;
  36513. /**
  36514. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36515. * @param ui The transform node that should be attched to the mesh
  36516. */
  36517. constructor(ui: TransformNode);
  36518. /**
  36519. * Initializes the behavior
  36520. */
  36521. init(): void;
  36522. private _closestFace;
  36523. private _zeroVector;
  36524. private _lookAtTmpMatrix;
  36525. private _lookAtToRef;
  36526. /**
  36527. * Attaches the AttachToBoxBehavior to the passed in mesh
  36528. * @param target The mesh that the specified node will be attached to
  36529. */
  36530. attach(target: Mesh): void;
  36531. /**
  36532. * Detaches the behavior from the mesh
  36533. */
  36534. detach(): void;
  36535. }
  36536. }
  36537. declare module BABYLON {
  36538. /**
  36539. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36540. */
  36541. export class FadeInOutBehavior implements Behavior<Mesh> {
  36542. /**
  36543. * Time in milliseconds to delay before fading in (Default: 0)
  36544. */
  36545. delay: number;
  36546. /**
  36547. * Time in milliseconds for the mesh to fade in (Default: 300)
  36548. */
  36549. fadeInTime: number;
  36550. private _millisecondsPerFrame;
  36551. private _hovered;
  36552. private _hoverValue;
  36553. private _ownerNode;
  36554. /**
  36555. * Instatiates the FadeInOutBehavior
  36556. */
  36557. constructor();
  36558. /**
  36559. * The name of the behavior
  36560. */
  36561. readonly name: string;
  36562. /**
  36563. * Initializes the behavior
  36564. */
  36565. init(): void;
  36566. /**
  36567. * Attaches the fade behavior on the passed in mesh
  36568. * @param ownerNode The mesh that will be faded in/out once attached
  36569. */
  36570. attach(ownerNode: Mesh): void;
  36571. /**
  36572. * Detaches the behavior from the mesh
  36573. */
  36574. detach(): void;
  36575. /**
  36576. * Triggers the mesh to begin fading in or out
  36577. * @param value if the object should fade in or out (true to fade in)
  36578. */
  36579. fadeIn(value: boolean): void;
  36580. private _update;
  36581. private _setAllVisibility;
  36582. }
  36583. }
  36584. declare module BABYLON {
  36585. /**
  36586. * Class containing a set of static utilities functions for managing Pivots
  36587. * @hidden
  36588. */
  36589. export class PivotTools {
  36590. private static _PivotCached;
  36591. private static _OldPivotPoint;
  36592. private static _PivotTranslation;
  36593. private static _PivotTmpVector;
  36594. /** @hidden */
  36595. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36596. /** @hidden */
  36597. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36598. }
  36599. }
  36600. declare module BABYLON {
  36601. /**
  36602. * Class containing static functions to help procedurally build meshes
  36603. */
  36604. export class PlaneBuilder {
  36605. /**
  36606. * Creates a plane mesh
  36607. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36608. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36609. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36610. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36611. * * 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
  36612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36613. * @param name defines the name of the mesh
  36614. * @param options defines the options used to create the mesh
  36615. * @param scene defines the hosting scene
  36616. * @returns the plane mesh
  36617. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36618. */
  36619. static CreatePlane(name: string, options: {
  36620. size?: number;
  36621. width?: number;
  36622. height?: number;
  36623. sideOrientation?: number;
  36624. frontUVs?: Vector4;
  36625. backUVs?: Vector4;
  36626. updatable?: boolean;
  36627. sourcePlane?: Plane;
  36628. }, scene?: Nullable<Scene>): Mesh;
  36629. }
  36630. }
  36631. declare module BABYLON {
  36632. /**
  36633. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36634. */
  36635. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36636. private static _AnyMouseID;
  36637. /**
  36638. * Abstract mesh the behavior is set on
  36639. */
  36640. attachedNode: AbstractMesh;
  36641. private _dragPlane;
  36642. private _scene;
  36643. private _pointerObserver;
  36644. private _beforeRenderObserver;
  36645. private static _planeScene;
  36646. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36647. /**
  36648. * 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)
  36649. */
  36650. maxDragAngle: number;
  36651. /**
  36652. * @hidden
  36653. */
  36654. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36655. /**
  36656. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36657. */
  36658. currentDraggingPointerID: number;
  36659. /**
  36660. * The last position where the pointer hit the drag plane in world space
  36661. */
  36662. lastDragPosition: Vector3;
  36663. /**
  36664. * If the behavior is currently in a dragging state
  36665. */
  36666. dragging: boolean;
  36667. /**
  36668. * 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)
  36669. */
  36670. dragDeltaRatio: number;
  36671. /**
  36672. * If the drag plane orientation should be updated during the dragging (Default: true)
  36673. */
  36674. updateDragPlane: boolean;
  36675. private _debugMode;
  36676. private _moving;
  36677. /**
  36678. * Fires each time the attached mesh is dragged with the pointer
  36679. * * delta between last drag position and current drag position in world space
  36680. * * dragDistance along the drag axis
  36681. * * dragPlaneNormal normal of the current drag plane used during the drag
  36682. * * dragPlanePoint in world space where the drag intersects the drag plane
  36683. */
  36684. onDragObservable: Observable<{
  36685. delta: Vector3;
  36686. dragPlanePoint: Vector3;
  36687. dragPlaneNormal: Vector3;
  36688. dragDistance: number;
  36689. pointerId: number;
  36690. }>;
  36691. /**
  36692. * Fires each time a drag begins (eg. mouse down on mesh)
  36693. */
  36694. onDragStartObservable: Observable<{
  36695. dragPlanePoint: Vector3;
  36696. pointerId: number;
  36697. }>;
  36698. /**
  36699. * Fires each time a drag ends (eg. mouse release after drag)
  36700. */
  36701. onDragEndObservable: Observable<{
  36702. dragPlanePoint: Vector3;
  36703. pointerId: number;
  36704. }>;
  36705. /**
  36706. * If the attached mesh should be moved when dragged
  36707. */
  36708. moveAttached: boolean;
  36709. /**
  36710. * If the drag behavior will react to drag events (Default: true)
  36711. */
  36712. enabled: boolean;
  36713. /**
  36714. * If pointer events should start and release the drag (Default: true)
  36715. */
  36716. startAndReleaseDragOnPointerEvents: boolean;
  36717. /**
  36718. * If camera controls should be detached during the drag
  36719. */
  36720. detachCameraControls: boolean;
  36721. /**
  36722. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36723. */
  36724. useObjectOrienationForDragging: boolean;
  36725. private _options;
  36726. /**
  36727. * Creates a pointer drag behavior that can be attached to a mesh
  36728. * @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)
  36729. */
  36730. constructor(options?: {
  36731. dragAxis?: Vector3;
  36732. dragPlaneNormal?: Vector3;
  36733. });
  36734. /**
  36735. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36736. */
  36737. validateDrag: (targetPosition: Vector3) => boolean;
  36738. /**
  36739. * The name of the behavior
  36740. */
  36741. readonly name: string;
  36742. /**
  36743. * Initializes the behavior
  36744. */
  36745. init(): void;
  36746. private _tmpVector;
  36747. private _alternatePickedPoint;
  36748. private _worldDragAxis;
  36749. private _targetPosition;
  36750. private _attachedElement;
  36751. /**
  36752. * Attaches the drag behavior the passed in mesh
  36753. * @param ownerNode The mesh that will be dragged around once attached
  36754. */
  36755. attach(ownerNode: AbstractMesh): void;
  36756. /**
  36757. * Force relase the drag action by code.
  36758. */
  36759. releaseDrag(): void;
  36760. private _startDragRay;
  36761. private _lastPointerRay;
  36762. /**
  36763. * Simulates the start of a pointer drag event on the behavior
  36764. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36765. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36766. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36767. */
  36768. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36769. private _startDrag;
  36770. private _dragDelta;
  36771. private _moveDrag;
  36772. private _pickWithRayOnDragPlane;
  36773. private _pointA;
  36774. private _pointB;
  36775. private _pointC;
  36776. private _lineA;
  36777. private _lineB;
  36778. private _localAxis;
  36779. private _lookAt;
  36780. private _updateDragPlanePosition;
  36781. /**
  36782. * Detaches the behavior from the mesh
  36783. */
  36784. detach(): void;
  36785. }
  36786. }
  36787. declare module BABYLON {
  36788. /**
  36789. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36790. */
  36791. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36792. private _dragBehaviorA;
  36793. private _dragBehaviorB;
  36794. private _startDistance;
  36795. private _initialScale;
  36796. private _targetScale;
  36797. private _ownerNode;
  36798. private _sceneRenderObserver;
  36799. /**
  36800. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36801. */
  36802. constructor();
  36803. /**
  36804. * The name of the behavior
  36805. */
  36806. readonly name: string;
  36807. /**
  36808. * Initializes the behavior
  36809. */
  36810. init(): void;
  36811. private _getCurrentDistance;
  36812. /**
  36813. * Attaches the scale behavior the passed in mesh
  36814. * @param ownerNode The mesh that will be scaled around once attached
  36815. */
  36816. attach(ownerNode: Mesh): void;
  36817. /**
  36818. * Detaches the behavior from the mesh
  36819. */
  36820. detach(): void;
  36821. }
  36822. }
  36823. declare module BABYLON {
  36824. /**
  36825. * 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
  36826. */
  36827. export class SixDofDragBehavior implements Behavior<Mesh> {
  36828. private static _virtualScene;
  36829. private _ownerNode;
  36830. private _sceneRenderObserver;
  36831. private _scene;
  36832. private _targetPosition;
  36833. private _virtualOriginMesh;
  36834. private _virtualDragMesh;
  36835. private _pointerObserver;
  36836. private _moving;
  36837. private _startingOrientation;
  36838. /**
  36839. * 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)
  36840. */
  36841. private zDragFactor;
  36842. /**
  36843. * If the object should rotate to face the drag origin
  36844. */
  36845. rotateDraggedObject: boolean;
  36846. /**
  36847. * If the behavior is currently in a dragging state
  36848. */
  36849. dragging: boolean;
  36850. /**
  36851. * 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)
  36852. */
  36853. dragDeltaRatio: number;
  36854. /**
  36855. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36856. */
  36857. currentDraggingPointerID: number;
  36858. /**
  36859. * If camera controls should be detached during the drag
  36860. */
  36861. detachCameraControls: boolean;
  36862. /**
  36863. * Fires each time a drag starts
  36864. */
  36865. onDragStartObservable: Observable<{}>;
  36866. /**
  36867. * Fires each time a drag ends (eg. mouse release after drag)
  36868. */
  36869. onDragEndObservable: Observable<{}>;
  36870. /**
  36871. * 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
  36872. */
  36873. constructor();
  36874. /**
  36875. * The name of the behavior
  36876. */
  36877. readonly name: string;
  36878. /**
  36879. * Initializes the behavior
  36880. */
  36881. init(): void;
  36882. /**
  36883. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  36884. */
  36885. private readonly _pointerCamera;
  36886. /**
  36887. * Attaches the scale behavior the passed in mesh
  36888. * @param ownerNode The mesh that will be scaled around once attached
  36889. */
  36890. attach(ownerNode: Mesh): void;
  36891. /**
  36892. * Detaches the behavior from the mesh
  36893. */
  36894. detach(): void;
  36895. }
  36896. }
  36897. declare module BABYLON {
  36898. /**
  36899. * Class used to apply inverse kinematics to bones
  36900. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36901. */
  36902. export class BoneIKController {
  36903. private static _tmpVecs;
  36904. private static _tmpQuat;
  36905. private static _tmpMats;
  36906. /**
  36907. * Gets or sets the target mesh
  36908. */
  36909. targetMesh: AbstractMesh;
  36910. /** Gets or sets the mesh used as pole */
  36911. poleTargetMesh: AbstractMesh;
  36912. /**
  36913. * Gets or sets the bone used as pole
  36914. */
  36915. poleTargetBone: Nullable<Bone>;
  36916. /**
  36917. * Gets or sets the target position
  36918. */
  36919. targetPosition: Vector3;
  36920. /**
  36921. * Gets or sets the pole target position
  36922. */
  36923. poleTargetPosition: Vector3;
  36924. /**
  36925. * Gets or sets the pole target local offset
  36926. */
  36927. poleTargetLocalOffset: Vector3;
  36928. /**
  36929. * Gets or sets the pole angle
  36930. */
  36931. poleAngle: number;
  36932. /**
  36933. * Gets or sets the mesh associated with the controller
  36934. */
  36935. mesh: AbstractMesh;
  36936. /**
  36937. * 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)
  36938. */
  36939. slerpAmount: number;
  36940. private _bone1Quat;
  36941. private _bone1Mat;
  36942. private _bone2Ang;
  36943. private _bone1;
  36944. private _bone2;
  36945. private _bone1Length;
  36946. private _bone2Length;
  36947. private _maxAngle;
  36948. private _maxReach;
  36949. private _rightHandedSystem;
  36950. private _bendAxis;
  36951. private _slerping;
  36952. private _adjustRoll;
  36953. /**
  36954. * Gets or sets maximum allowed angle
  36955. */
  36956. maxAngle: number;
  36957. /**
  36958. * Creates a new BoneIKController
  36959. * @param mesh defines the mesh to control
  36960. * @param bone defines the bone to control
  36961. * @param options defines options to set up the controller
  36962. */
  36963. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36964. targetMesh?: AbstractMesh;
  36965. poleTargetMesh?: AbstractMesh;
  36966. poleTargetBone?: Bone;
  36967. poleTargetLocalOffset?: Vector3;
  36968. poleAngle?: number;
  36969. bendAxis?: Vector3;
  36970. maxAngle?: number;
  36971. slerpAmount?: number;
  36972. });
  36973. private _setMaxAngle;
  36974. /**
  36975. * Force the controller to update the bones
  36976. */
  36977. update(): void;
  36978. }
  36979. }
  36980. declare module BABYLON {
  36981. /**
  36982. * Class used to make a bone look toward a point in space
  36983. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36984. */
  36985. export class BoneLookController {
  36986. private static _tmpVecs;
  36987. private static _tmpQuat;
  36988. private static _tmpMats;
  36989. /**
  36990. * The target Vector3 that the bone will look at
  36991. */
  36992. target: Vector3;
  36993. /**
  36994. * The mesh that the bone is attached to
  36995. */
  36996. mesh: AbstractMesh;
  36997. /**
  36998. * The bone that will be looking to the target
  36999. */
  37000. bone: Bone;
  37001. /**
  37002. * The up axis of the coordinate system that is used when the bone is rotated
  37003. */
  37004. upAxis: Vector3;
  37005. /**
  37006. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37007. */
  37008. upAxisSpace: Space;
  37009. /**
  37010. * Used to make an adjustment to the yaw of the bone
  37011. */
  37012. adjustYaw: number;
  37013. /**
  37014. * Used to make an adjustment to the pitch of the bone
  37015. */
  37016. adjustPitch: number;
  37017. /**
  37018. * Used to make an adjustment to the roll of the bone
  37019. */
  37020. adjustRoll: number;
  37021. /**
  37022. * 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)
  37023. */
  37024. slerpAmount: number;
  37025. private _minYaw;
  37026. private _maxYaw;
  37027. private _minPitch;
  37028. private _maxPitch;
  37029. private _minYawSin;
  37030. private _minYawCos;
  37031. private _maxYawSin;
  37032. private _maxYawCos;
  37033. private _midYawConstraint;
  37034. private _minPitchTan;
  37035. private _maxPitchTan;
  37036. private _boneQuat;
  37037. private _slerping;
  37038. private _transformYawPitch;
  37039. private _transformYawPitchInv;
  37040. private _firstFrameSkipped;
  37041. private _yawRange;
  37042. private _fowardAxis;
  37043. /**
  37044. * Gets or sets the minimum yaw angle that the bone can look to
  37045. */
  37046. minYaw: number;
  37047. /**
  37048. * Gets or sets the maximum yaw angle that the bone can look to
  37049. */
  37050. maxYaw: number;
  37051. /**
  37052. * Gets or sets the minimum pitch angle that the bone can look to
  37053. */
  37054. minPitch: number;
  37055. /**
  37056. * Gets or sets the maximum pitch angle that the bone can look to
  37057. */
  37058. maxPitch: number;
  37059. /**
  37060. * Create a BoneLookController
  37061. * @param mesh the mesh that the bone belongs to
  37062. * @param bone the bone that will be looking to the target
  37063. * @param target the target Vector3 to look at
  37064. * @param options optional settings:
  37065. * * maxYaw: the maximum angle the bone will yaw to
  37066. * * minYaw: the minimum angle the bone will yaw to
  37067. * * maxPitch: the maximum angle the bone will pitch to
  37068. * * minPitch: the minimum angle the bone will yaw to
  37069. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37070. * * upAxis: the up axis of the coordinate system
  37071. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37072. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37073. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37074. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37075. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37076. * * adjustRoll: used to make an adjustment to the roll of the bone
  37077. **/
  37078. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37079. maxYaw?: number;
  37080. minYaw?: number;
  37081. maxPitch?: number;
  37082. minPitch?: number;
  37083. slerpAmount?: number;
  37084. upAxis?: Vector3;
  37085. upAxisSpace?: Space;
  37086. yawAxis?: Vector3;
  37087. pitchAxis?: Vector3;
  37088. adjustYaw?: number;
  37089. adjustPitch?: number;
  37090. adjustRoll?: number;
  37091. });
  37092. /**
  37093. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37094. */
  37095. update(): void;
  37096. private _getAngleDiff;
  37097. private _getAngleBetween;
  37098. private _isAngleBetween;
  37099. }
  37100. }
  37101. declare module BABYLON {
  37102. /**
  37103. * Manage the gamepad inputs to control an arc rotate camera.
  37104. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37105. */
  37106. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37107. /**
  37108. * Defines the camera the input is attached to.
  37109. */
  37110. camera: ArcRotateCamera;
  37111. /**
  37112. * Defines the gamepad the input is gathering event from.
  37113. */
  37114. gamepad: Nullable<Gamepad>;
  37115. /**
  37116. * Defines the gamepad rotation sensiblity.
  37117. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37118. */
  37119. gamepadRotationSensibility: number;
  37120. /**
  37121. * Defines the gamepad move sensiblity.
  37122. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37123. */
  37124. gamepadMoveSensibility: number;
  37125. private _onGamepadConnectedObserver;
  37126. private _onGamepadDisconnectedObserver;
  37127. /**
  37128. * Attach the input controls to a specific dom element to get the input from.
  37129. * @param element Defines the element the controls should be listened from
  37130. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37131. */
  37132. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37133. /**
  37134. * Detach the current controls from the specified dom element.
  37135. * @param element Defines the element to stop listening the inputs from
  37136. */
  37137. detachControl(element: Nullable<HTMLElement>): void;
  37138. /**
  37139. * Update the current camera state depending on the inputs that have been used this frame.
  37140. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37141. */
  37142. checkInputs(): void;
  37143. /**
  37144. * Gets the class name of the current intput.
  37145. * @returns the class name
  37146. */
  37147. getClassName(): string;
  37148. /**
  37149. * Get the friendly name associated with the input class.
  37150. * @returns the input friendly name
  37151. */
  37152. getSimpleName(): string;
  37153. }
  37154. }
  37155. declare module BABYLON {
  37156. interface ArcRotateCameraInputsManager {
  37157. /**
  37158. * Add orientation input support to the input manager.
  37159. * @returns the current input manager
  37160. */
  37161. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37162. }
  37163. /**
  37164. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37165. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37166. */
  37167. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37168. /**
  37169. * Defines the camera the input is attached to.
  37170. */
  37171. camera: ArcRotateCamera;
  37172. /**
  37173. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37174. */
  37175. alphaCorrection: number;
  37176. /**
  37177. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37178. */
  37179. gammaCorrection: number;
  37180. private _alpha;
  37181. private _gamma;
  37182. private _dirty;
  37183. private _deviceOrientationHandler;
  37184. /**
  37185. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37186. */
  37187. constructor();
  37188. /**
  37189. * Attach the input controls to a specific dom element to get the input from.
  37190. * @param element Defines the element the controls should be listened from
  37191. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37192. */
  37193. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37194. /** @hidden */
  37195. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37196. /**
  37197. * Update the current camera state depending on the inputs that have been used this frame.
  37198. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37199. */
  37200. checkInputs(): void;
  37201. /**
  37202. * Detach the current controls from the specified dom element.
  37203. * @param element Defines the element to stop listening the inputs from
  37204. */
  37205. detachControl(element: Nullable<HTMLElement>): void;
  37206. /**
  37207. * Gets the class name of the current intput.
  37208. * @returns the class name
  37209. */
  37210. getClassName(): string;
  37211. /**
  37212. * Get the friendly name associated with the input class.
  37213. * @returns the input friendly name
  37214. */
  37215. getSimpleName(): string;
  37216. }
  37217. }
  37218. declare module BABYLON {
  37219. /**
  37220. * Listen to mouse events to control the camera.
  37221. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37222. */
  37223. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37224. /**
  37225. * Defines the camera the input is attached to.
  37226. */
  37227. camera: FlyCamera;
  37228. /**
  37229. * Defines if touch is enabled. (Default is true.)
  37230. */
  37231. touchEnabled: boolean;
  37232. /**
  37233. * Defines the buttons associated with the input to handle camera rotation.
  37234. */
  37235. buttons: number[];
  37236. /**
  37237. * Assign buttons for Yaw control.
  37238. */
  37239. buttonsYaw: number[];
  37240. /**
  37241. * Assign buttons for Pitch control.
  37242. */
  37243. buttonsPitch: number[];
  37244. /**
  37245. * Assign buttons for Roll control.
  37246. */
  37247. buttonsRoll: number[];
  37248. /**
  37249. * Detect if any button is being pressed while mouse is moved.
  37250. * -1 = Mouse locked.
  37251. * 0 = Left button.
  37252. * 1 = Middle Button.
  37253. * 2 = Right Button.
  37254. */
  37255. activeButton: number;
  37256. /**
  37257. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37258. * Higher values reduce its sensitivity.
  37259. */
  37260. angularSensibility: number;
  37261. private _mousemoveCallback;
  37262. private _observer;
  37263. private _rollObserver;
  37264. private previousPosition;
  37265. private noPreventDefault;
  37266. private element;
  37267. /**
  37268. * Listen to mouse events to control the camera.
  37269. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37270. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37271. */
  37272. constructor(touchEnabled?: boolean);
  37273. /**
  37274. * Attach the mouse control to the HTML DOM element.
  37275. * @param element Defines the element that listens to the input events.
  37276. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37277. */
  37278. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37279. /**
  37280. * Detach the current controls from the specified dom element.
  37281. * @param element Defines the element to stop listening the inputs from
  37282. */
  37283. detachControl(element: Nullable<HTMLElement>): void;
  37284. /**
  37285. * Gets the class name of the current input.
  37286. * @returns the class name.
  37287. */
  37288. getClassName(): string;
  37289. /**
  37290. * Get the friendly name associated with the input class.
  37291. * @returns the input's friendly name.
  37292. */
  37293. getSimpleName(): string;
  37294. private _pointerInput;
  37295. private _onMouseMove;
  37296. /**
  37297. * Rotate camera by mouse offset.
  37298. */
  37299. private rotateCamera;
  37300. }
  37301. }
  37302. declare module BABYLON {
  37303. /**
  37304. * Default Inputs manager for the FlyCamera.
  37305. * It groups all the default supported inputs for ease of use.
  37306. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37307. */
  37308. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37309. /**
  37310. * Instantiates a new FlyCameraInputsManager.
  37311. * @param camera Defines the camera the inputs belong to.
  37312. */
  37313. constructor(camera: FlyCamera);
  37314. /**
  37315. * Add keyboard input support to the input manager.
  37316. * @returns the new FlyCameraKeyboardMoveInput().
  37317. */
  37318. addKeyboard(): FlyCameraInputsManager;
  37319. /**
  37320. * Add mouse input support to the input manager.
  37321. * @param touchEnabled Enable touch screen support.
  37322. * @returns the new FlyCameraMouseInput().
  37323. */
  37324. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37325. }
  37326. }
  37327. declare module BABYLON {
  37328. /**
  37329. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37330. * such as in a 3D Space Shooter or a Flight Simulator.
  37331. */
  37332. export class FlyCamera extends TargetCamera {
  37333. /**
  37334. * Define the collision ellipsoid of the camera.
  37335. * This is helpful for simulating a camera body, like a player's body.
  37336. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37337. */
  37338. ellipsoid: Vector3;
  37339. /**
  37340. * Define an offset for the position of the ellipsoid around the camera.
  37341. * This can be helpful if the camera is attached away from the player's body center,
  37342. * such as at its head.
  37343. */
  37344. ellipsoidOffset: Vector3;
  37345. /**
  37346. * Enable or disable collisions of the camera with the rest of the scene objects.
  37347. */
  37348. checkCollisions: boolean;
  37349. /**
  37350. * Enable or disable gravity on the camera.
  37351. */
  37352. applyGravity: boolean;
  37353. /**
  37354. * Define the current direction the camera is moving to.
  37355. */
  37356. cameraDirection: Vector3;
  37357. /**
  37358. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37359. * This overrides and empties cameraRotation.
  37360. */
  37361. rotationQuaternion: Quaternion;
  37362. /**
  37363. * Track Roll to maintain the wanted Rolling when looking around.
  37364. */
  37365. _trackRoll: number;
  37366. /**
  37367. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37368. */
  37369. rollCorrect: number;
  37370. /**
  37371. * Mimic a banked turn, Rolling the camera when Yawing.
  37372. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37373. */
  37374. bankedTurn: boolean;
  37375. /**
  37376. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37377. */
  37378. bankedTurnLimit: number;
  37379. /**
  37380. * Value of 0 disables the banked Roll.
  37381. * Value of 1 is equal to the Yaw angle in radians.
  37382. */
  37383. bankedTurnMultiplier: number;
  37384. /**
  37385. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37386. */
  37387. inputs: FlyCameraInputsManager;
  37388. /**
  37389. * Gets the input sensibility for mouse input.
  37390. * Higher values reduce sensitivity.
  37391. */
  37392. /**
  37393. * Sets the input sensibility for a mouse input.
  37394. * Higher values reduce sensitivity.
  37395. */
  37396. angularSensibility: number;
  37397. /**
  37398. * Get the keys for camera movement forward.
  37399. */
  37400. /**
  37401. * Set the keys for camera movement forward.
  37402. */
  37403. keysForward: number[];
  37404. /**
  37405. * Get the keys for camera movement backward.
  37406. */
  37407. keysBackward: number[];
  37408. /**
  37409. * Get the keys for camera movement up.
  37410. */
  37411. /**
  37412. * Set the keys for camera movement up.
  37413. */
  37414. keysUp: number[];
  37415. /**
  37416. * Get the keys for camera movement down.
  37417. */
  37418. /**
  37419. * Set the keys for camera movement down.
  37420. */
  37421. keysDown: number[];
  37422. /**
  37423. * Get the keys for camera movement left.
  37424. */
  37425. /**
  37426. * Set the keys for camera movement left.
  37427. */
  37428. keysLeft: number[];
  37429. /**
  37430. * Set the keys for camera movement right.
  37431. */
  37432. /**
  37433. * Set the keys for camera movement right.
  37434. */
  37435. keysRight: number[];
  37436. /**
  37437. * Event raised when the camera collides with a mesh in the scene.
  37438. */
  37439. onCollide: (collidedMesh: AbstractMesh) => void;
  37440. private _collider;
  37441. private _needMoveForGravity;
  37442. private _oldPosition;
  37443. private _diffPosition;
  37444. private _newPosition;
  37445. /** @hidden */
  37446. _localDirection: Vector3;
  37447. /** @hidden */
  37448. _transformedDirection: Vector3;
  37449. /**
  37450. * Instantiates a FlyCamera.
  37451. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37452. * such as in a 3D Space Shooter or a Flight Simulator.
  37453. * @param name Define the name of the camera in the scene.
  37454. * @param position Define the starting position of the camera in the scene.
  37455. * @param scene Define the scene the camera belongs to.
  37456. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37457. */
  37458. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37459. /**
  37460. * Attach a control to the HTML DOM element.
  37461. * @param element Defines the element that listens to the input events.
  37462. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37463. */
  37464. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37465. /**
  37466. * Detach a control from the HTML DOM element.
  37467. * The camera will stop reacting to that input.
  37468. * @param element Defines the element that listens to the input events.
  37469. */
  37470. detachControl(element: HTMLElement): void;
  37471. private _collisionMask;
  37472. /**
  37473. * Get the mask that the camera ignores in collision events.
  37474. */
  37475. /**
  37476. * Set the mask that the camera ignores in collision events.
  37477. */
  37478. collisionMask: number;
  37479. /** @hidden */
  37480. _collideWithWorld(displacement: Vector3): void;
  37481. /** @hidden */
  37482. private _onCollisionPositionChange;
  37483. /** @hidden */
  37484. _checkInputs(): void;
  37485. /** @hidden */
  37486. _decideIfNeedsToMove(): boolean;
  37487. /** @hidden */
  37488. _updatePosition(): void;
  37489. /**
  37490. * Restore the Roll to its target value at the rate specified.
  37491. * @param rate - Higher means slower restoring.
  37492. * @hidden
  37493. */
  37494. restoreRoll(rate: number): void;
  37495. /**
  37496. * Destroy the camera and release the current resources held by it.
  37497. */
  37498. dispose(): void;
  37499. /**
  37500. * Get the current object class name.
  37501. * @returns the class name.
  37502. */
  37503. getClassName(): string;
  37504. }
  37505. }
  37506. declare module BABYLON {
  37507. /**
  37508. * Listen to keyboard events to control the camera.
  37509. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37510. */
  37511. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37512. /**
  37513. * Defines the camera the input is attached to.
  37514. */
  37515. camera: FlyCamera;
  37516. /**
  37517. * The list of keyboard keys used to control the forward move of the camera.
  37518. */
  37519. keysForward: number[];
  37520. /**
  37521. * The list of keyboard keys used to control the backward move of the camera.
  37522. */
  37523. keysBackward: number[];
  37524. /**
  37525. * The list of keyboard keys used to control the forward move of the camera.
  37526. */
  37527. keysUp: number[];
  37528. /**
  37529. * The list of keyboard keys used to control the backward move of the camera.
  37530. */
  37531. keysDown: number[];
  37532. /**
  37533. * The list of keyboard keys used to control the right strafe move of the camera.
  37534. */
  37535. keysRight: number[];
  37536. /**
  37537. * The list of keyboard keys used to control the left strafe move of the camera.
  37538. */
  37539. keysLeft: number[];
  37540. private _keys;
  37541. private _onCanvasBlurObserver;
  37542. private _onKeyboardObserver;
  37543. private _engine;
  37544. private _scene;
  37545. /**
  37546. * Attach the input controls to a specific dom element to get the input from.
  37547. * @param element Defines the element the controls should be listened from
  37548. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37549. */
  37550. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37551. /**
  37552. * Detach the current controls from the specified dom element.
  37553. * @param element Defines the element to stop listening the inputs from
  37554. */
  37555. detachControl(element: Nullable<HTMLElement>): void;
  37556. /**
  37557. * Gets the class name of the current intput.
  37558. * @returns the class name
  37559. */
  37560. getClassName(): string;
  37561. /** @hidden */
  37562. _onLostFocus(e: FocusEvent): void;
  37563. /**
  37564. * Get the friendly name associated with the input class.
  37565. * @returns the input friendly name
  37566. */
  37567. getSimpleName(): string;
  37568. /**
  37569. * Update the current camera state depending on the inputs that have been used this frame.
  37570. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37571. */
  37572. checkInputs(): void;
  37573. }
  37574. }
  37575. declare module BABYLON {
  37576. /**
  37577. * Manage the mouse wheel inputs to control a follow camera.
  37578. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37579. */
  37580. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37581. /**
  37582. * Defines the camera the input is attached to.
  37583. */
  37584. camera: FollowCamera;
  37585. /**
  37586. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37587. */
  37588. axisControlRadius: boolean;
  37589. /**
  37590. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37591. */
  37592. axisControlHeight: boolean;
  37593. /**
  37594. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37595. */
  37596. axisControlRotation: boolean;
  37597. /**
  37598. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37599. * relation to mouseWheel events.
  37600. */
  37601. wheelPrecision: number;
  37602. /**
  37603. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37604. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37605. */
  37606. wheelDeltaPercentage: number;
  37607. private _wheel;
  37608. private _observer;
  37609. /**
  37610. * Attach the input controls to a specific dom element to get the input from.
  37611. * @param element Defines the element the controls should be listened from
  37612. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37613. */
  37614. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37615. /**
  37616. * Detach the current controls from the specified dom element.
  37617. * @param element Defines the element to stop listening the inputs from
  37618. */
  37619. detachControl(element: Nullable<HTMLElement>): void;
  37620. /**
  37621. * Gets the class name of the current intput.
  37622. * @returns the class name
  37623. */
  37624. getClassName(): string;
  37625. /**
  37626. * Get the friendly name associated with the input class.
  37627. * @returns the input friendly name
  37628. */
  37629. getSimpleName(): string;
  37630. }
  37631. }
  37632. declare module BABYLON {
  37633. /**
  37634. * Manage the pointers inputs to control an follow camera.
  37635. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37636. */
  37637. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37638. /**
  37639. * Defines the camera the input is attached to.
  37640. */
  37641. camera: FollowCamera;
  37642. /**
  37643. * Gets the class name of the current input.
  37644. * @returns the class name
  37645. */
  37646. getClassName(): string;
  37647. /**
  37648. * Defines the pointer angular sensibility along the X axis or how fast is
  37649. * the camera rotating.
  37650. * A negative number will reverse the axis direction.
  37651. */
  37652. angularSensibilityX: number;
  37653. /**
  37654. * Defines the pointer angular sensibility along the Y axis or how fast is
  37655. * the camera rotating.
  37656. * A negative number will reverse the axis direction.
  37657. */
  37658. angularSensibilityY: number;
  37659. /**
  37660. * Defines the pointer pinch precision or how fast is the camera zooming.
  37661. * A negative number will reverse the axis direction.
  37662. */
  37663. pinchPrecision: number;
  37664. /**
  37665. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37666. * from 0.
  37667. * It defines the percentage of current camera.radius to use as delta when
  37668. * pinch zoom is used.
  37669. */
  37670. pinchDeltaPercentage: number;
  37671. /**
  37672. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37673. */
  37674. axisXControlRadius: boolean;
  37675. /**
  37676. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37677. */
  37678. axisXControlHeight: boolean;
  37679. /**
  37680. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37681. */
  37682. axisXControlRotation: boolean;
  37683. /**
  37684. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37685. */
  37686. axisYControlRadius: boolean;
  37687. /**
  37688. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37689. */
  37690. axisYControlHeight: boolean;
  37691. /**
  37692. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37693. */
  37694. axisYControlRotation: boolean;
  37695. /**
  37696. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37697. */
  37698. axisPinchControlRadius: boolean;
  37699. /**
  37700. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37701. */
  37702. axisPinchControlHeight: boolean;
  37703. /**
  37704. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37705. */
  37706. axisPinchControlRotation: boolean;
  37707. /**
  37708. * Log error messages if basic misconfiguration has occurred.
  37709. */
  37710. warningEnable: boolean;
  37711. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37712. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37713. private _warningCounter;
  37714. private _warning;
  37715. }
  37716. }
  37717. declare module BABYLON {
  37718. /**
  37719. * Default Inputs manager for the FollowCamera.
  37720. * It groups all the default supported inputs for ease of use.
  37721. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37722. */
  37723. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37724. /**
  37725. * Instantiates a new FollowCameraInputsManager.
  37726. * @param camera Defines the camera the inputs belong to
  37727. */
  37728. constructor(camera: FollowCamera);
  37729. /**
  37730. * Add keyboard input support to the input manager.
  37731. * @returns the current input manager
  37732. */
  37733. addKeyboard(): FollowCameraInputsManager;
  37734. /**
  37735. * Add mouse wheel input support to the input manager.
  37736. * @returns the current input manager
  37737. */
  37738. addMouseWheel(): FollowCameraInputsManager;
  37739. /**
  37740. * Add pointers input support to the input manager.
  37741. * @returns the current input manager
  37742. */
  37743. addPointers(): FollowCameraInputsManager;
  37744. /**
  37745. * Add orientation input support to the input manager.
  37746. * @returns the current input manager
  37747. */
  37748. addVRDeviceOrientation(): FollowCameraInputsManager;
  37749. }
  37750. }
  37751. declare module BABYLON {
  37752. /**
  37753. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37754. * an arc rotate version arcFollowCamera are available.
  37755. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37756. */
  37757. export class FollowCamera extends TargetCamera {
  37758. /**
  37759. * Distance the follow camera should follow an object at
  37760. */
  37761. radius: number;
  37762. /**
  37763. * Minimum allowed distance of the camera to the axis of rotation
  37764. * (The camera can not get closer).
  37765. * This can help limiting how the Camera is able to move in the scene.
  37766. */
  37767. lowerRadiusLimit: Nullable<number>;
  37768. /**
  37769. * Maximum allowed distance of the camera to the axis of rotation
  37770. * (The camera can not get further).
  37771. * This can help limiting how the Camera is able to move in the scene.
  37772. */
  37773. upperRadiusLimit: Nullable<number>;
  37774. /**
  37775. * Define a rotation offset between the camera and the object it follows
  37776. */
  37777. rotationOffset: number;
  37778. /**
  37779. * Minimum allowed angle to camera position relative to target object.
  37780. * This can help limiting how the Camera is able to move in the scene.
  37781. */
  37782. lowerRotationOffsetLimit: Nullable<number>;
  37783. /**
  37784. * Maximum allowed angle to camera position relative to target object.
  37785. * This can help limiting how the Camera is able to move in the scene.
  37786. */
  37787. upperRotationOffsetLimit: Nullable<number>;
  37788. /**
  37789. * Define a height offset between the camera and the object it follows.
  37790. * It can help following an object from the top (like a car chaing a plane)
  37791. */
  37792. heightOffset: number;
  37793. /**
  37794. * Minimum allowed height of camera position relative to target object.
  37795. * This can help limiting how the Camera is able to move in the scene.
  37796. */
  37797. lowerHeightOffsetLimit: Nullable<number>;
  37798. /**
  37799. * Maximum allowed height of camera position relative to target object.
  37800. * This can help limiting how the Camera is able to move in the scene.
  37801. */
  37802. upperHeightOffsetLimit: Nullable<number>;
  37803. /**
  37804. * Define how fast the camera can accelerate to follow it s target.
  37805. */
  37806. cameraAcceleration: number;
  37807. /**
  37808. * Define the speed limit of the camera following an object.
  37809. */
  37810. maxCameraSpeed: number;
  37811. /**
  37812. * Define the target of the camera.
  37813. */
  37814. lockedTarget: Nullable<AbstractMesh>;
  37815. /**
  37816. * Defines the input associated with the camera.
  37817. */
  37818. inputs: FollowCameraInputsManager;
  37819. /**
  37820. * Instantiates the follow camera.
  37821. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37822. * @param name Define the name of the camera in the scene
  37823. * @param position Define the position of the camera
  37824. * @param scene Define the scene the camera belong to
  37825. * @param lockedTarget Define the target of the camera
  37826. */
  37827. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37828. private _follow;
  37829. /**
  37830. * Attached controls to the current camera.
  37831. * @param element Defines the element the controls should be listened from
  37832. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37833. */
  37834. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37835. /**
  37836. * Detach the current controls from the camera.
  37837. * The camera will stop reacting to inputs.
  37838. * @param element Defines the element to stop listening the inputs from
  37839. */
  37840. detachControl(element: HTMLElement): void;
  37841. /** @hidden */
  37842. _checkInputs(): void;
  37843. private _checkLimits;
  37844. /**
  37845. * Gets the camera class name.
  37846. * @returns the class name
  37847. */
  37848. getClassName(): string;
  37849. }
  37850. /**
  37851. * Arc Rotate version of the follow camera.
  37852. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37853. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37854. */
  37855. export class ArcFollowCamera extends TargetCamera {
  37856. /** The longitudinal angle of the camera */
  37857. alpha: number;
  37858. /** The latitudinal angle of the camera */
  37859. beta: number;
  37860. /** The radius of the camera from its target */
  37861. radius: number;
  37862. /** Define the camera target (the messh it should follow) */
  37863. target: Nullable<AbstractMesh>;
  37864. private _cartesianCoordinates;
  37865. /**
  37866. * Instantiates a new ArcFollowCamera
  37867. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37868. * @param name Define the name of the camera
  37869. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37870. * @param beta Define the rotation angle of the camera around the elevation axis
  37871. * @param radius Define the radius of the camera from its target point
  37872. * @param target Define the target of the camera
  37873. * @param scene Define the scene the camera belongs to
  37874. */
  37875. constructor(name: string,
  37876. /** The longitudinal angle of the camera */
  37877. alpha: number,
  37878. /** The latitudinal angle of the camera */
  37879. beta: number,
  37880. /** The radius of the camera from its target */
  37881. radius: number,
  37882. /** Define the camera target (the messh it should follow) */
  37883. target: Nullable<AbstractMesh>, scene: Scene);
  37884. private _follow;
  37885. /** @hidden */
  37886. _checkInputs(): void;
  37887. /**
  37888. * Returns the class name of the object.
  37889. * It is mostly used internally for serialization purposes.
  37890. */
  37891. getClassName(): string;
  37892. }
  37893. }
  37894. declare module BABYLON {
  37895. /**
  37896. * Manage the keyboard inputs to control the movement of a follow camera.
  37897. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37898. */
  37899. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37900. /**
  37901. * Defines the camera the input is attached to.
  37902. */
  37903. camera: FollowCamera;
  37904. /**
  37905. * Defines the list of key codes associated with the up action (increase heightOffset)
  37906. */
  37907. keysHeightOffsetIncr: number[];
  37908. /**
  37909. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37910. */
  37911. keysHeightOffsetDecr: number[];
  37912. /**
  37913. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37914. */
  37915. keysHeightOffsetModifierAlt: boolean;
  37916. /**
  37917. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37918. */
  37919. keysHeightOffsetModifierCtrl: boolean;
  37920. /**
  37921. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37922. */
  37923. keysHeightOffsetModifierShift: boolean;
  37924. /**
  37925. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37926. */
  37927. keysRotationOffsetIncr: number[];
  37928. /**
  37929. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37930. */
  37931. keysRotationOffsetDecr: number[];
  37932. /**
  37933. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37934. */
  37935. keysRotationOffsetModifierAlt: boolean;
  37936. /**
  37937. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37938. */
  37939. keysRotationOffsetModifierCtrl: boolean;
  37940. /**
  37941. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37942. */
  37943. keysRotationOffsetModifierShift: boolean;
  37944. /**
  37945. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37946. */
  37947. keysRadiusIncr: number[];
  37948. /**
  37949. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37950. */
  37951. keysRadiusDecr: number[];
  37952. /**
  37953. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37954. */
  37955. keysRadiusModifierAlt: boolean;
  37956. /**
  37957. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37958. */
  37959. keysRadiusModifierCtrl: boolean;
  37960. /**
  37961. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37962. */
  37963. keysRadiusModifierShift: boolean;
  37964. /**
  37965. * Defines the rate of change of heightOffset.
  37966. */
  37967. heightSensibility: number;
  37968. /**
  37969. * Defines the rate of change of rotationOffset.
  37970. */
  37971. rotationSensibility: number;
  37972. /**
  37973. * Defines the rate of change of radius.
  37974. */
  37975. radiusSensibility: number;
  37976. private _keys;
  37977. private _ctrlPressed;
  37978. private _altPressed;
  37979. private _shiftPressed;
  37980. private _onCanvasBlurObserver;
  37981. private _onKeyboardObserver;
  37982. private _engine;
  37983. private _scene;
  37984. /**
  37985. * Attach the input controls to a specific dom element to get the input from.
  37986. * @param element Defines the element the controls should be listened from
  37987. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37988. */
  37989. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37990. /**
  37991. * Detach the current controls from the specified dom element.
  37992. * @param element Defines the element to stop listening the inputs from
  37993. */
  37994. detachControl(element: Nullable<HTMLElement>): void;
  37995. /**
  37996. * Update the current camera state depending on the inputs that have been used this frame.
  37997. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37998. */
  37999. checkInputs(): void;
  38000. /**
  38001. * Gets the class name of the current input.
  38002. * @returns the class name
  38003. */
  38004. getClassName(): string;
  38005. /**
  38006. * Get the friendly name associated with the input class.
  38007. * @returns the input friendly name
  38008. */
  38009. getSimpleName(): string;
  38010. /**
  38011. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38012. * allow modification of the heightOffset value.
  38013. */
  38014. private _modifierHeightOffset;
  38015. /**
  38016. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38017. * allow modification of the rotationOffset value.
  38018. */
  38019. private _modifierRotationOffset;
  38020. /**
  38021. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38022. * allow modification of the radius value.
  38023. */
  38024. private _modifierRadius;
  38025. }
  38026. }
  38027. declare module BABYLON {
  38028. interface FreeCameraInputsManager {
  38029. /**
  38030. * @hidden
  38031. */
  38032. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38033. /**
  38034. * Add orientation input support to the input manager.
  38035. * @returns the current input manager
  38036. */
  38037. addDeviceOrientation(): FreeCameraInputsManager;
  38038. }
  38039. /**
  38040. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38041. * Screen rotation is taken into account.
  38042. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38043. */
  38044. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38045. private _camera;
  38046. private _screenOrientationAngle;
  38047. private _constantTranform;
  38048. private _screenQuaternion;
  38049. private _alpha;
  38050. private _beta;
  38051. private _gamma;
  38052. /**
  38053. * Can be used to detect if a device orientation sensor is availible on a device
  38054. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  38055. * @returns a promise that will resolve on orientation change
  38056. */
  38057. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  38058. /**
  38059. * @hidden
  38060. */
  38061. _onDeviceOrientationChangedObservable: Observable<void>;
  38062. /**
  38063. * Instantiates a new input
  38064. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38065. */
  38066. constructor();
  38067. /**
  38068. * Define the camera controlled by the input.
  38069. */
  38070. camera: FreeCamera;
  38071. /**
  38072. * Attach the input controls to a specific dom element to get the input from.
  38073. * @param element Defines the element the controls should be listened from
  38074. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38075. */
  38076. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38077. private _orientationChanged;
  38078. private _deviceOrientation;
  38079. /**
  38080. * Detach the current controls from the specified dom element.
  38081. * @param element Defines the element to stop listening the inputs from
  38082. */
  38083. detachControl(element: Nullable<HTMLElement>): void;
  38084. /**
  38085. * Update the current camera state depending on the inputs that have been used this frame.
  38086. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38087. */
  38088. checkInputs(): void;
  38089. /**
  38090. * Gets the class name of the current intput.
  38091. * @returns the class name
  38092. */
  38093. getClassName(): string;
  38094. /**
  38095. * Get the friendly name associated with the input class.
  38096. * @returns the input friendly name
  38097. */
  38098. getSimpleName(): string;
  38099. }
  38100. }
  38101. declare module BABYLON {
  38102. /**
  38103. * Manage the gamepad inputs to control a free camera.
  38104. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38105. */
  38106. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38107. /**
  38108. * Define the camera the input is attached to.
  38109. */
  38110. camera: FreeCamera;
  38111. /**
  38112. * Define the Gamepad controlling the input
  38113. */
  38114. gamepad: Nullable<Gamepad>;
  38115. /**
  38116. * Defines the gamepad rotation sensiblity.
  38117. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38118. */
  38119. gamepadAngularSensibility: number;
  38120. /**
  38121. * Defines the gamepad move sensiblity.
  38122. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38123. */
  38124. gamepadMoveSensibility: number;
  38125. private _onGamepadConnectedObserver;
  38126. private _onGamepadDisconnectedObserver;
  38127. private _cameraTransform;
  38128. private _deltaTransform;
  38129. private _vector3;
  38130. private _vector2;
  38131. /**
  38132. * Attach the input controls to a specific dom element to get the input from.
  38133. * @param element Defines the element the controls should be listened from
  38134. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38135. */
  38136. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38137. /**
  38138. * Detach the current controls from the specified dom element.
  38139. * @param element Defines the element to stop listening the inputs from
  38140. */
  38141. detachControl(element: Nullable<HTMLElement>): void;
  38142. /**
  38143. * Update the current camera state depending on the inputs that have been used this frame.
  38144. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38145. */
  38146. checkInputs(): void;
  38147. /**
  38148. * Gets the class name of the current intput.
  38149. * @returns the class name
  38150. */
  38151. getClassName(): string;
  38152. /**
  38153. * Get the friendly name associated with the input class.
  38154. * @returns the input friendly name
  38155. */
  38156. getSimpleName(): string;
  38157. }
  38158. }
  38159. declare module BABYLON {
  38160. /**
  38161. * Defines the potential axis of a Joystick
  38162. */
  38163. export enum JoystickAxis {
  38164. /** X axis */
  38165. X = 0,
  38166. /** Y axis */
  38167. Y = 1,
  38168. /** Z axis */
  38169. Z = 2
  38170. }
  38171. /**
  38172. * Class used to define virtual joystick (used in touch mode)
  38173. */
  38174. export class VirtualJoystick {
  38175. /**
  38176. * Gets or sets a boolean indicating that left and right values must be inverted
  38177. */
  38178. reverseLeftRight: boolean;
  38179. /**
  38180. * Gets or sets a boolean indicating that up and down values must be inverted
  38181. */
  38182. reverseUpDown: boolean;
  38183. /**
  38184. * Gets the offset value for the position (ie. the change of the position value)
  38185. */
  38186. deltaPosition: Vector3;
  38187. /**
  38188. * Gets a boolean indicating if the virtual joystick was pressed
  38189. */
  38190. pressed: boolean;
  38191. /**
  38192. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38193. */
  38194. static Canvas: Nullable<HTMLCanvasElement>;
  38195. private static _globalJoystickIndex;
  38196. private static vjCanvasContext;
  38197. private static vjCanvasWidth;
  38198. private static vjCanvasHeight;
  38199. private static halfWidth;
  38200. private _action;
  38201. private _axisTargetedByLeftAndRight;
  38202. private _axisTargetedByUpAndDown;
  38203. private _joystickSensibility;
  38204. private _inversedSensibility;
  38205. private _joystickPointerID;
  38206. private _joystickColor;
  38207. private _joystickPointerPos;
  38208. private _joystickPreviousPointerPos;
  38209. private _joystickPointerStartPos;
  38210. private _deltaJoystickVector;
  38211. private _leftJoystick;
  38212. private _touches;
  38213. private _onPointerDownHandlerRef;
  38214. private _onPointerMoveHandlerRef;
  38215. private _onPointerUpHandlerRef;
  38216. private _onResize;
  38217. /**
  38218. * Creates a new virtual joystick
  38219. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38220. */
  38221. constructor(leftJoystick?: boolean);
  38222. /**
  38223. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38224. * @param newJoystickSensibility defines the new sensibility
  38225. */
  38226. setJoystickSensibility(newJoystickSensibility: number): void;
  38227. private _onPointerDown;
  38228. private _onPointerMove;
  38229. private _onPointerUp;
  38230. /**
  38231. * Change the color of the virtual joystick
  38232. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38233. */
  38234. setJoystickColor(newColor: string): void;
  38235. /**
  38236. * Defines a callback to call when the joystick is touched
  38237. * @param action defines the callback
  38238. */
  38239. setActionOnTouch(action: () => any): void;
  38240. /**
  38241. * Defines which axis you'd like to control for left & right
  38242. * @param axis defines the axis to use
  38243. */
  38244. setAxisForLeftRight(axis: JoystickAxis): void;
  38245. /**
  38246. * Defines which axis you'd like to control for up & down
  38247. * @param axis defines the axis to use
  38248. */
  38249. setAxisForUpDown(axis: JoystickAxis): void;
  38250. private _drawVirtualJoystick;
  38251. /**
  38252. * Release internal HTML canvas
  38253. */
  38254. releaseCanvas(): void;
  38255. }
  38256. }
  38257. declare module BABYLON {
  38258. interface FreeCameraInputsManager {
  38259. /**
  38260. * Add virtual joystick input support to the input manager.
  38261. * @returns the current input manager
  38262. */
  38263. addVirtualJoystick(): FreeCameraInputsManager;
  38264. }
  38265. /**
  38266. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38267. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38268. */
  38269. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38270. /**
  38271. * Defines the camera the input is attached to.
  38272. */
  38273. camera: FreeCamera;
  38274. private _leftjoystick;
  38275. private _rightjoystick;
  38276. /**
  38277. * Gets the left stick of the virtual joystick.
  38278. * @returns The virtual Joystick
  38279. */
  38280. getLeftJoystick(): VirtualJoystick;
  38281. /**
  38282. * Gets the right stick of the virtual joystick.
  38283. * @returns The virtual Joystick
  38284. */
  38285. getRightJoystick(): VirtualJoystick;
  38286. /**
  38287. * Update the current camera state depending on the inputs that have been used this frame.
  38288. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38289. */
  38290. checkInputs(): void;
  38291. /**
  38292. * Attach the input controls to a specific dom element to get the input from.
  38293. * @param element Defines the element the controls should be listened from
  38294. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38295. */
  38296. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38297. /**
  38298. * Detach the current controls from the specified dom element.
  38299. * @param element Defines the element to stop listening the inputs from
  38300. */
  38301. detachControl(element: Nullable<HTMLElement>): void;
  38302. /**
  38303. * Gets the class name of the current intput.
  38304. * @returns the class name
  38305. */
  38306. getClassName(): string;
  38307. /**
  38308. * Get the friendly name associated with the input class.
  38309. * @returns the input friendly name
  38310. */
  38311. getSimpleName(): string;
  38312. }
  38313. }
  38314. declare module BABYLON {
  38315. /**
  38316. * This represents a FPS type of camera controlled by touch.
  38317. * This is like a universal camera minus the Gamepad controls.
  38318. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38319. */
  38320. export class TouchCamera extends FreeCamera {
  38321. /**
  38322. * Defines the touch sensibility for rotation.
  38323. * The higher the faster.
  38324. */
  38325. touchAngularSensibility: number;
  38326. /**
  38327. * Defines the touch sensibility for move.
  38328. * The higher the faster.
  38329. */
  38330. touchMoveSensibility: number;
  38331. /**
  38332. * Instantiates a new touch camera.
  38333. * This represents a FPS type of camera controlled by touch.
  38334. * This is like a universal camera minus the Gamepad controls.
  38335. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38336. * @param name Define the name of the camera in the scene
  38337. * @param position Define the start position of the camera in the scene
  38338. * @param scene Define the scene the camera belongs to
  38339. */
  38340. constructor(name: string, position: Vector3, scene: Scene);
  38341. /**
  38342. * Gets the current object class name.
  38343. * @return the class name
  38344. */
  38345. getClassName(): string;
  38346. /** @hidden */
  38347. _setupInputs(): void;
  38348. }
  38349. }
  38350. declare module BABYLON {
  38351. /**
  38352. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38353. * being tilted forward or back and left or right.
  38354. */
  38355. export class DeviceOrientationCamera extends FreeCamera {
  38356. private _initialQuaternion;
  38357. private _quaternionCache;
  38358. private _tmpDragQuaternion;
  38359. private _disablePointerInputWhenUsingDeviceOrientation;
  38360. /**
  38361. * Creates a new device orientation camera
  38362. * @param name The name of the camera
  38363. * @param position The start position camera
  38364. * @param scene The scene the camera belongs to
  38365. */
  38366. constructor(name: string, position: Vector3, scene: Scene);
  38367. /**
  38368. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  38369. */
  38370. disablePointerInputWhenUsingDeviceOrientation: boolean;
  38371. private _dragFactor;
  38372. /**
  38373. * Enabled turning on the y axis when the orientation sensor is active
  38374. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38375. */
  38376. enableHorizontalDragging(dragFactor?: number): void;
  38377. /**
  38378. * Gets the current instance class name ("DeviceOrientationCamera").
  38379. * This helps avoiding instanceof at run time.
  38380. * @returns the class name
  38381. */
  38382. getClassName(): string;
  38383. /**
  38384. * @hidden
  38385. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38386. */
  38387. _checkInputs(): void;
  38388. /**
  38389. * Reset the camera to its default orientation on the specified axis only.
  38390. * @param axis The axis to reset
  38391. */
  38392. resetToCurrentRotation(axis?: Axis): void;
  38393. }
  38394. }
  38395. declare module BABYLON {
  38396. /**
  38397. * Defines supported buttons for XBox360 compatible gamepads
  38398. */
  38399. export enum Xbox360Button {
  38400. /** A */
  38401. A = 0,
  38402. /** B */
  38403. B = 1,
  38404. /** X */
  38405. X = 2,
  38406. /** Y */
  38407. Y = 3,
  38408. /** Start */
  38409. Start = 4,
  38410. /** Back */
  38411. Back = 5,
  38412. /** Left button */
  38413. LB = 6,
  38414. /** Right button */
  38415. RB = 7,
  38416. /** Left stick */
  38417. LeftStick = 8,
  38418. /** Right stick */
  38419. RightStick = 9
  38420. }
  38421. /** Defines values for XBox360 DPad */
  38422. export enum Xbox360Dpad {
  38423. /** Up */
  38424. Up = 0,
  38425. /** Down */
  38426. Down = 1,
  38427. /** Left */
  38428. Left = 2,
  38429. /** Right */
  38430. Right = 3
  38431. }
  38432. /**
  38433. * Defines a XBox360 gamepad
  38434. */
  38435. export class Xbox360Pad extends Gamepad {
  38436. private _leftTrigger;
  38437. private _rightTrigger;
  38438. private _onlefttriggerchanged;
  38439. private _onrighttriggerchanged;
  38440. private _onbuttondown;
  38441. private _onbuttonup;
  38442. private _ondpaddown;
  38443. private _ondpadup;
  38444. /** Observable raised when a button is pressed */
  38445. onButtonDownObservable: Observable<Xbox360Button>;
  38446. /** Observable raised when a button is released */
  38447. onButtonUpObservable: Observable<Xbox360Button>;
  38448. /** Observable raised when a pad is pressed */
  38449. onPadDownObservable: Observable<Xbox360Dpad>;
  38450. /** Observable raised when a pad is released */
  38451. onPadUpObservable: Observable<Xbox360Dpad>;
  38452. private _buttonA;
  38453. private _buttonB;
  38454. private _buttonX;
  38455. private _buttonY;
  38456. private _buttonBack;
  38457. private _buttonStart;
  38458. private _buttonLB;
  38459. private _buttonRB;
  38460. private _buttonLeftStick;
  38461. private _buttonRightStick;
  38462. private _dPadUp;
  38463. private _dPadDown;
  38464. private _dPadLeft;
  38465. private _dPadRight;
  38466. private _isXboxOnePad;
  38467. /**
  38468. * Creates a new XBox360 gamepad object
  38469. * @param id defines the id of this gamepad
  38470. * @param index defines its index
  38471. * @param gamepad defines the internal HTML gamepad object
  38472. * @param xboxOne defines if it is a XBox One gamepad
  38473. */
  38474. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38475. /**
  38476. * Defines the callback to call when left trigger is pressed
  38477. * @param callback defines the callback to use
  38478. */
  38479. onlefttriggerchanged(callback: (value: number) => void): void;
  38480. /**
  38481. * Defines the callback to call when right trigger is pressed
  38482. * @param callback defines the callback to use
  38483. */
  38484. onrighttriggerchanged(callback: (value: number) => void): void;
  38485. /**
  38486. * Gets the left trigger value
  38487. */
  38488. /**
  38489. * Sets the left trigger value
  38490. */
  38491. leftTrigger: number;
  38492. /**
  38493. * Gets the right trigger value
  38494. */
  38495. /**
  38496. * Sets the right trigger value
  38497. */
  38498. rightTrigger: number;
  38499. /**
  38500. * Defines the callback to call when a button is pressed
  38501. * @param callback defines the callback to use
  38502. */
  38503. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38504. /**
  38505. * Defines the callback to call when a button is released
  38506. * @param callback defines the callback to use
  38507. */
  38508. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38509. /**
  38510. * Defines the callback to call when a pad is pressed
  38511. * @param callback defines the callback to use
  38512. */
  38513. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38514. /**
  38515. * Defines the callback to call when a pad is released
  38516. * @param callback defines the callback to use
  38517. */
  38518. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38519. private _setButtonValue;
  38520. private _setDPadValue;
  38521. /**
  38522. * Gets the value of the `A` button
  38523. */
  38524. /**
  38525. * Sets the value of the `A` button
  38526. */
  38527. buttonA: number;
  38528. /**
  38529. * Gets the value of the `B` button
  38530. */
  38531. /**
  38532. * Sets the value of the `B` button
  38533. */
  38534. buttonB: number;
  38535. /**
  38536. * Gets the value of the `X` button
  38537. */
  38538. /**
  38539. * Sets the value of the `X` button
  38540. */
  38541. buttonX: number;
  38542. /**
  38543. * Gets the value of the `Y` button
  38544. */
  38545. /**
  38546. * Sets the value of the `Y` button
  38547. */
  38548. buttonY: number;
  38549. /**
  38550. * Gets the value of the `Start` button
  38551. */
  38552. /**
  38553. * Sets the value of the `Start` button
  38554. */
  38555. buttonStart: number;
  38556. /**
  38557. * Gets the value of the `Back` button
  38558. */
  38559. /**
  38560. * Sets the value of the `Back` button
  38561. */
  38562. buttonBack: number;
  38563. /**
  38564. * Gets the value of the `Left` button
  38565. */
  38566. /**
  38567. * Sets the value of the `Left` button
  38568. */
  38569. buttonLB: number;
  38570. /**
  38571. * Gets the value of the `Right` button
  38572. */
  38573. /**
  38574. * Sets the value of the `Right` button
  38575. */
  38576. buttonRB: number;
  38577. /**
  38578. * Gets the value of the Left joystick
  38579. */
  38580. /**
  38581. * Sets the value of the Left joystick
  38582. */
  38583. buttonLeftStick: number;
  38584. /**
  38585. * Gets the value of the Right joystick
  38586. */
  38587. /**
  38588. * Sets the value of the Right joystick
  38589. */
  38590. buttonRightStick: number;
  38591. /**
  38592. * Gets the value of D-pad up
  38593. */
  38594. /**
  38595. * Sets the value of D-pad up
  38596. */
  38597. dPadUp: number;
  38598. /**
  38599. * Gets the value of D-pad down
  38600. */
  38601. /**
  38602. * Sets the value of D-pad down
  38603. */
  38604. dPadDown: number;
  38605. /**
  38606. * Gets the value of D-pad left
  38607. */
  38608. /**
  38609. * Sets the value of D-pad left
  38610. */
  38611. dPadLeft: number;
  38612. /**
  38613. * Gets the value of D-pad right
  38614. */
  38615. /**
  38616. * Sets the value of D-pad right
  38617. */
  38618. dPadRight: number;
  38619. /**
  38620. * Force the gamepad to synchronize with device values
  38621. */
  38622. update(): void;
  38623. /**
  38624. * Disposes the gamepad
  38625. */
  38626. dispose(): void;
  38627. }
  38628. }
  38629. declare module BABYLON {
  38630. /**
  38631. * Defines supported buttons for DualShock compatible gamepads
  38632. */
  38633. export enum DualShockButton {
  38634. /** Cross */
  38635. Cross = 0,
  38636. /** Circle */
  38637. Circle = 1,
  38638. /** Square */
  38639. Square = 2,
  38640. /** Triangle */
  38641. Triangle = 3,
  38642. /** Options */
  38643. Options = 4,
  38644. /** Share */
  38645. Share = 5,
  38646. /** L1 */
  38647. L1 = 6,
  38648. /** R1 */
  38649. R1 = 7,
  38650. /** Left stick */
  38651. LeftStick = 8,
  38652. /** Right stick */
  38653. RightStick = 9
  38654. }
  38655. /** Defines values for DualShock DPad */
  38656. export enum DualShockDpad {
  38657. /** Up */
  38658. Up = 0,
  38659. /** Down */
  38660. Down = 1,
  38661. /** Left */
  38662. Left = 2,
  38663. /** Right */
  38664. Right = 3
  38665. }
  38666. /**
  38667. * Defines a DualShock gamepad
  38668. */
  38669. export class DualShockPad extends Gamepad {
  38670. private _leftTrigger;
  38671. private _rightTrigger;
  38672. private _onlefttriggerchanged;
  38673. private _onrighttriggerchanged;
  38674. private _onbuttondown;
  38675. private _onbuttonup;
  38676. private _ondpaddown;
  38677. private _ondpadup;
  38678. /** Observable raised when a button is pressed */
  38679. onButtonDownObservable: Observable<DualShockButton>;
  38680. /** Observable raised when a button is released */
  38681. onButtonUpObservable: Observable<DualShockButton>;
  38682. /** Observable raised when a pad is pressed */
  38683. onPadDownObservable: Observable<DualShockDpad>;
  38684. /** Observable raised when a pad is released */
  38685. onPadUpObservable: Observable<DualShockDpad>;
  38686. private _buttonCross;
  38687. private _buttonCircle;
  38688. private _buttonSquare;
  38689. private _buttonTriangle;
  38690. private _buttonShare;
  38691. private _buttonOptions;
  38692. private _buttonL1;
  38693. private _buttonR1;
  38694. private _buttonLeftStick;
  38695. private _buttonRightStick;
  38696. private _dPadUp;
  38697. private _dPadDown;
  38698. private _dPadLeft;
  38699. private _dPadRight;
  38700. /**
  38701. * Creates a new DualShock gamepad object
  38702. * @param id defines the id of this gamepad
  38703. * @param index defines its index
  38704. * @param gamepad defines the internal HTML gamepad object
  38705. */
  38706. constructor(id: string, index: number, gamepad: any);
  38707. /**
  38708. * Defines the callback to call when left trigger is pressed
  38709. * @param callback defines the callback to use
  38710. */
  38711. onlefttriggerchanged(callback: (value: number) => void): void;
  38712. /**
  38713. * Defines the callback to call when right trigger is pressed
  38714. * @param callback defines the callback to use
  38715. */
  38716. onrighttriggerchanged(callback: (value: number) => void): void;
  38717. /**
  38718. * Gets the left trigger value
  38719. */
  38720. /**
  38721. * Sets the left trigger value
  38722. */
  38723. leftTrigger: number;
  38724. /**
  38725. * Gets the right trigger value
  38726. */
  38727. /**
  38728. * Sets the right trigger value
  38729. */
  38730. rightTrigger: number;
  38731. /**
  38732. * Defines the callback to call when a button is pressed
  38733. * @param callback defines the callback to use
  38734. */
  38735. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  38736. /**
  38737. * Defines the callback to call when a button is released
  38738. * @param callback defines the callback to use
  38739. */
  38740. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  38741. /**
  38742. * Defines the callback to call when a pad is pressed
  38743. * @param callback defines the callback to use
  38744. */
  38745. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  38746. /**
  38747. * Defines the callback to call when a pad is released
  38748. * @param callback defines the callback to use
  38749. */
  38750. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  38751. private _setButtonValue;
  38752. private _setDPadValue;
  38753. /**
  38754. * Gets the value of the `Cross` button
  38755. */
  38756. /**
  38757. * Sets the value of the `Cross` button
  38758. */
  38759. buttonCross: number;
  38760. /**
  38761. * Gets the value of the `Circle` button
  38762. */
  38763. /**
  38764. * Sets the value of the `Circle` button
  38765. */
  38766. buttonCircle: number;
  38767. /**
  38768. * Gets the value of the `Square` button
  38769. */
  38770. /**
  38771. * Sets the value of the `Square` button
  38772. */
  38773. buttonSquare: number;
  38774. /**
  38775. * Gets the value of the `Triangle` button
  38776. */
  38777. /**
  38778. * Sets the value of the `Triangle` button
  38779. */
  38780. buttonTriangle: number;
  38781. /**
  38782. * Gets the value of the `Options` button
  38783. */
  38784. /**
  38785. * Sets the value of the `Options` button
  38786. */
  38787. buttonOptions: number;
  38788. /**
  38789. * Gets the value of the `Share` button
  38790. */
  38791. /**
  38792. * Sets the value of the `Share` button
  38793. */
  38794. buttonShare: number;
  38795. /**
  38796. * Gets the value of the `L1` button
  38797. */
  38798. /**
  38799. * Sets the value of the `L1` button
  38800. */
  38801. buttonL1: number;
  38802. /**
  38803. * Gets the value of the `R1` button
  38804. */
  38805. /**
  38806. * Sets the value of the `R1` button
  38807. */
  38808. buttonR1: number;
  38809. /**
  38810. * Gets the value of the Left joystick
  38811. */
  38812. /**
  38813. * Sets the value of the Left joystick
  38814. */
  38815. buttonLeftStick: number;
  38816. /**
  38817. * Gets the value of the Right joystick
  38818. */
  38819. /**
  38820. * Sets the value of the Right joystick
  38821. */
  38822. buttonRightStick: number;
  38823. /**
  38824. * Gets the value of D-pad up
  38825. */
  38826. /**
  38827. * Sets the value of D-pad up
  38828. */
  38829. dPadUp: number;
  38830. /**
  38831. * Gets the value of D-pad down
  38832. */
  38833. /**
  38834. * Sets the value of D-pad down
  38835. */
  38836. dPadDown: number;
  38837. /**
  38838. * Gets the value of D-pad left
  38839. */
  38840. /**
  38841. * Sets the value of D-pad left
  38842. */
  38843. dPadLeft: number;
  38844. /**
  38845. * Gets the value of D-pad right
  38846. */
  38847. /**
  38848. * Sets the value of D-pad right
  38849. */
  38850. dPadRight: number;
  38851. /**
  38852. * Force the gamepad to synchronize with device values
  38853. */
  38854. update(): void;
  38855. /**
  38856. * Disposes the gamepad
  38857. */
  38858. dispose(): void;
  38859. }
  38860. }
  38861. declare module BABYLON {
  38862. /**
  38863. * Manager for handling gamepads
  38864. */
  38865. export class GamepadManager {
  38866. private _scene?;
  38867. private _babylonGamepads;
  38868. private _oneGamepadConnected;
  38869. /** @hidden */
  38870. _isMonitoring: boolean;
  38871. private _gamepadEventSupported;
  38872. private _gamepadSupport;
  38873. /**
  38874. * observable to be triggered when the gamepad controller has been connected
  38875. */
  38876. onGamepadConnectedObservable: Observable<Gamepad>;
  38877. /**
  38878. * observable to be triggered when the gamepad controller has been disconnected
  38879. */
  38880. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38881. private _onGamepadConnectedEvent;
  38882. private _onGamepadDisconnectedEvent;
  38883. /**
  38884. * Initializes the gamepad manager
  38885. * @param _scene BabylonJS scene
  38886. */
  38887. constructor(_scene?: Scene | undefined);
  38888. /**
  38889. * The gamepads in the game pad manager
  38890. */
  38891. readonly gamepads: Gamepad[];
  38892. /**
  38893. * Get the gamepad controllers based on type
  38894. * @param type The type of gamepad controller
  38895. * @returns Nullable gamepad
  38896. */
  38897. getGamepadByType(type?: number): Nullable<Gamepad>;
  38898. /**
  38899. * Disposes the gamepad manager
  38900. */
  38901. dispose(): void;
  38902. private _addNewGamepad;
  38903. private _startMonitoringGamepads;
  38904. private _stopMonitoringGamepads;
  38905. /** @hidden */
  38906. _checkGamepadsStatus(): void;
  38907. private _updateGamepadObjects;
  38908. }
  38909. }
  38910. declare module BABYLON {
  38911. interface Scene {
  38912. /** @hidden */
  38913. _gamepadManager: Nullable<GamepadManager>;
  38914. /**
  38915. * Gets the gamepad manager associated with the scene
  38916. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38917. */
  38918. gamepadManager: GamepadManager;
  38919. }
  38920. /**
  38921. * Interface representing a free camera inputs manager
  38922. */
  38923. interface FreeCameraInputsManager {
  38924. /**
  38925. * Adds gamepad input support to the FreeCameraInputsManager.
  38926. * @returns the FreeCameraInputsManager
  38927. */
  38928. addGamepad(): FreeCameraInputsManager;
  38929. }
  38930. /**
  38931. * Interface representing an arc rotate camera inputs manager
  38932. */
  38933. interface ArcRotateCameraInputsManager {
  38934. /**
  38935. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38936. * @returns the camera inputs manager
  38937. */
  38938. addGamepad(): ArcRotateCameraInputsManager;
  38939. }
  38940. /**
  38941. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38942. */
  38943. export class GamepadSystemSceneComponent implements ISceneComponent {
  38944. /**
  38945. * The component name helpfull to identify the component in the list of scene components.
  38946. */
  38947. readonly name: string;
  38948. /**
  38949. * The scene the component belongs to.
  38950. */
  38951. scene: Scene;
  38952. /**
  38953. * Creates a new instance of the component for the given scene
  38954. * @param scene Defines the scene to register the component in
  38955. */
  38956. constructor(scene: Scene);
  38957. /**
  38958. * Registers the component in a given scene
  38959. */
  38960. register(): void;
  38961. /**
  38962. * Rebuilds the elements related to this component in case of
  38963. * context lost for instance.
  38964. */
  38965. rebuild(): void;
  38966. /**
  38967. * Disposes the component and the associated ressources
  38968. */
  38969. dispose(): void;
  38970. private _beforeCameraUpdate;
  38971. }
  38972. }
  38973. declare module BABYLON {
  38974. /**
  38975. * 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,
  38976. * which still works and will still be found in many Playgrounds.
  38977. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38978. */
  38979. export class UniversalCamera extends TouchCamera {
  38980. /**
  38981. * Defines the gamepad rotation sensiblity.
  38982. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38983. */
  38984. gamepadAngularSensibility: number;
  38985. /**
  38986. * Defines the gamepad move sensiblity.
  38987. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38988. */
  38989. gamepadMoveSensibility: number;
  38990. /**
  38991. * 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,
  38992. * which still works and will still be found in many Playgrounds.
  38993. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38994. * @param name Define the name of the camera in the scene
  38995. * @param position Define the start position of the camera in the scene
  38996. * @param scene Define the scene the camera belongs to
  38997. */
  38998. constructor(name: string, position: Vector3, scene: Scene);
  38999. /**
  39000. * Gets the current object class name.
  39001. * @return the class name
  39002. */
  39003. getClassName(): string;
  39004. }
  39005. }
  39006. declare module BABYLON {
  39007. /**
  39008. * This represents a FPS type of camera. This is only here for back compat purpose.
  39009. * Please use the UniversalCamera instead as both are identical.
  39010. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39011. */
  39012. export class GamepadCamera extends UniversalCamera {
  39013. /**
  39014. * Instantiates a new Gamepad Camera
  39015. * This represents a FPS type of camera. This is only here for back compat purpose.
  39016. * Please use the UniversalCamera instead as both are identical.
  39017. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39018. * @param name Define the name of the camera in the scene
  39019. * @param position Define the start position of the camera in the scene
  39020. * @param scene Define the scene the camera belongs to
  39021. */
  39022. constructor(name: string, position: Vector3, scene: Scene);
  39023. /**
  39024. * Gets the current object class name.
  39025. * @return the class name
  39026. */
  39027. getClassName(): string;
  39028. }
  39029. }
  39030. declare module BABYLON {
  39031. /** @hidden */
  39032. export var passPixelShader: {
  39033. name: string;
  39034. shader: string;
  39035. };
  39036. }
  39037. declare module BABYLON {
  39038. /** @hidden */
  39039. export var passCubePixelShader: {
  39040. name: string;
  39041. shader: string;
  39042. };
  39043. }
  39044. declare module BABYLON {
  39045. /**
  39046. * PassPostProcess which produces an output the same as it's input
  39047. */
  39048. export class PassPostProcess extends PostProcess {
  39049. /**
  39050. * Creates the PassPostProcess
  39051. * @param name The name of the effect.
  39052. * @param options The required width/height ratio to downsize to before computing the render pass.
  39053. * @param camera The camera to apply the render pass to.
  39054. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39055. * @param engine The engine which the post process will be applied. (default: current engine)
  39056. * @param reusable If the post process can be reused on the same frame. (default: false)
  39057. * @param textureType The type of texture to be used when performing the post processing.
  39058. * @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)
  39059. */
  39060. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39061. }
  39062. /**
  39063. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39064. */
  39065. export class PassCubePostProcess extends PostProcess {
  39066. private _face;
  39067. /**
  39068. * Gets or sets the cube face to display.
  39069. * * 0 is +X
  39070. * * 1 is -X
  39071. * * 2 is +Y
  39072. * * 3 is -Y
  39073. * * 4 is +Z
  39074. * * 5 is -Z
  39075. */
  39076. face: number;
  39077. /**
  39078. * Creates the PassCubePostProcess
  39079. * @param name The name of the effect.
  39080. * @param options The required width/height ratio to downsize to before computing the render pass.
  39081. * @param camera The camera to apply the render pass to.
  39082. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39083. * @param engine The engine which the post process will be applied. (default: current engine)
  39084. * @param reusable If the post process can be reused on the same frame. (default: false)
  39085. * @param textureType The type of texture to be used when performing the post processing.
  39086. * @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)
  39087. */
  39088. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39089. }
  39090. }
  39091. declare module BABYLON {
  39092. /** @hidden */
  39093. export var anaglyphPixelShader: {
  39094. name: string;
  39095. shader: string;
  39096. };
  39097. }
  39098. declare module BABYLON {
  39099. /**
  39100. * Postprocess used to generate anaglyphic rendering
  39101. */
  39102. export class AnaglyphPostProcess extends PostProcess {
  39103. private _passedProcess;
  39104. /**
  39105. * Creates a new AnaglyphPostProcess
  39106. * @param name defines postprocess name
  39107. * @param options defines creation options or target ratio scale
  39108. * @param rigCameras defines cameras using this postprocess
  39109. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39110. * @param engine defines hosting engine
  39111. * @param reusable defines if the postprocess will be reused multiple times per frame
  39112. */
  39113. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39114. }
  39115. }
  39116. declare module BABYLON {
  39117. /**
  39118. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39119. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39120. */
  39121. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39122. /**
  39123. * Creates a new AnaglyphArcRotateCamera
  39124. * @param name defines camera name
  39125. * @param alpha defines alpha angle (in radians)
  39126. * @param beta defines beta angle (in radians)
  39127. * @param radius defines radius
  39128. * @param target defines camera target
  39129. * @param interaxialDistance defines distance between each color axis
  39130. * @param scene defines the hosting scene
  39131. */
  39132. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39133. /**
  39134. * Gets camera class name
  39135. * @returns AnaglyphArcRotateCamera
  39136. */
  39137. getClassName(): string;
  39138. }
  39139. }
  39140. declare module BABYLON {
  39141. /**
  39142. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39143. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39144. */
  39145. export class AnaglyphFreeCamera extends FreeCamera {
  39146. /**
  39147. * Creates a new AnaglyphFreeCamera
  39148. * @param name defines camera name
  39149. * @param position defines initial position
  39150. * @param interaxialDistance defines distance between each color axis
  39151. * @param scene defines the hosting scene
  39152. */
  39153. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39154. /**
  39155. * Gets camera class name
  39156. * @returns AnaglyphFreeCamera
  39157. */
  39158. getClassName(): string;
  39159. }
  39160. }
  39161. declare module BABYLON {
  39162. /**
  39163. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39164. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39165. */
  39166. export class AnaglyphGamepadCamera extends GamepadCamera {
  39167. /**
  39168. * Creates a new AnaglyphGamepadCamera
  39169. * @param name defines camera name
  39170. * @param position defines initial position
  39171. * @param interaxialDistance defines distance between each color axis
  39172. * @param scene defines the hosting scene
  39173. */
  39174. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39175. /**
  39176. * Gets camera class name
  39177. * @returns AnaglyphGamepadCamera
  39178. */
  39179. getClassName(): string;
  39180. }
  39181. }
  39182. declare module BABYLON {
  39183. /**
  39184. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39185. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39186. */
  39187. export class AnaglyphUniversalCamera extends UniversalCamera {
  39188. /**
  39189. * Creates a new AnaglyphUniversalCamera
  39190. * @param name defines camera name
  39191. * @param position defines initial position
  39192. * @param interaxialDistance defines distance between each color axis
  39193. * @param scene defines the hosting scene
  39194. */
  39195. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39196. /**
  39197. * Gets camera class name
  39198. * @returns AnaglyphUniversalCamera
  39199. */
  39200. getClassName(): string;
  39201. }
  39202. }
  39203. declare module BABYLON {
  39204. /** @hidden */
  39205. export var stereoscopicInterlacePixelShader: {
  39206. name: string;
  39207. shader: string;
  39208. };
  39209. }
  39210. declare module BABYLON {
  39211. /**
  39212. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39213. */
  39214. export class StereoscopicInterlacePostProcess extends PostProcess {
  39215. private _stepSize;
  39216. private _passedProcess;
  39217. /**
  39218. * Initializes a StereoscopicInterlacePostProcess
  39219. * @param name The name of the effect.
  39220. * @param rigCameras The rig cameras to be appled to the post process
  39221. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39222. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39223. * @param engine The engine which the post process will be applied. (default: current engine)
  39224. * @param reusable If the post process can be reused on the same frame. (default: false)
  39225. */
  39226. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39227. }
  39228. }
  39229. declare module BABYLON {
  39230. /**
  39231. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39232. * @see http://doc.babylonjs.com/features/cameras
  39233. */
  39234. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39235. /**
  39236. * Creates a new StereoscopicArcRotateCamera
  39237. * @param name defines camera name
  39238. * @param alpha defines alpha angle (in radians)
  39239. * @param beta defines beta angle (in radians)
  39240. * @param radius defines radius
  39241. * @param target defines camera target
  39242. * @param interaxialDistance defines distance between each color axis
  39243. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39244. * @param scene defines the hosting scene
  39245. */
  39246. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39247. /**
  39248. * Gets camera class name
  39249. * @returns StereoscopicArcRotateCamera
  39250. */
  39251. getClassName(): string;
  39252. }
  39253. }
  39254. declare module BABYLON {
  39255. /**
  39256. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39257. * @see http://doc.babylonjs.com/features/cameras
  39258. */
  39259. export class StereoscopicFreeCamera extends FreeCamera {
  39260. /**
  39261. * Creates a new StereoscopicFreeCamera
  39262. * @param name defines camera name
  39263. * @param position defines initial position
  39264. * @param interaxialDistance defines distance between each color axis
  39265. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39266. * @param scene defines the hosting scene
  39267. */
  39268. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39269. /**
  39270. * Gets camera class name
  39271. * @returns StereoscopicFreeCamera
  39272. */
  39273. getClassName(): string;
  39274. }
  39275. }
  39276. declare module BABYLON {
  39277. /**
  39278. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39279. * @see http://doc.babylonjs.com/features/cameras
  39280. */
  39281. export class StereoscopicGamepadCamera extends GamepadCamera {
  39282. /**
  39283. * Creates a new StereoscopicGamepadCamera
  39284. * @param name defines camera name
  39285. * @param position defines initial position
  39286. * @param interaxialDistance defines distance between each color axis
  39287. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39288. * @param scene defines the hosting scene
  39289. */
  39290. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39291. /**
  39292. * Gets camera class name
  39293. * @returns StereoscopicGamepadCamera
  39294. */
  39295. getClassName(): string;
  39296. }
  39297. }
  39298. declare module BABYLON {
  39299. /**
  39300. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39301. * @see http://doc.babylonjs.com/features/cameras
  39302. */
  39303. export class StereoscopicUniversalCamera extends UniversalCamera {
  39304. /**
  39305. * Creates a new StereoscopicUniversalCamera
  39306. * @param name defines camera name
  39307. * @param position defines initial position
  39308. * @param interaxialDistance defines distance between each color axis
  39309. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39310. * @param scene defines the hosting scene
  39311. */
  39312. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39313. /**
  39314. * Gets camera class name
  39315. * @returns StereoscopicUniversalCamera
  39316. */
  39317. getClassName(): string;
  39318. }
  39319. }
  39320. declare module BABYLON {
  39321. /**
  39322. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39323. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39324. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39325. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39326. */
  39327. export class VirtualJoysticksCamera extends FreeCamera {
  39328. /**
  39329. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39330. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39331. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39332. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39333. * @param name Define the name of the camera in the scene
  39334. * @param position Define the start position of the camera in the scene
  39335. * @param scene Define the scene the camera belongs to
  39336. */
  39337. constructor(name: string, position: Vector3, scene: Scene);
  39338. /**
  39339. * Gets the current object class name.
  39340. * @return the class name
  39341. */
  39342. getClassName(): string;
  39343. }
  39344. }
  39345. declare module BABYLON {
  39346. /**
  39347. * This represents all the required metrics to create a VR camera.
  39348. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39349. */
  39350. export class VRCameraMetrics {
  39351. /**
  39352. * Define the horizontal resolution off the screen.
  39353. */
  39354. hResolution: number;
  39355. /**
  39356. * Define the vertical resolution off the screen.
  39357. */
  39358. vResolution: number;
  39359. /**
  39360. * Define the horizontal screen size.
  39361. */
  39362. hScreenSize: number;
  39363. /**
  39364. * Define the vertical screen size.
  39365. */
  39366. vScreenSize: number;
  39367. /**
  39368. * Define the vertical screen center position.
  39369. */
  39370. vScreenCenter: number;
  39371. /**
  39372. * Define the distance of the eyes to the screen.
  39373. */
  39374. eyeToScreenDistance: number;
  39375. /**
  39376. * Define the distance between both lenses
  39377. */
  39378. lensSeparationDistance: number;
  39379. /**
  39380. * Define the distance between both viewer's eyes.
  39381. */
  39382. interpupillaryDistance: number;
  39383. /**
  39384. * Define the distortion factor of the VR postprocess.
  39385. * Please, touch with care.
  39386. */
  39387. distortionK: number[];
  39388. /**
  39389. * Define the chromatic aberration correction factors for the VR post process.
  39390. */
  39391. chromaAbCorrection: number[];
  39392. /**
  39393. * Define the scale factor of the post process.
  39394. * The smaller the better but the slower.
  39395. */
  39396. postProcessScaleFactor: number;
  39397. /**
  39398. * Define an offset for the lens center.
  39399. */
  39400. lensCenterOffset: number;
  39401. /**
  39402. * Define if the current vr camera should compensate the distortion of the lense or not.
  39403. */
  39404. compensateDistortion: boolean;
  39405. /**
  39406. * Defines if multiview should be enabled when rendering (Default: false)
  39407. */
  39408. multiviewEnabled: boolean;
  39409. /**
  39410. * Gets the rendering aspect ratio based on the provided resolutions.
  39411. */
  39412. readonly aspectRatio: number;
  39413. /**
  39414. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39415. */
  39416. readonly aspectRatioFov: number;
  39417. /**
  39418. * @hidden
  39419. */
  39420. readonly leftHMatrix: Matrix;
  39421. /**
  39422. * @hidden
  39423. */
  39424. readonly rightHMatrix: Matrix;
  39425. /**
  39426. * @hidden
  39427. */
  39428. readonly leftPreViewMatrix: Matrix;
  39429. /**
  39430. * @hidden
  39431. */
  39432. readonly rightPreViewMatrix: Matrix;
  39433. /**
  39434. * Get the default VRMetrics based on the most generic setup.
  39435. * @returns the default vr metrics
  39436. */
  39437. static GetDefault(): VRCameraMetrics;
  39438. }
  39439. }
  39440. declare module BABYLON {
  39441. /** @hidden */
  39442. export var vrDistortionCorrectionPixelShader: {
  39443. name: string;
  39444. shader: string;
  39445. };
  39446. }
  39447. declare module BABYLON {
  39448. /**
  39449. * VRDistortionCorrectionPostProcess used for mobile VR
  39450. */
  39451. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39452. private _isRightEye;
  39453. private _distortionFactors;
  39454. private _postProcessScaleFactor;
  39455. private _lensCenterOffset;
  39456. private _scaleIn;
  39457. private _scaleFactor;
  39458. private _lensCenter;
  39459. /**
  39460. * Initializes the VRDistortionCorrectionPostProcess
  39461. * @param name The name of the effect.
  39462. * @param camera The camera to apply the render pass to.
  39463. * @param isRightEye If this is for the right eye distortion
  39464. * @param vrMetrics All the required metrics for the VR camera
  39465. */
  39466. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39467. }
  39468. }
  39469. declare module BABYLON {
  39470. /**
  39471. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39472. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39473. */
  39474. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39475. /**
  39476. * Creates a new VRDeviceOrientationArcRotateCamera
  39477. * @param name defines camera name
  39478. * @param alpha defines the camera rotation along the logitudinal axis
  39479. * @param beta defines the camera rotation along the latitudinal axis
  39480. * @param radius defines the camera distance from its target
  39481. * @param target defines the camera target
  39482. * @param scene defines the scene the camera belongs to
  39483. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39484. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39485. */
  39486. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39487. /**
  39488. * Gets camera class name
  39489. * @returns VRDeviceOrientationArcRotateCamera
  39490. */
  39491. getClassName(): string;
  39492. }
  39493. }
  39494. declare module BABYLON {
  39495. /**
  39496. * Camera used to simulate VR rendering (based on FreeCamera)
  39497. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39498. */
  39499. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39500. /**
  39501. * Creates a new VRDeviceOrientationFreeCamera
  39502. * @param name defines camera name
  39503. * @param position defines the start position of the camera
  39504. * @param scene defines the scene the camera belongs to
  39505. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39506. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39507. */
  39508. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39509. /**
  39510. * Gets camera class name
  39511. * @returns VRDeviceOrientationFreeCamera
  39512. */
  39513. getClassName(): string;
  39514. }
  39515. }
  39516. declare module BABYLON {
  39517. /**
  39518. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39519. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39520. */
  39521. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39522. /**
  39523. * Creates a new VRDeviceOrientationGamepadCamera
  39524. * @param name defines camera name
  39525. * @param position defines the start position of the camera
  39526. * @param scene defines the scene the camera belongs to
  39527. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39528. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39529. */
  39530. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39531. /**
  39532. * Gets camera class name
  39533. * @returns VRDeviceOrientationGamepadCamera
  39534. */
  39535. getClassName(): string;
  39536. }
  39537. }
  39538. declare module BABYLON {
  39539. /**
  39540. * Base class of materials working in push mode in babylon JS
  39541. * @hidden
  39542. */
  39543. export class PushMaterial extends Material {
  39544. protected _activeEffect: Effect;
  39545. protected _normalMatrix: Matrix;
  39546. /**
  39547. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39548. * This means that the material can keep using a previous shader while a new one is being compiled.
  39549. * This is mostly used when shader parallel compilation is supported (true by default)
  39550. */
  39551. allowShaderHotSwapping: boolean;
  39552. constructor(name: string, scene: Scene);
  39553. getEffect(): Effect;
  39554. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39555. /**
  39556. * Binds the given world matrix to the active effect
  39557. *
  39558. * @param world the matrix to bind
  39559. */
  39560. bindOnlyWorldMatrix(world: Matrix): void;
  39561. /**
  39562. * Binds the given normal matrix to the active effect
  39563. *
  39564. * @param normalMatrix the matrix to bind
  39565. */
  39566. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39567. bind(world: Matrix, mesh?: Mesh): void;
  39568. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39569. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39570. }
  39571. }
  39572. declare module BABYLON {
  39573. /**
  39574. * This groups all the flags used to control the materials channel.
  39575. */
  39576. export class MaterialFlags {
  39577. private static _DiffuseTextureEnabled;
  39578. /**
  39579. * Are diffuse textures enabled in the application.
  39580. */
  39581. static DiffuseTextureEnabled: boolean;
  39582. private static _AmbientTextureEnabled;
  39583. /**
  39584. * Are ambient textures enabled in the application.
  39585. */
  39586. static AmbientTextureEnabled: boolean;
  39587. private static _OpacityTextureEnabled;
  39588. /**
  39589. * Are opacity textures enabled in the application.
  39590. */
  39591. static OpacityTextureEnabled: boolean;
  39592. private static _ReflectionTextureEnabled;
  39593. /**
  39594. * Are reflection textures enabled in the application.
  39595. */
  39596. static ReflectionTextureEnabled: boolean;
  39597. private static _EmissiveTextureEnabled;
  39598. /**
  39599. * Are emissive textures enabled in the application.
  39600. */
  39601. static EmissiveTextureEnabled: boolean;
  39602. private static _SpecularTextureEnabled;
  39603. /**
  39604. * Are specular textures enabled in the application.
  39605. */
  39606. static SpecularTextureEnabled: boolean;
  39607. private static _BumpTextureEnabled;
  39608. /**
  39609. * Are bump textures enabled in the application.
  39610. */
  39611. static BumpTextureEnabled: boolean;
  39612. private static _LightmapTextureEnabled;
  39613. /**
  39614. * Are lightmap textures enabled in the application.
  39615. */
  39616. static LightmapTextureEnabled: boolean;
  39617. private static _RefractionTextureEnabled;
  39618. /**
  39619. * Are refraction textures enabled in the application.
  39620. */
  39621. static RefractionTextureEnabled: boolean;
  39622. private static _ColorGradingTextureEnabled;
  39623. /**
  39624. * Are color grading textures enabled in the application.
  39625. */
  39626. static ColorGradingTextureEnabled: boolean;
  39627. private static _FresnelEnabled;
  39628. /**
  39629. * Are fresnels enabled in the application.
  39630. */
  39631. static FresnelEnabled: boolean;
  39632. private static _ClearCoatTextureEnabled;
  39633. /**
  39634. * Are clear coat textures enabled in the application.
  39635. */
  39636. static ClearCoatTextureEnabled: boolean;
  39637. private static _ClearCoatBumpTextureEnabled;
  39638. /**
  39639. * Are clear coat bump textures enabled in the application.
  39640. */
  39641. static ClearCoatBumpTextureEnabled: boolean;
  39642. private static _ClearCoatTintTextureEnabled;
  39643. /**
  39644. * Are clear coat tint textures enabled in the application.
  39645. */
  39646. static ClearCoatTintTextureEnabled: boolean;
  39647. private static _SheenTextureEnabled;
  39648. /**
  39649. * Are sheen textures enabled in the application.
  39650. */
  39651. static SheenTextureEnabled: boolean;
  39652. private static _AnisotropicTextureEnabled;
  39653. /**
  39654. * Are anisotropic textures enabled in the application.
  39655. */
  39656. static AnisotropicTextureEnabled: boolean;
  39657. private static _ThicknessTextureEnabled;
  39658. /**
  39659. * Are thickness textures enabled in the application.
  39660. */
  39661. static ThicknessTextureEnabled: boolean;
  39662. }
  39663. }
  39664. declare module BABYLON {
  39665. /** @hidden */
  39666. export var defaultFragmentDeclaration: {
  39667. name: string;
  39668. shader: string;
  39669. };
  39670. }
  39671. declare module BABYLON {
  39672. /** @hidden */
  39673. export var defaultUboDeclaration: {
  39674. name: string;
  39675. shader: string;
  39676. };
  39677. }
  39678. declare module BABYLON {
  39679. /** @hidden */
  39680. export var lightFragmentDeclaration: {
  39681. name: string;
  39682. shader: string;
  39683. };
  39684. }
  39685. declare module BABYLON {
  39686. /** @hidden */
  39687. export var lightUboDeclaration: {
  39688. name: string;
  39689. shader: string;
  39690. };
  39691. }
  39692. declare module BABYLON {
  39693. /** @hidden */
  39694. export var lightsFragmentFunctions: {
  39695. name: string;
  39696. shader: string;
  39697. };
  39698. }
  39699. declare module BABYLON {
  39700. /** @hidden */
  39701. export var shadowsFragmentFunctions: {
  39702. name: string;
  39703. shader: string;
  39704. };
  39705. }
  39706. declare module BABYLON {
  39707. /** @hidden */
  39708. export var fresnelFunction: {
  39709. name: string;
  39710. shader: string;
  39711. };
  39712. }
  39713. declare module BABYLON {
  39714. /** @hidden */
  39715. export var reflectionFunction: {
  39716. name: string;
  39717. shader: string;
  39718. };
  39719. }
  39720. declare module BABYLON {
  39721. /** @hidden */
  39722. export var bumpFragmentFunctions: {
  39723. name: string;
  39724. shader: string;
  39725. };
  39726. }
  39727. declare module BABYLON {
  39728. /** @hidden */
  39729. export var logDepthDeclaration: {
  39730. name: string;
  39731. shader: string;
  39732. };
  39733. }
  39734. declare module BABYLON {
  39735. /** @hidden */
  39736. export var bumpFragment: {
  39737. name: string;
  39738. shader: string;
  39739. };
  39740. }
  39741. declare module BABYLON {
  39742. /** @hidden */
  39743. export var depthPrePass: {
  39744. name: string;
  39745. shader: string;
  39746. };
  39747. }
  39748. declare module BABYLON {
  39749. /** @hidden */
  39750. export var lightFragment: {
  39751. name: string;
  39752. shader: string;
  39753. };
  39754. }
  39755. declare module BABYLON {
  39756. /** @hidden */
  39757. export var logDepthFragment: {
  39758. name: string;
  39759. shader: string;
  39760. };
  39761. }
  39762. declare module BABYLON {
  39763. /** @hidden */
  39764. export var defaultPixelShader: {
  39765. name: string;
  39766. shader: string;
  39767. };
  39768. }
  39769. declare module BABYLON {
  39770. /** @hidden */
  39771. export var defaultVertexDeclaration: {
  39772. name: string;
  39773. shader: string;
  39774. };
  39775. }
  39776. declare module BABYLON {
  39777. /** @hidden */
  39778. export var bumpVertexDeclaration: {
  39779. name: string;
  39780. shader: string;
  39781. };
  39782. }
  39783. declare module BABYLON {
  39784. /** @hidden */
  39785. export var bumpVertex: {
  39786. name: string;
  39787. shader: string;
  39788. };
  39789. }
  39790. declare module BABYLON {
  39791. /** @hidden */
  39792. export var fogVertex: {
  39793. name: string;
  39794. shader: string;
  39795. };
  39796. }
  39797. declare module BABYLON {
  39798. /** @hidden */
  39799. export var shadowsVertex: {
  39800. name: string;
  39801. shader: string;
  39802. };
  39803. }
  39804. declare module BABYLON {
  39805. /** @hidden */
  39806. export var pointCloudVertex: {
  39807. name: string;
  39808. shader: string;
  39809. };
  39810. }
  39811. declare module BABYLON {
  39812. /** @hidden */
  39813. export var logDepthVertex: {
  39814. name: string;
  39815. shader: string;
  39816. };
  39817. }
  39818. declare module BABYLON {
  39819. /** @hidden */
  39820. export var defaultVertexShader: {
  39821. name: string;
  39822. shader: string;
  39823. };
  39824. }
  39825. declare module BABYLON {
  39826. /** @hidden */
  39827. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39828. MAINUV1: boolean;
  39829. MAINUV2: boolean;
  39830. DIFFUSE: boolean;
  39831. DIFFUSEDIRECTUV: number;
  39832. AMBIENT: boolean;
  39833. AMBIENTDIRECTUV: number;
  39834. OPACITY: boolean;
  39835. OPACITYDIRECTUV: number;
  39836. OPACITYRGB: boolean;
  39837. REFLECTION: boolean;
  39838. EMISSIVE: boolean;
  39839. EMISSIVEDIRECTUV: number;
  39840. SPECULAR: boolean;
  39841. SPECULARDIRECTUV: number;
  39842. BUMP: boolean;
  39843. BUMPDIRECTUV: number;
  39844. PARALLAX: boolean;
  39845. PARALLAXOCCLUSION: boolean;
  39846. SPECULAROVERALPHA: boolean;
  39847. CLIPPLANE: boolean;
  39848. CLIPPLANE2: boolean;
  39849. CLIPPLANE3: boolean;
  39850. CLIPPLANE4: boolean;
  39851. ALPHATEST: boolean;
  39852. DEPTHPREPASS: boolean;
  39853. ALPHAFROMDIFFUSE: boolean;
  39854. POINTSIZE: boolean;
  39855. FOG: boolean;
  39856. SPECULARTERM: boolean;
  39857. DIFFUSEFRESNEL: boolean;
  39858. OPACITYFRESNEL: boolean;
  39859. REFLECTIONFRESNEL: boolean;
  39860. REFRACTIONFRESNEL: boolean;
  39861. EMISSIVEFRESNEL: boolean;
  39862. FRESNEL: boolean;
  39863. NORMAL: boolean;
  39864. UV1: boolean;
  39865. UV2: boolean;
  39866. VERTEXCOLOR: boolean;
  39867. VERTEXALPHA: boolean;
  39868. NUM_BONE_INFLUENCERS: number;
  39869. BonesPerMesh: number;
  39870. BONETEXTURE: boolean;
  39871. INSTANCES: boolean;
  39872. GLOSSINESS: boolean;
  39873. ROUGHNESS: boolean;
  39874. EMISSIVEASILLUMINATION: boolean;
  39875. LINKEMISSIVEWITHDIFFUSE: boolean;
  39876. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39877. LIGHTMAP: boolean;
  39878. LIGHTMAPDIRECTUV: number;
  39879. OBJECTSPACE_NORMALMAP: boolean;
  39880. USELIGHTMAPASSHADOWMAP: boolean;
  39881. REFLECTIONMAP_3D: boolean;
  39882. REFLECTIONMAP_SPHERICAL: boolean;
  39883. REFLECTIONMAP_PLANAR: boolean;
  39884. REFLECTIONMAP_CUBIC: boolean;
  39885. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39886. REFLECTIONMAP_PROJECTION: boolean;
  39887. REFLECTIONMAP_SKYBOX: boolean;
  39888. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39889. REFLECTIONMAP_EXPLICIT: boolean;
  39890. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39891. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39892. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39893. INVERTCUBICMAP: boolean;
  39894. LOGARITHMICDEPTH: boolean;
  39895. REFRACTION: boolean;
  39896. REFRACTIONMAP_3D: boolean;
  39897. REFLECTIONOVERALPHA: boolean;
  39898. TWOSIDEDLIGHTING: boolean;
  39899. SHADOWFLOAT: boolean;
  39900. MORPHTARGETS: boolean;
  39901. MORPHTARGETS_NORMAL: boolean;
  39902. MORPHTARGETS_TANGENT: boolean;
  39903. MORPHTARGETS_UV: boolean;
  39904. NUM_MORPH_INFLUENCERS: number;
  39905. NONUNIFORMSCALING: boolean;
  39906. PREMULTIPLYALPHA: boolean;
  39907. IMAGEPROCESSING: boolean;
  39908. VIGNETTE: boolean;
  39909. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39910. VIGNETTEBLENDMODEOPAQUE: boolean;
  39911. TONEMAPPING: boolean;
  39912. TONEMAPPING_ACES: boolean;
  39913. CONTRAST: boolean;
  39914. COLORCURVES: boolean;
  39915. COLORGRADING: boolean;
  39916. COLORGRADING3D: boolean;
  39917. SAMPLER3DGREENDEPTH: boolean;
  39918. SAMPLER3DBGRMAP: boolean;
  39919. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39920. MULTIVIEW: boolean;
  39921. /**
  39922. * If the reflection texture on this material is in linear color space
  39923. * @hidden
  39924. */
  39925. IS_REFLECTION_LINEAR: boolean;
  39926. /**
  39927. * If the refraction texture on this material is in linear color space
  39928. * @hidden
  39929. */
  39930. IS_REFRACTION_LINEAR: boolean;
  39931. EXPOSURE: boolean;
  39932. constructor();
  39933. setReflectionMode(modeToEnable: string): void;
  39934. }
  39935. /**
  39936. * This is the default material used in Babylon. It is the best trade off between quality
  39937. * and performances.
  39938. * @see http://doc.babylonjs.com/babylon101/materials
  39939. */
  39940. export class StandardMaterial extends PushMaterial {
  39941. private _diffuseTexture;
  39942. /**
  39943. * The basic texture of the material as viewed under a light.
  39944. */
  39945. diffuseTexture: Nullable<BaseTexture>;
  39946. private _ambientTexture;
  39947. /**
  39948. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39949. */
  39950. ambientTexture: Nullable<BaseTexture>;
  39951. private _opacityTexture;
  39952. /**
  39953. * Define the transparency of the material from a texture.
  39954. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39955. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39956. */
  39957. opacityTexture: Nullable<BaseTexture>;
  39958. private _reflectionTexture;
  39959. /**
  39960. * Define the texture used to display the reflection.
  39961. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39962. */
  39963. reflectionTexture: Nullable<BaseTexture>;
  39964. private _emissiveTexture;
  39965. /**
  39966. * Define texture of the material as if self lit.
  39967. * This will be mixed in the final result even in the absence of light.
  39968. */
  39969. emissiveTexture: Nullable<BaseTexture>;
  39970. private _specularTexture;
  39971. /**
  39972. * Define how the color and intensity of the highlight given by the light in the material.
  39973. */
  39974. specularTexture: Nullable<BaseTexture>;
  39975. private _bumpTexture;
  39976. /**
  39977. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39978. * 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.
  39979. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39980. */
  39981. bumpTexture: Nullable<BaseTexture>;
  39982. private _lightmapTexture;
  39983. /**
  39984. * Complex lighting can be computationally expensive to compute at runtime.
  39985. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39986. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39987. */
  39988. lightmapTexture: Nullable<BaseTexture>;
  39989. private _refractionTexture;
  39990. /**
  39991. * Define the texture used to display the refraction.
  39992. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39993. */
  39994. refractionTexture: Nullable<BaseTexture>;
  39995. /**
  39996. * The color of the material lit by the environmental background lighting.
  39997. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39998. */
  39999. ambientColor: Color3;
  40000. /**
  40001. * The basic color of the material as viewed under a light.
  40002. */
  40003. diffuseColor: Color3;
  40004. /**
  40005. * Define how the color and intensity of the highlight given by the light in the material.
  40006. */
  40007. specularColor: Color3;
  40008. /**
  40009. * Define the color of the material as if self lit.
  40010. * This will be mixed in the final result even in the absence of light.
  40011. */
  40012. emissiveColor: Color3;
  40013. /**
  40014. * Defines how sharp are the highlights in the material.
  40015. * The bigger the value the sharper giving a more glossy feeling to the result.
  40016. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40017. */
  40018. specularPower: number;
  40019. private _useAlphaFromDiffuseTexture;
  40020. /**
  40021. * Does the transparency come from the diffuse texture alpha channel.
  40022. */
  40023. useAlphaFromDiffuseTexture: boolean;
  40024. private _useEmissiveAsIllumination;
  40025. /**
  40026. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40027. */
  40028. useEmissiveAsIllumination: boolean;
  40029. private _linkEmissiveWithDiffuse;
  40030. /**
  40031. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40032. * the emissive level when the final color is close to one.
  40033. */
  40034. linkEmissiveWithDiffuse: boolean;
  40035. private _useSpecularOverAlpha;
  40036. /**
  40037. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40038. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40039. */
  40040. useSpecularOverAlpha: boolean;
  40041. private _useReflectionOverAlpha;
  40042. /**
  40043. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40044. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40045. */
  40046. useReflectionOverAlpha: boolean;
  40047. private _disableLighting;
  40048. /**
  40049. * Does lights from the scene impacts this material.
  40050. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40051. */
  40052. disableLighting: boolean;
  40053. private _useObjectSpaceNormalMap;
  40054. /**
  40055. * Allows using an object space normal map (instead of tangent space).
  40056. */
  40057. useObjectSpaceNormalMap: boolean;
  40058. private _useParallax;
  40059. /**
  40060. * Is parallax enabled or not.
  40061. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40062. */
  40063. useParallax: boolean;
  40064. private _useParallaxOcclusion;
  40065. /**
  40066. * Is parallax occlusion enabled or not.
  40067. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40068. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40069. */
  40070. useParallaxOcclusion: boolean;
  40071. /**
  40072. * 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.
  40073. */
  40074. parallaxScaleBias: number;
  40075. private _roughness;
  40076. /**
  40077. * Helps to define how blurry the reflections should appears in the material.
  40078. */
  40079. roughness: number;
  40080. /**
  40081. * In case of refraction, define the value of the index of refraction.
  40082. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40083. */
  40084. indexOfRefraction: number;
  40085. /**
  40086. * Invert the refraction texture alongside the y axis.
  40087. * It can be useful with procedural textures or probe for instance.
  40088. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40089. */
  40090. invertRefractionY: boolean;
  40091. /**
  40092. * Defines the alpha limits in alpha test mode.
  40093. */
  40094. alphaCutOff: number;
  40095. private _useLightmapAsShadowmap;
  40096. /**
  40097. * In case of light mapping, define whether the map contains light or shadow informations.
  40098. */
  40099. useLightmapAsShadowmap: boolean;
  40100. private _diffuseFresnelParameters;
  40101. /**
  40102. * Define the diffuse fresnel parameters of the material.
  40103. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40104. */
  40105. diffuseFresnelParameters: FresnelParameters;
  40106. private _opacityFresnelParameters;
  40107. /**
  40108. * Define the opacity fresnel parameters of the material.
  40109. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40110. */
  40111. opacityFresnelParameters: FresnelParameters;
  40112. private _reflectionFresnelParameters;
  40113. /**
  40114. * Define the reflection fresnel parameters of the material.
  40115. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40116. */
  40117. reflectionFresnelParameters: FresnelParameters;
  40118. private _refractionFresnelParameters;
  40119. /**
  40120. * Define the refraction fresnel parameters of the material.
  40121. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40122. */
  40123. refractionFresnelParameters: FresnelParameters;
  40124. private _emissiveFresnelParameters;
  40125. /**
  40126. * Define the emissive fresnel parameters of the material.
  40127. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40128. */
  40129. emissiveFresnelParameters: FresnelParameters;
  40130. private _useReflectionFresnelFromSpecular;
  40131. /**
  40132. * If true automatically deducts the fresnels values from the material specularity.
  40133. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40134. */
  40135. useReflectionFresnelFromSpecular: boolean;
  40136. private _useGlossinessFromSpecularMapAlpha;
  40137. /**
  40138. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40139. */
  40140. useGlossinessFromSpecularMapAlpha: boolean;
  40141. private _maxSimultaneousLights;
  40142. /**
  40143. * Defines the maximum number of lights that can be used in the material
  40144. */
  40145. maxSimultaneousLights: number;
  40146. private _invertNormalMapX;
  40147. /**
  40148. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40149. */
  40150. invertNormalMapX: boolean;
  40151. private _invertNormalMapY;
  40152. /**
  40153. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40154. */
  40155. invertNormalMapY: boolean;
  40156. private _twoSidedLighting;
  40157. /**
  40158. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40159. */
  40160. twoSidedLighting: boolean;
  40161. /**
  40162. * Default configuration related to image processing available in the standard Material.
  40163. */
  40164. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40165. /**
  40166. * Gets the image processing configuration used either in this material.
  40167. */
  40168. /**
  40169. * Sets the Default image processing configuration used either in the this material.
  40170. *
  40171. * If sets to null, the scene one is in use.
  40172. */
  40173. imageProcessingConfiguration: ImageProcessingConfiguration;
  40174. /**
  40175. * Keep track of the image processing observer to allow dispose and replace.
  40176. */
  40177. private _imageProcessingObserver;
  40178. /**
  40179. * Attaches a new image processing configuration to the Standard Material.
  40180. * @param configuration
  40181. */
  40182. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40183. /**
  40184. * Gets wether the color curves effect is enabled.
  40185. */
  40186. /**
  40187. * Sets wether the color curves effect is enabled.
  40188. */
  40189. cameraColorCurvesEnabled: boolean;
  40190. /**
  40191. * Gets wether the color grading effect is enabled.
  40192. */
  40193. /**
  40194. * Gets wether the color grading effect is enabled.
  40195. */
  40196. cameraColorGradingEnabled: boolean;
  40197. /**
  40198. * Gets wether tonemapping is enabled or not.
  40199. */
  40200. /**
  40201. * Sets wether tonemapping is enabled or not
  40202. */
  40203. cameraToneMappingEnabled: boolean;
  40204. /**
  40205. * The camera exposure used on this material.
  40206. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40207. * This corresponds to a photographic exposure.
  40208. */
  40209. /**
  40210. * The camera exposure used on this material.
  40211. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40212. * This corresponds to a photographic exposure.
  40213. */
  40214. cameraExposure: number;
  40215. /**
  40216. * Gets The camera contrast used on this material.
  40217. */
  40218. /**
  40219. * Sets The camera contrast used on this material.
  40220. */
  40221. cameraContrast: number;
  40222. /**
  40223. * Gets the Color Grading 2D Lookup Texture.
  40224. */
  40225. /**
  40226. * Sets the Color Grading 2D Lookup Texture.
  40227. */
  40228. cameraColorGradingTexture: Nullable<BaseTexture>;
  40229. /**
  40230. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40231. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40232. * 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;
  40233. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40234. */
  40235. /**
  40236. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40237. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40238. * 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;
  40239. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40240. */
  40241. cameraColorCurves: Nullable<ColorCurves>;
  40242. /**
  40243. * Custom callback helping to override the default shader used in the material.
  40244. */
  40245. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40246. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40247. protected _worldViewProjectionMatrix: Matrix;
  40248. protected _globalAmbientColor: Color3;
  40249. protected _useLogarithmicDepth: boolean;
  40250. protected _rebuildInParallel: boolean;
  40251. /**
  40252. * Instantiates a new standard material.
  40253. * This is the default material used in Babylon. It is the best trade off between quality
  40254. * and performances.
  40255. * @see http://doc.babylonjs.com/babylon101/materials
  40256. * @param name Define the name of the material in the scene
  40257. * @param scene Define the scene the material belong to
  40258. */
  40259. constructor(name: string, scene: Scene);
  40260. /**
  40261. * Gets a boolean indicating that current material needs to register RTT
  40262. */
  40263. readonly hasRenderTargetTextures: boolean;
  40264. /**
  40265. * Gets the current class name of the material e.g. "StandardMaterial"
  40266. * Mainly use in serialization.
  40267. * @returns the class name
  40268. */
  40269. getClassName(): string;
  40270. /**
  40271. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40272. * You can try switching to logarithmic depth.
  40273. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40274. */
  40275. useLogarithmicDepth: boolean;
  40276. /**
  40277. * Specifies if the material will require alpha blending
  40278. * @returns a boolean specifying if alpha blending is needed
  40279. */
  40280. needAlphaBlending(): boolean;
  40281. /**
  40282. * Specifies if this material should be rendered in alpha test mode
  40283. * @returns a boolean specifying if an alpha test is needed.
  40284. */
  40285. needAlphaTesting(): boolean;
  40286. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40287. /**
  40288. * Get the texture used for alpha test purpose.
  40289. * @returns the diffuse texture in case of the standard material.
  40290. */
  40291. getAlphaTestTexture(): Nullable<BaseTexture>;
  40292. /**
  40293. * Get if the submesh is ready to be used and all its information available.
  40294. * Child classes can use it to update shaders
  40295. * @param mesh defines the mesh to check
  40296. * @param subMesh defines which submesh to check
  40297. * @param useInstances specifies that instances should be used
  40298. * @returns a boolean indicating that the submesh is ready or not
  40299. */
  40300. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40301. /**
  40302. * Builds the material UBO layouts.
  40303. * Used internally during the effect preparation.
  40304. */
  40305. buildUniformLayout(): void;
  40306. /**
  40307. * Unbinds the material from the mesh
  40308. */
  40309. unbind(): void;
  40310. /**
  40311. * Binds the submesh to this material by preparing the effect and shader to draw
  40312. * @param world defines the world transformation matrix
  40313. * @param mesh defines the mesh containing the submesh
  40314. * @param subMesh defines the submesh to bind the material to
  40315. */
  40316. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40317. /**
  40318. * Get the list of animatables in the material.
  40319. * @returns the list of animatables object used in the material
  40320. */
  40321. getAnimatables(): IAnimatable[];
  40322. /**
  40323. * Gets the active textures from the material
  40324. * @returns an array of textures
  40325. */
  40326. getActiveTextures(): BaseTexture[];
  40327. /**
  40328. * Specifies if the material uses a texture
  40329. * @param texture defines the texture to check against the material
  40330. * @returns a boolean specifying if the material uses the texture
  40331. */
  40332. hasTexture(texture: BaseTexture): boolean;
  40333. /**
  40334. * Disposes the material
  40335. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40336. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40337. */
  40338. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40339. /**
  40340. * Makes a duplicate of the material, and gives it a new name
  40341. * @param name defines the new name for the duplicated material
  40342. * @returns the cloned material
  40343. */
  40344. clone(name: string): StandardMaterial;
  40345. /**
  40346. * Serializes this material in a JSON representation
  40347. * @returns the serialized material object
  40348. */
  40349. serialize(): any;
  40350. /**
  40351. * Creates a standard material from parsed material data
  40352. * @param source defines the JSON representation of the material
  40353. * @param scene defines the hosting scene
  40354. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40355. * @returns a new standard material
  40356. */
  40357. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40358. /**
  40359. * Are diffuse textures enabled in the application.
  40360. */
  40361. static DiffuseTextureEnabled: boolean;
  40362. /**
  40363. * Are ambient textures enabled in the application.
  40364. */
  40365. static AmbientTextureEnabled: boolean;
  40366. /**
  40367. * Are opacity textures enabled in the application.
  40368. */
  40369. static OpacityTextureEnabled: boolean;
  40370. /**
  40371. * Are reflection textures enabled in the application.
  40372. */
  40373. static ReflectionTextureEnabled: boolean;
  40374. /**
  40375. * Are emissive textures enabled in the application.
  40376. */
  40377. static EmissiveTextureEnabled: boolean;
  40378. /**
  40379. * Are specular textures enabled in the application.
  40380. */
  40381. static SpecularTextureEnabled: boolean;
  40382. /**
  40383. * Are bump textures enabled in the application.
  40384. */
  40385. static BumpTextureEnabled: boolean;
  40386. /**
  40387. * Are lightmap textures enabled in the application.
  40388. */
  40389. static LightmapTextureEnabled: boolean;
  40390. /**
  40391. * Are refraction textures enabled in the application.
  40392. */
  40393. static RefractionTextureEnabled: boolean;
  40394. /**
  40395. * Are color grading textures enabled in the application.
  40396. */
  40397. static ColorGradingTextureEnabled: boolean;
  40398. /**
  40399. * Are fresnels enabled in the application.
  40400. */
  40401. static FresnelEnabled: boolean;
  40402. }
  40403. }
  40404. declare module BABYLON {
  40405. /**
  40406. * A class extending Texture allowing drawing on a texture
  40407. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40408. */
  40409. export class DynamicTexture extends Texture {
  40410. private _generateMipMaps;
  40411. private _canvas;
  40412. private _context;
  40413. private _engine;
  40414. /**
  40415. * Creates a DynamicTexture
  40416. * @param name defines the name of the texture
  40417. * @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
  40418. * @param scene defines the scene where you want the texture
  40419. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40420. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40421. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40422. */
  40423. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40424. /**
  40425. * Get the current class name of the texture useful for serialization or dynamic coding.
  40426. * @returns "DynamicTexture"
  40427. */
  40428. getClassName(): string;
  40429. /**
  40430. * Gets the current state of canRescale
  40431. */
  40432. readonly canRescale: boolean;
  40433. private _recreate;
  40434. /**
  40435. * Scales the texture
  40436. * @param ratio the scale factor to apply to both width and height
  40437. */
  40438. scale(ratio: number): void;
  40439. /**
  40440. * Resizes the texture
  40441. * @param width the new width
  40442. * @param height the new height
  40443. */
  40444. scaleTo(width: number, height: number): void;
  40445. /**
  40446. * Gets the context of the canvas used by the texture
  40447. * @returns the canvas context of the dynamic texture
  40448. */
  40449. getContext(): CanvasRenderingContext2D;
  40450. /**
  40451. * Clears the texture
  40452. */
  40453. clear(): void;
  40454. /**
  40455. * Updates the texture
  40456. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40457. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40458. */
  40459. update(invertY?: boolean, premulAlpha?: boolean): void;
  40460. /**
  40461. * Draws text onto the texture
  40462. * @param text defines the text to be drawn
  40463. * @param x defines the placement of the text from the left
  40464. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40465. * @param font defines the font to be used with font-style, font-size, font-name
  40466. * @param color defines the color used for the text
  40467. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40468. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40469. * @param update defines whether texture is immediately update (default is true)
  40470. */
  40471. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40472. /**
  40473. * Clones the texture
  40474. * @returns the clone of the texture.
  40475. */
  40476. clone(): DynamicTexture;
  40477. /**
  40478. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40479. * @returns a serialized dynamic texture object
  40480. */
  40481. serialize(): any;
  40482. /** @hidden */
  40483. _rebuild(): void;
  40484. }
  40485. }
  40486. declare module BABYLON {
  40487. /** @hidden */
  40488. export var imageProcessingPixelShader: {
  40489. name: string;
  40490. shader: string;
  40491. };
  40492. }
  40493. declare module BABYLON {
  40494. /**
  40495. * ImageProcessingPostProcess
  40496. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40497. */
  40498. export class ImageProcessingPostProcess extends PostProcess {
  40499. /**
  40500. * Default configuration related to image processing available in the PBR Material.
  40501. */
  40502. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40503. /**
  40504. * Gets the image processing configuration used either in this material.
  40505. */
  40506. /**
  40507. * Sets the Default image processing configuration used either in the this material.
  40508. *
  40509. * If sets to null, the scene one is in use.
  40510. */
  40511. imageProcessingConfiguration: ImageProcessingConfiguration;
  40512. /**
  40513. * Keep track of the image processing observer to allow dispose and replace.
  40514. */
  40515. private _imageProcessingObserver;
  40516. /**
  40517. * Attaches a new image processing configuration to the PBR Material.
  40518. * @param configuration
  40519. */
  40520. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40521. /**
  40522. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40523. */
  40524. /**
  40525. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40526. */
  40527. colorCurves: Nullable<ColorCurves>;
  40528. /**
  40529. * Gets wether the color curves effect is enabled.
  40530. */
  40531. /**
  40532. * Sets wether the color curves effect is enabled.
  40533. */
  40534. colorCurvesEnabled: boolean;
  40535. /**
  40536. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40537. */
  40538. /**
  40539. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40540. */
  40541. colorGradingTexture: Nullable<BaseTexture>;
  40542. /**
  40543. * Gets wether the color grading effect is enabled.
  40544. */
  40545. /**
  40546. * Gets wether the color grading effect is enabled.
  40547. */
  40548. colorGradingEnabled: boolean;
  40549. /**
  40550. * Gets exposure used in the effect.
  40551. */
  40552. /**
  40553. * Sets exposure used in the effect.
  40554. */
  40555. exposure: number;
  40556. /**
  40557. * Gets wether tonemapping is enabled or not.
  40558. */
  40559. /**
  40560. * Sets wether tonemapping is enabled or not
  40561. */
  40562. toneMappingEnabled: boolean;
  40563. /**
  40564. * Gets the type of tone mapping effect.
  40565. */
  40566. /**
  40567. * Sets the type of tone mapping effect.
  40568. */
  40569. toneMappingType: number;
  40570. /**
  40571. * Gets contrast used in the effect.
  40572. */
  40573. /**
  40574. * Sets contrast used in the effect.
  40575. */
  40576. contrast: number;
  40577. /**
  40578. * Gets Vignette stretch size.
  40579. */
  40580. /**
  40581. * Sets Vignette stretch size.
  40582. */
  40583. vignetteStretch: number;
  40584. /**
  40585. * Gets Vignette centre X Offset.
  40586. */
  40587. /**
  40588. * Sets Vignette centre X Offset.
  40589. */
  40590. vignetteCentreX: number;
  40591. /**
  40592. * Gets Vignette centre Y Offset.
  40593. */
  40594. /**
  40595. * Sets Vignette centre Y Offset.
  40596. */
  40597. vignetteCentreY: number;
  40598. /**
  40599. * Gets Vignette weight or intensity of the vignette effect.
  40600. */
  40601. /**
  40602. * Sets Vignette weight or intensity of the vignette effect.
  40603. */
  40604. vignetteWeight: number;
  40605. /**
  40606. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40607. * if vignetteEnabled is set to true.
  40608. */
  40609. /**
  40610. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40611. * if vignetteEnabled is set to true.
  40612. */
  40613. vignetteColor: Color4;
  40614. /**
  40615. * Gets Camera field of view used by the Vignette effect.
  40616. */
  40617. /**
  40618. * Sets Camera field of view used by the Vignette effect.
  40619. */
  40620. vignetteCameraFov: number;
  40621. /**
  40622. * Gets the vignette blend mode allowing different kind of effect.
  40623. */
  40624. /**
  40625. * Sets the vignette blend mode allowing different kind of effect.
  40626. */
  40627. vignetteBlendMode: number;
  40628. /**
  40629. * Gets wether the vignette effect is enabled.
  40630. */
  40631. /**
  40632. * Sets wether the vignette effect is enabled.
  40633. */
  40634. vignetteEnabled: boolean;
  40635. private _fromLinearSpace;
  40636. /**
  40637. * Gets wether the input of the processing is in Gamma or Linear Space.
  40638. */
  40639. /**
  40640. * Sets wether the input of the processing is in Gamma or Linear Space.
  40641. */
  40642. fromLinearSpace: boolean;
  40643. /**
  40644. * Defines cache preventing GC.
  40645. */
  40646. private _defines;
  40647. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40648. /**
  40649. * "ImageProcessingPostProcess"
  40650. * @returns "ImageProcessingPostProcess"
  40651. */
  40652. getClassName(): string;
  40653. protected _updateParameters(): void;
  40654. dispose(camera?: Camera): void;
  40655. }
  40656. }
  40657. declare module BABYLON {
  40658. /**
  40659. * Class containing static functions to help procedurally build meshes
  40660. */
  40661. export class GroundBuilder {
  40662. /**
  40663. * Creates a ground mesh
  40664. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40665. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40666. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40667. * @param name defines the name of the mesh
  40668. * @param options defines the options used to create the mesh
  40669. * @param scene defines the hosting scene
  40670. * @returns the ground mesh
  40671. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40672. */
  40673. static CreateGround(name: string, options: {
  40674. width?: number;
  40675. height?: number;
  40676. subdivisions?: number;
  40677. subdivisionsX?: number;
  40678. subdivisionsY?: number;
  40679. updatable?: boolean;
  40680. }, scene: any): Mesh;
  40681. /**
  40682. * Creates a tiled ground mesh
  40683. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40684. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40685. * * 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
  40686. * * 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
  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 options defines the options used to create the mesh
  40690. * @param scene defines the hosting scene
  40691. * @returns the tiled ground mesh
  40692. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40693. */
  40694. static CreateTiledGround(name: string, options: {
  40695. xmin: number;
  40696. zmin: number;
  40697. xmax: number;
  40698. zmax: number;
  40699. subdivisions?: {
  40700. w: number;
  40701. h: number;
  40702. };
  40703. precision?: {
  40704. w: number;
  40705. h: number;
  40706. };
  40707. updatable?: boolean;
  40708. }, scene?: Nullable<Scene>): Mesh;
  40709. /**
  40710. * Creates a ground mesh from a height map
  40711. * * The parameter `url` sets the URL of the height map image resource.
  40712. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40713. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40714. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40715. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40716. * * 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.
  40717. * * 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).
  40718. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40719. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40720. * @param name defines the name of the mesh
  40721. * @param url defines the url to the height map
  40722. * @param options defines the options used to create the mesh
  40723. * @param scene defines the hosting scene
  40724. * @returns the ground mesh
  40725. * @see https://doc.babylonjs.com/babylon101/height_map
  40726. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40727. */
  40728. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40729. width?: number;
  40730. height?: number;
  40731. subdivisions?: number;
  40732. minHeight?: number;
  40733. maxHeight?: number;
  40734. colorFilter?: Color3;
  40735. alphaFilter?: number;
  40736. updatable?: boolean;
  40737. onReady?: (mesh: GroundMesh) => void;
  40738. }, scene?: Nullable<Scene>): GroundMesh;
  40739. }
  40740. }
  40741. declare module BABYLON {
  40742. /**
  40743. * Class containing static functions to help procedurally build meshes
  40744. */
  40745. export class TorusBuilder {
  40746. /**
  40747. * Creates a torus mesh
  40748. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40749. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40750. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40751. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40752. * * 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
  40753. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40754. * @param name defines the name of the mesh
  40755. * @param options defines the options used to create the mesh
  40756. * @param scene defines the hosting scene
  40757. * @returns the torus mesh
  40758. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40759. */
  40760. static CreateTorus(name: string, options: {
  40761. diameter?: number;
  40762. thickness?: number;
  40763. tessellation?: number;
  40764. updatable?: boolean;
  40765. sideOrientation?: number;
  40766. frontUVs?: Vector4;
  40767. backUVs?: Vector4;
  40768. }, scene: any): Mesh;
  40769. }
  40770. }
  40771. declare module BABYLON {
  40772. /**
  40773. * Class containing static functions to help procedurally build meshes
  40774. */
  40775. export class CylinderBuilder {
  40776. /**
  40777. * Creates a cylinder or a cone mesh
  40778. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40779. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40780. * * 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.
  40781. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40782. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40783. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40784. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40785. * * 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).
  40786. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40787. * * 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).
  40788. * * 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
  40789. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40790. * * 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
  40791. * * 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.
  40792. * * If `enclose` is false, a ring surface is one element.
  40793. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40794. * * 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
  40795. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40796. * * 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
  40797. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40798. * @param name defines the name of the mesh
  40799. * @param options defines the options used to create the mesh
  40800. * @param scene defines the hosting scene
  40801. * @returns the cylinder mesh
  40802. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40803. */
  40804. static CreateCylinder(name: string, options: {
  40805. height?: number;
  40806. diameterTop?: number;
  40807. diameterBottom?: number;
  40808. diameter?: number;
  40809. tessellation?: number;
  40810. subdivisions?: number;
  40811. arc?: number;
  40812. faceColors?: Color4[];
  40813. faceUV?: Vector4[];
  40814. updatable?: boolean;
  40815. hasRings?: boolean;
  40816. enclose?: boolean;
  40817. cap?: number;
  40818. sideOrientation?: number;
  40819. frontUVs?: Vector4;
  40820. backUVs?: Vector4;
  40821. }, scene: any): Mesh;
  40822. }
  40823. }
  40824. declare module BABYLON {
  40825. /**
  40826. * Options to modify the vr teleportation behavior.
  40827. */
  40828. export interface VRTeleportationOptions {
  40829. /**
  40830. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40831. */
  40832. floorMeshName?: string;
  40833. /**
  40834. * A list of meshes to be used as the teleportation floor. (default: empty)
  40835. */
  40836. floorMeshes?: Mesh[];
  40837. }
  40838. /**
  40839. * Options to modify the vr experience helper's behavior.
  40840. */
  40841. export interface VRExperienceHelperOptions extends WebVROptions {
  40842. /**
  40843. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40844. */
  40845. createDeviceOrientationCamera?: boolean;
  40846. /**
  40847. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40848. */
  40849. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40850. /**
  40851. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40852. */
  40853. laserToggle?: boolean;
  40854. /**
  40855. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40856. */
  40857. floorMeshes?: Mesh[];
  40858. /**
  40859. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40860. */
  40861. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40862. }
  40863. /**
  40864. * Event containing information after VR has been entered
  40865. */
  40866. export class OnAfterEnteringVRObservableEvent {
  40867. /**
  40868. * If entering vr was successful
  40869. */
  40870. success: boolean;
  40871. }
  40872. /**
  40873. * Helps to quickly add VR support to an existing scene.
  40874. * See http://doc.babylonjs.com/how_to/webvr_helper
  40875. */
  40876. export class VRExperienceHelper {
  40877. /** Options to modify the vr experience helper's behavior. */
  40878. webVROptions: VRExperienceHelperOptions;
  40879. private _scene;
  40880. private _position;
  40881. private _btnVR;
  40882. private _btnVRDisplayed;
  40883. private _webVRsupported;
  40884. private _webVRready;
  40885. private _webVRrequesting;
  40886. private _webVRpresenting;
  40887. private _hasEnteredVR;
  40888. private _fullscreenVRpresenting;
  40889. private _canvas;
  40890. private _webVRCamera;
  40891. private _vrDeviceOrientationCamera;
  40892. private _deviceOrientationCamera;
  40893. private _existingCamera;
  40894. private _onKeyDown;
  40895. private _onVrDisplayPresentChange;
  40896. private _onVRDisplayChanged;
  40897. private _onVRRequestPresentStart;
  40898. private _onVRRequestPresentComplete;
  40899. /**
  40900. * 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)
  40901. */
  40902. enableGazeEvenWhenNoPointerLock: boolean;
  40903. /**
  40904. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  40905. */
  40906. exitVROnDoubleTap: boolean;
  40907. /**
  40908. * Observable raised right before entering VR.
  40909. */
  40910. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40911. /**
  40912. * Observable raised when entering VR has completed.
  40913. */
  40914. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40915. /**
  40916. * Observable raised when exiting VR.
  40917. */
  40918. onExitingVRObservable: Observable<VRExperienceHelper>;
  40919. /**
  40920. * Observable raised when controller mesh is loaded.
  40921. */
  40922. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40923. /** Return this.onEnteringVRObservable
  40924. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40925. */
  40926. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40927. /** Return this.onExitingVRObservable
  40928. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40929. */
  40930. readonly onExitingVR: Observable<VRExperienceHelper>;
  40931. /** Return this.onControllerMeshLoadedObservable
  40932. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40933. */
  40934. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40935. private _rayLength;
  40936. private _useCustomVRButton;
  40937. private _teleportationRequested;
  40938. private _teleportActive;
  40939. private _floorMeshName;
  40940. private _floorMeshesCollection;
  40941. private _rotationAllowed;
  40942. private _teleportBackwardsVector;
  40943. private _teleportationTarget;
  40944. private _isDefaultTeleportationTarget;
  40945. private _postProcessMove;
  40946. private _teleportationFillColor;
  40947. private _teleportationBorderColor;
  40948. private _rotationAngle;
  40949. private _haloCenter;
  40950. private _cameraGazer;
  40951. private _padSensibilityUp;
  40952. private _padSensibilityDown;
  40953. private _leftController;
  40954. private _rightController;
  40955. /**
  40956. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40957. */
  40958. onNewMeshSelected: Observable<AbstractMesh>;
  40959. /**
  40960. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  40961. * This observable will provide the mesh and the controller used to select the mesh
  40962. */
  40963. onMeshSelectedWithController: Observable<{
  40964. mesh: AbstractMesh;
  40965. controller: WebVRController;
  40966. }>;
  40967. /**
  40968. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40969. */
  40970. onNewMeshPicked: Observable<PickingInfo>;
  40971. private _circleEase;
  40972. /**
  40973. * Observable raised before camera teleportation
  40974. */
  40975. onBeforeCameraTeleport: Observable<Vector3>;
  40976. /**
  40977. * Observable raised after camera teleportation
  40978. */
  40979. onAfterCameraTeleport: Observable<Vector3>;
  40980. /**
  40981. * Observable raised when current selected mesh gets unselected
  40982. */
  40983. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40984. private _raySelectionPredicate;
  40985. /**
  40986. * To be optionaly changed by user to define custom ray selection
  40987. */
  40988. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40989. /**
  40990. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40991. */
  40992. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40993. /**
  40994. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40995. */
  40996. teleportationEnabled: boolean;
  40997. private _defaultHeight;
  40998. private _teleportationInitialized;
  40999. private _interactionsEnabled;
  41000. private _interactionsRequested;
  41001. private _displayGaze;
  41002. private _displayLaserPointer;
  41003. /**
  41004. * The mesh used to display where the user is going to teleport.
  41005. */
  41006. /**
  41007. * Sets the mesh to be used to display where the user is going to teleport.
  41008. */
  41009. teleportationTarget: Mesh;
  41010. /**
  41011. * 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
  41012. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41013. * See http://doc.babylonjs.com/resources/baking_transformations
  41014. */
  41015. gazeTrackerMesh: Mesh;
  41016. /**
  41017. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41018. */
  41019. updateGazeTrackerScale: boolean;
  41020. /**
  41021. * If the gaze trackers color should be updated when selecting meshes
  41022. */
  41023. updateGazeTrackerColor: boolean;
  41024. /**
  41025. * The gaze tracking mesh corresponding to the left controller
  41026. */
  41027. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41028. /**
  41029. * The gaze tracking mesh corresponding to the right controller
  41030. */
  41031. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41032. /**
  41033. * If the ray of the gaze should be displayed.
  41034. */
  41035. /**
  41036. * Sets if the ray of the gaze should be displayed.
  41037. */
  41038. displayGaze: boolean;
  41039. /**
  41040. * If the ray of the LaserPointer should be displayed.
  41041. */
  41042. /**
  41043. * Sets if the ray of the LaserPointer should be displayed.
  41044. */
  41045. displayLaserPointer: boolean;
  41046. /**
  41047. * The deviceOrientationCamera used as the camera when not in VR.
  41048. */
  41049. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41050. /**
  41051. * Based on the current WebVR support, returns the current VR camera used.
  41052. */
  41053. readonly currentVRCamera: Nullable<Camera>;
  41054. /**
  41055. * The webVRCamera which is used when in VR.
  41056. */
  41057. readonly webVRCamera: WebVRFreeCamera;
  41058. /**
  41059. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41060. */
  41061. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41062. /**
  41063. * The html button that is used to trigger entering into VR.
  41064. */
  41065. readonly vrButton: Nullable<HTMLButtonElement>;
  41066. private readonly _teleportationRequestInitiated;
  41067. /**
  41068. * Defines wether or not Pointer lock should be requested when switching to
  41069. * full screen.
  41070. */
  41071. requestPointerLockOnFullScreen: boolean;
  41072. /**
  41073. * Instantiates a VRExperienceHelper.
  41074. * Helps to quickly add VR support to an existing scene.
  41075. * @param scene The scene the VRExperienceHelper belongs to.
  41076. * @param webVROptions Options to modify the vr experience helper's behavior.
  41077. */
  41078. constructor(scene: Scene,
  41079. /** Options to modify the vr experience helper's behavior. */
  41080. webVROptions?: VRExperienceHelperOptions);
  41081. private _onDefaultMeshLoaded;
  41082. private _onResize;
  41083. private _onFullscreenChange;
  41084. /**
  41085. * Gets a value indicating if we are currently in VR mode.
  41086. */
  41087. readonly isInVRMode: boolean;
  41088. private onVrDisplayPresentChange;
  41089. private onVRDisplayChanged;
  41090. private moveButtonToBottomRight;
  41091. private displayVRButton;
  41092. private updateButtonVisibility;
  41093. private _cachedAngularSensibility;
  41094. /**
  41095. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41096. * Otherwise, will use the fullscreen API.
  41097. */
  41098. enterVR(): void;
  41099. /**
  41100. * Attempt to exit VR, or fullscreen.
  41101. */
  41102. exitVR(): void;
  41103. /**
  41104. * The position of the vr experience helper.
  41105. */
  41106. /**
  41107. * Sets the position of the vr experience helper.
  41108. */
  41109. position: Vector3;
  41110. /**
  41111. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41112. */
  41113. enableInteractions(): void;
  41114. private readonly _noControllerIsActive;
  41115. private beforeRender;
  41116. private _isTeleportationFloor;
  41117. /**
  41118. * Adds a floor mesh to be used for teleportation.
  41119. * @param floorMesh the mesh to be used for teleportation.
  41120. */
  41121. addFloorMesh(floorMesh: Mesh): void;
  41122. /**
  41123. * Removes a floor mesh from being used for teleportation.
  41124. * @param floorMesh the mesh to be removed.
  41125. */
  41126. removeFloorMesh(floorMesh: Mesh): void;
  41127. /**
  41128. * Enables interactions and teleportation using the VR controllers and gaze.
  41129. * @param vrTeleportationOptions options to modify teleportation behavior.
  41130. */
  41131. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41132. private _onNewGamepadConnected;
  41133. private _tryEnableInteractionOnController;
  41134. private _onNewGamepadDisconnected;
  41135. private _enableInteractionOnController;
  41136. private _checkTeleportWithRay;
  41137. private _checkRotate;
  41138. private _checkTeleportBackwards;
  41139. private _enableTeleportationOnController;
  41140. private _createTeleportationCircles;
  41141. private _displayTeleportationTarget;
  41142. private _hideTeleportationTarget;
  41143. private _rotateCamera;
  41144. private _moveTeleportationSelectorTo;
  41145. private _workingVector;
  41146. private _workingQuaternion;
  41147. private _workingMatrix;
  41148. /**
  41149. * Teleports the users feet to the desired location
  41150. * @param location The location where the user's feet should be placed
  41151. */
  41152. teleportCamera(location: Vector3): void;
  41153. private _convertNormalToDirectionOfRay;
  41154. private _castRayAndSelectObject;
  41155. private _notifySelectedMeshUnselected;
  41156. /**
  41157. * Sets the color of the laser ray from the vr controllers.
  41158. * @param color new color for the ray.
  41159. */
  41160. changeLaserColor(color: Color3): void;
  41161. /**
  41162. * Sets the color of the ray from the vr headsets gaze.
  41163. * @param color new color for the ray.
  41164. */
  41165. changeGazeColor(color: Color3): void;
  41166. /**
  41167. * Exits VR and disposes of the vr experience helper
  41168. */
  41169. dispose(): void;
  41170. /**
  41171. * Gets the name of the VRExperienceHelper class
  41172. * @returns "VRExperienceHelper"
  41173. */
  41174. getClassName(): string;
  41175. }
  41176. }
  41177. declare module BABYLON {
  41178. /**
  41179. * Manages an XRSession to work with Babylon's engine
  41180. * @see https://doc.babylonjs.com/how_to/webxr
  41181. */
  41182. export class WebXRSessionManager implements IDisposable {
  41183. private scene;
  41184. /**
  41185. * Fires every time a new xrFrame arrives which can be used to update the camera
  41186. */
  41187. onXRFrameObservable: Observable<any>;
  41188. /**
  41189. * Fires when the xr session is ended either by the device or manually done
  41190. */
  41191. onXRSessionEnded: Observable<any>;
  41192. /**
  41193. * Underlying xr session
  41194. */
  41195. session: XRSession;
  41196. /**
  41197. * Type of reference space used when creating the session
  41198. */
  41199. referenceSpace: XRReferenceSpace;
  41200. /** @hidden */
  41201. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41202. /**
  41203. * Current XR frame
  41204. */
  41205. currentFrame: Nullable<XRFrame>;
  41206. private _xrNavigator;
  41207. private baseLayer;
  41208. /**
  41209. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41210. * @param scene The scene which the session should be created for
  41211. */
  41212. constructor(scene: Scene);
  41213. /**
  41214. * Initializes the manager
  41215. * After initialization enterXR can be called to start an XR session
  41216. * @returns Promise which resolves after it is initialized
  41217. */
  41218. initializeAsync(): Promise<void>;
  41219. /**
  41220. * Initializes an xr session
  41221. * @param xrSessionMode mode to initialize
  41222. * @returns a promise which will resolve once the session has been initialized
  41223. */
  41224. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  41225. /**
  41226. * Sets the reference space on the xr session
  41227. * @param referenceSpace space to set
  41228. * @returns a promise that will resolve once the reference space has been set
  41229. */
  41230. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  41231. /**
  41232. * Updates the render state of the session
  41233. * @param state state to set
  41234. * @returns a promise that resolves once the render state has been updated
  41235. */
  41236. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  41237. /**
  41238. * Starts rendering to the xr layer
  41239. * @returns a promise that will resolve once rendering has started
  41240. */
  41241. startRenderingToXRAsync(): Promise<void>;
  41242. /**
  41243. * Stops the xrSession and restores the renderloop
  41244. * @returns Promise which resolves after it exits XR
  41245. */
  41246. exitXRAsync(): Promise<unknown>;
  41247. /**
  41248. * Checks if a session would be supported for the creation options specified
  41249. * @param sessionMode session mode to check if supported eg. immersive-vr
  41250. * @returns true if supported
  41251. */
  41252. supportsSessionAsync(sessionMode: XRSessionMode): any;
  41253. /**
  41254. * @hidden
  41255. * Converts the render layer of xrSession to a render target
  41256. * @param session session to create render target for
  41257. * @param scene scene the new render target should be created for
  41258. */
  41259. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  41260. /**
  41261. * Disposes of the session manager
  41262. */
  41263. dispose(): void;
  41264. }
  41265. }
  41266. declare module BABYLON {
  41267. /**
  41268. * WebXR Camera which holds the views for the xrSession
  41269. * @see https://doc.babylonjs.com/how_to/webxr
  41270. */
  41271. export class WebXRCamera extends FreeCamera {
  41272. private static _TmpMatrix;
  41273. /**
  41274. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41275. * @param name the name of the camera
  41276. * @param scene the scene to add the camera to
  41277. */
  41278. constructor(name: string, scene: Scene);
  41279. private _updateNumberOfRigCameras;
  41280. /** @hidden */
  41281. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41282. /**
  41283. * Updates the cameras position from the current pose information of the XR session
  41284. * @param xrSessionManager the session containing pose information
  41285. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41286. */
  41287. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41288. }
  41289. }
  41290. declare module BABYLON {
  41291. /**
  41292. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41293. */
  41294. export class WebXRManagedOutputCanvas implements IDisposable {
  41295. private helper;
  41296. private _canvas;
  41297. /**
  41298. * xrpresent context of the canvas which can be used to display/mirror xr content
  41299. */
  41300. canvasContext: WebGLRenderingContext;
  41301. /**
  41302. * xr layer for the canvas
  41303. */
  41304. xrLayer: Nullable<XRWebGLLayer>;
  41305. /**
  41306. * Initializes the xr layer for the session
  41307. * @param xrSession xr session
  41308. * @returns a promise that will resolve once the XR Layer has been created
  41309. */
  41310. initializeXRLayerAsync(xrSession: any): any;
  41311. /**
  41312. * Initializes the canvas to be added/removed upon entering/exiting xr
  41313. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41314. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41315. */
  41316. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41317. /**
  41318. * Disposes of the object
  41319. */
  41320. dispose(): void;
  41321. private _setManagedOutputCanvas;
  41322. private _addCanvas;
  41323. private _removeCanvas;
  41324. }
  41325. }
  41326. declare module BABYLON {
  41327. /**
  41328. * States of the webXR experience
  41329. */
  41330. export enum WebXRState {
  41331. /**
  41332. * Transitioning to being in XR mode
  41333. */
  41334. ENTERING_XR = 0,
  41335. /**
  41336. * Transitioning to non XR mode
  41337. */
  41338. EXITING_XR = 1,
  41339. /**
  41340. * In XR mode and presenting
  41341. */
  41342. IN_XR = 2,
  41343. /**
  41344. * Not entered XR mode
  41345. */
  41346. NOT_IN_XR = 3
  41347. }
  41348. /**
  41349. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  41350. * @see https://doc.babylonjs.com/how_to/webxr
  41351. */
  41352. export class WebXRExperienceHelper implements IDisposable {
  41353. private scene;
  41354. /**
  41355. * 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
  41356. */
  41357. container: AbstractMesh;
  41358. /**
  41359. * Camera used to render xr content
  41360. */
  41361. camera: WebXRCamera;
  41362. /**
  41363. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41364. */
  41365. state: WebXRState;
  41366. private _setState;
  41367. private static _TmpVector;
  41368. /**
  41369. * Fires when the state of the experience helper has changed
  41370. */
  41371. onStateChangedObservable: Observable<WebXRState>;
  41372. /** Session manager used to keep track of xr session */
  41373. sessionManager: WebXRSessionManager;
  41374. private _nonVRCamera;
  41375. private _originalSceneAutoClear;
  41376. private _supported;
  41377. /**
  41378. * Creates the experience helper
  41379. * @param scene the scene to attach the experience helper to
  41380. * @returns a promise for the experience helper
  41381. */
  41382. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41383. /**
  41384. * Creates a WebXRExperienceHelper
  41385. * @param scene The scene the helper should be created in
  41386. */
  41387. private constructor();
  41388. /**
  41389. * Exits XR mode and returns the scene to its original state
  41390. * @returns promise that resolves after xr mode has exited
  41391. */
  41392. exitXRAsync(): Promise<unknown>;
  41393. /**
  41394. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41395. * @param sessionCreationOptions options for the XR session
  41396. * @param referenceSpaceType frame of reference of the XR session
  41397. * @param outputCanvas the output canvas that will be used to enter XR mode
  41398. * @returns promise that resolves after xr mode has entered
  41399. */
  41400. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  41401. /**
  41402. * Updates the global position of the camera by moving the camera's container
  41403. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41404. * @param position The desired global position of the camera
  41405. */
  41406. setPositionOfCameraUsingContainer(position: Vector3): void;
  41407. /**
  41408. * Rotates the xr camera by rotating the camera's container around the camera's position
  41409. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41410. * @param rotation the desired quaternion rotation to apply to the camera
  41411. */
  41412. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41413. /**
  41414. * Disposes of the experience helper
  41415. */
  41416. dispose(): void;
  41417. }
  41418. }
  41419. declare module BABYLON {
  41420. /**
  41421. * Button which can be used to enter a different mode of XR
  41422. */
  41423. export class WebXREnterExitUIButton {
  41424. /** button element */
  41425. element: HTMLElement;
  41426. /** XR initialization options for the button */
  41427. sessionMode: XRSessionMode;
  41428. /** Reference space type */
  41429. referenceSpaceType: XRReferenceSpaceType;
  41430. /**
  41431. * Creates a WebXREnterExitUIButton
  41432. * @param element button element
  41433. * @param sessionMode XR initialization session mode
  41434. * @param referenceSpaceType the type of reference space to be used
  41435. */
  41436. constructor(
  41437. /** button element */
  41438. element: HTMLElement,
  41439. /** XR initialization options for the button */
  41440. sessionMode: XRSessionMode,
  41441. /** Reference space type */
  41442. referenceSpaceType: XRReferenceSpaceType);
  41443. /**
  41444. * Overwritable function which can be used to update the button's visuals when the state changes
  41445. * @param activeButton the current active button in the UI
  41446. */
  41447. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41448. }
  41449. /**
  41450. * Options to create the webXR UI
  41451. */
  41452. export class WebXREnterExitUIOptions {
  41453. /**
  41454. * Context to enter xr with
  41455. */
  41456. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  41457. /**
  41458. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41459. */
  41460. customButtons?: Array<WebXREnterExitUIButton>;
  41461. }
  41462. /**
  41463. * UI to allow the user to enter/exit XR mode
  41464. */
  41465. export class WebXREnterExitUI implements IDisposable {
  41466. private scene;
  41467. private _overlay;
  41468. private _buttons;
  41469. private _activeButton;
  41470. /**
  41471. * Fired every time the active button is changed.
  41472. *
  41473. * When xr is entered via a button that launches xr that button will be the callback parameter
  41474. *
  41475. * When exiting xr the callback parameter will be null)
  41476. */
  41477. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41478. /**
  41479. * Creates UI to allow the user to enter/exit XR mode
  41480. * @param scene the scene to add the ui to
  41481. * @param helper the xr experience helper to enter/exit xr with
  41482. * @param options options to configure the UI
  41483. * @returns the created ui
  41484. */
  41485. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41486. private constructor();
  41487. private _updateButtons;
  41488. /**
  41489. * Disposes of the object
  41490. */
  41491. dispose(): void;
  41492. }
  41493. }
  41494. declare module BABYLON {
  41495. /**
  41496. * Represents an XR input
  41497. */
  41498. export class WebXRController {
  41499. private scene;
  41500. /** The underlying input source for the controller */
  41501. inputSource: XRInputSource;
  41502. private parentContainer;
  41503. /**
  41504. * 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
  41505. */
  41506. grip?: AbstractMesh;
  41507. /**
  41508. * Pointer which can be used to select objects or attach a visible laser to
  41509. */
  41510. pointer: AbstractMesh;
  41511. /**
  41512. * Event that fires when the controller is removed/disposed
  41513. */
  41514. onDisposeObservable: Observable<{}>;
  41515. private _tmpMatrix;
  41516. private _tmpQuaternion;
  41517. private _tmpVector;
  41518. /**
  41519. * Creates the controller
  41520. * @see https://doc.babylonjs.com/how_to/webxr
  41521. * @param scene the scene which the controller should be associated to
  41522. * @param inputSource the underlying input source for the controller
  41523. * @param parentContainer parent that the controller meshes should be children of
  41524. */
  41525. constructor(scene: Scene,
  41526. /** The underlying input source for the controller */
  41527. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  41528. /**
  41529. * Updates the controller pose based on the given XRFrame
  41530. * @param xrFrame xr frame to update the pose with
  41531. * @param referenceSpace reference space to use
  41532. */
  41533. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  41534. /**
  41535. * Gets a world space ray coming from the controller
  41536. * @param result the resulting ray
  41537. */
  41538. getWorldPointerRayToRef(result: Ray): void;
  41539. /**
  41540. * Disposes of the object
  41541. */
  41542. dispose(): void;
  41543. }
  41544. }
  41545. declare module BABYLON {
  41546. /**
  41547. * XR input used to track XR inputs such as controllers/rays
  41548. */
  41549. export class WebXRInput implements IDisposable {
  41550. /**
  41551. * Base experience the input listens to
  41552. */
  41553. baseExperience: WebXRExperienceHelper;
  41554. /**
  41555. * XR controllers being tracked
  41556. */
  41557. controllers: Array<WebXRController>;
  41558. private _frameObserver;
  41559. private _stateObserver;
  41560. /**
  41561. * Event when a controller has been connected/added
  41562. */
  41563. onControllerAddedObservable: Observable<WebXRController>;
  41564. /**
  41565. * Event when a controller has been removed/disconnected
  41566. */
  41567. onControllerRemovedObservable: Observable<WebXRController>;
  41568. /**
  41569. * Initializes the WebXRInput
  41570. * @param baseExperience experience helper which the input should be created for
  41571. */
  41572. constructor(
  41573. /**
  41574. * Base experience the input listens to
  41575. */
  41576. baseExperience: WebXRExperienceHelper);
  41577. private _onInputSourcesChange;
  41578. private _addAndRemoveControllers;
  41579. /**
  41580. * Disposes of the object
  41581. */
  41582. dispose(): void;
  41583. }
  41584. }
  41585. declare module BABYLON {
  41586. /**
  41587. * Enables teleportation
  41588. */
  41589. export class WebXRControllerTeleportation {
  41590. private _teleportationFillColor;
  41591. private _teleportationBorderColor;
  41592. private _tmpRay;
  41593. private _tmpVector;
  41594. /**
  41595. * Creates a WebXRControllerTeleportation
  41596. * @param input input manager to add teleportation to
  41597. * @param floorMeshes floormeshes which can be teleported to
  41598. */
  41599. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  41600. }
  41601. }
  41602. declare module BABYLON {
  41603. /**
  41604. * Handles pointer input automatically for the pointer of XR controllers
  41605. */
  41606. export class WebXRControllerPointerSelection {
  41607. private static _idCounter;
  41608. private _tmpRay;
  41609. /**
  41610. * Creates a WebXRControllerPointerSelection
  41611. * @param input input manager to setup pointer selection
  41612. */
  41613. constructor(input: WebXRInput);
  41614. private _convertNormalToDirectionOfRay;
  41615. private _updatePointerDistance;
  41616. }
  41617. }
  41618. declare module BABYLON {
  41619. /**
  41620. * Class used to represent data loading progression
  41621. */
  41622. export class SceneLoaderProgressEvent {
  41623. /** defines if data length to load can be evaluated */
  41624. readonly lengthComputable: boolean;
  41625. /** defines the loaded data length */
  41626. readonly loaded: number;
  41627. /** defines the data length to load */
  41628. readonly total: number;
  41629. /**
  41630. * Create a new progress event
  41631. * @param lengthComputable defines if data length to load can be evaluated
  41632. * @param loaded defines the loaded data length
  41633. * @param total defines the data length to load
  41634. */
  41635. constructor(
  41636. /** defines if data length to load can be evaluated */
  41637. lengthComputable: boolean,
  41638. /** defines the loaded data length */
  41639. loaded: number,
  41640. /** defines the data length to load */
  41641. total: number);
  41642. /**
  41643. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41644. * @param event defines the source event
  41645. * @returns a new SceneLoaderProgressEvent
  41646. */
  41647. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41648. }
  41649. /**
  41650. * Interface used by SceneLoader plugins to define supported file extensions
  41651. */
  41652. export interface ISceneLoaderPluginExtensions {
  41653. /**
  41654. * Defines the list of supported extensions
  41655. */
  41656. [extension: string]: {
  41657. isBinary: boolean;
  41658. };
  41659. }
  41660. /**
  41661. * Interface used by SceneLoader plugin factory
  41662. */
  41663. export interface ISceneLoaderPluginFactory {
  41664. /**
  41665. * Defines the name of the factory
  41666. */
  41667. name: string;
  41668. /**
  41669. * Function called to create a new plugin
  41670. * @return the new plugin
  41671. */
  41672. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41673. /**
  41674. * Boolean indicating if the plugin can direct load specific data
  41675. */
  41676. canDirectLoad?: (data: string) => boolean;
  41677. }
  41678. /**
  41679. * Interface used to define a SceneLoader plugin
  41680. */
  41681. export interface ISceneLoaderPlugin {
  41682. /**
  41683. * The friendly name of this plugin.
  41684. */
  41685. name: string;
  41686. /**
  41687. * The file extensions supported by this plugin.
  41688. */
  41689. extensions: string | ISceneLoaderPluginExtensions;
  41690. /**
  41691. * Import meshes into a scene.
  41692. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41693. * @param scene The scene to import into
  41694. * @param data The data to import
  41695. * @param rootUrl The root url for scene and resources
  41696. * @param meshes The meshes array to import into
  41697. * @param particleSystems The particle systems array to import into
  41698. * @param skeletons The skeletons array to import into
  41699. * @param onError The callback when import fails
  41700. * @returns True if successful or false otherwise
  41701. */
  41702. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41703. /**
  41704. * Load into a scene.
  41705. * @param scene The scene to load into
  41706. * @param data The data to import
  41707. * @param rootUrl The root url for scene and resources
  41708. * @param onError The callback when import fails
  41709. * @returns true if successful or false otherwise
  41710. */
  41711. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41712. /**
  41713. * The callback that returns true if the data can be directly loaded.
  41714. */
  41715. canDirectLoad?: (data: string) => boolean;
  41716. /**
  41717. * The callback that allows custom handling of the root url based on the response url.
  41718. */
  41719. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41720. /**
  41721. * Load into an asset container.
  41722. * @param scene The scene to load into
  41723. * @param data The data to import
  41724. * @param rootUrl The root url for scene and resources
  41725. * @param onError The callback when import fails
  41726. * @returns The loaded asset container
  41727. */
  41728. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41729. }
  41730. /**
  41731. * Interface used to define an async SceneLoader plugin
  41732. */
  41733. export interface ISceneLoaderPluginAsync {
  41734. /**
  41735. * The friendly name of this plugin.
  41736. */
  41737. name: string;
  41738. /**
  41739. * The file extensions supported by this plugin.
  41740. */
  41741. extensions: string | ISceneLoaderPluginExtensions;
  41742. /**
  41743. * Import meshes into a scene.
  41744. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41745. * @param scene The scene to import into
  41746. * @param data The data to import
  41747. * @param rootUrl The root url for scene and resources
  41748. * @param onProgress The callback when the load progresses
  41749. * @param fileName Defines the name of the file to load
  41750. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41751. */
  41752. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41753. meshes: AbstractMesh[];
  41754. particleSystems: IParticleSystem[];
  41755. skeletons: Skeleton[];
  41756. animationGroups: AnimationGroup[];
  41757. }>;
  41758. /**
  41759. * Load into a scene.
  41760. * @param scene The scene to load into
  41761. * @param data The data to import
  41762. * @param rootUrl The root url for scene and resources
  41763. * @param onProgress The callback when the load progresses
  41764. * @param fileName Defines the name of the file to load
  41765. * @returns Nothing
  41766. */
  41767. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41768. /**
  41769. * The callback that returns true if the data can be directly loaded.
  41770. */
  41771. canDirectLoad?: (data: string) => boolean;
  41772. /**
  41773. * The callback that allows custom handling of the root url based on the response url.
  41774. */
  41775. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41776. /**
  41777. * Load into an asset container.
  41778. * @param scene The scene to load into
  41779. * @param data The data to import
  41780. * @param rootUrl The root url for scene and resources
  41781. * @param onProgress The callback when the load progresses
  41782. * @param fileName Defines the name of the file to load
  41783. * @returns The loaded asset container
  41784. */
  41785. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41786. }
  41787. /**
  41788. * Class used to load scene from various file formats using registered plugins
  41789. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41790. */
  41791. export class SceneLoader {
  41792. /**
  41793. * No logging while loading
  41794. */
  41795. static readonly NO_LOGGING: number;
  41796. /**
  41797. * Minimal logging while loading
  41798. */
  41799. static readonly MINIMAL_LOGGING: number;
  41800. /**
  41801. * Summary logging while loading
  41802. */
  41803. static readonly SUMMARY_LOGGING: number;
  41804. /**
  41805. * Detailled logging while loading
  41806. */
  41807. static readonly DETAILED_LOGGING: number;
  41808. /**
  41809. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41810. */
  41811. static ForceFullSceneLoadingForIncremental: boolean;
  41812. /**
  41813. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41814. */
  41815. static ShowLoadingScreen: boolean;
  41816. /**
  41817. * Defines the current logging level (while loading the scene)
  41818. * @ignorenaming
  41819. */
  41820. static loggingLevel: number;
  41821. /**
  41822. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41823. */
  41824. static CleanBoneMatrixWeights: boolean;
  41825. /**
  41826. * Event raised when a plugin is used to load a scene
  41827. */
  41828. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41829. private static _registeredPlugins;
  41830. private static _getDefaultPlugin;
  41831. private static _getPluginForExtension;
  41832. private static _getPluginForDirectLoad;
  41833. private static _getPluginForFilename;
  41834. private static _getDirectLoad;
  41835. private static _loadData;
  41836. private static _getFileInfo;
  41837. /**
  41838. * Gets a plugin that can load the given extension
  41839. * @param extension defines the extension to load
  41840. * @returns a plugin or null if none works
  41841. */
  41842. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41843. /**
  41844. * Gets a boolean indicating that the given extension can be loaded
  41845. * @param extension defines the extension to load
  41846. * @returns true if the extension is supported
  41847. */
  41848. static IsPluginForExtensionAvailable(extension: string): boolean;
  41849. /**
  41850. * Adds a new plugin to the list of registered plugins
  41851. * @param plugin defines the plugin to add
  41852. */
  41853. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41854. /**
  41855. * Import meshes into a scene
  41856. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41857. * @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)
  41858. * @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)
  41859. * @param scene the instance of BABYLON.Scene to append to
  41860. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41861. * @param onProgress a callback with a progress event for each file being loaded
  41862. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41863. * @param pluginExtension the extension used to determine the plugin
  41864. * @returns The loaded plugin
  41865. */
  41866. 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>;
  41867. /**
  41868. * Import meshes into a scene
  41869. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41870. * @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)
  41871. * @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)
  41872. * @param scene the instance of BABYLON.Scene to append to
  41873. * @param onProgress a callback with a progress event for each file being loaded
  41874. * @param pluginExtension the extension used to determine the plugin
  41875. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41876. */
  41877. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41878. meshes: AbstractMesh[];
  41879. particleSystems: IParticleSystem[];
  41880. skeletons: Skeleton[];
  41881. animationGroups: AnimationGroup[];
  41882. }>;
  41883. /**
  41884. * Load a scene
  41885. * @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)
  41886. * @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)
  41887. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41888. * @param onSuccess a callback with the scene when import succeeds
  41889. * @param onProgress a callback with a progress event for each file being loaded
  41890. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41891. * @param pluginExtension the extension used to determine the plugin
  41892. * @returns The loaded plugin
  41893. */
  41894. 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>;
  41895. /**
  41896. * Load a scene
  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 engine is the instance of BABYLON.Engine to use to create the scene
  41900. * @param onProgress a callback with a progress event for each file being loaded
  41901. * @param pluginExtension the extension used to determine the plugin
  41902. * @returns The loaded scene
  41903. */
  41904. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41905. /**
  41906. * Append a scene
  41907. * @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)
  41908. * @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)
  41909. * @param scene is the instance of BABYLON.Scene to append to
  41910. * @param onSuccess a callback with the scene when import succeeds
  41911. * @param onProgress a callback with a progress event for each file being loaded
  41912. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41913. * @param pluginExtension the extension used to determine the plugin
  41914. * @returns The loaded plugin
  41915. */
  41916. 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>;
  41917. /**
  41918. * Append a scene
  41919. * @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)
  41920. * @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)
  41921. * @param scene is the instance of BABYLON.Scene to append to
  41922. * @param onProgress a callback with a progress event for each file being loaded
  41923. * @param pluginExtension the extension used to determine the plugin
  41924. * @returns The given scene
  41925. */
  41926. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41927. /**
  41928. * Load a scene into an asset container
  41929. * @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)
  41930. * @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)
  41931. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41932. * @param onSuccess a callback with the scene when import succeeds
  41933. * @param onProgress a callback with a progress event for each file being loaded
  41934. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41935. * @param pluginExtension the extension used to determine the plugin
  41936. * @returns The loaded plugin
  41937. */
  41938. 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>;
  41939. /**
  41940. * Load a scene into an asset container
  41941. * @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)
  41942. * @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)
  41943. * @param scene is the instance of Scene to append to
  41944. * @param onProgress a callback with a progress event for each file being loaded
  41945. * @param pluginExtension the extension used to determine the plugin
  41946. * @returns The loaded asset container
  41947. */
  41948. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41949. }
  41950. }
  41951. declare module BABYLON {
  41952. /**
  41953. * Generic Controller
  41954. */
  41955. export class GenericController extends WebVRController {
  41956. /**
  41957. * Base Url for the controller model.
  41958. */
  41959. static readonly MODEL_BASE_URL: string;
  41960. /**
  41961. * File name for the controller model.
  41962. */
  41963. static readonly MODEL_FILENAME: string;
  41964. /**
  41965. * Creates a new GenericController from a gamepad
  41966. * @param vrGamepad the gamepad that the controller should be created from
  41967. */
  41968. constructor(vrGamepad: any);
  41969. /**
  41970. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41971. * @param scene scene in which to add meshes
  41972. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41973. */
  41974. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41975. /**
  41976. * Called once for each button that changed state since the last frame
  41977. * @param buttonIdx Which button index changed
  41978. * @param state New state of the button
  41979. * @param changes Which properties on the state changed since last frame
  41980. */
  41981. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41982. }
  41983. }
  41984. declare module BABYLON {
  41985. /**
  41986. * Defines the WindowsMotionController object that the state of the windows motion controller
  41987. */
  41988. export class WindowsMotionController extends WebVRController {
  41989. /**
  41990. * The base url used to load the left and right controller models
  41991. */
  41992. static MODEL_BASE_URL: string;
  41993. /**
  41994. * The name of the left controller model file
  41995. */
  41996. static MODEL_LEFT_FILENAME: string;
  41997. /**
  41998. * The name of the right controller model file
  41999. */
  42000. static MODEL_RIGHT_FILENAME: string;
  42001. /**
  42002. * The controller name prefix for this controller type
  42003. */
  42004. static readonly GAMEPAD_ID_PREFIX: string;
  42005. /**
  42006. * The controller id pattern for this controller type
  42007. */
  42008. private static readonly GAMEPAD_ID_PATTERN;
  42009. private _loadedMeshInfo;
  42010. private readonly _mapping;
  42011. /**
  42012. * Fired when the trackpad on this controller is clicked
  42013. */
  42014. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42015. /**
  42016. * Fired when the trackpad on this controller is modified
  42017. */
  42018. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42019. /**
  42020. * The current x and y values of this controller's trackpad
  42021. */
  42022. trackpad: StickValues;
  42023. /**
  42024. * Creates a new WindowsMotionController from a gamepad
  42025. * @param vrGamepad the gamepad that the controller should be created from
  42026. */
  42027. constructor(vrGamepad: any);
  42028. /**
  42029. * Fired when the trigger on this controller is modified
  42030. */
  42031. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42032. /**
  42033. * Fired when the menu button on this controller is modified
  42034. */
  42035. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42036. /**
  42037. * Fired when the grip button on this controller is modified
  42038. */
  42039. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42040. /**
  42041. * Fired when the thumbstick button on this controller is modified
  42042. */
  42043. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42044. /**
  42045. * Fired when the touchpad button on this controller is modified
  42046. */
  42047. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42048. /**
  42049. * Fired when the touchpad values on this controller are modified
  42050. */
  42051. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42052. private _updateTrackpad;
  42053. /**
  42054. * Called once per frame by the engine.
  42055. */
  42056. update(): void;
  42057. /**
  42058. * Called once for each button that changed state since the last frame
  42059. * @param buttonIdx Which button index changed
  42060. * @param state New state of the button
  42061. * @param changes Which properties on the state changed since last frame
  42062. */
  42063. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42064. /**
  42065. * Moves the buttons on the controller mesh based on their current state
  42066. * @param buttonName the name of the button to move
  42067. * @param buttonValue the value of the button which determines the buttons new position
  42068. */
  42069. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42070. /**
  42071. * Moves the axis on the controller mesh based on its current state
  42072. * @param axis the index of the axis
  42073. * @param axisValue the value of the axis which determines the meshes new position
  42074. * @hidden
  42075. */
  42076. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42077. /**
  42078. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42079. * @param scene scene in which to add meshes
  42080. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42081. */
  42082. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42083. /**
  42084. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42085. * can be transformed by button presses and axes values, based on this._mapping.
  42086. *
  42087. * @param scene scene in which the meshes exist
  42088. * @param meshes list of meshes that make up the controller model to process
  42089. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42090. */
  42091. private processModel;
  42092. private createMeshInfo;
  42093. /**
  42094. * Gets the ray of the controller in the direction the controller is pointing
  42095. * @param length the length the resulting ray should be
  42096. * @returns a ray in the direction the controller is pointing
  42097. */
  42098. getForwardRay(length?: number): Ray;
  42099. /**
  42100. * Disposes of the controller
  42101. */
  42102. dispose(): void;
  42103. }
  42104. }
  42105. declare module BABYLON {
  42106. /**
  42107. * Oculus Touch Controller
  42108. */
  42109. export class OculusTouchController extends WebVRController {
  42110. /**
  42111. * Base Url for the controller model.
  42112. */
  42113. static MODEL_BASE_URL: string;
  42114. /**
  42115. * File name for the left controller model.
  42116. */
  42117. static MODEL_LEFT_FILENAME: string;
  42118. /**
  42119. * File name for the right controller model.
  42120. */
  42121. static MODEL_RIGHT_FILENAME: string;
  42122. /**
  42123. * Base Url for the Quest controller model.
  42124. */
  42125. static QUEST_MODEL_BASE_URL: string;
  42126. /**
  42127. * @hidden
  42128. * If the controllers are running on a device that needs the updated Quest controller models
  42129. */
  42130. static _IsQuest: boolean;
  42131. /**
  42132. * Fired when the secondary trigger on this controller is modified
  42133. */
  42134. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42135. /**
  42136. * Fired when the thumb rest on this controller is modified
  42137. */
  42138. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42139. /**
  42140. * Creates a new OculusTouchController from a gamepad
  42141. * @param vrGamepad the gamepad that the controller should be created from
  42142. */
  42143. constructor(vrGamepad: any);
  42144. /**
  42145. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42146. * @param scene scene in which to add meshes
  42147. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42148. */
  42149. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42150. /**
  42151. * Fired when the A button on this controller is modified
  42152. */
  42153. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42154. /**
  42155. * Fired when the B button on this controller is modified
  42156. */
  42157. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42158. /**
  42159. * Fired when the X button on this controller is modified
  42160. */
  42161. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42162. /**
  42163. * Fired when the Y button on this controller is modified
  42164. */
  42165. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42166. /**
  42167. * Called once for each button that changed state since the last frame
  42168. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42169. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42170. * 2) secondary trigger (same)
  42171. * 3) A (right) X (left), touch, pressed = value
  42172. * 4) B / Y
  42173. * 5) thumb rest
  42174. * @param buttonIdx Which button index changed
  42175. * @param state New state of the button
  42176. * @param changes Which properties on the state changed since last frame
  42177. */
  42178. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42179. }
  42180. }
  42181. declare module BABYLON {
  42182. /**
  42183. * Vive Controller
  42184. */
  42185. export class ViveController extends WebVRController {
  42186. /**
  42187. * Base Url for the controller model.
  42188. */
  42189. static MODEL_BASE_URL: string;
  42190. /**
  42191. * File name for the controller model.
  42192. */
  42193. static MODEL_FILENAME: string;
  42194. /**
  42195. * Creates a new ViveController from a gamepad
  42196. * @param vrGamepad the gamepad that the controller should be created from
  42197. */
  42198. constructor(vrGamepad: any);
  42199. /**
  42200. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42201. * @param scene scene in which to add meshes
  42202. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42203. */
  42204. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42205. /**
  42206. * Fired when the left button on this controller is modified
  42207. */
  42208. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42209. /**
  42210. * Fired when the right button on this controller is modified
  42211. */
  42212. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42213. /**
  42214. * Fired when the menu button on this controller is modified
  42215. */
  42216. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42217. /**
  42218. * Called once for each button that changed state since the last frame
  42219. * Vive mapping:
  42220. * 0: touchpad
  42221. * 1: trigger
  42222. * 2: left AND right buttons
  42223. * 3: menu button
  42224. * @param buttonIdx Which button index changed
  42225. * @param state New state of the button
  42226. * @param changes Which properties on the state changed since last frame
  42227. */
  42228. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42229. }
  42230. }
  42231. declare module BABYLON {
  42232. /**
  42233. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  42234. */
  42235. export class WebXRControllerModelLoader {
  42236. /**
  42237. * Creates the WebXRControllerModelLoader
  42238. * @param input xr input that creates the controllers
  42239. */
  42240. constructor(input: WebXRInput);
  42241. }
  42242. }
  42243. declare module BABYLON {
  42244. /**
  42245. * Contains an array of blocks representing the octree
  42246. */
  42247. export interface IOctreeContainer<T> {
  42248. /**
  42249. * Blocks within the octree
  42250. */
  42251. blocks: Array<OctreeBlock<T>>;
  42252. }
  42253. /**
  42254. * Class used to store a cell in an octree
  42255. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42256. */
  42257. export class OctreeBlock<T> {
  42258. /**
  42259. * Gets the content of the current block
  42260. */
  42261. entries: T[];
  42262. /**
  42263. * Gets the list of block children
  42264. */
  42265. blocks: Array<OctreeBlock<T>>;
  42266. private _depth;
  42267. private _maxDepth;
  42268. private _capacity;
  42269. private _minPoint;
  42270. private _maxPoint;
  42271. private _boundingVectors;
  42272. private _creationFunc;
  42273. /**
  42274. * Creates a new block
  42275. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42276. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42277. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42278. * @param depth defines the current depth of this block in the octree
  42279. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42280. * @param creationFunc defines a callback to call when an element is added to the block
  42281. */
  42282. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42283. /**
  42284. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42285. */
  42286. readonly capacity: number;
  42287. /**
  42288. * Gets the minimum vector (in world space) of the block's bounding box
  42289. */
  42290. readonly minPoint: Vector3;
  42291. /**
  42292. * Gets the maximum vector (in world space) of the block's bounding box
  42293. */
  42294. readonly maxPoint: Vector3;
  42295. /**
  42296. * Add a new element to this block
  42297. * @param entry defines the element to add
  42298. */
  42299. addEntry(entry: T): void;
  42300. /**
  42301. * Remove an element from this block
  42302. * @param entry defines the element to remove
  42303. */
  42304. removeEntry(entry: T): void;
  42305. /**
  42306. * Add an array of elements to this block
  42307. * @param entries defines the array of elements to add
  42308. */
  42309. addEntries(entries: T[]): void;
  42310. /**
  42311. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42312. * @param frustumPlanes defines the frustum planes to test
  42313. * @param selection defines the array to store current content if selection is positive
  42314. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42315. */
  42316. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42317. /**
  42318. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42319. * @param sphereCenter defines the bounding sphere center
  42320. * @param sphereRadius defines the bounding sphere radius
  42321. * @param selection defines the array to store current content if selection is positive
  42322. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42323. */
  42324. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42325. /**
  42326. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42327. * @param ray defines the ray to test with
  42328. * @param selection defines the array to store current content if selection is positive
  42329. */
  42330. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42331. /**
  42332. * Subdivide the content into child blocks (this block will then be empty)
  42333. */
  42334. createInnerBlocks(): void;
  42335. /**
  42336. * @hidden
  42337. */
  42338. 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;
  42339. }
  42340. }
  42341. declare module BABYLON {
  42342. /**
  42343. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42344. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42345. */
  42346. export class Octree<T> {
  42347. /** 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.) */
  42348. maxDepth: number;
  42349. /**
  42350. * Blocks within the octree containing objects
  42351. */
  42352. blocks: Array<OctreeBlock<T>>;
  42353. /**
  42354. * Content stored in the octree
  42355. */
  42356. dynamicContent: T[];
  42357. private _maxBlockCapacity;
  42358. private _selectionContent;
  42359. private _creationFunc;
  42360. /**
  42361. * Creates a octree
  42362. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42363. * @param creationFunc function to be used to instatiate the octree
  42364. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42365. * @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.)
  42366. */
  42367. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42368. /** 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.) */
  42369. maxDepth?: number);
  42370. /**
  42371. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42372. * @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);
  42373. * @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);
  42374. * @param entries meshes to be added to the octree blocks
  42375. */
  42376. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42377. /**
  42378. * Adds a mesh to the octree
  42379. * @param entry Mesh to add to the octree
  42380. */
  42381. addMesh(entry: T): void;
  42382. /**
  42383. * Remove an element from the octree
  42384. * @param entry defines the element to remove
  42385. */
  42386. removeMesh(entry: T): void;
  42387. /**
  42388. * Selects an array of meshes within the frustum
  42389. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42390. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42391. * @returns array of meshes within the frustum
  42392. */
  42393. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42394. /**
  42395. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42396. * @param sphereCenter defines the bounding sphere center
  42397. * @param sphereRadius defines the bounding sphere radius
  42398. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42399. * @returns an array of objects that intersect the sphere
  42400. */
  42401. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42402. /**
  42403. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42404. * @param ray defines the ray to test with
  42405. * @returns array of intersected objects
  42406. */
  42407. intersectsRay(ray: Ray): SmartArray<T>;
  42408. /**
  42409. * Adds a mesh into the octree block if it intersects the block
  42410. */
  42411. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42412. /**
  42413. * Adds a submesh into the octree block if it intersects the block
  42414. */
  42415. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42416. }
  42417. }
  42418. declare module BABYLON {
  42419. interface Scene {
  42420. /**
  42421. * @hidden
  42422. * Backing Filed
  42423. */
  42424. _selectionOctree: Octree<AbstractMesh>;
  42425. /**
  42426. * Gets the octree used to boost mesh selection (picking)
  42427. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42428. */
  42429. selectionOctree: Octree<AbstractMesh>;
  42430. /**
  42431. * Creates or updates the octree used to boost selection (picking)
  42432. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42433. * @param maxCapacity defines the maximum capacity per leaf
  42434. * @param maxDepth defines the maximum depth of the octree
  42435. * @returns an octree of AbstractMesh
  42436. */
  42437. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42438. }
  42439. interface AbstractMesh {
  42440. /**
  42441. * @hidden
  42442. * Backing Field
  42443. */
  42444. _submeshesOctree: Octree<SubMesh>;
  42445. /**
  42446. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42447. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42448. * @param maxCapacity defines the maximum size of each block (64 by default)
  42449. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42450. * @returns the new octree
  42451. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42452. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42453. */
  42454. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42455. }
  42456. /**
  42457. * Defines the octree scene component responsible to manage any octrees
  42458. * in a given scene.
  42459. */
  42460. export class OctreeSceneComponent {
  42461. /**
  42462. * The component name help to identify the component in the list of scene components.
  42463. */
  42464. readonly name: string;
  42465. /**
  42466. * The scene the component belongs to.
  42467. */
  42468. scene: Scene;
  42469. /**
  42470. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42471. */
  42472. readonly checksIsEnabled: boolean;
  42473. /**
  42474. * Creates a new instance of the component for the given scene
  42475. * @param scene Defines the scene to register the component in
  42476. */
  42477. constructor(scene: Scene);
  42478. /**
  42479. * Registers the component in a given scene
  42480. */
  42481. register(): void;
  42482. /**
  42483. * Return the list of active meshes
  42484. * @returns the list of active meshes
  42485. */
  42486. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42487. /**
  42488. * Return the list of active sub meshes
  42489. * @param mesh The mesh to get the candidates sub meshes from
  42490. * @returns the list of active sub meshes
  42491. */
  42492. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42493. private _tempRay;
  42494. /**
  42495. * Return the list of sub meshes intersecting with a given local ray
  42496. * @param mesh defines the mesh to find the submesh for
  42497. * @param localRay defines the ray in local space
  42498. * @returns the list of intersecting sub meshes
  42499. */
  42500. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42501. /**
  42502. * Return the list of sub meshes colliding with a collider
  42503. * @param mesh defines the mesh to find the submesh for
  42504. * @param collider defines the collider to evaluate the collision against
  42505. * @returns the list of colliding sub meshes
  42506. */
  42507. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42508. /**
  42509. * Rebuilds the elements related to this component in case of
  42510. * context lost for instance.
  42511. */
  42512. rebuild(): void;
  42513. /**
  42514. * Disposes the component and the associated ressources.
  42515. */
  42516. dispose(): void;
  42517. }
  42518. }
  42519. declare module BABYLON {
  42520. /**
  42521. * Renders a layer on top of an existing scene
  42522. */
  42523. export class UtilityLayerRenderer implements IDisposable {
  42524. /** the original scene that will be rendered on top of */
  42525. originalScene: Scene;
  42526. private _pointerCaptures;
  42527. private _lastPointerEvents;
  42528. private static _DefaultUtilityLayer;
  42529. private static _DefaultKeepDepthUtilityLayer;
  42530. private _sharedGizmoLight;
  42531. private _renderCamera;
  42532. /**
  42533. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42534. * @returns the camera that is used when rendering the utility layer
  42535. */
  42536. getRenderCamera(): Nullable<Camera>;
  42537. /**
  42538. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42539. * @param cam the camera that should be used when rendering the utility layer
  42540. */
  42541. setRenderCamera(cam: Nullable<Camera>): void;
  42542. /**
  42543. * @hidden
  42544. * Light which used by gizmos to get light shading
  42545. */
  42546. _getSharedGizmoLight(): HemisphericLight;
  42547. /**
  42548. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42549. */
  42550. pickUtilitySceneFirst: boolean;
  42551. /**
  42552. * 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)
  42553. */
  42554. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42555. /**
  42556. * 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)
  42557. */
  42558. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42559. /**
  42560. * The scene that is rendered on top of the original scene
  42561. */
  42562. utilityLayerScene: Scene;
  42563. /**
  42564. * If the utility layer should automatically be rendered on top of existing scene
  42565. */
  42566. shouldRender: boolean;
  42567. /**
  42568. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42569. */
  42570. onlyCheckPointerDownEvents: boolean;
  42571. /**
  42572. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42573. */
  42574. processAllEvents: boolean;
  42575. /**
  42576. * Observable raised when the pointer move from the utility layer scene to the main scene
  42577. */
  42578. onPointerOutObservable: Observable<number>;
  42579. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42580. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42581. private _afterRenderObserver;
  42582. private _sceneDisposeObserver;
  42583. private _originalPointerObserver;
  42584. /**
  42585. * Instantiates a UtilityLayerRenderer
  42586. * @param originalScene the original scene that will be rendered on top of
  42587. * @param handleEvents boolean indicating if the utility layer should handle events
  42588. */
  42589. constructor(
  42590. /** the original scene that will be rendered on top of */
  42591. originalScene: Scene, handleEvents?: boolean);
  42592. private _notifyObservers;
  42593. /**
  42594. * Renders the utility layers scene on top of the original scene
  42595. */
  42596. render(): void;
  42597. /**
  42598. * Disposes of the renderer
  42599. */
  42600. dispose(): void;
  42601. private _updateCamera;
  42602. }
  42603. }
  42604. declare module BABYLON {
  42605. /**
  42606. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42607. */
  42608. export class Gizmo implements IDisposable {
  42609. /** The utility layer the gizmo will be added to */
  42610. gizmoLayer: UtilityLayerRenderer;
  42611. /**
  42612. * The root mesh of the gizmo
  42613. */
  42614. _rootMesh: Mesh;
  42615. private _attachedMesh;
  42616. /**
  42617. * Ratio for the scale of the gizmo (Default: 1)
  42618. */
  42619. scaleRatio: number;
  42620. /**
  42621. * If a custom mesh has been set (Default: false)
  42622. */
  42623. protected _customMeshSet: boolean;
  42624. /**
  42625. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42626. * * When set, interactions will be enabled
  42627. */
  42628. attachedMesh: Nullable<AbstractMesh>;
  42629. /**
  42630. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42631. * @param mesh The mesh to replace the default mesh of the gizmo
  42632. */
  42633. setCustomMesh(mesh: Mesh): void;
  42634. /**
  42635. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42636. */
  42637. updateGizmoRotationToMatchAttachedMesh: boolean;
  42638. /**
  42639. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42640. */
  42641. updateGizmoPositionToMatchAttachedMesh: boolean;
  42642. /**
  42643. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  42644. */
  42645. updateScale: boolean;
  42646. protected _interactionsEnabled: boolean;
  42647. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42648. private _beforeRenderObserver;
  42649. private _tempVector;
  42650. /**
  42651. * Creates a gizmo
  42652. * @param gizmoLayer The utility layer the gizmo will be added to
  42653. */
  42654. constructor(
  42655. /** The utility layer the gizmo will be added to */
  42656. gizmoLayer?: UtilityLayerRenderer);
  42657. /**
  42658. * Updates the gizmo to match the attached mesh's position/rotation
  42659. */
  42660. protected _update(): void;
  42661. /**
  42662. * Disposes of the gizmo
  42663. */
  42664. dispose(): void;
  42665. }
  42666. }
  42667. declare module BABYLON {
  42668. /**
  42669. * Single plane drag gizmo
  42670. */
  42671. export class PlaneDragGizmo extends Gizmo {
  42672. /**
  42673. * Drag behavior responsible for the gizmos dragging interactions
  42674. */
  42675. dragBehavior: PointerDragBehavior;
  42676. private _pointerObserver;
  42677. /**
  42678. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42679. */
  42680. snapDistance: number;
  42681. /**
  42682. * Event that fires each time the gizmo snaps to a new location.
  42683. * * snapDistance is the the change in distance
  42684. */
  42685. onSnapObservable: Observable<{
  42686. snapDistance: number;
  42687. }>;
  42688. private _plane;
  42689. private _coloredMaterial;
  42690. private _hoverMaterial;
  42691. private _isEnabled;
  42692. private _parent;
  42693. /** @hidden */
  42694. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42695. /** @hidden */
  42696. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42697. /**
  42698. * Creates a PlaneDragGizmo
  42699. * @param gizmoLayer The utility layer the gizmo will be added to
  42700. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42701. * @param color The color of the gizmo
  42702. */
  42703. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42704. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42705. /**
  42706. * If the gizmo is enabled
  42707. */
  42708. isEnabled: boolean;
  42709. /**
  42710. * Disposes of the gizmo
  42711. */
  42712. dispose(): void;
  42713. }
  42714. }
  42715. declare module BABYLON {
  42716. /**
  42717. * Gizmo that enables dragging a mesh along 3 axis
  42718. */
  42719. export class PositionGizmo extends Gizmo {
  42720. /**
  42721. * Internal gizmo used for interactions on the x axis
  42722. */
  42723. xGizmo: AxisDragGizmo;
  42724. /**
  42725. * Internal gizmo used for interactions on the y axis
  42726. */
  42727. yGizmo: AxisDragGizmo;
  42728. /**
  42729. * Internal gizmo used for interactions on the z axis
  42730. */
  42731. zGizmo: AxisDragGizmo;
  42732. /**
  42733. * Internal gizmo used for interactions on the yz plane
  42734. */
  42735. xPlaneGizmo: PlaneDragGizmo;
  42736. /**
  42737. * Internal gizmo used for interactions on the xz plane
  42738. */
  42739. yPlaneGizmo: PlaneDragGizmo;
  42740. /**
  42741. * Internal gizmo used for interactions on the xy plane
  42742. */
  42743. zPlaneGizmo: PlaneDragGizmo;
  42744. /**
  42745. * private variables
  42746. */
  42747. private _meshAttached;
  42748. private _updateGizmoRotationToMatchAttachedMesh;
  42749. private _snapDistance;
  42750. private _scaleRatio;
  42751. /** Fires an event when any of it's sub gizmos are dragged */
  42752. onDragStartObservable: Observable<unknown>;
  42753. /** Fires an event when any of it's sub gizmos are released from dragging */
  42754. onDragEndObservable: Observable<unknown>;
  42755. /**
  42756. * If set to true, planar drag is enabled
  42757. */
  42758. private _planarGizmoEnabled;
  42759. attachedMesh: Nullable<AbstractMesh>;
  42760. /**
  42761. * Creates a PositionGizmo
  42762. * @param gizmoLayer The utility layer the gizmo will be added to
  42763. */
  42764. constructor(gizmoLayer?: UtilityLayerRenderer);
  42765. /**
  42766. * If the planar drag gizmo is enabled
  42767. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42768. */
  42769. planarGizmoEnabled: boolean;
  42770. updateGizmoRotationToMatchAttachedMesh: boolean;
  42771. /**
  42772. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42773. */
  42774. snapDistance: number;
  42775. /**
  42776. * Ratio for the scale of the gizmo (Default: 1)
  42777. */
  42778. scaleRatio: number;
  42779. /**
  42780. * Disposes of the gizmo
  42781. */
  42782. dispose(): void;
  42783. /**
  42784. * CustomMeshes are not supported by this gizmo
  42785. * @param mesh The mesh to replace the default mesh of the gizmo
  42786. */
  42787. setCustomMesh(mesh: Mesh): void;
  42788. }
  42789. }
  42790. declare module BABYLON {
  42791. /**
  42792. * Single axis drag gizmo
  42793. */
  42794. export class AxisDragGizmo extends Gizmo {
  42795. /**
  42796. * Drag behavior responsible for the gizmos dragging interactions
  42797. */
  42798. dragBehavior: PointerDragBehavior;
  42799. private _pointerObserver;
  42800. /**
  42801. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42802. */
  42803. snapDistance: number;
  42804. /**
  42805. * Event that fires each time the gizmo snaps to a new location.
  42806. * * snapDistance is the the change in distance
  42807. */
  42808. onSnapObservable: Observable<{
  42809. snapDistance: number;
  42810. }>;
  42811. private _isEnabled;
  42812. private _parent;
  42813. private _arrow;
  42814. private _coloredMaterial;
  42815. private _hoverMaterial;
  42816. /** @hidden */
  42817. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42818. /** @hidden */
  42819. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42820. /**
  42821. * Creates an AxisDragGizmo
  42822. * @param gizmoLayer The utility layer the gizmo will be added to
  42823. * @param dragAxis The axis which the gizmo will be able to drag on
  42824. * @param color The color of the gizmo
  42825. */
  42826. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42827. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42828. /**
  42829. * If the gizmo is enabled
  42830. */
  42831. isEnabled: boolean;
  42832. /**
  42833. * Disposes of the gizmo
  42834. */
  42835. dispose(): void;
  42836. }
  42837. }
  42838. declare module BABYLON.Debug {
  42839. /**
  42840. * The Axes viewer will show 3 axes in a specific point in space
  42841. */
  42842. export class AxesViewer {
  42843. private _xAxis;
  42844. private _yAxis;
  42845. private _zAxis;
  42846. private _scaleLinesFactor;
  42847. private _instanced;
  42848. /**
  42849. * Gets the hosting scene
  42850. */
  42851. scene: Scene;
  42852. /**
  42853. * Gets or sets a number used to scale line length
  42854. */
  42855. scaleLines: number;
  42856. /** Gets the node hierarchy used to render x-axis */
  42857. readonly xAxis: TransformNode;
  42858. /** Gets the node hierarchy used to render y-axis */
  42859. readonly yAxis: TransformNode;
  42860. /** Gets the node hierarchy used to render z-axis */
  42861. readonly zAxis: TransformNode;
  42862. /**
  42863. * Creates a new AxesViewer
  42864. * @param scene defines the hosting scene
  42865. * @param scaleLines defines a number used to scale line length (1 by default)
  42866. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42867. * @param xAxis defines the node hierarchy used to render the x-axis
  42868. * @param yAxis defines the node hierarchy used to render the y-axis
  42869. * @param zAxis defines the node hierarchy used to render the z-axis
  42870. */
  42871. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42872. /**
  42873. * Force the viewer to update
  42874. * @param position defines the position of the viewer
  42875. * @param xaxis defines the x axis of the viewer
  42876. * @param yaxis defines the y axis of the viewer
  42877. * @param zaxis defines the z axis of the viewer
  42878. */
  42879. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42880. /**
  42881. * Creates an instance of this axes viewer.
  42882. * @returns a new axes viewer with instanced meshes
  42883. */
  42884. createInstance(): AxesViewer;
  42885. /** Releases resources */
  42886. dispose(): void;
  42887. private static _SetRenderingGroupId;
  42888. }
  42889. }
  42890. declare module BABYLON.Debug {
  42891. /**
  42892. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42893. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42894. */
  42895. export class BoneAxesViewer extends AxesViewer {
  42896. /**
  42897. * Gets or sets the target mesh where to display the axes viewer
  42898. */
  42899. mesh: Nullable<Mesh>;
  42900. /**
  42901. * Gets or sets the target bone where to display the axes viewer
  42902. */
  42903. bone: Nullable<Bone>;
  42904. /** Gets current position */
  42905. pos: Vector3;
  42906. /** Gets direction of X axis */
  42907. xaxis: Vector3;
  42908. /** Gets direction of Y axis */
  42909. yaxis: Vector3;
  42910. /** Gets direction of Z axis */
  42911. zaxis: Vector3;
  42912. /**
  42913. * Creates a new BoneAxesViewer
  42914. * @param scene defines the hosting scene
  42915. * @param bone defines the target bone
  42916. * @param mesh defines the target mesh
  42917. * @param scaleLines defines a scaling factor for line length (1 by default)
  42918. */
  42919. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42920. /**
  42921. * Force the viewer to update
  42922. */
  42923. update(): void;
  42924. /** Releases resources */
  42925. dispose(): void;
  42926. }
  42927. }
  42928. declare module BABYLON {
  42929. /**
  42930. * Interface used to define scene explorer extensibility option
  42931. */
  42932. export interface IExplorerExtensibilityOption {
  42933. /**
  42934. * Define the option label
  42935. */
  42936. label: string;
  42937. /**
  42938. * Defines the action to execute on click
  42939. */
  42940. action: (entity: any) => void;
  42941. }
  42942. /**
  42943. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42944. */
  42945. export interface IExplorerExtensibilityGroup {
  42946. /**
  42947. * Defines a predicate to test if a given type mut be extended
  42948. */
  42949. predicate: (entity: any) => boolean;
  42950. /**
  42951. * Gets the list of options added to a type
  42952. */
  42953. entries: IExplorerExtensibilityOption[];
  42954. }
  42955. /**
  42956. * Interface used to define the options to use to create the Inspector
  42957. */
  42958. export interface IInspectorOptions {
  42959. /**
  42960. * Display in overlay mode (default: false)
  42961. */
  42962. overlay?: boolean;
  42963. /**
  42964. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42965. */
  42966. globalRoot?: HTMLElement;
  42967. /**
  42968. * Display the Scene explorer
  42969. */
  42970. showExplorer?: boolean;
  42971. /**
  42972. * Display the property inspector
  42973. */
  42974. showInspector?: boolean;
  42975. /**
  42976. * Display in embed mode (both panes on the right)
  42977. */
  42978. embedMode?: boolean;
  42979. /**
  42980. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42981. */
  42982. handleResize?: boolean;
  42983. /**
  42984. * Allow the panes to popup (default: true)
  42985. */
  42986. enablePopup?: boolean;
  42987. /**
  42988. * Allow the panes to be closed by users (default: true)
  42989. */
  42990. enableClose?: boolean;
  42991. /**
  42992. * Optional list of extensibility entries
  42993. */
  42994. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42995. /**
  42996. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42997. */
  42998. inspectorURL?: string;
  42999. }
  43000. interface Scene {
  43001. /**
  43002. * @hidden
  43003. * Backing field
  43004. */
  43005. _debugLayer: DebugLayer;
  43006. /**
  43007. * Gets the debug layer (aka Inspector) associated with the scene
  43008. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43009. */
  43010. debugLayer: DebugLayer;
  43011. }
  43012. /**
  43013. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43014. * what is happening in your scene
  43015. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43016. */
  43017. export class DebugLayer {
  43018. /**
  43019. * Define the url to get the inspector script from.
  43020. * By default it uses the babylonjs CDN.
  43021. * @ignoreNaming
  43022. */
  43023. static InspectorURL: string;
  43024. private _scene;
  43025. private BJSINSPECTOR;
  43026. private _onPropertyChangedObservable?;
  43027. /**
  43028. * Observable triggered when a property is changed through the inspector.
  43029. */
  43030. readonly onPropertyChangedObservable: any;
  43031. /**
  43032. * Instantiates a new debug layer.
  43033. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43034. * what is happening in your scene
  43035. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43036. * @param scene Defines the scene to inspect
  43037. */
  43038. constructor(scene: Scene);
  43039. /** Creates the inspector window. */
  43040. private _createInspector;
  43041. /**
  43042. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  43043. * @param entity defines the entity to select
  43044. * @param lineContainerTitle defines the specific block to highlight
  43045. */
  43046. select(entity: any, lineContainerTitle?: string): void;
  43047. /** Get the inspector from bundle or global */
  43048. private _getGlobalInspector;
  43049. /**
  43050. * Get if the inspector is visible or not.
  43051. * @returns true if visible otherwise, false
  43052. */
  43053. isVisible(): boolean;
  43054. /**
  43055. * Hide the inspector and close its window.
  43056. */
  43057. hide(): void;
  43058. /**
  43059. * Launch the debugLayer.
  43060. * @param config Define the configuration of the inspector
  43061. * @return a promise fulfilled when the debug layer is visible
  43062. */
  43063. show(config?: IInspectorOptions): Promise<DebugLayer>;
  43064. }
  43065. }
  43066. declare module BABYLON {
  43067. /**
  43068. * Class containing static functions to help procedurally build meshes
  43069. */
  43070. export class BoxBuilder {
  43071. /**
  43072. * Creates a box mesh
  43073. * * The parameter `size` sets the size (float) of each box side (default 1)
  43074. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  43075. * * 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)
  43076. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  43077. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43078. * * 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
  43079. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43080. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  43081. * @param name defines the name of the mesh
  43082. * @param options defines the options used to create the mesh
  43083. * @param scene defines the hosting scene
  43084. * @returns the box mesh
  43085. */
  43086. static CreateBox(name: string, options: {
  43087. size?: number;
  43088. width?: number;
  43089. height?: number;
  43090. depth?: number;
  43091. faceUV?: Vector4[];
  43092. faceColors?: Color4[];
  43093. sideOrientation?: number;
  43094. frontUVs?: Vector4;
  43095. backUVs?: Vector4;
  43096. wrap?: boolean;
  43097. topBaseAt?: number;
  43098. bottomBaseAt?: number;
  43099. updatable?: boolean;
  43100. }, scene?: Nullable<Scene>): Mesh;
  43101. }
  43102. }
  43103. declare module BABYLON {
  43104. /**
  43105. * Class containing static functions to help procedurally build meshes
  43106. */
  43107. export class SphereBuilder {
  43108. /**
  43109. * Creates a sphere mesh
  43110. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43111. * * 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`)
  43112. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43113. * * 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
  43114. * * 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)
  43115. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43116. * * 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
  43117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43118. * @param name defines the name of the mesh
  43119. * @param options defines the options used to create the mesh
  43120. * @param scene defines the hosting scene
  43121. * @returns the sphere mesh
  43122. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43123. */
  43124. static CreateSphere(name: string, options: {
  43125. segments?: number;
  43126. diameter?: number;
  43127. diameterX?: number;
  43128. diameterY?: number;
  43129. diameterZ?: number;
  43130. arc?: number;
  43131. slice?: number;
  43132. sideOrientation?: number;
  43133. frontUVs?: Vector4;
  43134. backUVs?: Vector4;
  43135. updatable?: boolean;
  43136. }, scene?: Nullable<Scene>): Mesh;
  43137. }
  43138. }
  43139. declare module BABYLON.Debug {
  43140. /**
  43141. * Used to show the physics impostor around the specific mesh
  43142. */
  43143. export class PhysicsViewer {
  43144. /** @hidden */
  43145. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43146. /** @hidden */
  43147. protected _meshes: Array<Nullable<AbstractMesh>>;
  43148. /** @hidden */
  43149. protected _scene: Nullable<Scene>;
  43150. /** @hidden */
  43151. protected _numMeshes: number;
  43152. /** @hidden */
  43153. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43154. private _renderFunction;
  43155. private _utilityLayer;
  43156. private _debugBoxMesh;
  43157. private _debugSphereMesh;
  43158. private _debugCylinderMesh;
  43159. private _debugMaterial;
  43160. private _debugMeshMeshes;
  43161. /**
  43162. * Creates a new PhysicsViewer
  43163. * @param scene defines the hosting scene
  43164. */
  43165. constructor(scene: Scene);
  43166. /** @hidden */
  43167. protected _updateDebugMeshes(): void;
  43168. /**
  43169. * Renders a specified physic impostor
  43170. * @param impostor defines the impostor to render
  43171. * @param targetMesh defines the mesh represented by the impostor
  43172. * @returns the new debug mesh used to render the impostor
  43173. */
  43174. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43175. /**
  43176. * Hides a specified physic impostor
  43177. * @param impostor defines the impostor to hide
  43178. */
  43179. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43180. private _getDebugMaterial;
  43181. private _getDebugBoxMesh;
  43182. private _getDebugSphereMesh;
  43183. private _getDebugCylinderMesh;
  43184. private _getDebugMeshMesh;
  43185. private _getDebugMesh;
  43186. /** Releases all resources */
  43187. dispose(): void;
  43188. }
  43189. }
  43190. declare module BABYLON {
  43191. /**
  43192. * Class containing static functions to help procedurally build meshes
  43193. */
  43194. export class LinesBuilder {
  43195. /**
  43196. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43197. * * 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
  43198. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43199. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43200. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43201. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43202. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43203. * * 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
  43204. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43206. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43207. * @param name defines the name of the new line system
  43208. * @param options defines the options used to create the line system
  43209. * @param scene defines the hosting scene
  43210. * @returns a new line system mesh
  43211. */
  43212. static CreateLineSystem(name: string, options: {
  43213. lines: Vector3[][];
  43214. updatable?: boolean;
  43215. instance?: Nullable<LinesMesh>;
  43216. colors?: Nullable<Color4[][]>;
  43217. useVertexAlpha?: boolean;
  43218. }, scene: Nullable<Scene>): LinesMesh;
  43219. /**
  43220. * Creates a line mesh
  43221. * 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
  43222. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43223. * * The parameter `points` is an array successive Vector3
  43224. * * 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
  43225. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43226. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43227. * * When updating an instance, remember that only point positions can change, not the number of points
  43228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43229. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43230. * @param name defines the name of the new line system
  43231. * @param options defines the options used to create the line system
  43232. * @param scene defines the hosting scene
  43233. * @returns a new line mesh
  43234. */
  43235. static CreateLines(name: string, options: {
  43236. points: Vector3[];
  43237. updatable?: boolean;
  43238. instance?: Nullable<LinesMesh>;
  43239. colors?: Color4[];
  43240. useVertexAlpha?: boolean;
  43241. }, scene?: Nullable<Scene>): LinesMesh;
  43242. /**
  43243. * Creates a dashed line mesh
  43244. * * 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
  43245. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43246. * * The parameter `points` is an array successive Vector3
  43247. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43248. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43249. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43250. * * 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
  43251. * * When updating an instance, remember that only point positions can change, not the number of points
  43252. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43253. * @param name defines the name of the mesh
  43254. * @param options defines the options used to create the mesh
  43255. * @param scene defines the hosting scene
  43256. * @returns the dashed line mesh
  43257. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43258. */
  43259. static CreateDashedLines(name: string, options: {
  43260. points: Vector3[];
  43261. dashSize?: number;
  43262. gapSize?: number;
  43263. dashNb?: number;
  43264. updatable?: boolean;
  43265. instance?: LinesMesh;
  43266. }, scene?: Nullable<Scene>): LinesMesh;
  43267. }
  43268. }
  43269. declare module BABYLON {
  43270. /**
  43271. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43272. * in order to better appreciate the issue one might have.
  43273. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43274. */
  43275. export class RayHelper {
  43276. /**
  43277. * Defines the ray we are currently tryin to visualize.
  43278. */
  43279. ray: Nullable<Ray>;
  43280. private _renderPoints;
  43281. private _renderLine;
  43282. private _renderFunction;
  43283. private _scene;
  43284. private _updateToMeshFunction;
  43285. private _attachedToMesh;
  43286. private _meshSpaceDirection;
  43287. private _meshSpaceOrigin;
  43288. /**
  43289. * Helper function to create a colored helper in a scene in one line.
  43290. * @param ray Defines the ray we are currently tryin to visualize
  43291. * @param scene Defines the scene the ray is used in
  43292. * @param color Defines the color we want to see the ray in
  43293. * @returns The newly created ray helper.
  43294. */
  43295. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43296. /**
  43297. * Instantiate a new ray helper.
  43298. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43299. * in order to better appreciate the issue one might have.
  43300. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43301. * @param ray Defines the ray we are currently tryin to visualize
  43302. */
  43303. constructor(ray: Ray);
  43304. /**
  43305. * Shows the ray we are willing to debug.
  43306. * @param scene Defines the scene the ray needs to be rendered in
  43307. * @param color Defines the color the ray needs to be rendered in
  43308. */
  43309. show(scene: Scene, color?: Color3): void;
  43310. /**
  43311. * Hides the ray we are debugging.
  43312. */
  43313. hide(): void;
  43314. private _render;
  43315. /**
  43316. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43317. * @param mesh Defines the mesh we want the helper attached to
  43318. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43319. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43320. * @param length Defines the length of the ray
  43321. */
  43322. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43323. /**
  43324. * Detach the ray helper from the mesh it has previously been attached to.
  43325. */
  43326. detachFromMesh(): void;
  43327. private _updateToMesh;
  43328. /**
  43329. * Dispose the helper and release its associated resources.
  43330. */
  43331. dispose(): void;
  43332. }
  43333. }
  43334. declare module BABYLON.Debug {
  43335. /**
  43336. * Class used to render a debug view of a given skeleton
  43337. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43338. */
  43339. export class SkeletonViewer {
  43340. /** defines the skeleton to render */
  43341. skeleton: Skeleton;
  43342. /** defines the mesh attached to the skeleton */
  43343. mesh: AbstractMesh;
  43344. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43345. autoUpdateBonesMatrices: boolean;
  43346. /** defines the rendering group id to use with the viewer */
  43347. renderingGroupId: number;
  43348. /** Gets or sets the color used to render the skeleton */
  43349. color: Color3;
  43350. private _scene;
  43351. private _debugLines;
  43352. private _debugMesh;
  43353. private _isEnabled;
  43354. private _renderFunction;
  43355. private _utilityLayer;
  43356. /**
  43357. * Returns the mesh used to render the bones
  43358. */
  43359. readonly debugMesh: Nullable<LinesMesh>;
  43360. /**
  43361. * Creates a new SkeletonViewer
  43362. * @param skeleton defines the skeleton to render
  43363. * @param mesh defines the mesh attached to the skeleton
  43364. * @param scene defines the hosting scene
  43365. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43366. * @param renderingGroupId defines the rendering group id to use with the viewer
  43367. */
  43368. constructor(
  43369. /** defines the skeleton to render */
  43370. skeleton: Skeleton,
  43371. /** defines the mesh attached to the skeleton */
  43372. mesh: AbstractMesh, scene: Scene,
  43373. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43374. autoUpdateBonesMatrices?: boolean,
  43375. /** defines the rendering group id to use with the viewer */
  43376. renderingGroupId?: number);
  43377. /** Gets or sets a boolean indicating if the viewer is enabled */
  43378. isEnabled: boolean;
  43379. private _getBonePosition;
  43380. private _getLinesForBonesWithLength;
  43381. private _getLinesForBonesNoLength;
  43382. /** Update the viewer to sync with current skeleton state */
  43383. update(): void;
  43384. /** Release associated resources */
  43385. dispose(): void;
  43386. }
  43387. }
  43388. declare module BABYLON {
  43389. /**
  43390. * Options to create the null engine
  43391. */
  43392. export class NullEngineOptions {
  43393. /**
  43394. * Render width (Default: 512)
  43395. */
  43396. renderWidth: number;
  43397. /**
  43398. * Render height (Default: 256)
  43399. */
  43400. renderHeight: number;
  43401. /**
  43402. * Texture size (Default: 512)
  43403. */
  43404. textureSize: number;
  43405. /**
  43406. * If delta time between frames should be constant
  43407. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43408. */
  43409. deterministicLockstep: boolean;
  43410. /**
  43411. * Maximum about of steps between frames (Default: 4)
  43412. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43413. */
  43414. lockstepMaxSteps: number;
  43415. }
  43416. /**
  43417. * The null engine class provides support for headless version of babylon.js.
  43418. * This can be used in server side scenario or for testing purposes
  43419. */
  43420. export class NullEngine extends Engine {
  43421. private _options;
  43422. /**
  43423. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43424. */
  43425. isDeterministicLockStep(): boolean;
  43426. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  43427. getLockstepMaxSteps(): number;
  43428. /**
  43429. * Sets hardware scaling, used to save performance if needed
  43430. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  43431. */
  43432. getHardwareScalingLevel(): number;
  43433. constructor(options?: NullEngineOptions);
  43434. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43435. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43436. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43437. getRenderWidth(useScreen?: boolean): number;
  43438. getRenderHeight(useScreen?: boolean): number;
  43439. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  43440. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43441. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43442. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43443. bindSamplers(effect: Effect): void;
  43444. enableEffect(effect: Effect): void;
  43445. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43446. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43447. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43448. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43449. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43450. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43451. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43452. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43453. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43454. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43455. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43456. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43457. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43458. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43459. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43460. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43461. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43462. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43463. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43464. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43465. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43466. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43467. bindBuffers(vertexBuffers: {
  43468. [key: string]: VertexBuffer;
  43469. }, indexBuffer: DataBuffer, effect: Effect): void;
  43470. wipeCaches(bruteForce?: boolean): void;
  43471. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43472. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43473. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43474. /** @hidden */
  43475. _createTexture(): WebGLTexture;
  43476. /** @hidden */
  43477. _releaseTexture(texture: InternalTexture): void;
  43478. 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;
  43479. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43480. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43481. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43482. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43483. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43484. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43485. areAllEffectsReady(): boolean;
  43486. /**
  43487. * @hidden
  43488. * Get the current error code of the webGL context
  43489. * @returns the error code
  43490. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43491. */
  43492. getError(): number;
  43493. /** @hidden */
  43494. _getUnpackAlignement(): number;
  43495. /** @hidden */
  43496. _unpackFlipY(value: boolean): void;
  43497. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43498. /**
  43499. * Updates a dynamic vertex buffer.
  43500. * @param vertexBuffer the vertex buffer to update
  43501. * @param data the data used to update the vertex buffer
  43502. * @param byteOffset the byte offset of the data (optional)
  43503. * @param byteLength the byte length of the data (optional)
  43504. */
  43505. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43506. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43507. /** @hidden */
  43508. _bindTexture(channel: number, texture: InternalTexture): void;
  43509. protected _deleteBuffer(buffer: WebGLBuffer): void;
  43510. releaseEffects(): void;
  43511. displayLoadingUI(): void;
  43512. hideLoadingUI(): void;
  43513. /** @hidden */
  43514. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43515. /** @hidden */
  43516. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43517. /** @hidden */
  43518. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43519. /** @hidden */
  43520. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43521. }
  43522. }
  43523. declare module BABYLON {
  43524. /** @hidden */
  43525. export class _OcclusionDataStorage {
  43526. /** @hidden */
  43527. occlusionInternalRetryCounter: number;
  43528. /** @hidden */
  43529. isOcclusionQueryInProgress: boolean;
  43530. /** @hidden */
  43531. isOccluded: boolean;
  43532. /** @hidden */
  43533. occlusionRetryCount: number;
  43534. /** @hidden */
  43535. occlusionType: number;
  43536. /** @hidden */
  43537. occlusionQueryAlgorithmType: number;
  43538. }
  43539. interface Engine {
  43540. /**
  43541. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43542. * @return the new query
  43543. */
  43544. createQuery(): WebGLQuery;
  43545. /**
  43546. * Delete and release a webGL query
  43547. * @param query defines the query to delete
  43548. * @return the current engine
  43549. */
  43550. deleteQuery(query: WebGLQuery): Engine;
  43551. /**
  43552. * Check if a given query has resolved and got its value
  43553. * @param query defines the query to check
  43554. * @returns true if the query got its value
  43555. */
  43556. isQueryResultAvailable(query: WebGLQuery): boolean;
  43557. /**
  43558. * Gets the value of a given query
  43559. * @param query defines the query to check
  43560. * @returns the value of the query
  43561. */
  43562. getQueryResult(query: WebGLQuery): number;
  43563. /**
  43564. * Initiates an occlusion query
  43565. * @param algorithmType defines the algorithm to use
  43566. * @param query defines the query to use
  43567. * @returns the current engine
  43568. * @see http://doc.babylonjs.com/features/occlusionquery
  43569. */
  43570. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43571. /**
  43572. * Ends an occlusion query
  43573. * @see http://doc.babylonjs.com/features/occlusionquery
  43574. * @param algorithmType defines the algorithm to use
  43575. * @returns the current engine
  43576. */
  43577. endOcclusionQuery(algorithmType: number): Engine;
  43578. /**
  43579. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43580. * Please note that only one query can be issued at a time
  43581. * @returns a time token used to track the time span
  43582. */
  43583. startTimeQuery(): Nullable<_TimeToken>;
  43584. /**
  43585. * Ends a time query
  43586. * @param token defines the token used to measure the time span
  43587. * @returns the time spent (in ns)
  43588. */
  43589. endTimeQuery(token: _TimeToken): int;
  43590. /** @hidden */
  43591. _currentNonTimestampToken: Nullable<_TimeToken>;
  43592. /** @hidden */
  43593. _createTimeQuery(): WebGLQuery;
  43594. /** @hidden */
  43595. _deleteTimeQuery(query: WebGLQuery): void;
  43596. /** @hidden */
  43597. _getGlAlgorithmType(algorithmType: number): number;
  43598. /** @hidden */
  43599. _getTimeQueryResult(query: WebGLQuery): any;
  43600. /** @hidden */
  43601. _getTimeQueryAvailability(query: WebGLQuery): any;
  43602. }
  43603. interface AbstractMesh {
  43604. /**
  43605. * Backing filed
  43606. * @hidden
  43607. */
  43608. __occlusionDataStorage: _OcclusionDataStorage;
  43609. /**
  43610. * Access property
  43611. * @hidden
  43612. */
  43613. _occlusionDataStorage: _OcclusionDataStorage;
  43614. /**
  43615. * 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.
  43616. * The default value is -1 which means don't break the query and wait till the result
  43617. * @see http://doc.babylonjs.com/features/occlusionquery
  43618. */
  43619. occlusionRetryCount: number;
  43620. /**
  43621. * 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:
  43622. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43623. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43624. * * 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.
  43625. * @see http://doc.babylonjs.com/features/occlusionquery
  43626. */
  43627. occlusionType: number;
  43628. /**
  43629. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43630. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43631. * * 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.
  43632. * @see http://doc.babylonjs.com/features/occlusionquery
  43633. */
  43634. occlusionQueryAlgorithmType: number;
  43635. /**
  43636. * 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
  43637. * @see http://doc.babylonjs.com/features/occlusionquery
  43638. */
  43639. isOccluded: boolean;
  43640. /**
  43641. * Flag to check the progress status of the query
  43642. * @see http://doc.babylonjs.com/features/occlusionquery
  43643. */
  43644. isOcclusionQueryInProgress: boolean;
  43645. }
  43646. }
  43647. declare module BABYLON {
  43648. /** @hidden */
  43649. export var _forceTransformFeedbackToBundle: boolean;
  43650. interface Engine {
  43651. /**
  43652. * Creates a webGL transform feedback object
  43653. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43654. * @returns the webGL transform feedback object
  43655. */
  43656. createTransformFeedback(): WebGLTransformFeedback;
  43657. /**
  43658. * Delete a webGL transform feedback object
  43659. * @param value defines the webGL transform feedback object to delete
  43660. */
  43661. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43662. /**
  43663. * Bind a webGL transform feedback object to the webgl context
  43664. * @param value defines the webGL transform feedback object to bind
  43665. */
  43666. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43667. /**
  43668. * Begins a transform feedback operation
  43669. * @param usePoints defines if points or triangles must be used
  43670. */
  43671. beginTransformFeedback(usePoints: boolean): void;
  43672. /**
  43673. * Ends a transform feedback operation
  43674. */
  43675. endTransformFeedback(): void;
  43676. /**
  43677. * Specify the varyings to use with transform feedback
  43678. * @param program defines the associated webGL program
  43679. * @param value defines the list of strings representing the varying names
  43680. */
  43681. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43682. /**
  43683. * Bind a webGL buffer for a transform feedback operation
  43684. * @param value defines the webGL buffer to bind
  43685. */
  43686. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43687. }
  43688. }
  43689. declare module BABYLON {
  43690. /**
  43691. * Creation options of the multi render target texture.
  43692. */
  43693. export interface IMultiRenderTargetOptions {
  43694. /**
  43695. * Define if the texture needs to create mip maps after render.
  43696. */
  43697. generateMipMaps?: boolean;
  43698. /**
  43699. * Define the types of all the draw buffers we want to create
  43700. */
  43701. types?: number[];
  43702. /**
  43703. * Define the sampling modes of all the draw buffers we want to create
  43704. */
  43705. samplingModes?: number[];
  43706. /**
  43707. * Define if a depth buffer is required
  43708. */
  43709. generateDepthBuffer?: boolean;
  43710. /**
  43711. * Define if a stencil buffer is required
  43712. */
  43713. generateStencilBuffer?: boolean;
  43714. /**
  43715. * Define if a depth texture is required instead of a depth buffer
  43716. */
  43717. generateDepthTexture?: boolean;
  43718. /**
  43719. * Define the number of desired draw buffers
  43720. */
  43721. textureCount?: number;
  43722. /**
  43723. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43724. */
  43725. doNotChangeAspectRatio?: boolean;
  43726. /**
  43727. * Define the default type of the buffers we are creating
  43728. */
  43729. defaultType?: number;
  43730. }
  43731. /**
  43732. * A multi render target, like a render target provides the ability to render to a texture.
  43733. * Unlike the render target, it can render to several draw buffers in one draw.
  43734. * This is specially interesting in deferred rendering or for any effects requiring more than
  43735. * just one color from a single pass.
  43736. */
  43737. export class MultiRenderTarget extends RenderTargetTexture {
  43738. private _internalTextures;
  43739. private _textures;
  43740. private _multiRenderTargetOptions;
  43741. /**
  43742. * Get if draw buffers are currently supported by the used hardware and browser.
  43743. */
  43744. readonly isSupported: boolean;
  43745. /**
  43746. * Get the list of textures generated by the multi render target.
  43747. */
  43748. readonly textures: Texture[];
  43749. /**
  43750. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43751. */
  43752. readonly depthTexture: Texture;
  43753. /**
  43754. * Set the wrapping mode on U of all the textures we are rendering to.
  43755. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43756. */
  43757. wrapU: number;
  43758. /**
  43759. * Set the wrapping mode on V of all the textures we are rendering to.
  43760. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43761. */
  43762. wrapV: number;
  43763. /**
  43764. * Instantiate a new multi render target texture.
  43765. * A multi render target, like a render target provides the ability to render to a texture.
  43766. * Unlike the render target, it can render to several draw buffers in one draw.
  43767. * This is specially interesting in deferred rendering or for any effects requiring more than
  43768. * just one color from a single pass.
  43769. * @param name Define the name of the texture
  43770. * @param size Define the size of the buffers to render to
  43771. * @param count Define the number of target we are rendering into
  43772. * @param scene Define the scene the texture belongs to
  43773. * @param options Define the options used to create the multi render target
  43774. */
  43775. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43776. /** @hidden */
  43777. _rebuild(): void;
  43778. private _createInternalTextures;
  43779. private _createTextures;
  43780. /**
  43781. * Define the number of samples used if MSAA is enabled.
  43782. */
  43783. samples: number;
  43784. /**
  43785. * Resize all the textures in the multi render target.
  43786. * Be carrefull as it will recreate all the data in the new texture.
  43787. * @param size Define the new size
  43788. */
  43789. resize(size: any): void;
  43790. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43791. /**
  43792. * Dispose the render targets and their associated resources
  43793. */
  43794. dispose(): void;
  43795. /**
  43796. * Release all the underlying texture used as draw buffers.
  43797. */
  43798. releaseInternalTextures(): void;
  43799. }
  43800. }
  43801. declare module BABYLON {
  43802. interface Engine {
  43803. /**
  43804. * Unbind a list of render target textures from the webGL context
  43805. * This is used only when drawBuffer extension or webGL2 are active
  43806. * @param textures defines the render target textures to unbind
  43807. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43808. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43809. */
  43810. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43811. /**
  43812. * Create a multi render target texture
  43813. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43814. * @param size defines the size of the texture
  43815. * @param options defines the creation options
  43816. * @returns the cube texture as an InternalTexture
  43817. */
  43818. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43819. /**
  43820. * Update the sample count for a given multiple render target texture
  43821. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43822. * @param textures defines the textures to update
  43823. * @param samples defines the sample count to set
  43824. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43825. */
  43826. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43827. }
  43828. }
  43829. declare module BABYLON {
  43830. /** @hidden */
  43831. export var rgbdEncodePixelShader: {
  43832. name: string;
  43833. shader: string;
  43834. };
  43835. }
  43836. declare module BABYLON {
  43837. /** @hidden */
  43838. export var rgbdDecodePixelShader: {
  43839. name: string;
  43840. shader: string;
  43841. };
  43842. }
  43843. declare module BABYLON {
  43844. /**
  43845. * Raw texture data and descriptor sufficient for WebGL texture upload
  43846. */
  43847. export interface EnvironmentTextureInfo {
  43848. /**
  43849. * Version of the environment map
  43850. */
  43851. version: number;
  43852. /**
  43853. * Width of image
  43854. */
  43855. width: number;
  43856. /**
  43857. * Irradiance information stored in the file.
  43858. */
  43859. irradiance: any;
  43860. /**
  43861. * Specular information stored in the file.
  43862. */
  43863. specular: any;
  43864. }
  43865. /**
  43866. * Defines One Image in the file. It requires only the position in the file
  43867. * as well as the length.
  43868. */
  43869. interface BufferImageData {
  43870. /**
  43871. * Length of the image data.
  43872. */
  43873. length: number;
  43874. /**
  43875. * Position of the data from the null terminator delimiting the end of the JSON.
  43876. */
  43877. position: number;
  43878. }
  43879. /**
  43880. * Defines the specular data enclosed in the file.
  43881. * This corresponds to the version 1 of the data.
  43882. */
  43883. export interface EnvironmentTextureSpecularInfoV1 {
  43884. /**
  43885. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  43886. */
  43887. specularDataPosition?: number;
  43888. /**
  43889. * This contains all the images data needed to reconstruct the cubemap.
  43890. */
  43891. mipmaps: Array<BufferImageData>;
  43892. /**
  43893. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  43894. */
  43895. lodGenerationScale: number;
  43896. }
  43897. /**
  43898. * Sets of helpers addressing the serialization and deserialization of environment texture
  43899. * stored in a BabylonJS env file.
  43900. * Those files are usually stored as .env files.
  43901. */
  43902. export class EnvironmentTextureTools {
  43903. /**
  43904. * Magic number identifying the env file.
  43905. */
  43906. private static _MagicBytes;
  43907. /**
  43908. * Gets the environment info from an env file.
  43909. * @param data The array buffer containing the .env bytes.
  43910. * @returns the environment file info (the json header) if successfully parsed.
  43911. */
  43912. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  43913. /**
  43914. * Creates an environment texture from a loaded cube texture.
  43915. * @param texture defines the cube texture to convert in env file
  43916. * @return a promise containing the environment data if succesfull.
  43917. */
  43918. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  43919. /**
  43920. * Creates a JSON representation of the spherical data.
  43921. * @param texture defines the texture containing the polynomials
  43922. * @return the JSON representation of the spherical info
  43923. */
  43924. private static _CreateEnvTextureIrradiance;
  43925. /**
  43926. * Creates the ArrayBufferViews used for initializing environment texture image data.
  43927. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  43928. * @param info parameters that determine what views will be created for accessing the underlying buffer
  43929. * @return the views described by info providing access to the underlying buffer
  43930. */
  43931. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  43932. /**
  43933. * Uploads the texture info contained in the env file to the GPU.
  43934. * @param texture defines the internal texture to upload to
  43935. * @param arrayBuffer defines the buffer cotaining the data to load
  43936. * @param info defines the texture info retrieved through the GetEnvInfo method
  43937. * @returns a promise
  43938. */
  43939. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  43940. /**
  43941. * Uploads the levels of image data to the GPU.
  43942. * @param texture defines the internal texture to upload to
  43943. * @param imageData defines the array buffer views of image data [mipmap][face]
  43944. * @returns a promise
  43945. */
  43946. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  43947. /**
  43948. * Uploads spherical polynomials information to the texture.
  43949. * @param texture defines the texture we are trying to upload the information to
  43950. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  43951. */
  43952. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  43953. /** @hidden */
  43954. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  43955. }
  43956. }
  43957. declare module BABYLON {
  43958. /**
  43959. * Contains position and normal vectors for a vertex
  43960. */
  43961. export class PositionNormalVertex {
  43962. /** the position of the vertex (defaut: 0,0,0) */
  43963. position: Vector3;
  43964. /** the normal of the vertex (defaut: 0,1,0) */
  43965. normal: Vector3;
  43966. /**
  43967. * Creates a PositionNormalVertex
  43968. * @param position the position of the vertex (defaut: 0,0,0)
  43969. * @param normal the normal of the vertex (defaut: 0,1,0)
  43970. */
  43971. constructor(
  43972. /** the position of the vertex (defaut: 0,0,0) */
  43973. position?: Vector3,
  43974. /** the normal of the vertex (defaut: 0,1,0) */
  43975. normal?: Vector3);
  43976. /**
  43977. * Clones the PositionNormalVertex
  43978. * @returns the cloned PositionNormalVertex
  43979. */
  43980. clone(): PositionNormalVertex;
  43981. }
  43982. /**
  43983. * Contains position, normal and uv vectors for a vertex
  43984. */
  43985. export class PositionNormalTextureVertex {
  43986. /** the position of the vertex (defaut: 0,0,0) */
  43987. position: Vector3;
  43988. /** the normal of the vertex (defaut: 0,1,0) */
  43989. normal: Vector3;
  43990. /** the uv of the vertex (default: 0,0) */
  43991. uv: Vector2;
  43992. /**
  43993. * Creates a PositionNormalTextureVertex
  43994. * @param position the position of the vertex (defaut: 0,0,0)
  43995. * @param normal the normal of the vertex (defaut: 0,1,0)
  43996. * @param uv the uv of the vertex (default: 0,0)
  43997. */
  43998. constructor(
  43999. /** the position of the vertex (defaut: 0,0,0) */
  44000. position?: Vector3,
  44001. /** the normal of the vertex (defaut: 0,1,0) */
  44002. normal?: Vector3,
  44003. /** the uv of the vertex (default: 0,0) */
  44004. uv?: Vector2);
  44005. /**
  44006. * Clones the PositionNormalTextureVertex
  44007. * @returns the cloned PositionNormalTextureVertex
  44008. */
  44009. clone(): PositionNormalTextureVertex;
  44010. }
  44011. }
  44012. declare module BABYLON {
  44013. /** @hidden */
  44014. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  44015. private _genericAttributeLocation;
  44016. private _varyingLocationCount;
  44017. private _varyingLocationMap;
  44018. private _replacements;
  44019. private _textureCount;
  44020. private _uniforms;
  44021. lineProcessor(line: string): string;
  44022. attributeProcessor(attribute: string): string;
  44023. varyingProcessor(varying: string, isFragment: boolean): string;
  44024. uniformProcessor(uniform: string): string;
  44025. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  44026. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  44027. }
  44028. }
  44029. declare module BABYLON {
  44030. /**
  44031. * Container for accessors for natively-stored mesh data buffers.
  44032. */
  44033. class NativeDataBuffer extends DataBuffer {
  44034. /**
  44035. * Accessor value used to identify/retrieve a natively-stored index buffer.
  44036. */
  44037. nativeIndexBuffer?: any;
  44038. /**
  44039. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  44040. */
  44041. nativeVertexBuffer?: any;
  44042. }
  44043. /** @hidden */
  44044. export class NativeEngine extends Engine {
  44045. private readonly _native;
  44046. getHardwareScalingLevel(): number;
  44047. constructor();
  44048. /**
  44049. * Can be used to override the current requestAnimationFrame requester.
  44050. * @hidden
  44051. */
  44052. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  44053. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44054. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  44055. createVertexBuffer(data: DataArray): NativeDataBuffer;
  44056. recordVertexArrayObject(vertexBuffers: {
  44057. [key: string]: VertexBuffer;
  44058. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  44059. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44060. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44061. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  44062. /**
  44063. * Draw a list of indexed primitives
  44064. * @param fillMode defines the primitive to use
  44065. * @param indexStart defines the starting index
  44066. * @param indexCount defines the number of index to draw
  44067. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44068. */
  44069. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  44070. /**
  44071. * Draw a list of unindexed primitives
  44072. * @param fillMode defines the primitive to use
  44073. * @param verticesStart defines the index of first vertex to draw
  44074. * @param verticesCount defines the count of vertices to draw
  44075. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44076. */
  44077. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  44078. createPipelineContext(): IPipelineContext;
  44079. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  44080. /** @hidden */
  44081. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  44082. /** @hidden */
  44083. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  44084. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44085. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44086. protected _setProgram(program: WebGLProgram): void;
  44087. _releaseEffect(effect: Effect): void;
  44088. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  44089. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  44090. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  44091. bindSamplers(effect: Effect): void;
  44092. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  44093. getRenderWidth(useScreen?: boolean): number;
  44094. getRenderHeight(useScreen?: boolean): number;
  44095. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  44096. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44097. /**
  44098. * Set the z offset to apply to current rendering
  44099. * @param value defines the offset to apply
  44100. */
  44101. setZOffset(value: number): void;
  44102. /**
  44103. * Gets the current value of the zOffset
  44104. * @returns the current zOffset state
  44105. */
  44106. getZOffset(): number;
  44107. /**
  44108. * Enable or disable depth buffering
  44109. * @param enable defines the state to set
  44110. */
  44111. setDepthBuffer(enable: boolean): void;
  44112. /**
  44113. * Gets a boolean indicating if depth writing is enabled
  44114. * @returns the current depth writing state
  44115. */
  44116. getDepthWrite(): boolean;
  44117. /**
  44118. * Enable or disable depth writing
  44119. * @param enable defines the state to set
  44120. */
  44121. setDepthWrite(enable: boolean): void;
  44122. /**
  44123. * Enable or disable color writing
  44124. * @param enable defines the state to set
  44125. */
  44126. setColorWrite(enable: boolean): void;
  44127. /**
  44128. * Gets a boolean indicating if color writing is enabled
  44129. * @returns the current color writing state
  44130. */
  44131. getColorWrite(): boolean;
  44132. /**
  44133. * Sets alpha constants used by some alpha blending modes
  44134. * @param r defines the red component
  44135. * @param g defines the green component
  44136. * @param b defines the blue component
  44137. * @param a defines the alpha component
  44138. */
  44139. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  44140. /**
  44141. * Sets the current alpha mode
  44142. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  44143. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  44144. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44145. */
  44146. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  44147. /**
  44148. * Gets the current alpha mode
  44149. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44150. * @returns the current alpha mode
  44151. */
  44152. getAlphaMode(): number;
  44153. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  44154. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  44155. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  44156. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  44157. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  44158. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  44159. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  44160. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  44161. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  44162. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  44163. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  44164. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  44165. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  44166. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44167. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44168. setFloat(uniform: WebGLUniformLocation, value: number): void;
  44169. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  44170. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  44171. setBool(uniform: WebGLUniformLocation, bool: number): void;
  44172. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  44173. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  44174. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  44175. wipeCaches(bruteForce?: boolean): void;
  44176. _createTexture(): WebGLTexture;
  44177. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  44178. /**
  44179. * Usually called from BABYLON.Texture.ts.
  44180. * Passed information to create a WebGLTexture
  44181. * @param urlArg defines a value which contains one of the following:
  44182. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  44183. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  44184. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  44185. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  44186. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  44187. * @param scene needed for loading to the correct scene
  44188. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  44189. * @param onLoad optional callback to be called upon successful completion
  44190. * @param onError optional callback to be called upon failure
  44191. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  44192. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  44193. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  44194. * @param forcedExtension defines the extension to use to pick the right loader
  44195. * @returns a InternalTexture for assignment back into BABYLON.Texture
  44196. */
  44197. 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 | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  44198. /**
  44199. * Creates a cube texture
  44200. * @param rootUrl defines the url where the files to load is located
  44201. * @param scene defines the current scene
  44202. * @param files defines the list of files to load (1 per face)
  44203. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  44204. * @param onLoad defines an optional callback raised when the texture is loaded
  44205. * @param onError defines an optional callback raised if there is an issue to load the texture
  44206. * @param format defines the format of the data
  44207. * @param forcedExtension defines the extension to use to pick the right loader
  44208. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  44209. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  44210. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  44211. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  44212. * @returns the cube texture as an InternalTexture
  44213. */
  44214. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  44215. private _getSamplingFilter;
  44216. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  44217. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  44218. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  44219. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44220. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  44221. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  44222. /**
  44223. * Updates a dynamic vertex buffer.
  44224. * @param vertexBuffer the vertex buffer to update
  44225. * @param data the data used to update the vertex buffer
  44226. * @param byteOffset the byte offset of the data (optional)
  44227. * @param byteLength the byte length of the data (optional)
  44228. */
  44229. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  44230. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  44231. private _updateAnisotropicLevel;
  44232. private _getAddressMode;
  44233. /** @hidden */
  44234. _bindTexture(channel: number, texture: InternalTexture): void;
  44235. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  44236. releaseEffects(): void;
  44237. /** @hidden */
  44238. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44239. /** @hidden */
  44240. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44241. /** @hidden */
  44242. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44243. /** @hidden */
  44244. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44245. }
  44246. }
  44247. declare module BABYLON {
  44248. /**
  44249. * Gather the list of clipboard event types as constants.
  44250. */
  44251. export class ClipboardEventTypes {
  44252. /**
  44253. * The clipboard event is fired when a copy command is active (pressed).
  44254. */
  44255. static readonly COPY: number;
  44256. /**
  44257. * The clipboard event is fired when a cut command is active (pressed).
  44258. */
  44259. static readonly CUT: number;
  44260. /**
  44261. * The clipboard event is fired when a paste command is active (pressed).
  44262. */
  44263. static readonly PASTE: number;
  44264. }
  44265. /**
  44266. * This class is used to store clipboard related info for the onClipboardObservable event.
  44267. */
  44268. export class ClipboardInfo {
  44269. /**
  44270. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44271. */
  44272. type: number;
  44273. /**
  44274. * Defines the related dom event
  44275. */
  44276. event: ClipboardEvent;
  44277. /**
  44278. *Creates an instance of ClipboardInfo.
  44279. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  44280. * @param event Defines the related dom event
  44281. */
  44282. constructor(
  44283. /**
  44284. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44285. */
  44286. type: number,
  44287. /**
  44288. * Defines the related dom event
  44289. */
  44290. event: ClipboardEvent);
  44291. /**
  44292. * Get the clipboard event's type from the keycode.
  44293. * @param keyCode Defines the keyCode for the current keyboard event.
  44294. * @return {number}
  44295. */
  44296. static GetTypeFromCharacter(keyCode: number): number;
  44297. }
  44298. }
  44299. declare module BABYLON {
  44300. /**
  44301. * Google Daydream controller
  44302. */
  44303. export class DaydreamController extends WebVRController {
  44304. /**
  44305. * Base Url for the controller model.
  44306. */
  44307. static MODEL_BASE_URL: string;
  44308. /**
  44309. * File name for the controller model.
  44310. */
  44311. static MODEL_FILENAME: string;
  44312. /**
  44313. * Gamepad Id prefix used to identify Daydream Controller.
  44314. */
  44315. static readonly GAMEPAD_ID_PREFIX: string;
  44316. /**
  44317. * Creates a new DaydreamController from a gamepad
  44318. * @param vrGamepad the gamepad that the controller should be created from
  44319. */
  44320. constructor(vrGamepad: any);
  44321. /**
  44322. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44323. * @param scene scene in which to add meshes
  44324. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44325. */
  44326. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44327. /**
  44328. * Called once for each button that changed state since the last frame
  44329. * @param buttonIdx Which button index changed
  44330. * @param state New state of the button
  44331. * @param changes Which properties on the state changed since last frame
  44332. */
  44333. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44334. }
  44335. }
  44336. declare module BABYLON {
  44337. /**
  44338. * Gear VR Controller
  44339. */
  44340. export class GearVRController extends WebVRController {
  44341. /**
  44342. * Base Url for the controller model.
  44343. */
  44344. static MODEL_BASE_URL: string;
  44345. /**
  44346. * File name for the controller model.
  44347. */
  44348. static MODEL_FILENAME: string;
  44349. /**
  44350. * Gamepad Id prefix used to identify this controller.
  44351. */
  44352. static readonly GAMEPAD_ID_PREFIX: string;
  44353. private readonly _buttonIndexToObservableNameMap;
  44354. /**
  44355. * Creates a new GearVRController from a gamepad
  44356. * @param vrGamepad the gamepad that the controller should be created from
  44357. */
  44358. constructor(vrGamepad: any);
  44359. /**
  44360. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44361. * @param scene scene in which to add meshes
  44362. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44363. */
  44364. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44365. /**
  44366. * Called once for each button that changed state since the last frame
  44367. * @param buttonIdx Which button index changed
  44368. * @param state New state of the button
  44369. * @param changes Which properties on the state changed since last frame
  44370. */
  44371. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44372. }
  44373. }
  44374. declare module BABYLON {
  44375. /**
  44376. * Class containing static functions to help procedurally build meshes
  44377. */
  44378. export class PolyhedronBuilder {
  44379. /**
  44380. * Creates a polyhedron mesh
  44381. * * 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
  44382. * * The parameter `size` (positive float, default 1) sets the polygon size
  44383. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44384. * * 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`
  44385. * * 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
  44386. * * 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)`)
  44387. * * 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
  44388. * * 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
  44389. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44390. * * 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
  44391. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44392. * @param name defines the name of the mesh
  44393. * @param options defines the options used to create the mesh
  44394. * @param scene defines the hosting scene
  44395. * @returns the polyhedron mesh
  44396. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44397. */
  44398. static CreatePolyhedron(name: string, options: {
  44399. type?: number;
  44400. size?: number;
  44401. sizeX?: number;
  44402. sizeY?: number;
  44403. sizeZ?: number;
  44404. custom?: any;
  44405. faceUV?: Vector4[];
  44406. faceColors?: Color4[];
  44407. flat?: boolean;
  44408. updatable?: boolean;
  44409. sideOrientation?: number;
  44410. frontUVs?: Vector4;
  44411. backUVs?: Vector4;
  44412. }, scene?: Nullable<Scene>): Mesh;
  44413. }
  44414. }
  44415. declare module BABYLON {
  44416. /**
  44417. * Gizmo that enables scaling a mesh along 3 axis
  44418. */
  44419. export class ScaleGizmo extends Gizmo {
  44420. /**
  44421. * Internal gizmo used for interactions on the x axis
  44422. */
  44423. xGizmo: AxisScaleGizmo;
  44424. /**
  44425. * Internal gizmo used for interactions on the y axis
  44426. */
  44427. yGizmo: AxisScaleGizmo;
  44428. /**
  44429. * Internal gizmo used for interactions on the z axis
  44430. */
  44431. zGizmo: AxisScaleGizmo;
  44432. /**
  44433. * Internal gizmo used to scale all axis equally
  44434. */
  44435. uniformScaleGizmo: AxisScaleGizmo;
  44436. private _meshAttached;
  44437. private _updateGizmoRotationToMatchAttachedMesh;
  44438. private _snapDistance;
  44439. private _scaleRatio;
  44440. private _uniformScalingMesh;
  44441. private _octahedron;
  44442. /** Fires an event when any of it's sub gizmos are dragged */
  44443. onDragStartObservable: Observable<unknown>;
  44444. /** Fires an event when any of it's sub gizmos are released from dragging */
  44445. onDragEndObservable: Observable<unknown>;
  44446. attachedMesh: Nullable<AbstractMesh>;
  44447. /**
  44448. * Creates a ScaleGizmo
  44449. * @param gizmoLayer The utility layer the gizmo will be added to
  44450. */
  44451. constructor(gizmoLayer?: UtilityLayerRenderer);
  44452. updateGizmoRotationToMatchAttachedMesh: boolean;
  44453. /**
  44454. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44455. */
  44456. snapDistance: number;
  44457. /**
  44458. * Ratio for the scale of the gizmo (Default: 1)
  44459. */
  44460. scaleRatio: number;
  44461. /**
  44462. * Disposes of the gizmo
  44463. */
  44464. dispose(): void;
  44465. }
  44466. }
  44467. declare module BABYLON {
  44468. /**
  44469. * Single axis scale gizmo
  44470. */
  44471. export class AxisScaleGizmo extends Gizmo {
  44472. /**
  44473. * Drag behavior responsible for the gizmos dragging interactions
  44474. */
  44475. dragBehavior: PointerDragBehavior;
  44476. private _pointerObserver;
  44477. /**
  44478. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44479. */
  44480. snapDistance: number;
  44481. /**
  44482. * Event that fires each time the gizmo snaps to a new location.
  44483. * * snapDistance is the the change in distance
  44484. */
  44485. onSnapObservable: Observable<{
  44486. snapDistance: number;
  44487. }>;
  44488. /**
  44489. * If the scaling operation should be done on all axis (default: false)
  44490. */
  44491. uniformScaling: boolean;
  44492. private _isEnabled;
  44493. private _parent;
  44494. private _arrow;
  44495. private _coloredMaterial;
  44496. private _hoverMaterial;
  44497. /**
  44498. * Creates an AxisScaleGizmo
  44499. * @param gizmoLayer The utility layer the gizmo will be added to
  44500. * @param dragAxis The axis which the gizmo will be able to scale on
  44501. * @param color The color of the gizmo
  44502. */
  44503. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  44504. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44505. /**
  44506. * If the gizmo is enabled
  44507. */
  44508. isEnabled: boolean;
  44509. /**
  44510. * Disposes of the gizmo
  44511. */
  44512. dispose(): void;
  44513. /**
  44514. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44515. * @param mesh The mesh to replace the default mesh of the gizmo
  44516. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44517. */
  44518. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44519. }
  44520. }
  44521. declare module BABYLON {
  44522. /**
  44523. * Bounding box gizmo
  44524. */
  44525. export class BoundingBoxGizmo extends Gizmo {
  44526. private _lineBoundingBox;
  44527. private _rotateSpheresParent;
  44528. private _scaleBoxesParent;
  44529. private _boundingDimensions;
  44530. private _renderObserver;
  44531. private _pointerObserver;
  44532. private _scaleDragSpeed;
  44533. private _tmpQuaternion;
  44534. private _tmpVector;
  44535. private _tmpRotationMatrix;
  44536. /**
  44537. * 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)
  44538. */
  44539. ignoreChildren: boolean;
  44540. /**
  44541. * 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)
  44542. */
  44543. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44544. /**
  44545. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44546. */
  44547. rotationSphereSize: number;
  44548. /**
  44549. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44550. */
  44551. scaleBoxSize: number;
  44552. /**
  44553. * 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)
  44554. */
  44555. fixedDragMeshScreenSize: boolean;
  44556. /**
  44557. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44558. */
  44559. fixedDragMeshScreenSizeDistanceFactor: number;
  44560. /**
  44561. * Fired when a rotation sphere or scale box is dragged
  44562. */
  44563. onDragStartObservable: Observable<{}>;
  44564. /**
  44565. * Fired when a scale box is dragged
  44566. */
  44567. onScaleBoxDragObservable: Observable<{}>;
  44568. /**
  44569. * Fired when a scale box drag is ended
  44570. */
  44571. onScaleBoxDragEndObservable: Observable<{}>;
  44572. /**
  44573. * Fired when a rotation sphere is dragged
  44574. */
  44575. onRotationSphereDragObservable: Observable<{}>;
  44576. /**
  44577. * Fired when a rotation sphere drag is ended
  44578. */
  44579. onRotationSphereDragEndObservable: Observable<{}>;
  44580. /**
  44581. * 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)
  44582. */
  44583. scalePivot: Nullable<Vector3>;
  44584. /**
  44585. * Mesh used as a pivot to rotate the attached mesh
  44586. */
  44587. private _anchorMesh;
  44588. private _existingMeshScale;
  44589. private _dragMesh;
  44590. private pointerDragBehavior;
  44591. private coloredMaterial;
  44592. private hoverColoredMaterial;
  44593. /**
  44594. * Sets the color of the bounding box gizmo
  44595. * @param color the color to set
  44596. */
  44597. setColor(color: Color3): void;
  44598. /**
  44599. * Creates an BoundingBoxGizmo
  44600. * @param gizmoLayer The utility layer the gizmo will be added to
  44601. * @param color The color of the gizmo
  44602. */
  44603. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44604. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44605. private _selectNode;
  44606. /**
  44607. * Updates the bounding box information for the Gizmo
  44608. */
  44609. updateBoundingBox(): void;
  44610. private _updateRotationSpheres;
  44611. private _updateScaleBoxes;
  44612. /**
  44613. * Enables rotation on the specified axis and disables rotation on the others
  44614. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  44615. */
  44616. setEnabledRotationAxis(axis: string): void;
  44617. /**
  44618. * Enables/disables scaling
  44619. * @param enable if scaling should be enabled
  44620. */
  44621. setEnabledScaling(enable: boolean): void;
  44622. private _updateDummy;
  44623. /**
  44624. * Enables a pointer drag behavior on the bounding box of the gizmo
  44625. */
  44626. enableDragBehavior(): void;
  44627. /**
  44628. * Disposes of the gizmo
  44629. */
  44630. dispose(): void;
  44631. /**
  44632. * 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)
  44633. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  44634. * @returns the bounding box mesh with the passed in mesh as a child
  44635. */
  44636. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  44637. /**
  44638. * CustomMeshes are not supported by this gizmo
  44639. * @param mesh The mesh to replace the default mesh of the gizmo
  44640. */
  44641. setCustomMesh(mesh: Mesh): void;
  44642. }
  44643. }
  44644. declare module BABYLON {
  44645. /**
  44646. * Single plane rotation gizmo
  44647. */
  44648. export class PlaneRotationGizmo extends Gizmo {
  44649. /**
  44650. * Drag behavior responsible for the gizmos dragging interactions
  44651. */
  44652. dragBehavior: PointerDragBehavior;
  44653. private _pointerObserver;
  44654. /**
  44655. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  44656. */
  44657. snapDistance: number;
  44658. /**
  44659. * Event that fires each time the gizmo snaps to a new location.
  44660. * * snapDistance is the the change in distance
  44661. */
  44662. onSnapObservable: Observable<{
  44663. snapDistance: number;
  44664. }>;
  44665. private _isEnabled;
  44666. private _parent;
  44667. /**
  44668. * Creates a PlaneRotationGizmo
  44669. * @param gizmoLayer The utility layer the gizmo will be added to
  44670. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  44671. * @param color The color of the gizmo
  44672. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44673. * @param useEulerRotation Use and update Euler angle instead of quaternion
  44674. */
  44675. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  44676. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44677. /**
  44678. * If the gizmo is enabled
  44679. */
  44680. isEnabled: boolean;
  44681. /**
  44682. * Disposes of the gizmo
  44683. */
  44684. dispose(): void;
  44685. }
  44686. }
  44687. declare module BABYLON {
  44688. /**
  44689. * Gizmo that enables rotating a mesh along 3 axis
  44690. */
  44691. export class RotationGizmo extends Gizmo {
  44692. /**
  44693. * Internal gizmo used for interactions on the x axis
  44694. */
  44695. xGizmo: PlaneRotationGizmo;
  44696. /**
  44697. * Internal gizmo used for interactions on the y axis
  44698. */
  44699. yGizmo: PlaneRotationGizmo;
  44700. /**
  44701. * Internal gizmo used for interactions on the z axis
  44702. */
  44703. zGizmo: PlaneRotationGizmo;
  44704. /** Fires an event when any of it's sub gizmos are dragged */
  44705. onDragStartObservable: Observable<unknown>;
  44706. /** Fires an event when any of it's sub gizmos are released from dragging */
  44707. onDragEndObservable: Observable<unknown>;
  44708. private _meshAttached;
  44709. attachedMesh: Nullable<AbstractMesh>;
  44710. /**
  44711. * Creates a RotationGizmo
  44712. * @param gizmoLayer The utility layer the gizmo will be added to
  44713. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44714. * @param useEulerRotation Use and update Euler angle instead of quaternion
  44715. */
  44716. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  44717. updateGizmoRotationToMatchAttachedMesh: boolean;
  44718. /**
  44719. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44720. */
  44721. snapDistance: number;
  44722. /**
  44723. * Ratio for the scale of the gizmo (Default: 1)
  44724. */
  44725. scaleRatio: number;
  44726. /**
  44727. * Disposes of the gizmo
  44728. */
  44729. dispose(): void;
  44730. /**
  44731. * CustomMeshes are not supported by this gizmo
  44732. * @param mesh The mesh to replace the default mesh of the gizmo
  44733. */
  44734. setCustomMesh(mesh: Mesh): void;
  44735. }
  44736. }
  44737. declare module BABYLON {
  44738. /**
  44739. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44740. */
  44741. export class GizmoManager implements IDisposable {
  44742. private scene;
  44743. /**
  44744. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44745. */
  44746. gizmos: {
  44747. positionGizmo: Nullable<PositionGizmo>;
  44748. rotationGizmo: Nullable<RotationGizmo>;
  44749. scaleGizmo: Nullable<ScaleGizmo>;
  44750. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44751. };
  44752. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44753. clearGizmoOnEmptyPointerEvent: boolean;
  44754. /** Fires an event when the manager is attached to a mesh */
  44755. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44756. private _gizmosEnabled;
  44757. private _pointerObserver;
  44758. private _attachedMesh;
  44759. private _boundingBoxColor;
  44760. private _defaultUtilityLayer;
  44761. private _defaultKeepDepthUtilityLayer;
  44762. /**
  44763. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44764. */
  44765. boundingBoxDragBehavior: SixDofDragBehavior;
  44766. /**
  44767. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44768. */
  44769. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44770. /**
  44771. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44772. */
  44773. usePointerToAttachGizmos: boolean;
  44774. /**
  44775. * Utility layer that the bounding box gizmo belongs to
  44776. */
  44777. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  44778. /**
  44779. * Utility layer that all gizmos besides bounding box belong to
  44780. */
  44781. readonly utilityLayer: UtilityLayerRenderer;
  44782. /**
  44783. * Instatiates a gizmo manager
  44784. * @param scene the scene to overlay the gizmos on top of
  44785. */
  44786. constructor(scene: Scene);
  44787. /**
  44788. * Attaches a set of gizmos to the specified mesh
  44789. * @param mesh The mesh the gizmo's should be attached to
  44790. */
  44791. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44792. /**
  44793. * If the position gizmo is enabled
  44794. */
  44795. positionGizmoEnabled: boolean;
  44796. /**
  44797. * If the rotation gizmo is enabled
  44798. */
  44799. rotationGizmoEnabled: boolean;
  44800. /**
  44801. * If the scale gizmo is enabled
  44802. */
  44803. scaleGizmoEnabled: boolean;
  44804. /**
  44805. * If the boundingBox gizmo is enabled
  44806. */
  44807. boundingBoxGizmoEnabled: boolean;
  44808. /**
  44809. * Disposes of the gizmo manager
  44810. */
  44811. dispose(): void;
  44812. }
  44813. }
  44814. declare module BABYLON {
  44815. /**
  44816. * A directional light is defined by a direction (what a surprise!).
  44817. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44818. * 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.
  44819. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44820. */
  44821. export class DirectionalLight extends ShadowLight {
  44822. private _shadowFrustumSize;
  44823. /**
  44824. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44825. */
  44826. /**
  44827. * Specifies a fix frustum size for the shadow generation.
  44828. */
  44829. shadowFrustumSize: number;
  44830. private _shadowOrthoScale;
  44831. /**
  44832. * Gets the shadow projection scale against the optimal computed one.
  44833. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44834. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44835. */
  44836. /**
  44837. * Sets the shadow projection scale against the optimal computed one.
  44838. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44839. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44840. */
  44841. shadowOrthoScale: number;
  44842. /**
  44843. * Automatically compute the projection matrix to best fit (including all the casters)
  44844. * on each frame.
  44845. */
  44846. autoUpdateExtends: boolean;
  44847. private _orthoLeft;
  44848. private _orthoRight;
  44849. private _orthoTop;
  44850. private _orthoBottom;
  44851. /**
  44852. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44853. * The directional light is emitted from everywhere in the given direction.
  44854. * It can cast shadows.
  44855. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44856. * @param name The friendly name of the light
  44857. * @param direction The direction of the light
  44858. * @param scene The scene the light belongs to
  44859. */
  44860. constructor(name: string, direction: Vector3, scene: Scene);
  44861. /**
  44862. * Returns the string "DirectionalLight".
  44863. * @return The class name
  44864. */
  44865. getClassName(): string;
  44866. /**
  44867. * Returns the integer 1.
  44868. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44869. */
  44870. getTypeID(): number;
  44871. /**
  44872. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44873. * Returns the DirectionalLight Shadow projection matrix.
  44874. */
  44875. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44876. /**
  44877. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44878. * Returns the DirectionalLight Shadow projection matrix.
  44879. */
  44880. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44881. /**
  44882. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44883. * Returns the DirectionalLight Shadow projection matrix.
  44884. */
  44885. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44886. protected _buildUniformLayout(): void;
  44887. /**
  44888. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44889. * @param effect The effect to update
  44890. * @param lightIndex The index of the light in the effect to update
  44891. * @returns The directional light
  44892. */
  44893. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44894. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  44895. /**
  44896. * Gets the minZ used for shadow according to both the scene and the light.
  44897. *
  44898. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44899. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44900. * @param activeCamera The camera we are returning the min for
  44901. * @returns the depth min z
  44902. */
  44903. getDepthMinZ(activeCamera: Camera): number;
  44904. /**
  44905. * Gets the maxZ used for shadow according to both the scene and the light.
  44906. *
  44907. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44908. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44909. * @param activeCamera The camera we are returning the max for
  44910. * @returns the depth max z
  44911. */
  44912. getDepthMaxZ(activeCamera: Camera): number;
  44913. /**
  44914. * Prepares the list of defines specific to the light type.
  44915. * @param defines the list of defines
  44916. * @param lightIndex defines the index of the light for the effect
  44917. */
  44918. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44919. }
  44920. }
  44921. declare module BABYLON {
  44922. /**
  44923. * Class containing static functions to help procedurally build meshes
  44924. */
  44925. export class HemisphereBuilder {
  44926. /**
  44927. * Creates a hemisphere mesh
  44928. * @param name defines the name of the mesh
  44929. * @param options defines the options used to create the mesh
  44930. * @param scene defines the hosting scene
  44931. * @returns the hemisphere mesh
  44932. */
  44933. static CreateHemisphere(name: string, options: {
  44934. segments?: number;
  44935. diameter?: number;
  44936. sideOrientation?: number;
  44937. }, scene: any): Mesh;
  44938. }
  44939. }
  44940. declare module BABYLON {
  44941. /**
  44942. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44943. * These values define a cone of light starting from the position, emitting toward the direction.
  44944. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44945. * and the exponent defines the speed of the decay of the light with distance (reach).
  44946. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44947. */
  44948. export class SpotLight extends ShadowLight {
  44949. private _angle;
  44950. private _innerAngle;
  44951. private _cosHalfAngle;
  44952. private _lightAngleScale;
  44953. private _lightAngleOffset;
  44954. /**
  44955. * Gets the cone angle of the spot light in Radians.
  44956. */
  44957. /**
  44958. * Sets the cone angle of the spot light in Radians.
  44959. */
  44960. angle: number;
  44961. /**
  44962. * Only used in gltf falloff mode, this defines the angle where
  44963. * the directional falloff will start before cutting at angle which could be seen
  44964. * as outer angle.
  44965. */
  44966. /**
  44967. * Only used in gltf falloff mode, this defines the angle where
  44968. * the directional falloff will start before cutting at angle which could be seen
  44969. * as outer angle.
  44970. */
  44971. innerAngle: number;
  44972. private _shadowAngleScale;
  44973. /**
  44974. * Allows scaling the angle of the light for shadow generation only.
  44975. */
  44976. /**
  44977. * Allows scaling the angle of the light for shadow generation only.
  44978. */
  44979. shadowAngleScale: number;
  44980. /**
  44981. * The light decay speed with the distance from the emission spot.
  44982. */
  44983. exponent: number;
  44984. private _projectionTextureMatrix;
  44985. /**
  44986. * Allows reading the projecton texture
  44987. */
  44988. readonly projectionTextureMatrix: Matrix;
  44989. protected _projectionTextureLightNear: number;
  44990. /**
  44991. * Gets the near clip of the Spotlight for texture projection.
  44992. */
  44993. /**
  44994. * Sets the near clip of the Spotlight for texture projection.
  44995. */
  44996. projectionTextureLightNear: number;
  44997. protected _projectionTextureLightFar: number;
  44998. /**
  44999. * Gets the far clip of the Spotlight for texture projection.
  45000. */
  45001. /**
  45002. * Sets the far clip of the Spotlight for texture projection.
  45003. */
  45004. projectionTextureLightFar: number;
  45005. protected _projectionTextureUpDirection: Vector3;
  45006. /**
  45007. * Gets the Up vector of the Spotlight for texture projection.
  45008. */
  45009. /**
  45010. * Sets the Up vector of the Spotlight for texture projection.
  45011. */
  45012. projectionTextureUpDirection: Vector3;
  45013. private _projectionTexture;
  45014. /**
  45015. * Gets the projection texture of the light.
  45016. */
  45017. /**
  45018. * Sets the projection texture of the light.
  45019. */
  45020. projectionTexture: Nullable<BaseTexture>;
  45021. private _projectionTextureViewLightDirty;
  45022. private _projectionTextureProjectionLightDirty;
  45023. private _projectionTextureDirty;
  45024. private _projectionTextureViewTargetVector;
  45025. private _projectionTextureViewLightMatrix;
  45026. private _projectionTextureProjectionLightMatrix;
  45027. private _projectionTextureScalingMatrix;
  45028. /**
  45029. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45030. * It can cast shadows.
  45031. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45032. * @param name The light friendly name
  45033. * @param position The position of the spot light in the scene
  45034. * @param direction The direction of the light in the scene
  45035. * @param angle The cone angle of the light in Radians
  45036. * @param exponent The light decay speed with the distance from the emission spot
  45037. * @param scene The scene the lights belongs to
  45038. */
  45039. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45040. /**
  45041. * Returns the string "SpotLight".
  45042. * @returns the class name
  45043. */
  45044. getClassName(): string;
  45045. /**
  45046. * Returns the integer 2.
  45047. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45048. */
  45049. getTypeID(): number;
  45050. /**
  45051. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45052. */
  45053. protected _setDirection(value: Vector3): void;
  45054. /**
  45055. * Overrides the position setter to recompute the projection texture view light Matrix.
  45056. */
  45057. protected _setPosition(value: Vector3): void;
  45058. /**
  45059. * 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.
  45060. * Returns the SpotLight.
  45061. */
  45062. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45063. protected _computeProjectionTextureViewLightMatrix(): void;
  45064. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45065. /**
  45066. * Main function for light texture projection matrix computing.
  45067. */
  45068. protected _computeProjectionTextureMatrix(): void;
  45069. protected _buildUniformLayout(): void;
  45070. private _computeAngleValues;
  45071. /**
  45072. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45073. * @param effect The effect to update
  45074. * @param lightIndex The index of the light in the effect to update
  45075. * @returns The spot light
  45076. */
  45077. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45078. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  45079. /**
  45080. * Disposes the light and the associated resources.
  45081. */
  45082. dispose(): void;
  45083. /**
  45084. * Prepares the list of defines specific to the light type.
  45085. * @param defines the list of defines
  45086. * @param lightIndex defines the index of the light for the effect
  45087. */
  45088. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45089. }
  45090. }
  45091. declare module BABYLON {
  45092. /**
  45093. * Gizmo that enables viewing a light
  45094. */
  45095. export class LightGizmo extends Gizmo {
  45096. private _lightMesh;
  45097. private _material;
  45098. private cachedPosition;
  45099. private cachedForward;
  45100. /**
  45101. * Creates a LightGizmo
  45102. * @param gizmoLayer The utility layer the gizmo will be added to
  45103. */
  45104. constructor(gizmoLayer?: UtilityLayerRenderer);
  45105. private _light;
  45106. /**
  45107. * The light that the gizmo is attached to
  45108. */
  45109. light: Nullable<Light>;
  45110. /**
  45111. * Gets the material used to render the light gizmo
  45112. */
  45113. readonly material: StandardMaterial;
  45114. /**
  45115. * @hidden
  45116. * Updates the gizmo to match the attached mesh's position/rotation
  45117. */
  45118. protected _update(): void;
  45119. private static _Scale;
  45120. /**
  45121. * Creates the lines for a light mesh
  45122. */
  45123. private static _createLightLines;
  45124. /**
  45125. * Disposes of the light gizmo
  45126. */
  45127. dispose(): void;
  45128. private static _CreateHemisphericLightMesh;
  45129. private static _CreatePointLightMesh;
  45130. private static _CreateSpotLightMesh;
  45131. private static _CreateDirectionalLightMesh;
  45132. }
  45133. }
  45134. declare module BABYLON {
  45135. /** @hidden */
  45136. export var backgroundFragmentDeclaration: {
  45137. name: string;
  45138. shader: string;
  45139. };
  45140. }
  45141. declare module BABYLON {
  45142. /** @hidden */
  45143. export var backgroundUboDeclaration: {
  45144. name: string;
  45145. shader: string;
  45146. };
  45147. }
  45148. declare module BABYLON {
  45149. /** @hidden */
  45150. export var backgroundPixelShader: {
  45151. name: string;
  45152. shader: string;
  45153. };
  45154. }
  45155. declare module BABYLON {
  45156. /** @hidden */
  45157. export var backgroundVertexDeclaration: {
  45158. name: string;
  45159. shader: string;
  45160. };
  45161. }
  45162. declare module BABYLON {
  45163. /** @hidden */
  45164. export var backgroundVertexShader: {
  45165. name: string;
  45166. shader: string;
  45167. };
  45168. }
  45169. declare module BABYLON {
  45170. /**
  45171. * Background material used to create an efficient environement around your scene.
  45172. */
  45173. export class BackgroundMaterial extends PushMaterial {
  45174. /**
  45175. * Standard reflectance value at parallel view angle.
  45176. */
  45177. static StandardReflectance0: number;
  45178. /**
  45179. * Standard reflectance value at grazing angle.
  45180. */
  45181. static StandardReflectance90: number;
  45182. protected _primaryColor: Color3;
  45183. /**
  45184. * Key light Color (multiply against the environement texture)
  45185. */
  45186. primaryColor: Color3;
  45187. protected __perceptualColor: Nullable<Color3>;
  45188. /**
  45189. * Experimental Internal Use Only.
  45190. *
  45191. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45192. * This acts as a helper to set the primary color to a more "human friendly" value.
  45193. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45194. * output color as close as possible from the chosen value.
  45195. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45196. * part of lighting setup.)
  45197. */
  45198. _perceptualColor: Nullable<Color3>;
  45199. protected _primaryColorShadowLevel: float;
  45200. /**
  45201. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45202. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45203. */
  45204. primaryColorShadowLevel: float;
  45205. protected _primaryColorHighlightLevel: float;
  45206. /**
  45207. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45208. * The primary color is used at the level chosen to define what the white area would look.
  45209. */
  45210. primaryColorHighlightLevel: float;
  45211. protected _reflectionTexture: Nullable<BaseTexture>;
  45212. /**
  45213. * Reflection Texture used in the material.
  45214. * Should be author in a specific way for the best result (refer to the documentation).
  45215. */
  45216. reflectionTexture: Nullable<BaseTexture>;
  45217. protected _reflectionBlur: float;
  45218. /**
  45219. * Reflection Texture level of blur.
  45220. *
  45221. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45222. * texture twice.
  45223. */
  45224. reflectionBlur: float;
  45225. protected _diffuseTexture: Nullable<BaseTexture>;
  45226. /**
  45227. * Diffuse Texture used in the material.
  45228. * Should be author in a specific way for the best result (refer to the documentation).
  45229. */
  45230. diffuseTexture: Nullable<BaseTexture>;
  45231. protected _shadowLights: Nullable<IShadowLight[]>;
  45232. /**
  45233. * Specify the list of lights casting shadow on the material.
  45234. * All scene shadow lights will be included if null.
  45235. */
  45236. shadowLights: Nullable<IShadowLight[]>;
  45237. protected _shadowLevel: float;
  45238. /**
  45239. * Helps adjusting the shadow to a softer level if required.
  45240. * 0 means black shadows and 1 means no shadows.
  45241. */
  45242. shadowLevel: float;
  45243. protected _sceneCenter: Vector3;
  45244. /**
  45245. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45246. * It is usually zero but might be interesting to modify according to your setup.
  45247. */
  45248. sceneCenter: Vector3;
  45249. protected _opacityFresnel: boolean;
  45250. /**
  45251. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45252. * This helps ensuring a nice transition when the camera goes under the ground.
  45253. */
  45254. opacityFresnel: boolean;
  45255. protected _reflectionFresnel: boolean;
  45256. /**
  45257. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45258. * This helps adding a mirror texture on the ground.
  45259. */
  45260. reflectionFresnel: boolean;
  45261. protected _reflectionFalloffDistance: number;
  45262. /**
  45263. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45264. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45265. */
  45266. reflectionFalloffDistance: number;
  45267. protected _reflectionAmount: number;
  45268. /**
  45269. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45270. */
  45271. reflectionAmount: number;
  45272. protected _reflectionReflectance0: number;
  45273. /**
  45274. * This specifies the weight of the reflection at grazing angle.
  45275. */
  45276. reflectionReflectance0: number;
  45277. protected _reflectionReflectance90: number;
  45278. /**
  45279. * This specifies the weight of the reflection at a perpendicular point of view.
  45280. */
  45281. reflectionReflectance90: number;
  45282. /**
  45283. * Sets the reflection reflectance fresnel values according to the default standard
  45284. * empirically know to work well :-)
  45285. */
  45286. reflectionStandardFresnelWeight: number;
  45287. protected _useRGBColor: boolean;
  45288. /**
  45289. * Helps to directly use the maps channels instead of their level.
  45290. */
  45291. useRGBColor: boolean;
  45292. protected _enableNoise: boolean;
  45293. /**
  45294. * This helps reducing the banding effect that could occur on the background.
  45295. */
  45296. enableNoise: boolean;
  45297. /**
  45298. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45299. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45300. * Recommended to be keep at 1.0 except for special cases.
  45301. */
  45302. fovMultiplier: number;
  45303. private _fovMultiplier;
  45304. /**
  45305. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45306. */
  45307. useEquirectangularFOV: boolean;
  45308. private _maxSimultaneousLights;
  45309. /**
  45310. * Number of Simultaneous lights allowed on the material.
  45311. */
  45312. maxSimultaneousLights: int;
  45313. /**
  45314. * Default configuration related to image processing available in the Background Material.
  45315. */
  45316. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45317. /**
  45318. * Keep track of the image processing observer to allow dispose and replace.
  45319. */
  45320. private _imageProcessingObserver;
  45321. /**
  45322. * Attaches a new image processing configuration to the PBR Material.
  45323. * @param configuration (if null the scene configuration will be use)
  45324. */
  45325. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45326. /**
  45327. * Gets the image processing configuration used either in this material.
  45328. */
  45329. /**
  45330. * Sets the Default image processing configuration used either in the this material.
  45331. *
  45332. * If sets to null, the scene one is in use.
  45333. */
  45334. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45335. /**
  45336. * Gets wether the color curves effect is enabled.
  45337. */
  45338. /**
  45339. * Sets wether the color curves effect is enabled.
  45340. */
  45341. cameraColorCurvesEnabled: boolean;
  45342. /**
  45343. * Gets wether the color grading effect is enabled.
  45344. */
  45345. /**
  45346. * Gets wether the color grading effect is enabled.
  45347. */
  45348. cameraColorGradingEnabled: boolean;
  45349. /**
  45350. * Gets wether tonemapping is enabled or not.
  45351. */
  45352. /**
  45353. * Sets wether tonemapping is enabled or not
  45354. */
  45355. cameraToneMappingEnabled: boolean;
  45356. /**
  45357. * The camera exposure used on this material.
  45358. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45359. * This corresponds to a photographic exposure.
  45360. */
  45361. /**
  45362. * The camera exposure used on this material.
  45363. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45364. * This corresponds to a photographic exposure.
  45365. */
  45366. cameraExposure: float;
  45367. /**
  45368. * Gets The camera contrast used on this material.
  45369. */
  45370. /**
  45371. * Sets The camera contrast used on this material.
  45372. */
  45373. cameraContrast: float;
  45374. /**
  45375. * Gets the Color Grading 2D Lookup Texture.
  45376. */
  45377. /**
  45378. * Sets the Color Grading 2D Lookup Texture.
  45379. */
  45380. cameraColorGradingTexture: Nullable<BaseTexture>;
  45381. /**
  45382. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45383. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45384. * 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;
  45385. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45386. */
  45387. /**
  45388. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45389. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45390. * 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;
  45391. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45392. */
  45393. cameraColorCurves: Nullable<ColorCurves>;
  45394. /**
  45395. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45396. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45397. */
  45398. switchToBGR: boolean;
  45399. private _renderTargets;
  45400. private _reflectionControls;
  45401. private _white;
  45402. private _primaryShadowColor;
  45403. private _primaryHighlightColor;
  45404. /**
  45405. * Instantiates a Background Material in the given scene
  45406. * @param name The friendly name of the material
  45407. * @param scene The scene to add the material to
  45408. */
  45409. constructor(name: string, scene: Scene);
  45410. /**
  45411. * Gets a boolean indicating that current material needs to register RTT
  45412. */
  45413. readonly hasRenderTargetTextures: boolean;
  45414. /**
  45415. * The entire material has been created in order to prevent overdraw.
  45416. * @returns false
  45417. */
  45418. needAlphaTesting(): boolean;
  45419. /**
  45420. * The entire material has been created in order to prevent overdraw.
  45421. * @returns true if blending is enable
  45422. */
  45423. needAlphaBlending(): boolean;
  45424. /**
  45425. * Checks wether the material is ready to be rendered for a given mesh.
  45426. * @param mesh The mesh to render
  45427. * @param subMesh The submesh to check against
  45428. * @param useInstances Specify wether or not the material is used with instances
  45429. * @returns true if all the dependencies are ready (Textures, Effects...)
  45430. */
  45431. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45432. /**
  45433. * Compute the primary color according to the chosen perceptual color.
  45434. */
  45435. private _computePrimaryColorFromPerceptualColor;
  45436. /**
  45437. * Compute the highlights and shadow colors according to their chosen levels.
  45438. */
  45439. private _computePrimaryColors;
  45440. /**
  45441. * Build the uniform buffer used in the material.
  45442. */
  45443. buildUniformLayout(): void;
  45444. /**
  45445. * Unbind the material.
  45446. */
  45447. unbind(): void;
  45448. /**
  45449. * Bind only the world matrix to the material.
  45450. * @param world The world matrix to bind.
  45451. */
  45452. bindOnlyWorldMatrix(world: Matrix): void;
  45453. /**
  45454. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45455. * @param world The world matrix to bind.
  45456. * @param subMesh The submesh to bind for.
  45457. */
  45458. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45459. /**
  45460. * Checks to see if a texture is used in the material.
  45461. * @param texture - Base texture to use.
  45462. * @returns - Boolean specifying if a texture is used in the material.
  45463. */
  45464. hasTexture(texture: BaseTexture): boolean;
  45465. /**
  45466. * Dispose the material.
  45467. * @param forceDisposeEffect Force disposal of the associated effect.
  45468. * @param forceDisposeTextures Force disposal of the associated textures.
  45469. */
  45470. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45471. /**
  45472. * Clones the material.
  45473. * @param name The cloned name.
  45474. * @returns The cloned material.
  45475. */
  45476. clone(name: string): BackgroundMaterial;
  45477. /**
  45478. * Serializes the current material to its JSON representation.
  45479. * @returns The JSON representation.
  45480. */
  45481. serialize(): any;
  45482. /**
  45483. * Gets the class name of the material
  45484. * @returns "BackgroundMaterial"
  45485. */
  45486. getClassName(): string;
  45487. /**
  45488. * Parse a JSON input to create back a background material.
  45489. * @param source The JSON data to parse
  45490. * @param scene The scene to create the parsed material in
  45491. * @param rootUrl The root url of the assets the material depends upon
  45492. * @returns the instantiated BackgroundMaterial.
  45493. */
  45494. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45495. }
  45496. }
  45497. declare module BABYLON {
  45498. /**
  45499. * Represents the different options available during the creation of
  45500. * a Environment helper.
  45501. *
  45502. * This can control the default ground, skybox and image processing setup of your scene.
  45503. */
  45504. export interface IEnvironmentHelperOptions {
  45505. /**
  45506. * Specifies wether or not to create a ground.
  45507. * True by default.
  45508. */
  45509. createGround: boolean;
  45510. /**
  45511. * Specifies the ground size.
  45512. * 15 by default.
  45513. */
  45514. groundSize: number;
  45515. /**
  45516. * The texture used on the ground for the main color.
  45517. * Comes from the BabylonJS CDN by default.
  45518. *
  45519. * Remarks: Can be either a texture or a url.
  45520. */
  45521. groundTexture: string | BaseTexture;
  45522. /**
  45523. * The color mixed in the ground texture by default.
  45524. * BabylonJS clearColor by default.
  45525. */
  45526. groundColor: Color3;
  45527. /**
  45528. * Specifies the ground opacity.
  45529. * 1 by default.
  45530. */
  45531. groundOpacity: number;
  45532. /**
  45533. * Enables the ground to receive shadows.
  45534. * True by default.
  45535. */
  45536. enableGroundShadow: boolean;
  45537. /**
  45538. * Helps preventing the shadow to be fully black on the ground.
  45539. * 0.5 by default.
  45540. */
  45541. groundShadowLevel: number;
  45542. /**
  45543. * Creates a mirror texture attach to the ground.
  45544. * false by default.
  45545. */
  45546. enableGroundMirror: boolean;
  45547. /**
  45548. * Specifies the ground mirror size ratio.
  45549. * 0.3 by default as the default kernel is 64.
  45550. */
  45551. groundMirrorSizeRatio: number;
  45552. /**
  45553. * Specifies the ground mirror blur kernel size.
  45554. * 64 by default.
  45555. */
  45556. groundMirrorBlurKernel: number;
  45557. /**
  45558. * Specifies the ground mirror visibility amount.
  45559. * 1 by default
  45560. */
  45561. groundMirrorAmount: number;
  45562. /**
  45563. * Specifies the ground mirror reflectance weight.
  45564. * This uses the standard weight of the background material to setup the fresnel effect
  45565. * of the mirror.
  45566. * 1 by default.
  45567. */
  45568. groundMirrorFresnelWeight: number;
  45569. /**
  45570. * Specifies the ground mirror Falloff distance.
  45571. * This can helps reducing the size of the reflection.
  45572. * 0 by Default.
  45573. */
  45574. groundMirrorFallOffDistance: number;
  45575. /**
  45576. * Specifies the ground mirror texture type.
  45577. * Unsigned Int by Default.
  45578. */
  45579. groundMirrorTextureType: number;
  45580. /**
  45581. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45582. * the shown objects.
  45583. */
  45584. groundYBias: number;
  45585. /**
  45586. * Specifies wether or not to create a skybox.
  45587. * True by default.
  45588. */
  45589. createSkybox: boolean;
  45590. /**
  45591. * Specifies the skybox size.
  45592. * 20 by default.
  45593. */
  45594. skyboxSize: number;
  45595. /**
  45596. * The texture used on the skybox for the main color.
  45597. * Comes from the BabylonJS CDN by default.
  45598. *
  45599. * Remarks: Can be either a texture or a url.
  45600. */
  45601. skyboxTexture: string | BaseTexture;
  45602. /**
  45603. * The color mixed in the skybox texture by default.
  45604. * BabylonJS clearColor by default.
  45605. */
  45606. skyboxColor: Color3;
  45607. /**
  45608. * The background rotation around the Y axis of the scene.
  45609. * This helps aligning the key lights of your scene with the background.
  45610. * 0 by default.
  45611. */
  45612. backgroundYRotation: number;
  45613. /**
  45614. * Compute automatically the size of the elements to best fit with the scene.
  45615. */
  45616. sizeAuto: boolean;
  45617. /**
  45618. * Default position of the rootMesh if autoSize is not true.
  45619. */
  45620. rootPosition: Vector3;
  45621. /**
  45622. * Sets up the image processing in the scene.
  45623. * true by default.
  45624. */
  45625. setupImageProcessing: boolean;
  45626. /**
  45627. * The texture used as your environment texture in the scene.
  45628. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45629. *
  45630. * Remarks: Can be either a texture or a url.
  45631. */
  45632. environmentTexture: string | BaseTexture;
  45633. /**
  45634. * The value of the exposure to apply to the scene.
  45635. * 0.6 by default if setupImageProcessing is true.
  45636. */
  45637. cameraExposure: number;
  45638. /**
  45639. * The value of the contrast to apply to the scene.
  45640. * 1.6 by default if setupImageProcessing is true.
  45641. */
  45642. cameraContrast: number;
  45643. /**
  45644. * Specifies wether or not tonemapping should be enabled in the scene.
  45645. * true by default if setupImageProcessing is true.
  45646. */
  45647. toneMappingEnabled: boolean;
  45648. }
  45649. /**
  45650. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45651. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45652. * It also helps with the default setup of your imageProcessing configuration.
  45653. */
  45654. export class EnvironmentHelper {
  45655. /**
  45656. * Default ground texture URL.
  45657. */
  45658. private static _groundTextureCDNUrl;
  45659. /**
  45660. * Default skybox texture URL.
  45661. */
  45662. private static _skyboxTextureCDNUrl;
  45663. /**
  45664. * Default environment texture URL.
  45665. */
  45666. private static _environmentTextureCDNUrl;
  45667. /**
  45668. * Creates the default options for the helper.
  45669. */
  45670. private static _getDefaultOptions;
  45671. private _rootMesh;
  45672. /**
  45673. * Gets the root mesh created by the helper.
  45674. */
  45675. readonly rootMesh: Mesh;
  45676. private _skybox;
  45677. /**
  45678. * Gets the skybox created by the helper.
  45679. */
  45680. readonly skybox: Nullable<Mesh>;
  45681. private _skyboxTexture;
  45682. /**
  45683. * Gets the skybox texture created by the helper.
  45684. */
  45685. readonly skyboxTexture: Nullable<BaseTexture>;
  45686. private _skyboxMaterial;
  45687. /**
  45688. * Gets the skybox material created by the helper.
  45689. */
  45690. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45691. private _ground;
  45692. /**
  45693. * Gets the ground mesh created by the helper.
  45694. */
  45695. readonly ground: Nullable<Mesh>;
  45696. private _groundTexture;
  45697. /**
  45698. * Gets the ground texture created by the helper.
  45699. */
  45700. readonly groundTexture: Nullable<BaseTexture>;
  45701. private _groundMirror;
  45702. /**
  45703. * Gets the ground mirror created by the helper.
  45704. */
  45705. readonly groundMirror: Nullable<MirrorTexture>;
  45706. /**
  45707. * Gets the ground mirror render list to helps pushing the meshes
  45708. * you wish in the ground reflection.
  45709. */
  45710. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45711. private _groundMaterial;
  45712. /**
  45713. * Gets the ground material created by the helper.
  45714. */
  45715. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45716. /**
  45717. * Stores the creation options.
  45718. */
  45719. private readonly _scene;
  45720. private _options;
  45721. /**
  45722. * This observable will be notified with any error during the creation of the environment,
  45723. * mainly texture creation errors.
  45724. */
  45725. onErrorObservable: Observable<{
  45726. message?: string;
  45727. exception?: any;
  45728. }>;
  45729. /**
  45730. * constructor
  45731. * @param options Defines the options we want to customize the helper
  45732. * @param scene The scene to add the material to
  45733. */
  45734. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45735. /**
  45736. * Updates the background according to the new options
  45737. * @param options
  45738. */
  45739. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45740. /**
  45741. * Sets the primary color of all the available elements.
  45742. * @param color the main color to affect to the ground and the background
  45743. */
  45744. setMainColor(color: Color3): void;
  45745. /**
  45746. * Setup the image processing according to the specified options.
  45747. */
  45748. private _setupImageProcessing;
  45749. /**
  45750. * Setup the environment texture according to the specified options.
  45751. */
  45752. private _setupEnvironmentTexture;
  45753. /**
  45754. * Setup the background according to the specified options.
  45755. */
  45756. private _setupBackground;
  45757. /**
  45758. * Get the scene sizes according to the setup.
  45759. */
  45760. private _getSceneSize;
  45761. /**
  45762. * Setup the ground according to the specified options.
  45763. */
  45764. private _setupGround;
  45765. /**
  45766. * Setup the ground material according to the specified options.
  45767. */
  45768. private _setupGroundMaterial;
  45769. /**
  45770. * Setup the ground diffuse texture according to the specified options.
  45771. */
  45772. private _setupGroundDiffuseTexture;
  45773. /**
  45774. * Setup the ground mirror texture according to the specified options.
  45775. */
  45776. private _setupGroundMirrorTexture;
  45777. /**
  45778. * Setup the ground to receive the mirror texture.
  45779. */
  45780. private _setupMirrorInGroundMaterial;
  45781. /**
  45782. * Setup the skybox according to the specified options.
  45783. */
  45784. private _setupSkybox;
  45785. /**
  45786. * Setup the skybox material according to the specified options.
  45787. */
  45788. private _setupSkyboxMaterial;
  45789. /**
  45790. * Setup the skybox reflection texture according to the specified options.
  45791. */
  45792. private _setupSkyboxReflectionTexture;
  45793. private _errorHandler;
  45794. /**
  45795. * Dispose all the elements created by the Helper.
  45796. */
  45797. dispose(): void;
  45798. }
  45799. }
  45800. declare module BABYLON {
  45801. /**
  45802. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45803. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45804. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45805. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45806. */
  45807. export class PhotoDome extends TransformNode {
  45808. /**
  45809. * Define the image as a Monoscopic panoramic 360 image.
  45810. */
  45811. static readonly MODE_MONOSCOPIC: number;
  45812. /**
  45813. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45814. */
  45815. static readonly MODE_TOPBOTTOM: number;
  45816. /**
  45817. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45818. */
  45819. static readonly MODE_SIDEBYSIDE: number;
  45820. private _useDirectMapping;
  45821. /**
  45822. * The texture being displayed on the sphere
  45823. */
  45824. protected _photoTexture: Texture;
  45825. /**
  45826. * Gets or sets the texture being displayed on the sphere
  45827. */
  45828. photoTexture: Texture;
  45829. /**
  45830. * Observable raised when an error occured while loading the 360 image
  45831. */
  45832. onLoadErrorObservable: Observable<string>;
  45833. /**
  45834. * The skybox material
  45835. */
  45836. protected _material: BackgroundMaterial;
  45837. /**
  45838. * The surface used for the skybox
  45839. */
  45840. protected _mesh: Mesh;
  45841. /**
  45842. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45843. * Also see the options.resolution property.
  45844. */
  45845. fovMultiplier: number;
  45846. private _imageMode;
  45847. /**
  45848. * Gets or set the current video mode for the video. It can be:
  45849. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  45850. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45851. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45852. */
  45853. imageMode: number;
  45854. /**
  45855. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45856. * @param name Element's name, child elements will append suffixes for their own names.
  45857. * @param urlsOfPhoto defines the url of the photo to display
  45858. * @param options defines an object containing optional or exposed sub element properties
  45859. * @param onError defines a callback called when an error occured while loading the texture
  45860. */
  45861. constructor(name: string, urlOfPhoto: string, options: {
  45862. resolution?: number;
  45863. size?: number;
  45864. useDirectMapping?: boolean;
  45865. faceForward?: boolean;
  45866. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45867. private _onBeforeCameraRenderObserver;
  45868. private _changeImageMode;
  45869. /**
  45870. * Releases resources associated with this node.
  45871. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45872. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45873. */
  45874. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45875. }
  45876. }
  45877. declare module BABYLON {
  45878. /**
  45879. * Class used to host texture specific utilities
  45880. */
  45881. export class BRDFTextureTools {
  45882. /**
  45883. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  45884. * @param texture the texture to expand.
  45885. */
  45886. private static _ExpandDefaultBRDFTexture;
  45887. /**
  45888. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45889. * @param scene defines the hosting scene
  45890. * @returns the environment BRDF texture
  45891. */
  45892. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45893. private static _environmentBRDFBase64Texture;
  45894. }
  45895. }
  45896. declare module BABYLON {
  45897. /**
  45898. * @hidden
  45899. */
  45900. export interface IMaterialClearCoatDefines {
  45901. CLEARCOAT: boolean;
  45902. CLEARCOAT_DEFAULTIOR: boolean;
  45903. CLEARCOAT_TEXTURE: boolean;
  45904. CLEARCOAT_TEXTUREDIRECTUV: number;
  45905. CLEARCOAT_BUMP: boolean;
  45906. CLEARCOAT_BUMPDIRECTUV: number;
  45907. CLEARCOAT_TINT: boolean;
  45908. CLEARCOAT_TINT_TEXTURE: boolean;
  45909. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45910. /** @hidden */
  45911. _areTexturesDirty: boolean;
  45912. }
  45913. /**
  45914. * Define the code related to the clear coat parameters of the pbr material.
  45915. */
  45916. export class PBRClearCoatConfiguration {
  45917. /**
  45918. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45919. * The default fits with a polyurethane material.
  45920. */
  45921. private static readonly _DefaultIndexOfRefraction;
  45922. private _isEnabled;
  45923. /**
  45924. * Defines if the clear coat is enabled in the material.
  45925. */
  45926. isEnabled: boolean;
  45927. /**
  45928. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45929. */
  45930. intensity: number;
  45931. /**
  45932. * Defines the clear coat layer roughness.
  45933. */
  45934. roughness: number;
  45935. private _indexOfRefraction;
  45936. /**
  45937. * Defines the index of refraction of the clear coat.
  45938. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45939. * The default fits with a polyurethane material.
  45940. * Changing the default value is more performance intensive.
  45941. */
  45942. indexOfRefraction: number;
  45943. private _texture;
  45944. /**
  45945. * Stores the clear coat values in a texture.
  45946. */
  45947. texture: Nullable<BaseTexture>;
  45948. private _bumpTexture;
  45949. /**
  45950. * Define the clear coat specific bump texture.
  45951. */
  45952. bumpTexture: Nullable<BaseTexture>;
  45953. private _isTintEnabled;
  45954. /**
  45955. * Defines if the clear coat tint is enabled in the material.
  45956. */
  45957. isTintEnabled: boolean;
  45958. /**
  45959. * Defines the clear coat tint of the material.
  45960. * This is only use if tint is enabled
  45961. */
  45962. tintColor: Color3;
  45963. /**
  45964. * Defines the distance at which the tint color should be found in the
  45965. * clear coat media.
  45966. * This is only use if tint is enabled
  45967. */
  45968. tintColorAtDistance: number;
  45969. /**
  45970. * Defines the clear coat layer thickness.
  45971. * This is only use if tint is enabled
  45972. */
  45973. tintThickness: number;
  45974. private _tintTexture;
  45975. /**
  45976. * Stores the clear tint values in a texture.
  45977. * rgb is tint
  45978. * a is a thickness factor
  45979. */
  45980. tintTexture: Nullable<BaseTexture>;
  45981. /** @hidden */
  45982. private _internalMarkAllSubMeshesAsTexturesDirty;
  45983. /** @hidden */
  45984. _markAllSubMeshesAsTexturesDirty(): void;
  45985. /**
  45986. * Instantiate a new istance of clear coat configuration.
  45987. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45988. */
  45989. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45990. /**
  45991. * Gets wehter the submesh is ready to be used or not.
  45992. * @param defines the list of "defines" to update.
  45993. * @param scene defines the scene the material belongs to.
  45994. * @param engine defines the engine the material belongs to.
  45995. * @param disableBumpMap defines wether the material disables bump or not.
  45996. * @returns - boolean indicating that the submesh is ready or not.
  45997. */
  45998. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  45999. /**
  46000. * Checks to see if a texture is used in the material.
  46001. * @param defines the list of "defines" to update.
  46002. * @param scene defines the scene to the material belongs to.
  46003. */
  46004. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  46005. /**
  46006. * Binds the material data.
  46007. * @param uniformBuffer defines the Uniform buffer to fill in.
  46008. * @param scene defines the scene the material belongs to.
  46009. * @param engine defines the engine the material belongs to.
  46010. * @param disableBumpMap defines wether the material disables bump or not.
  46011. * @param isFrozen defines wether the material is frozen or not.
  46012. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46013. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46014. */
  46015. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  46016. /**
  46017. * Checks to see if a texture is used in the material.
  46018. * @param texture - Base texture to use.
  46019. * @returns - Boolean specifying if a texture is used in the material.
  46020. */
  46021. hasTexture(texture: BaseTexture): boolean;
  46022. /**
  46023. * Returns an array of the actively used textures.
  46024. * @param activeTextures Array of BaseTextures
  46025. */
  46026. getActiveTextures(activeTextures: BaseTexture[]): void;
  46027. /**
  46028. * Returns the animatable textures.
  46029. * @param animatables Array of animatable textures.
  46030. */
  46031. getAnimatables(animatables: IAnimatable[]): void;
  46032. /**
  46033. * Disposes the resources of the material.
  46034. * @param forceDisposeTextures - Forces the disposal of all textures.
  46035. */
  46036. dispose(forceDisposeTextures?: boolean): void;
  46037. /**
  46038. * Get the current class name of the texture useful for serialization or dynamic coding.
  46039. * @returns "PBRClearCoatConfiguration"
  46040. */
  46041. getClassName(): string;
  46042. /**
  46043. * Add fallbacks to the effect fallbacks list.
  46044. * @param defines defines the Base texture to use.
  46045. * @param fallbacks defines the current fallback list.
  46046. * @param currentRank defines the current fallback rank.
  46047. * @returns the new fallback rank.
  46048. */
  46049. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46050. /**
  46051. * Add the required uniforms to the current list.
  46052. * @param uniforms defines the current uniform list.
  46053. */
  46054. static AddUniforms(uniforms: string[]): void;
  46055. /**
  46056. * Add the required samplers to the current list.
  46057. * @param samplers defines the current sampler list.
  46058. */
  46059. static AddSamplers(samplers: string[]): void;
  46060. /**
  46061. * Add the required uniforms to the current buffer.
  46062. * @param uniformBuffer defines the current uniform buffer.
  46063. */
  46064. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46065. /**
  46066. * Makes a duplicate of the current configuration into another one.
  46067. * @param clearCoatConfiguration define the config where to copy the info
  46068. */
  46069. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46070. /**
  46071. * Serializes this clear coat configuration.
  46072. * @returns - An object with the serialized config.
  46073. */
  46074. serialize(): any;
  46075. /**
  46076. * Parses a anisotropy Configuration from a serialized object.
  46077. * @param source - Serialized object.
  46078. * @param scene Defines the scene we are parsing for
  46079. * @param rootUrl Defines the rootUrl to load from
  46080. */
  46081. parse(source: any, scene: Scene, rootUrl: string): void;
  46082. }
  46083. }
  46084. declare module BABYLON {
  46085. /**
  46086. * @hidden
  46087. */
  46088. export interface IMaterialAnisotropicDefines {
  46089. ANISOTROPIC: boolean;
  46090. ANISOTROPIC_TEXTURE: boolean;
  46091. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46092. MAINUV1: boolean;
  46093. _areTexturesDirty: boolean;
  46094. _needUVs: boolean;
  46095. }
  46096. /**
  46097. * Define the code related to the anisotropic parameters of the pbr material.
  46098. */
  46099. export class PBRAnisotropicConfiguration {
  46100. private _isEnabled;
  46101. /**
  46102. * Defines if the anisotropy is enabled in the material.
  46103. */
  46104. isEnabled: boolean;
  46105. /**
  46106. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46107. */
  46108. intensity: number;
  46109. /**
  46110. * Defines if the effect is along the tangents, bitangents or in between.
  46111. * By default, the effect is "strectching" the highlights along the tangents.
  46112. */
  46113. direction: Vector2;
  46114. private _texture;
  46115. /**
  46116. * Stores the anisotropy values in a texture.
  46117. * rg is direction (like normal from -1 to 1)
  46118. * b is a intensity
  46119. */
  46120. texture: Nullable<BaseTexture>;
  46121. /** @hidden */
  46122. private _internalMarkAllSubMeshesAsTexturesDirty;
  46123. /** @hidden */
  46124. _markAllSubMeshesAsTexturesDirty(): void;
  46125. /**
  46126. * Instantiate a new istance of anisotropy configuration.
  46127. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46128. */
  46129. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46130. /**
  46131. * Specifies that the submesh is ready to be used.
  46132. * @param defines the list of "defines" to update.
  46133. * @param scene defines the scene the material belongs to.
  46134. * @returns - boolean indicating that the submesh is ready or not.
  46135. */
  46136. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46137. /**
  46138. * Checks to see if a texture is used in the material.
  46139. * @param defines the list of "defines" to update.
  46140. * @param mesh the mesh we are preparing the defines for.
  46141. * @param scene defines the scene the material belongs to.
  46142. */
  46143. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46144. /**
  46145. * Binds the material data.
  46146. * @param uniformBuffer defines the Uniform buffer to fill in.
  46147. * @param scene defines the scene the material belongs to.
  46148. * @param isFrozen defines wether the material is frozen or not.
  46149. */
  46150. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46151. /**
  46152. * Checks to see if a texture is used in the material.
  46153. * @param texture - Base texture to use.
  46154. * @returns - Boolean specifying if a texture is used in the material.
  46155. */
  46156. hasTexture(texture: BaseTexture): boolean;
  46157. /**
  46158. * Returns an array of the actively used textures.
  46159. * @param activeTextures Array of BaseTextures
  46160. */
  46161. getActiveTextures(activeTextures: BaseTexture[]): void;
  46162. /**
  46163. * Returns the animatable textures.
  46164. * @param animatables Array of animatable textures.
  46165. */
  46166. getAnimatables(animatables: IAnimatable[]): void;
  46167. /**
  46168. * Disposes the resources of the material.
  46169. * @param forceDisposeTextures - Forces the disposal of all textures.
  46170. */
  46171. dispose(forceDisposeTextures?: boolean): void;
  46172. /**
  46173. * Get the current class name of the texture useful for serialization or dynamic coding.
  46174. * @returns "PBRAnisotropicConfiguration"
  46175. */
  46176. getClassName(): string;
  46177. /**
  46178. * Add fallbacks to the effect fallbacks list.
  46179. * @param defines defines the Base texture to use.
  46180. * @param fallbacks defines the current fallback list.
  46181. * @param currentRank defines the current fallback rank.
  46182. * @returns the new fallback rank.
  46183. */
  46184. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46185. /**
  46186. * Add the required uniforms to the current list.
  46187. * @param uniforms defines the current uniform list.
  46188. */
  46189. static AddUniforms(uniforms: string[]): void;
  46190. /**
  46191. * Add the required uniforms to the current buffer.
  46192. * @param uniformBuffer defines the current uniform buffer.
  46193. */
  46194. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46195. /**
  46196. * Add the required samplers to the current list.
  46197. * @param samplers defines the current sampler list.
  46198. */
  46199. static AddSamplers(samplers: string[]): void;
  46200. /**
  46201. * Makes a duplicate of the current configuration into another one.
  46202. * @param anisotropicConfiguration define the config where to copy the info
  46203. */
  46204. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46205. /**
  46206. * Serializes this anisotropy configuration.
  46207. * @returns - An object with the serialized config.
  46208. */
  46209. serialize(): any;
  46210. /**
  46211. * Parses a anisotropy Configuration from a serialized object.
  46212. * @param source - Serialized object.
  46213. * @param scene Defines the scene we are parsing for
  46214. * @param rootUrl Defines the rootUrl to load from
  46215. */
  46216. parse(source: any, scene: Scene, rootUrl: string): void;
  46217. }
  46218. }
  46219. declare module BABYLON {
  46220. /**
  46221. * @hidden
  46222. */
  46223. export interface IMaterialBRDFDefines {
  46224. BRDF_V_HEIGHT_CORRELATED: boolean;
  46225. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46226. SPHERICAL_HARMONICS: boolean;
  46227. /** @hidden */
  46228. _areMiscDirty: boolean;
  46229. }
  46230. /**
  46231. * Define the code related to the BRDF parameters of the pbr material.
  46232. */
  46233. export class PBRBRDFConfiguration {
  46234. /**
  46235. * Default value used for the energy conservation.
  46236. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46237. */
  46238. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46239. /**
  46240. * Default value used for the Smith Visibility Height Correlated mode.
  46241. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46242. */
  46243. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46244. /**
  46245. * Default value used for the IBL diffuse part.
  46246. * This can help switching back to the polynomials mode globally which is a tiny bit
  46247. * less GPU intensive at the drawback of a lower quality.
  46248. */
  46249. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46250. private _useEnergyConservation;
  46251. /**
  46252. * Defines if the material uses energy conservation.
  46253. */
  46254. useEnergyConservation: boolean;
  46255. private _useSmithVisibilityHeightCorrelated;
  46256. /**
  46257. * LEGACY Mode set to false
  46258. * Defines if the material uses height smith correlated visibility term.
  46259. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46260. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46261. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46262. * Not relying on height correlated will also disable energy conservation.
  46263. */
  46264. useSmithVisibilityHeightCorrelated: boolean;
  46265. private _useSphericalHarmonics;
  46266. /**
  46267. * LEGACY Mode set to false
  46268. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46269. * diffuse part of the IBL.
  46270. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46271. * to the ground truth.
  46272. */
  46273. useSphericalHarmonics: boolean;
  46274. /** @hidden */
  46275. private _internalMarkAllSubMeshesAsMiscDirty;
  46276. /** @hidden */
  46277. _markAllSubMeshesAsMiscDirty(): void;
  46278. /**
  46279. * Instantiate a new istance of clear coat configuration.
  46280. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46281. */
  46282. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46283. /**
  46284. * Checks to see if a texture is used in the material.
  46285. * @param defines the list of "defines" to update.
  46286. */
  46287. prepareDefines(defines: IMaterialBRDFDefines): void;
  46288. /**
  46289. * Get the current class name of the texture useful for serialization or dynamic coding.
  46290. * @returns "PBRClearCoatConfiguration"
  46291. */
  46292. getClassName(): string;
  46293. /**
  46294. * Makes a duplicate of the current configuration into another one.
  46295. * @param brdfConfiguration define the config where to copy the info
  46296. */
  46297. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46298. /**
  46299. * Serializes this BRDF configuration.
  46300. * @returns - An object with the serialized config.
  46301. */
  46302. serialize(): any;
  46303. /**
  46304. * Parses a anisotropy Configuration from a serialized object.
  46305. * @param source - Serialized object.
  46306. * @param scene Defines the scene we are parsing for
  46307. * @param rootUrl Defines the rootUrl to load from
  46308. */
  46309. parse(source: any, scene: Scene, rootUrl: string): void;
  46310. }
  46311. }
  46312. declare module BABYLON {
  46313. /**
  46314. * @hidden
  46315. */
  46316. export interface IMaterialSheenDefines {
  46317. SHEEN: boolean;
  46318. SHEEN_TEXTURE: boolean;
  46319. SHEEN_TEXTUREDIRECTUV: number;
  46320. SHEEN_LINKWITHALBEDO: boolean;
  46321. /** @hidden */
  46322. _areTexturesDirty: boolean;
  46323. }
  46324. /**
  46325. * Define the code related to the Sheen parameters of the pbr material.
  46326. */
  46327. export class PBRSheenConfiguration {
  46328. private _isEnabled;
  46329. /**
  46330. * Defines if the material uses sheen.
  46331. */
  46332. isEnabled: boolean;
  46333. private _linkSheenWithAlbedo;
  46334. /**
  46335. * Defines if the sheen is linked to the sheen color.
  46336. */
  46337. linkSheenWithAlbedo: boolean;
  46338. /**
  46339. * Defines the sheen intensity.
  46340. */
  46341. intensity: number;
  46342. /**
  46343. * Defines the sheen color.
  46344. */
  46345. color: Color3;
  46346. private _texture;
  46347. /**
  46348. * Stores the sheen tint values in a texture.
  46349. * rgb is tint
  46350. * a is a intensity
  46351. */
  46352. texture: Nullable<BaseTexture>;
  46353. /** @hidden */
  46354. private _internalMarkAllSubMeshesAsTexturesDirty;
  46355. /** @hidden */
  46356. _markAllSubMeshesAsTexturesDirty(): void;
  46357. /**
  46358. * Instantiate a new istance of clear coat configuration.
  46359. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46360. */
  46361. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46362. /**
  46363. * Specifies that the submesh is ready to be used.
  46364. * @param defines the list of "defines" to update.
  46365. * @param scene defines the scene the material belongs to.
  46366. * @returns - boolean indicating that the submesh is ready or not.
  46367. */
  46368. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46369. /**
  46370. * Checks to see if a texture is used in the material.
  46371. * @param defines the list of "defines" to update.
  46372. * @param scene defines the scene the material belongs to.
  46373. */
  46374. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46375. /**
  46376. * Binds the material data.
  46377. * @param uniformBuffer defines the Uniform buffer to fill in.
  46378. * @param scene defines the scene the material belongs to.
  46379. * @param isFrozen defines wether the material is frozen or not.
  46380. */
  46381. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46382. /**
  46383. * Checks to see if a texture is used in the material.
  46384. * @param texture - Base texture to use.
  46385. * @returns - Boolean specifying if a texture is used in the material.
  46386. */
  46387. hasTexture(texture: BaseTexture): boolean;
  46388. /**
  46389. * Returns an array of the actively used textures.
  46390. * @param activeTextures Array of BaseTextures
  46391. */
  46392. getActiveTextures(activeTextures: BaseTexture[]): void;
  46393. /**
  46394. * Returns the animatable textures.
  46395. * @param animatables Array of animatable textures.
  46396. */
  46397. getAnimatables(animatables: IAnimatable[]): void;
  46398. /**
  46399. * Disposes the resources of the material.
  46400. * @param forceDisposeTextures - Forces the disposal of all textures.
  46401. */
  46402. dispose(forceDisposeTextures?: boolean): void;
  46403. /**
  46404. * Get the current class name of the texture useful for serialization or dynamic coding.
  46405. * @returns "PBRSheenConfiguration"
  46406. */
  46407. getClassName(): string;
  46408. /**
  46409. * Add fallbacks to the effect fallbacks list.
  46410. * @param defines defines the Base texture to use.
  46411. * @param fallbacks defines the current fallback list.
  46412. * @param currentRank defines the current fallback rank.
  46413. * @returns the new fallback rank.
  46414. */
  46415. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46416. /**
  46417. * Add the required uniforms to the current list.
  46418. * @param uniforms defines the current uniform list.
  46419. */
  46420. static AddUniforms(uniforms: string[]): void;
  46421. /**
  46422. * Add the required uniforms to the current buffer.
  46423. * @param uniformBuffer defines the current uniform buffer.
  46424. */
  46425. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46426. /**
  46427. * Add the required samplers to the current list.
  46428. * @param samplers defines the current sampler list.
  46429. */
  46430. static AddSamplers(samplers: string[]): void;
  46431. /**
  46432. * Makes a duplicate of the current configuration into another one.
  46433. * @param sheenConfiguration define the config where to copy the info
  46434. */
  46435. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46436. /**
  46437. * Serializes this BRDF configuration.
  46438. * @returns - An object with the serialized config.
  46439. */
  46440. serialize(): any;
  46441. /**
  46442. * Parses a anisotropy Configuration from a serialized object.
  46443. * @param source - Serialized object.
  46444. * @param scene Defines the scene we are parsing for
  46445. * @param rootUrl Defines the rootUrl to load from
  46446. */
  46447. parse(source: any, scene: Scene, rootUrl: string): void;
  46448. }
  46449. }
  46450. declare module BABYLON {
  46451. /**
  46452. * @hidden
  46453. */
  46454. export interface IMaterialSubSurfaceDefines {
  46455. SUBSURFACE: boolean;
  46456. SS_REFRACTION: boolean;
  46457. SS_TRANSLUCENCY: boolean;
  46458. SS_SCATERRING: boolean;
  46459. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46460. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46461. SS_REFRACTIONMAP_3D: boolean;
  46462. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46463. SS_LODINREFRACTIONALPHA: boolean;
  46464. SS_GAMMAREFRACTION: boolean;
  46465. SS_RGBDREFRACTION: boolean;
  46466. SS_LINEARSPECULARREFRACTION: boolean;
  46467. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46468. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46469. /** @hidden */
  46470. _areTexturesDirty: boolean;
  46471. }
  46472. /**
  46473. * Define the code related to the sub surface parameters of the pbr material.
  46474. */
  46475. export class PBRSubSurfaceConfiguration {
  46476. private _isRefractionEnabled;
  46477. /**
  46478. * Defines if the refraction is enabled in the material.
  46479. */
  46480. isRefractionEnabled: boolean;
  46481. private _isTranslucencyEnabled;
  46482. /**
  46483. * Defines if the translucency is enabled in the material.
  46484. */
  46485. isTranslucencyEnabled: boolean;
  46486. private _isScatteringEnabled;
  46487. /**
  46488. * Defines the refraction intensity of the material.
  46489. * The refraction when enabled replaces the Diffuse part of the material.
  46490. * The intensity helps transitionning between diffuse and refraction.
  46491. */
  46492. refractionIntensity: number;
  46493. /**
  46494. * Defines the translucency intensity of the material.
  46495. * When translucency has been enabled, this defines how much of the "translucency"
  46496. * is addded to the diffuse part of the material.
  46497. */
  46498. translucencyIntensity: number;
  46499. /**
  46500. * Defines the scattering intensity of the material.
  46501. * When scattering has been enabled, this defines how much of the "scattered light"
  46502. * is addded to the diffuse part of the material.
  46503. */
  46504. scatteringIntensity: number;
  46505. private _thicknessTexture;
  46506. /**
  46507. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  46508. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  46509. * 0 would mean minimumThickness
  46510. * 1 would mean maximumThickness
  46511. * The other channels might be use as a mask to vary the different effects intensity.
  46512. */
  46513. thicknessTexture: Nullable<BaseTexture>;
  46514. private _refractionTexture;
  46515. /**
  46516. * Defines the texture to use for refraction.
  46517. */
  46518. refractionTexture: Nullable<BaseTexture>;
  46519. private _indexOfRefraction;
  46520. /**
  46521. * Defines the index of refraction used in the material.
  46522. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  46523. */
  46524. indexOfRefraction: number;
  46525. private _invertRefractionY;
  46526. /**
  46527. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46528. */
  46529. invertRefractionY: boolean;
  46530. private _linkRefractionWithTransparency;
  46531. /**
  46532. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46533. * Materials half opaque for instance using refraction could benefit from this control.
  46534. */
  46535. linkRefractionWithTransparency: boolean;
  46536. /**
  46537. * Defines the minimum thickness stored in the thickness map.
  46538. * If no thickness map is defined, this value will be used to simulate thickness.
  46539. */
  46540. minimumThickness: number;
  46541. /**
  46542. * Defines the maximum thickness stored in the thickness map.
  46543. */
  46544. maximumThickness: number;
  46545. /**
  46546. * Defines the volume tint of the material.
  46547. * This is used for both translucency and scattering.
  46548. */
  46549. tintColor: Color3;
  46550. /**
  46551. * Defines the distance at which the tint color should be found in the media.
  46552. * This is used for refraction only.
  46553. */
  46554. tintColorAtDistance: number;
  46555. /**
  46556. * Defines how far each channel transmit through the media.
  46557. * It is defined as a color to simplify it selection.
  46558. */
  46559. diffusionDistance: Color3;
  46560. private _useMaskFromThicknessTexture;
  46561. /**
  46562. * Stores the intensity of the different subsurface effects in the thickness texture.
  46563. * * the green channel is the translucency intensity.
  46564. * * the blue channel is the scattering intensity.
  46565. * * the alpha channel is the refraction intensity.
  46566. */
  46567. useMaskFromThicknessTexture: boolean;
  46568. /** @hidden */
  46569. private _internalMarkAllSubMeshesAsTexturesDirty;
  46570. /** @hidden */
  46571. _markAllSubMeshesAsTexturesDirty(): void;
  46572. /**
  46573. * Instantiate a new istance of sub surface configuration.
  46574. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46575. */
  46576. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46577. /**
  46578. * Gets wehter the submesh is ready to be used or not.
  46579. * @param defines the list of "defines" to update.
  46580. * @param scene defines the scene the material belongs to.
  46581. * @returns - boolean indicating that the submesh is ready or not.
  46582. */
  46583. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46584. /**
  46585. * Checks to see if a texture is used in the material.
  46586. * @param defines the list of "defines" to update.
  46587. * @param scene defines the scene to the material belongs to.
  46588. */
  46589. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46590. /**
  46591. * Binds the material data.
  46592. * @param uniformBuffer defines the Uniform buffer to fill in.
  46593. * @param scene defines the scene the material belongs to.
  46594. * @param engine defines the engine the material belongs to.
  46595. * @param isFrozen defines wether the material is frozen or not.
  46596. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46597. */
  46598. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46599. /**
  46600. * Unbinds the material from the mesh.
  46601. * @param activeEffect defines the effect that should be unbound from.
  46602. * @returns true if unbound, otherwise false
  46603. */
  46604. unbind(activeEffect: Effect): boolean;
  46605. /**
  46606. * Returns the texture used for refraction or null if none is used.
  46607. * @param scene defines the scene the material belongs to.
  46608. * @returns - Refraction texture if present. If no refraction texture and refraction
  46609. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46610. */
  46611. private _getRefractionTexture;
  46612. /**
  46613. * Returns true if alpha blending should be disabled.
  46614. */
  46615. readonly disableAlphaBlending: boolean;
  46616. /**
  46617. * Fills the list of render target textures.
  46618. * @param renderTargets the list of render targets to update
  46619. */
  46620. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46621. /**
  46622. * Checks to see if a texture is used in the material.
  46623. * @param texture - Base texture to use.
  46624. * @returns - Boolean specifying if a texture is used in the material.
  46625. */
  46626. hasTexture(texture: BaseTexture): boolean;
  46627. /**
  46628. * Gets a boolean indicating that current material needs to register RTT
  46629. * @returns true if this uses a render target otherwise false.
  46630. */
  46631. hasRenderTargetTextures(): boolean;
  46632. /**
  46633. * Returns an array of the actively used textures.
  46634. * @param activeTextures Array of BaseTextures
  46635. */
  46636. getActiveTextures(activeTextures: BaseTexture[]): void;
  46637. /**
  46638. * Returns the animatable textures.
  46639. * @param animatables Array of animatable textures.
  46640. */
  46641. getAnimatables(animatables: IAnimatable[]): void;
  46642. /**
  46643. * Disposes the resources of the material.
  46644. * @param forceDisposeTextures - Forces the disposal of all textures.
  46645. */
  46646. dispose(forceDisposeTextures?: boolean): void;
  46647. /**
  46648. * Get the current class name of the texture useful for serialization or dynamic coding.
  46649. * @returns "PBRSubSurfaceConfiguration"
  46650. */
  46651. getClassName(): string;
  46652. /**
  46653. * Add fallbacks to the effect fallbacks list.
  46654. * @param defines defines the Base texture to use.
  46655. * @param fallbacks defines the current fallback list.
  46656. * @param currentRank defines the current fallback rank.
  46657. * @returns the new fallback rank.
  46658. */
  46659. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46660. /**
  46661. * Add the required uniforms to the current list.
  46662. * @param uniforms defines the current uniform list.
  46663. */
  46664. static AddUniforms(uniforms: string[]): void;
  46665. /**
  46666. * Add the required samplers to the current list.
  46667. * @param samplers defines the current sampler list.
  46668. */
  46669. static AddSamplers(samplers: string[]): void;
  46670. /**
  46671. * Add the required uniforms to the current buffer.
  46672. * @param uniformBuffer defines the current uniform buffer.
  46673. */
  46674. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46675. /**
  46676. * Makes a duplicate of the current configuration into another one.
  46677. * @param configuration define the config where to copy the info
  46678. */
  46679. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46680. /**
  46681. * Serializes this Sub Surface configuration.
  46682. * @returns - An object with the serialized config.
  46683. */
  46684. serialize(): any;
  46685. /**
  46686. * Parses a anisotropy Configuration from a serialized object.
  46687. * @param source - Serialized object.
  46688. * @param scene Defines the scene we are parsing for
  46689. * @param rootUrl Defines the rootUrl to load from
  46690. */
  46691. parse(source: any, scene: Scene, rootUrl: string): void;
  46692. }
  46693. }
  46694. declare module BABYLON {
  46695. /** @hidden */
  46696. export var pbrFragmentDeclaration: {
  46697. name: string;
  46698. shader: string;
  46699. };
  46700. }
  46701. declare module BABYLON {
  46702. /** @hidden */
  46703. export var pbrUboDeclaration: {
  46704. name: string;
  46705. shader: string;
  46706. };
  46707. }
  46708. declare module BABYLON {
  46709. /** @hidden */
  46710. export var pbrFragmentExtraDeclaration: {
  46711. name: string;
  46712. shader: string;
  46713. };
  46714. }
  46715. declare module BABYLON {
  46716. /** @hidden */
  46717. export var pbrFragmentSamplersDeclaration: {
  46718. name: string;
  46719. shader: string;
  46720. };
  46721. }
  46722. declare module BABYLON {
  46723. /** @hidden */
  46724. export var pbrHelperFunctions: {
  46725. name: string;
  46726. shader: string;
  46727. };
  46728. }
  46729. declare module BABYLON {
  46730. /** @hidden */
  46731. export var harmonicsFunctions: {
  46732. name: string;
  46733. shader: string;
  46734. };
  46735. }
  46736. declare module BABYLON {
  46737. /** @hidden */
  46738. export var pbrDirectLightingSetupFunctions: {
  46739. name: string;
  46740. shader: string;
  46741. };
  46742. }
  46743. declare module BABYLON {
  46744. /** @hidden */
  46745. export var pbrDirectLightingFalloffFunctions: {
  46746. name: string;
  46747. shader: string;
  46748. };
  46749. }
  46750. declare module BABYLON {
  46751. /** @hidden */
  46752. export var pbrBRDFFunctions: {
  46753. name: string;
  46754. shader: string;
  46755. };
  46756. }
  46757. declare module BABYLON {
  46758. /** @hidden */
  46759. export var pbrDirectLightingFunctions: {
  46760. name: string;
  46761. shader: string;
  46762. };
  46763. }
  46764. declare module BABYLON {
  46765. /** @hidden */
  46766. export var pbrIBLFunctions: {
  46767. name: string;
  46768. shader: string;
  46769. };
  46770. }
  46771. declare module BABYLON {
  46772. /** @hidden */
  46773. export var pbrDebug: {
  46774. name: string;
  46775. shader: string;
  46776. };
  46777. }
  46778. declare module BABYLON {
  46779. /** @hidden */
  46780. export var pbrPixelShader: {
  46781. name: string;
  46782. shader: string;
  46783. };
  46784. }
  46785. declare module BABYLON {
  46786. /** @hidden */
  46787. export var pbrVertexDeclaration: {
  46788. name: string;
  46789. shader: string;
  46790. };
  46791. }
  46792. declare module BABYLON {
  46793. /** @hidden */
  46794. export var pbrVertexShader: {
  46795. name: string;
  46796. shader: string;
  46797. };
  46798. }
  46799. declare module BABYLON {
  46800. /**
  46801. * Manages the defines for the PBR Material.
  46802. * @hidden
  46803. */
  46804. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46805. PBR: boolean;
  46806. MAINUV1: boolean;
  46807. MAINUV2: boolean;
  46808. UV1: boolean;
  46809. UV2: boolean;
  46810. ALBEDO: boolean;
  46811. ALBEDODIRECTUV: number;
  46812. VERTEXCOLOR: boolean;
  46813. AMBIENT: boolean;
  46814. AMBIENTDIRECTUV: number;
  46815. AMBIENTINGRAYSCALE: boolean;
  46816. OPACITY: boolean;
  46817. VERTEXALPHA: boolean;
  46818. OPACITYDIRECTUV: number;
  46819. OPACITYRGB: boolean;
  46820. ALPHATEST: boolean;
  46821. DEPTHPREPASS: boolean;
  46822. ALPHABLEND: boolean;
  46823. ALPHAFROMALBEDO: boolean;
  46824. ALPHATESTVALUE: string;
  46825. SPECULAROVERALPHA: boolean;
  46826. RADIANCEOVERALPHA: boolean;
  46827. ALPHAFRESNEL: boolean;
  46828. LINEARALPHAFRESNEL: boolean;
  46829. PREMULTIPLYALPHA: boolean;
  46830. EMISSIVE: boolean;
  46831. EMISSIVEDIRECTUV: number;
  46832. REFLECTIVITY: boolean;
  46833. REFLECTIVITYDIRECTUV: number;
  46834. SPECULARTERM: boolean;
  46835. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46836. MICROSURFACEAUTOMATIC: boolean;
  46837. LODBASEDMICROSFURACE: boolean;
  46838. MICROSURFACEMAP: boolean;
  46839. MICROSURFACEMAPDIRECTUV: number;
  46840. METALLICWORKFLOW: boolean;
  46841. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46842. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46843. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46844. AOSTOREINMETALMAPRED: boolean;
  46845. ENVIRONMENTBRDF: boolean;
  46846. ENVIRONMENTBRDF_RGBD: boolean;
  46847. NORMAL: boolean;
  46848. TANGENT: boolean;
  46849. BUMP: boolean;
  46850. BUMPDIRECTUV: number;
  46851. OBJECTSPACE_NORMALMAP: boolean;
  46852. PARALLAX: boolean;
  46853. PARALLAXOCCLUSION: boolean;
  46854. NORMALXYSCALE: boolean;
  46855. LIGHTMAP: boolean;
  46856. LIGHTMAPDIRECTUV: number;
  46857. USELIGHTMAPASSHADOWMAP: boolean;
  46858. GAMMALIGHTMAP: boolean;
  46859. REFLECTION: boolean;
  46860. REFLECTIONMAP_3D: boolean;
  46861. REFLECTIONMAP_SPHERICAL: boolean;
  46862. REFLECTIONMAP_PLANAR: boolean;
  46863. REFLECTIONMAP_CUBIC: boolean;
  46864. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46865. REFLECTIONMAP_PROJECTION: boolean;
  46866. REFLECTIONMAP_SKYBOX: boolean;
  46867. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46868. REFLECTIONMAP_EXPLICIT: boolean;
  46869. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46870. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46871. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46872. INVERTCUBICMAP: boolean;
  46873. USESPHERICALFROMREFLECTIONMAP: boolean;
  46874. USEIRRADIANCEMAP: boolean;
  46875. SPHERICAL_HARMONICS: boolean;
  46876. USESPHERICALINVERTEX: boolean;
  46877. REFLECTIONMAP_OPPOSITEZ: boolean;
  46878. LODINREFLECTIONALPHA: boolean;
  46879. GAMMAREFLECTION: boolean;
  46880. RGBDREFLECTION: boolean;
  46881. LINEARSPECULARREFLECTION: boolean;
  46882. RADIANCEOCCLUSION: boolean;
  46883. HORIZONOCCLUSION: boolean;
  46884. INSTANCES: boolean;
  46885. NUM_BONE_INFLUENCERS: number;
  46886. BonesPerMesh: number;
  46887. BONETEXTURE: boolean;
  46888. NONUNIFORMSCALING: boolean;
  46889. MORPHTARGETS: boolean;
  46890. MORPHTARGETS_NORMAL: boolean;
  46891. MORPHTARGETS_TANGENT: boolean;
  46892. MORPHTARGETS_UV: boolean;
  46893. NUM_MORPH_INFLUENCERS: number;
  46894. IMAGEPROCESSING: boolean;
  46895. VIGNETTE: boolean;
  46896. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46897. VIGNETTEBLENDMODEOPAQUE: boolean;
  46898. TONEMAPPING: boolean;
  46899. TONEMAPPING_ACES: boolean;
  46900. CONTRAST: boolean;
  46901. COLORCURVES: boolean;
  46902. COLORGRADING: boolean;
  46903. COLORGRADING3D: boolean;
  46904. SAMPLER3DGREENDEPTH: boolean;
  46905. SAMPLER3DBGRMAP: boolean;
  46906. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46907. EXPOSURE: boolean;
  46908. MULTIVIEW: boolean;
  46909. USEPHYSICALLIGHTFALLOFF: boolean;
  46910. USEGLTFLIGHTFALLOFF: boolean;
  46911. TWOSIDEDLIGHTING: boolean;
  46912. SHADOWFLOAT: boolean;
  46913. CLIPPLANE: boolean;
  46914. CLIPPLANE2: boolean;
  46915. CLIPPLANE3: boolean;
  46916. CLIPPLANE4: boolean;
  46917. POINTSIZE: boolean;
  46918. FOG: boolean;
  46919. LOGARITHMICDEPTH: boolean;
  46920. FORCENORMALFORWARD: boolean;
  46921. SPECULARAA: boolean;
  46922. CLEARCOAT: boolean;
  46923. CLEARCOAT_DEFAULTIOR: boolean;
  46924. CLEARCOAT_TEXTURE: boolean;
  46925. CLEARCOAT_TEXTUREDIRECTUV: number;
  46926. CLEARCOAT_BUMP: boolean;
  46927. CLEARCOAT_BUMPDIRECTUV: number;
  46928. CLEARCOAT_TINT: boolean;
  46929. CLEARCOAT_TINT_TEXTURE: boolean;
  46930. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46931. ANISOTROPIC: boolean;
  46932. ANISOTROPIC_TEXTURE: boolean;
  46933. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46934. BRDF_V_HEIGHT_CORRELATED: boolean;
  46935. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46936. SHEEN: boolean;
  46937. SHEEN_TEXTURE: boolean;
  46938. SHEEN_TEXTUREDIRECTUV: number;
  46939. SHEEN_LINKWITHALBEDO: boolean;
  46940. SUBSURFACE: boolean;
  46941. SS_REFRACTION: boolean;
  46942. SS_TRANSLUCENCY: boolean;
  46943. SS_SCATERRING: boolean;
  46944. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46945. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46946. SS_REFRACTIONMAP_3D: boolean;
  46947. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46948. SS_LODINREFRACTIONALPHA: boolean;
  46949. SS_GAMMAREFRACTION: boolean;
  46950. SS_RGBDREFRACTION: boolean;
  46951. SS_LINEARSPECULARREFRACTION: boolean;
  46952. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46953. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46954. UNLIT: boolean;
  46955. DEBUGMODE: number;
  46956. /**
  46957. * Initializes the PBR Material defines.
  46958. */
  46959. constructor();
  46960. /**
  46961. * Resets the PBR Material defines.
  46962. */
  46963. reset(): void;
  46964. }
  46965. /**
  46966. * The Physically based material base class of BJS.
  46967. *
  46968. * This offers the main features of a standard PBR material.
  46969. * For more information, please refer to the documentation :
  46970. * https://doc.babylonjs.com/how_to/physically_based_rendering
  46971. */
  46972. export abstract class PBRBaseMaterial extends PushMaterial {
  46973. /**
  46974. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46975. */
  46976. static readonly PBRMATERIAL_OPAQUE: number;
  46977. /**
  46978. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46979. */
  46980. static readonly PBRMATERIAL_ALPHATEST: number;
  46981. /**
  46982. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46983. */
  46984. static readonly PBRMATERIAL_ALPHABLEND: number;
  46985. /**
  46986. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46987. * They are also discarded below the alpha cutoff threshold to improve performances.
  46988. */
  46989. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46990. /**
  46991. * Defines the default value of how much AO map is occluding the analytical lights
  46992. * (point spot...).
  46993. */
  46994. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46995. /**
  46996. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  46997. */
  46998. static readonly LIGHTFALLOFF_PHYSICAL: number;
  46999. /**
  47000. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47001. * to enhance interoperability with other engines.
  47002. */
  47003. static readonly LIGHTFALLOFF_GLTF: number;
  47004. /**
  47005. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47006. * to enhance interoperability with other materials.
  47007. */
  47008. static readonly LIGHTFALLOFF_STANDARD: number;
  47009. /**
  47010. * Intensity of the direct lights e.g. the four lights available in your scene.
  47011. * This impacts both the direct diffuse and specular highlights.
  47012. */
  47013. protected _directIntensity: number;
  47014. /**
  47015. * Intensity of the emissive part of the material.
  47016. * This helps controlling the emissive effect without modifying the emissive color.
  47017. */
  47018. protected _emissiveIntensity: number;
  47019. /**
  47020. * Intensity of the environment e.g. how much the environment will light the object
  47021. * either through harmonics for rough material or through the refelction for shiny ones.
  47022. */
  47023. protected _environmentIntensity: number;
  47024. /**
  47025. * This is a special control allowing the reduction of the specular highlights coming from the
  47026. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47027. */
  47028. protected _specularIntensity: number;
  47029. /**
  47030. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47031. */
  47032. private _lightingInfos;
  47033. /**
  47034. * Debug Control allowing disabling the bump map on this material.
  47035. */
  47036. protected _disableBumpMap: boolean;
  47037. /**
  47038. * AKA Diffuse Texture in standard nomenclature.
  47039. */
  47040. protected _albedoTexture: Nullable<BaseTexture>;
  47041. /**
  47042. * AKA Occlusion Texture in other nomenclature.
  47043. */
  47044. protected _ambientTexture: Nullable<BaseTexture>;
  47045. /**
  47046. * AKA Occlusion Texture Intensity in other nomenclature.
  47047. */
  47048. protected _ambientTextureStrength: number;
  47049. /**
  47050. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47051. * 1 means it completely occludes it
  47052. * 0 mean it has no impact
  47053. */
  47054. protected _ambientTextureImpactOnAnalyticalLights: number;
  47055. /**
  47056. * Stores the alpha values in a texture.
  47057. */
  47058. protected _opacityTexture: Nullable<BaseTexture>;
  47059. /**
  47060. * Stores the reflection values in a texture.
  47061. */
  47062. protected _reflectionTexture: Nullable<BaseTexture>;
  47063. /**
  47064. * Stores the emissive values in a texture.
  47065. */
  47066. protected _emissiveTexture: Nullable<BaseTexture>;
  47067. /**
  47068. * AKA Specular texture in other nomenclature.
  47069. */
  47070. protected _reflectivityTexture: Nullable<BaseTexture>;
  47071. /**
  47072. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47073. */
  47074. protected _metallicTexture: Nullable<BaseTexture>;
  47075. /**
  47076. * Specifies the metallic scalar of the metallic/roughness workflow.
  47077. * Can also be used to scale the metalness values of the metallic texture.
  47078. */
  47079. protected _metallic: Nullable<number>;
  47080. /**
  47081. * Specifies the roughness scalar of the metallic/roughness workflow.
  47082. * Can also be used to scale the roughness values of the metallic texture.
  47083. */
  47084. protected _roughness: Nullable<number>;
  47085. /**
  47086. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47087. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47088. */
  47089. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47090. /**
  47091. * Stores surface normal data used to displace a mesh in a texture.
  47092. */
  47093. protected _bumpTexture: Nullable<BaseTexture>;
  47094. /**
  47095. * Stores the pre-calculated light information of a mesh in a texture.
  47096. */
  47097. protected _lightmapTexture: Nullable<BaseTexture>;
  47098. /**
  47099. * The color of a material in ambient lighting.
  47100. */
  47101. protected _ambientColor: Color3;
  47102. /**
  47103. * AKA Diffuse Color in other nomenclature.
  47104. */
  47105. protected _albedoColor: Color3;
  47106. /**
  47107. * AKA Specular Color in other nomenclature.
  47108. */
  47109. protected _reflectivityColor: Color3;
  47110. /**
  47111. * The color applied when light is reflected from a material.
  47112. */
  47113. protected _reflectionColor: Color3;
  47114. /**
  47115. * The color applied when light is emitted from a material.
  47116. */
  47117. protected _emissiveColor: Color3;
  47118. /**
  47119. * AKA Glossiness in other nomenclature.
  47120. */
  47121. protected _microSurface: number;
  47122. /**
  47123. * Specifies that the material will use the light map as a show map.
  47124. */
  47125. protected _useLightmapAsShadowmap: boolean;
  47126. /**
  47127. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47128. * makes the reflect vector face the model (under horizon).
  47129. */
  47130. protected _useHorizonOcclusion: boolean;
  47131. /**
  47132. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47133. * too much the area relying on ambient texture to define their ambient occlusion.
  47134. */
  47135. protected _useRadianceOcclusion: boolean;
  47136. /**
  47137. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47138. */
  47139. protected _useAlphaFromAlbedoTexture: boolean;
  47140. /**
  47141. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47142. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47143. */
  47144. protected _useSpecularOverAlpha: boolean;
  47145. /**
  47146. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47147. */
  47148. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47149. /**
  47150. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47151. */
  47152. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47153. /**
  47154. * Specifies if the metallic texture contains the roughness information in its green channel.
  47155. */
  47156. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47157. /**
  47158. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47159. */
  47160. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47161. /**
  47162. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47163. */
  47164. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47165. /**
  47166. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47167. */
  47168. protected _useAmbientInGrayScale: boolean;
  47169. /**
  47170. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47171. * The material will try to infer what glossiness each pixel should be.
  47172. */
  47173. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47174. /**
  47175. * Defines the falloff type used in this material.
  47176. * It by default is Physical.
  47177. */
  47178. protected _lightFalloff: number;
  47179. /**
  47180. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47181. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47182. */
  47183. protected _useRadianceOverAlpha: boolean;
  47184. /**
  47185. * Allows using an object space normal map (instead of tangent space).
  47186. */
  47187. protected _useObjectSpaceNormalMap: boolean;
  47188. /**
  47189. * Allows using the bump map in parallax mode.
  47190. */
  47191. protected _useParallax: boolean;
  47192. /**
  47193. * Allows using the bump map in parallax occlusion mode.
  47194. */
  47195. protected _useParallaxOcclusion: boolean;
  47196. /**
  47197. * Controls the scale bias of the parallax mode.
  47198. */
  47199. protected _parallaxScaleBias: number;
  47200. /**
  47201. * If sets to true, disables all the lights affecting the material.
  47202. */
  47203. protected _disableLighting: boolean;
  47204. /**
  47205. * Number of Simultaneous lights allowed on the material.
  47206. */
  47207. protected _maxSimultaneousLights: number;
  47208. /**
  47209. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47210. */
  47211. protected _invertNormalMapX: boolean;
  47212. /**
  47213. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47214. */
  47215. protected _invertNormalMapY: boolean;
  47216. /**
  47217. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47218. */
  47219. protected _twoSidedLighting: boolean;
  47220. /**
  47221. * Defines the alpha limits in alpha test mode.
  47222. */
  47223. protected _alphaCutOff: number;
  47224. /**
  47225. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47226. */
  47227. protected _forceAlphaTest: boolean;
  47228. /**
  47229. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47230. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47231. */
  47232. protected _useAlphaFresnel: boolean;
  47233. /**
  47234. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47235. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47236. */
  47237. protected _useLinearAlphaFresnel: boolean;
  47238. /**
  47239. * The transparency mode of the material.
  47240. */
  47241. protected _transparencyMode: Nullable<number>;
  47242. /**
  47243. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47244. * from cos thetav and roughness:
  47245. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47246. */
  47247. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47248. /**
  47249. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47250. */
  47251. protected _forceIrradianceInFragment: boolean;
  47252. /**
  47253. * Force normal to face away from face.
  47254. */
  47255. protected _forceNormalForward: boolean;
  47256. /**
  47257. * Enables specular anti aliasing in the PBR shader.
  47258. * It will both interacts on the Geometry for analytical and IBL lighting.
  47259. * It also prefilter the roughness map based on the bump values.
  47260. */
  47261. protected _enableSpecularAntiAliasing: boolean;
  47262. /**
  47263. * Default configuration related to image processing available in the PBR Material.
  47264. */
  47265. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47266. /**
  47267. * Keep track of the image processing observer to allow dispose and replace.
  47268. */
  47269. private _imageProcessingObserver;
  47270. /**
  47271. * Attaches a new image processing configuration to the PBR Material.
  47272. * @param configuration
  47273. */
  47274. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47275. /**
  47276. * Stores the available render targets.
  47277. */
  47278. private _renderTargets;
  47279. /**
  47280. * Sets the global ambient color for the material used in lighting calculations.
  47281. */
  47282. private _globalAmbientColor;
  47283. /**
  47284. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47285. */
  47286. private _useLogarithmicDepth;
  47287. /**
  47288. * If set to true, no lighting calculations will be applied.
  47289. */
  47290. private _unlit;
  47291. private _debugMode;
  47292. /**
  47293. * @hidden
  47294. * This is reserved for the inspector.
  47295. * Defines the material debug mode.
  47296. * It helps seeing only some components of the material while troubleshooting.
  47297. */
  47298. debugMode: number;
  47299. /**
  47300. * @hidden
  47301. * This is reserved for the inspector.
  47302. * Specify from where on screen the debug mode should start.
  47303. * The value goes from -1 (full screen) to 1 (not visible)
  47304. * It helps with side by side comparison against the final render
  47305. * This defaults to -1
  47306. */
  47307. private debugLimit;
  47308. /**
  47309. * @hidden
  47310. * This is reserved for the inspector.
  47311. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47312. * You can use the factor to better multiply the final value.
  47313. */
  47314. private debugFactor;
  47315. /**
  47316. * Defines the clear coat layer parameters for the material.
  47317. */
  47318. readonly clearCoat: PBRClearCoatConfiguration;
  47319. /**
  47320. * Defines the anisotropic parameters for the material.
  47321. */
  47322. readonly anisotropy: PBRAnisotropicConfiguration;
  47323. /**
  47324. * Defines the BRDF parameters for the material.
  47325. */
  47326. readonly brdf: PBRBRDFConfiguration;
  47327. /**
  47328. * Defines the Sheen parameters for the material.
  47329. */
  47330. readonly sheen: PBRSheenConfiguration;
  47331. /**
  47332. * Defines the SubSurface parameters for the material.
  47333. */
  47334. readonly subSurface: PBRSubSurfaceConfiguration;
  47335. /**
  47336. * Custom callback helping to override the default shader used in the material.
  47337. */
  47338. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47339. protected _rebuildInParallel: boolean;
  47340. /**
  47341. * Instantiates a new PBRMaterial instance.
  47342. *
  47343. * @param name The material name
  47344. * @param scene The scene the material will be use in.
  47345. */
  47346. constructor(name: string, scene: Scene);
  47347. /**
  47348. * Gets a boolean indicating that current material needs to register RTT
  47349. */
  47350. readonly hasRenderTargetTextures: boolean;
  47351. /**
  47352. * Gets the name of the material class.
  47353. */
  47354. getClassName(): string;
  47355. /**
  47356. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47357. */
  47358. /**
  47359. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47360. */
  47361. useLogarithmicDepth: boolean;
  47362. /**
  47363. * Gets the current transparency mode.
  47364. */
  47365. /**
  47366. * Sets the transparency mode of the material.
  47367. *
  47368. * | Value | Type | Description |
  47369. * | ----- | ----------------------------------- | ----------- |
  47370. * | 0 | OPAQUE | |
  47371. * | 1 | ALPHATEST | |
  47372. * | 2 | ALPHABLEND | |
  47373. * | 3 | ALPHATESTANDBLEND | |
  47374. *
  47375. */
  47376. transparencyMode: Nullable<number>;
  47377. /**
  47378. * Returns true if alpha blending should be disabled.
  47379. */
  47380. private readonly _disableAlphaBlending;
  47381. /**
  47382. * Specifies whether or not this material should be rendered in alpha blend mode.
  47383. */
  47384. needAlphaBlending(): boolean;
  47385. /**
  47386. * Specifies if the mesh will require alpha blending.
  47387. * @param mesh - BJS mesh.
  47388. */
  47389. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47390. /**
  47391. * Specifies whether or not this material should be rendered in alpha test mode.
  47392. */
  47393. needAlphaTesting(): boolean;
  47394. /**
  47395. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47396. */
  47397. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47398. /**
  47399. * Gets the texture used for the alpha test.
  47400. */
  47401. getAlphaTestTexture(): Nullable<BaseTexture>;
  47402. /**
  47403. * Specifies that the submesh is ready to be used.
  47404. * @param mesh - BJS mesh.
  47405. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47406. * @param useInstances - Specifies that instances should be used.
  47407. * @returns - boolean indicating that the submesh is ready or not.
  47408. */
  47409. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47410. /**
  47411. * Specifies if the material uses metallic roughness workflow.
  47412. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47413. */
  47414. isMetallicWorkflow(): boolean;
  47415. private _prepareEffect;
  47416. private _prepareDefines;
  47417. /**
  47418. * Force shader compilation
  47419. */
  47420. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  47421. clipPlane: boolean;
  47422. }>): void;
  47423. /**
  47424. * Initializes the uniform buffer layout for the shader.
  47425. */
  47426. buildUniformLayout(): void;
  47427. /**
  47428. * Unbinds the material from the mesh
  47429. */
  47430. unbind(): void;
  47431. /**
  47432. * Binds the submesh data.
  47433. * @param world - The world matrix.
  47434. * @param mesh - The BJS mesh.
  47435. * @param subMesh - A submesh of the BJS mesh.
  47436. */
  47437. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47438. /**
  47439. * Returns the animatable textures.
  47440. * @returns - Array of animatable textures.
  47441. */
  47442. getAnimatables(): IAnimatable[];
  47443. /**
  47444. * Returns the texture used for reflections.
  47445. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47446. */
  47447. private _getReflectionTexture;
  47448. /**
  47449. * Returns an array of the actively used textures.
  47450. * @returns - Array of BaseTextures
  47451. */
  47452. getActiveTextures(): BaseTexture[];
  47453. /**
  47454. * Checks to see if a texture is used in the material.
  47455. * @param texture - Base texture to use.
  47456. * @returns - Boolean specifying if a texture is used in the material.
  47457. */
  47458. hasTexture(texture: BaseTexture): boolean;
  47459. /**
  47460. * Disposes the resources of the material.
  47461. * @param forceDisposeEffect - Forces the disposal of effects.
  47462. * @param forceDisposeTextures - Forces the disposal of all textures.
  47463. */
  47464. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47465. }
  47466. }
  47467. declare module BABYLON {
  47468. /**
  47469. * The Physically based material of BJS.
  47470. *
  47471. * This offers the main features of a standard PBR material.
  47472. * For more information, please refer to the documentation :
  47473. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47474. */
  47475. export class PBRMaterial extends PBRBaseMaterial {
  47476. /**
  47477. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47478. */
  47479. static readonly PBRMATERIAL_OPAQUE: number;
  47480. /**
  47481. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47482. */
  47483. static readonly PBRMATERIAL_ALPHATEST: number;
  47484. /**
  47485. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47486. */
  47487. static readonly PBRMATERIAL_ALPHABLEND: number;
  47488. /**
  47489. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47490. * They are also discarded below the alpha cutoff threshold to improve performances.
  47491. */
  47492. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47493. /**
  47494. * Defines the default value of how much AO map is occluding the analytical lights
  47495. * (point spot...).
  47496. */
  47497. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47498. /**
  47499. * Intensity of the direct lights e.g. the four lights available in your scene.
  47500. * This impacts both the direct diffuse and specular highlights.
  47501. */
  47502. directIntensity: number;
  47503. /**
  47504. * Intensity of the emissive part of the material.
  47505. * This helps controlling the emissive effect without modifying the emissive color.
  47506. */
  47507. emissiveIntensity: number;
  47508. /**
  47509. * Intensity of the environment e.g. how much the environment will light the object
  47510. * either through harmonics for rough material or through the refelction for shiny ones.
  47511. */
  47512. environmentIntensity: number;
  47513. /**
  47514. * This is a special control allowing the reduction of the specular highlights coming from the
  47515. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47516. */
  47517. specularIntensity: number;
  47518. /**
  47519. * Debug Control allowing disabling the bump map on this material.
  47520. */
  47521. disableBumpMap: boolean;
  47522. /**
  47523. * AKA Diffuse Texture in standard nomenclature.
  47524. */
  47525. albedoTexture: BaseTexture;
  47526. /**
  47527. * AKA Occlusion Texture in other nomenclature.
  47528. */
  47529. ambientTexture: BaseTexture;
  47530. /**
  47531. * AKA Occlusion Texture Intensity in other nomenclature.
  47532. */
  47533. ambientTextureStrength: number;
  47534. /**
  47535. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47536. * 1 means it completely occludes it
  47537. * 0 mean it has no impact
  47538. */
  47539. ambientTextureImpactOnAnalyticalLights: number;
  47540. /**
  47541. * Stores the alpha values in a texture.
  47542. */
  47543. opacityTexture: BaseTexture;
  47544. /**
  47545. * Stores the reflection values in a texture.
  47546. */
  47547. reflectionTexture: Nullable<BaseTexture>;
  47548. /**
  47549. * Stores the emissive values in a texture.
  47550. */
  47551. emissiveTexture: BaseTexture;
  47552. /**
  47553. * AKA Specular texture in other nomenclature.
  47554. */
  47555. reflectivityTexture: BaseTexture;
  47556. /**
  47557. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47558. */
  47559. metallicTexture: BaseTexture;
  47560. /**
  47561. * Specifies the metallic scalar of the metallic/roughness workflow.
  47562. * Can also be used to scale the metalness values of the metallic texture.
  47563. */
  47564. metallic: Nullable<number>;
  47565. /**
  47566. * Specifies the roughness scalar of the metallic/roughness workflow.
  47567. * Can also be used to scale the roughness values of the metallic texture.
  47568. */
  47569. roughness: Nullable<number>;
  47570. /**
  47571. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47572. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47573. */
  47574. microSurfaceTexture: BaseTexture;
  47575. /**
  47576. * Stores surface normal data used to displace a mesh in a texture.
  47577. */
  47578. bumpTexture: BaseTexture;
  47579. /**
  47580. * Stores the pre-calculated light information of a mesh in a texture.
  47581. */
  47582. lightmapTexture: BaseTexture;
  47583. /**
  47584. * Stores the refracted light information in a texture.
  47585. */
  47586. refractionTexture: Nullable<BaseTexture>;
  47587. /**
  47588. * The color of a material in ambient lighting.
  47589. */
  47590. ambientColor: Color3;
  47591. /**
  47592. * AKA Diffuse Color in other nomenclature.
  47593. */
  47594. albedoColor: Color3;
  47595. /**
  47596. * AKA Specular Color in other nomenclature.
  47597. */
  47598. reflectivityColor: Color3;
  47599. /**
  47600. * The color reflected from the material.
  47601. */
  47602. reflectionColor: Color3;
  47603. /**
  47604. * The color emitted from the material.
  47605. */
  47606. emissiveColor: Color3;
  47607. /**
  47608. * AKA Glossiness in other nomenclature.
  47609. */
  47610. microSurface: number;
  47611. /**
  47612. * source material index of refraction (IOR)' / 'destination material IOR.
  47613. */
  47614. indexOfRefraction: number;
  47615. /**
  47616. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47617. */
  47618. invertRefractionY: boolean;
  47619. /**
  47620. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47621. * Materials half opaque for instance using refraction could benefit from this control.
  47622. */
  47623. linkRefractionWithTransparency: boolean;
  47624. /**
  47625. * If true, the light map contains occlusion information instead of lighting info.
  47626. */
  47627. useLightmapAsShadowmap: boolean;
  47628. /**
  47629. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47630. */
  47631. useAlphaFromAlbedoTexture: boolean;
  47632. /**
  47633. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47634. */
  47635. forceAlphaTest: boolean;
  47636. /**
  47637. * Defines the alpha limits in alpha test mode.
  47638. */
  47639. alphaCutOff: number;
  47640. /**
  47641. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47642. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47643. */
  47644. useSpecularOverAlpha: boolean;
  47645. /**
  47646. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47647. */
  47648. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47649. /**
  47650. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47651. */
  47652. useRoughnessFromMetallicTextureAlpha: boolean;
  47653. /**
  47654. * Specifies if the metallic texture contains the roughness information in its green channel.
  47655. */
  47656. useRoughnessFromMetallicTextureGreen: boolean;
  47657. /**
  47658. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47659. */
  47660. useMetallnessFromMetallicTextureBlue: boolean;
  47661. /**
  47662. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47663. */
  47664. useAmbientOcclusionFromMetallicTextureRed: boolean;
  47665. /**
  47666. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47667. */
  47668. useAmbientInGrayScale: boolean;
  47669. /**
  47670. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47671. * The material will try to infer what glossiness each pixel should be.
  47672. */
  47673. useAutoMicroSurfaceFromReflectivityMap: boolean;
  47674. /**
  47675. * BJS is using an harcoded light falloff based on a manually sets up range.
  47676. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47677. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47678. */
  47679. /**
  47680. * BJS is using an harcoded light falloff based on a manually sets up range.
  47681. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47682. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47683. */
  47684. usePhysicalLightFalloff: boolean;
  47685. /**
  47686. * In order to support the falloff compatibility with gltf, a special mode has been added
  47687. * to reproduce the gltf light falloff.
  47688. */
  47689. /**
  47690. * In order to support the falloff compatibility with gltf, a special mode has been added
  47691. * to reproduce the gltf light falloff.
  47692. */
  47693. useGLTFLightFalloff: boolean;
  47694. /**
  47695. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47696. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47697. */
  47698. useRadianceOverAlpha: boolean;
  47699. /**
  47700. * Allows using an object space normal map (instead of tangent space).
  47701. */
  47702. useObjectSpaceNormalMap: boolean;
  47703. /**
  47704. * Allows using the bump map in parallax mode.
  47705. */
  47706. useParallax: boolean;
  47707. /**
  47708. * Allows using the bump map in parallax occlusion mode.
  47709. */
  47710. useParallaxOcclusion: boolean;
  47711. /**
  47712. * Controls the scale bias of the parallax mode.
  47713. */
  47714. parallaxScaleBias: number;
  47715. /**
  47716. * If sets to true, disables all the lights affecting the material.
  47717. */
  47718. disableLighting: boolean;
  47719. /**
  47720. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47721. */
  47722. forceIrradianceInFragment: boolean;
  47723. /**
  47724. * Number of Simultaneous lights allowed on the material.
  47725. */
  47726. maxSimultaneousLights: number;
  47727. /**
  47728. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47729. */
  47730. invertNormalMapX: boolean;
  47731. /**
  47732. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47733. */
  47734. invertNormalMapY: boolean;
  47735. /**
  47736. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47737. */
  47738. twoSidedLighting: boolean;
  47739. /**
  47740. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47741. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47742. */
  47743. useAlphaFresnel: boolean;
  47744. /**
  47745. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47746. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47747. */
  47748. useLinearAlphaFresnel: boolean;
  47749. /**
  47750. * Let user defines the brdf lookup texture used for IBL.
  47751. * A default 8bit version is embedded but you could point at :
  47752. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  47753. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47754. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  47755. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47756. */
  47757. environmentBRDFTexture: Nullable<BaseTexture>;
  47758. /**
  47759. * Force normal to face away from face.
  47760. */
  47761. forceNormalForward: boolean;
  47762. /**
  47763. * Enables specular anti aliasing in the PBR shader.
  47764. * It will both interacts on the Geometry for analytical and IBL lighting.
  47765. * It also prefilter the roughness map based on the bump values.
  47766. */
  47767. enableSpecularAntiAliasing: boolean;
  47768. /**
  47769. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47770. * makes the reflect vector face the model (under horizon).
  47771. */
  47772. useHorizonOcclusion: boolean;
  47773. /**
  47774. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47775. * too much the area relying on ambient texture to define their ambient occlusion.
  47776. */
  47777. useRadianceOcclusion: boolean;
  47778. /**
  47779. * If set to true, no lighting calculations will be applied.
  47780. */
  47781. unlit: boolean;
  47782. /**
  47783. * Gets the image processing configuration used either in this material.
  47784. */
  47785. /**
  47786. * Sets the Default image processing configuration used either in the this material.
  47787. *
  47788. * If sets to null, the scene one is in use.
  47789. */
  47790. imageProcessingConfiguration: ImageProcessingConfiguration;
  47791. /**
  47792. * Gets wether the color curves effect is enabled.
  47793. */
  47794. /**
  47795. * Sets wether the color curves effect is enabled.
  47796. */
  47797. cameraColorCurvesEnabled: boolean;
  47798. /**
  47799. * Gets wether the color grading effect is enabled.
  47800. */
  47801. /**
  47802. * Gets wether the color grading effect is enabled.
  47803. */
  47804. cameraColorGradingEnabled: boolean;
  47805. /**
  47806. * Gets wether tonemapping is enabled or not.
  47807. */
  47808. /**
  47809. * Sets wether tonemapping is enabled or not
  47810. */
  47811. cameraToneMappingEnabled: boolean;
  47812. /**
  47813. * The camera exposure used on this material.
  47814. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47815. * This corresponds to a photographic exposure.
  47816. */
  47817. /**
  47818. * The camera exposure used on this material.
  47819. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47820. * This corresponds to a photographic exposure.
  47821. */
  47822. cameraExposure: number;
  47823. /**
  47824. * Gets The camera contrast used on this material.
  47825. */
  47826. /**
  47827. * Sets The camera contrast used on this material.
  47828. */
  47829. cameraContrast: number;
  47830. /**
  47831. * Gets the Color Grading 2D Lookup Texture.
  47832. */
  47833. /**
  47834. * Sets the Color Grading 2D Lookup Texture.
  47835. */
  47836. cameraColorGradingTexture: Nullable<BaseTexture>;
  47837. /**
  47838. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47839. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47840. * 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;
  47841. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47842. */
  47843. /**
  47844. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47845. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47846. * 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;
  47847. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47848. */
  47849. cameraColorCurves: Nullable<ColorCurves>;
  47850. /**
  47851. * Instantiates a new PBRMaterial instance.
  47852. *
  47853. * @param name The material name
  47854. * @param scene The scene the material will be use in.
  47855. */
  47856. constructor(name: string, scene: Scene);
  47857. /**
  47858. * Returns the name of this material class.
  47859. */
  47860. getClassName(): string;
  47861. /**
  47862. * Makes a duplicate of the current material.
  47863. * @param name - name to use for the new material.
  47864. */
  47865. clone(name: string): PBRMaterial;
  47866. /**
  47867. * Serializes this PBR Material.
  47868. * @returns - An object with the serialized material.
  47869. */
  47870. serialize(): any;
  47871. /**
  47872. * Parses a PBR Material from a serialized object.
  47873. * @param source - Serialized object.
  47874. * @param scene - BJS scene instance.
  47875. * @param rootUrl - url for the scene object
  47876. * @returns - PBRMaterial
  47877. */
  47878. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47879. }
  47880. }
  47881. declare module BABYLON {
  47882. /**
  47883. * Direct draw surface info
  47884. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47885. */
  47886. export interface DDSInfo {
  47887. /**
  47888. * Width of the texture
  47889. */
  47890. width: number;
  47891. /**
  47892. * Width of the texture
  47893. */
  47894. height: number;
  47895. /**
  47896. * Number of Mipmaps for the texture
  47897. * @see https://en.wikipedia.org/wiki/Mipmap
  47898. */
  47899. mipmapCount: number;
  47900. /**
  47901. * If the textures format is a known fourCC format
  47902. * @see https://www.fourcc.org/
  47903. */
  47904. isFourCC: boolean;
  47905. /**
  47906. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47907. */
  47908. isRGB: boolean;
  47909. /**
  47910. * If the texture is a lumincance format
  47911. */
  47912. isLuminance: boolean;
  47913. /**
  47914. * If this is a cube texture
  47915. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47916. */
  47917. isCube: boolean;
  47918. /**
  47919. * If the texture is a compressed format eg. FOURCC_DXT1
  47920. */
  47921. isCompressed: boolean;
  47922. /**
  47923. * The dxgiFormat of the texture
  47924. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47925. */
  47926. dxgiFormat: number;
  47927. /**
  47928. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47929. */
  47930. textureType: number;
  47931. /**
  47932. * Sphericle polynomial created for the dds texture
  47933. */
  47934. sphericalPolynomial?: SphericalPolynomial;
  47935. }
  47936. /**
  47937. * Class used to provide DDS decompression tools
  47938. */
  47939. export class DDSTools {
  47940. /**
  47941. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47942. */
  47943. static StoreLODInAlphaChannel: boolean;
  47944. /**
  47945. * Gets DDS information from an array buffer
  47946. * @param arrayBuffer defines the array buffer to read data from
  47947. * @returns the DDS information
  47948. */
  47949. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47950. private static _FloatView;
  47951. private static _Int32View;
  47952. private static _ToHalfFloat;
  47953. private static _FromHalfFloat;
  47954. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47955. private static _GetHalfFloatRGBAArrayBuffer;
  47956. private static _GetFloatRGBAArrayBuffer;
  47957. private static _GetFloatAsUIntRGBAArrayBuffer;
  47958. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47959. private static _GetRGBAArrayBuffer;
  47960. private static _ExtractLongWordOrder;
  47961. private static _GetRGBArrayBuffer;
  47962. private static _GetLuminanceArrayBuffer;
  47963. /**
  47964. * Uploads DDS Levels to a Babylon Texture
  47965. * @hidden
  47966. */
  47967. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47968. }
  47969. interface Engine {
  47970. /**
  47971. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47972. * @param rootUrl defines the url where the file to load is located
  47973. * @param scene defines the current scene
  47974. * @param lodScale defines scale to apply to the mip map selection
  47975. * @param lodOffset defines offset to apply to the mip map selection
  47976. * @param onLoad defines an optional callback raised when the texture is loaded
  47977. * @param onError defines an optional callback raised if there is an issue to load the texture
  47978. * @param format defines the format of the data
  47979. * @param forcedExtension defines the extension to use to pick the right loader
  47980. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47981. * @returns the cube texture as an InternalTexture
  47982. */
  47983. 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;
  47984. }
  47985. }
  47986. declare module BABYLON {
  47987. /**
  47988. * Implementation of the DDS Texture Loader.
  47989. * @hidden
  47990. */
  47991. export class _DDSTextureLoader implements IInternalTextureLoader {
  47992. /**
  47993. * Defines wether the loader supports cascade loading the different faces.
  47994. */
  47995. readonly supportCascades: boolean;
  47996. /**
  47997. * This returns if the loader support the current file information.
  47998. * @param extension defines the file extension of the file being loaded
  47999. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48000. * @param fallback defines the fallback internal texture if any
  48001. * @param isBase64 defines whether the texture is encoded as a base64
  48002. * @param isBuffer defines whether the texture data are stored as a buffer
  48003. * @returns true if the loader can load the specified file
  48004. */
  48005. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48006. /**
  48007. * Transform the url before loading if required.
  48008. * @param rootUrl the url of the texture
  48009. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48010. * @returns the transformed texture
  48011. */
  48012. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48013. /**
  48014. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48015. * @param rootUrl the url of the texture
  48016. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48017. * @returns the fallback texture
  48018. */
  48019. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48020. /**
  48021. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48022. * @param data contains the texture data
  48023. * @param texture defines the BabylonJS internal texture
  48024. * @param createPolynomials will be true if polynomials have been requested
  48025. * @param onLoad defines the callback to trigger once the texture is ready
  48026. * @param onError defines the callback to trigger in case of error
  48027. */
  48028. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48029. /**
  48030. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48031. * @param data contains the texture data
  48032. * @param texture defines the BabylonJS internal texture
  48033. * @param callback defines the method to call once ready to upload
  48034. */
  48035. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48036. }
  48037. }
  48038. declare module BABYLON {
  48039. /**
  48040. * Implementation of the ENV Texture Loader.
  48041. * @hidden
  48042. */
  48043. export class _ENVTextureLoader implements IInternalTextureLoader {
  48044. /**
  48045. * Defines wether the loader supports cascade loading the different faces.
  48046. */
  48047. readonly supportCascades: boolean;
  48048. /**
  48049. * This returns if the loader support the current file information.
  48050. * @param extension defines the file extension of the file being loaded
  48051. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48052. * @param fallback defines the fallback internal texture if any
  48053. * @param isBase64 defines whether the texture is encoded as a base64
  48054. * @param isBuffer defines whether the texture data are stored as a buffer
  48055. * @returns true if the loader can load the specified file
  48056. */
  48057. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48058. /**
  48059. * Transform the url before loading if required.
  48060. * @param rootUrl the url of the texture
  48061. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48062. * @returns the transformed texture
  48063. */
  48064. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48065. /**
  48066. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48067. * @param rootUrl the url of the texture
  48068. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48069. * @returns the fallback texture
  48070. */
  48071. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48072. /**
  48073. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48074. * @param data contains the texture data
  48075. * @param texture defines the BabylonJS internal texture
  48076. * @param createPolynomials will be true if polynomials have been requested
  48077. * @param onLoad defines the callback to trigger once the texture is ready
  48078. * @param onError defines the callback to trigger in case of error
  48079. */
  48080. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48081. /**
  48082. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48083. * @param data contains the texture data
  48084. * @param texture defines the BabylonJS internal texture
  48085. * @param callback defines the method to call once ready to upload
  48086. */
  48087. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48088. }
  48089. }
  48090. declare module BABYLON {
  48091. /**
  48092. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48093. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48094. */
  48095. export class KhronosTextureContainer {
  48096. /** contents of the KTX container file */
  48097. arrayBuffer: any;
  48098. private static HEADER_LEN;
  48099. private static COMPRESSED_2D;
  48100. private static COMPRESSED_3D;
  48101. private static TEX_2D;
  48102. private static TEX_3D;
  48103. /**
  48104. * Gets the openGL type
  48105. */
  48106. glType: number;
  48107. /**
  48108. * Gets the openGL type size
  48109. */
  48110. glTypeSize: number;
  48111. /**
  48112. * Gets the openGL format
  48113. */
  48114. glFormat: number;
  48115. /**
  48116. * Gets the openGL internal format
  48117. */
  48118. glInternalFormat: number;
  48119. /**
  48120. * Gets the base internal format
  48121. */
  48122. glBaseInternalFormat: number;
  48123. /**
  48124. * Gets image width in pixel
  48125. */
  48126. pixelWidth: number;
  48127. /**
  48128. * Gets image height in pixel
  48129. */
  48130. pixelHeight: number;
  48131. /**
  48132. * Gets image depth in pixels
  48133. */
  48134. pixelDepth: number;
  48135. /**
  48136. * Gets the number of array elements
  48137. */
  48138. numberOfArrayElements: number;
  48139. /**
  48140. * Gets the number of faces
  48141. */
  48142. numberOfFaces: number;
  48143. /**
  48144. * Gets the number of mipmap levels
  48145. */
  48146. numberOfMipmapLevels: number;
  48147. /**
  48148. * Gets the bytes of key value data
  48149. */
  48150. bytesOfKeyValueData: number;
  48151. /**
  48152. * Gets the load type
  48153. */
  48154. loadType: number;
  48155. /**
  48156. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48157. */
  48158. isInvalid: boolean;
  48159. /**
  48160. * Creates a new KhronosTextureContainer
  48161. * @param arrayBuffer contents of the KTX container file
  48162. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48163. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48164. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48165. */
  48166. constructor(
  48167. /** contents of the KTX container file */
  48168. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48169. /**
  48170. * Uploads KTX content to a Babylon Texture.
  48171. * It is assumed that the texture has already been created & is currently bound
  48172. * @hidden
  48173. */
  48174. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48175. private _upload2DCompressedLevels;
  48176. }
  48177. }
  48178. declare module BABYLON {
  48179. /**
  48180. * Implementation of the KTX Texture Loader.
  48181. * @hidden
  48182. */
  48183. export class _KTXTextureLoader implements IInternalTextureLoader {
  48184. /**
  48185. * Defines wether the loader supports cascade loading the different faces.
  48186. */
  48187. readonly supportCascades: boolean;
  48188. /**
  48189. * This returns if the loader support the current file information.
  48190. * @param extension defines the file extension of the file being loaded
  48191. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48192. * @param fallback defines the fallback internal texture if any
  48193. * @param isBase64 defines whether the texture is encoded as a base64
  48194. * @param isBuffer defines whether the texture data are stored as a buffer
  48195. * @returns true if the loader can load the specified file
  48196. */
  48197. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48198. /**
  48199. * Transform the url before loading if required.
  48200. * @param rootUrl the url of the texture
  48201. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48202. * @returns the transformed texture
  48203. */
  48204. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48205. /**
  48206. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48207. * @param rootUrl the url of the texture
  48208. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48209. * @returns the fallback texture
  48210. */
  48211. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48212. /**
  48213. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48214. * @param data contains the texture data
  48215. * @param texture defines the BabylonJS internal texture
  48216. * @param createPolynomials will be true if polynomials have been requested
  48217. * @param onLoad defines the callback to trigger once the texture is ready
  48218. * @param onError defines the callback to trigger in case of error
  48219. */
  48220. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48221. /**
  48222. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48223. * @param data contains the texture data
  48224. * @param texture defines the BabylonJS internal texture
  48225. * @param callback defines the method to call once ready to upload
  48226. */
  48227. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48228. }
  48229. }
  48230. declare module BABYLON {
  48231. /**
  48232. * Options for the default xr helper
  48233. */
  48234. export class WebXRDefaultExperienceOptions {
  48235. /**
  48236. * Floor meshes that should be used for teleporting
  48237. */
  48238. floorMeshes: Array<AbstractMesh>;
  48239. }
  48240. /**
  48241. * Default experience which provides a similar setup to the previous webVRExperience
  48242. */
  48243. export class WebXRDefaultExperience {
  48244. /**
  48245. * Base experience
  48246. */
  48247. baseExperience: WebXRExperienceHelper;
  48248. /**
  48249. * Input experience extension
  48250. */
  48251. input: WebXRInput;
  48252. /**
  48253. * Loads the controller models
  48254. */
  48255. controllerModelLoader: WebXRControllerModelLoader;
  48256. /**
  48257. * Enables laser pointer and selection
  48258. */
  48259. pointerSelection: WebXRControllerPointerSelection;
  48260. /**
  48261. * Enables teleportation
  48262. */
  48263. teleportation: WebXRControllerTeleportation;
  48264. /**
  48265. * Enables ui for enetering/exiting xr
  48266. */
  48267. enterExitUI: WebXREnterExitUI;
  48268. /**
  48269. * Default output canvas xr should render to
  48270. */
  48271. outputCanvas: WebXRManagedOutputCanvas;
  48272. /**
  48273. * Creates the default xr experience
  48274. * @param scene scene
  48275. * @param options options for basic configuration
  48276. * @returns resulting WebXRDefaultExperience
  48277. */
  48278. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48279. private constructor();
  48280. /**
  48281. * DIsposes of the experience helper
  48282. */
  48283. dispose(): void;
  48284. }
  48285. }
  48286. declare module BABYLON {
  48287. /** @hidden */
  48288. export var _forceSceneHelpersToBundle: boolean;
  48289. interface Scene {
  48290. /**
  48291. * Creates a default light for the scene.
  48292. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48293. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48294. */
  48295. createDefaultLight(replace?: boolean): void;
  48296. /**
  48297. * Creates a default camera for the scene.
  48298. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48299. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48300. * @param replace has default false, when true replaces the active camera in the scene
  48301. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48302. */
  48303. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48304. /**
  48305. * Creates a default camera and a default light.
  48306. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48307. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48308. * @param replace has the default false, when true replaces the active camera/light in the scene
  48309. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48310. */
  48311. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48312. /**
  48313. * Creates a new sky box
  48314. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48315. * @param environmentTexture defines the texture to use as environment texture
  48316. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48317. * @param scale defines the overall scale of the skybox
  48318. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48319. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48320. * @returns a new mesh holding the sky box
  48321. */
  48322. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48323. /**
  48324. * Creates a new environment
  48325. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48326. * @param options defines the options you can use to configure the environment
  48327. * @returns the new EnvironmentHelper
  48328. */
  48329. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48330. /**
  48331. * Creates a new VREXperienceHelper
  48332. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48333. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48334. * @returns a new VREXperienceHelper
  48335. */
  48336. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48337. /**
  48338. * Creates a new WebXRDefaultExperience
  48339. * @see http://doc.babylonjs.com/how_to/webxr
  48340. * @param options experience options
  48341. * @returns a promise for a new WebXRDefaultExperience
  48342. */
  48343. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48344. }
  48345. }
  48346. declare module BABYLON {
  48347. /**
  48348. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48349. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48350. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48351. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48352. */
  48353. export class VideoDome extends TransformNode {
  48354. /**
  48355. * Define the video source as a Monoscopic panoramic 360 video.
  48356. */
  48357. static readonly MODE_MONOSCOPIC: number;
  48358. /**
  48359. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48360. */
  48361. static readonly MODE_TOPBOTTOM: number;
  48362. /**
  48363. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48364. */
  48365. static readonly MODE_SIDEBYSIDE: number;
  48366. private _halfDome;
  48367. private _useDirectMapping;
  48368. /**
  48369. * The video texture being displayed on the sphere
  48370. */
  48371. protected _videoTexture: VideoTexture;
  48372. /**
  48373. * Gets the video texture being displayed on the sphere
  48374. */
  48375. readonly videoTexture: VideoTexture;
  48376. /**
  48377. * The skybox material
  48378. */
  48379. protected _material: BackgroundMaterial;
  48380. /**
  48381. * The surface used for the skybox
  48382. */
  48383. protected _mesh: Mesh;
  48384. /**
  48385. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  48386. */
  48387. private _halfDomeMask;
  48388. /**
  48389. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48390. * Also see the options.resolution property.
  48391. */
  48392. fovMultiplier: number;
  48393. private _videoMode;
  48394. /**
  48395. * Gets or set the current video mode for the video. It can be:
  48396. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48397. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48398. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48399. */
  48400. videoMode: number;
  48401. /**
  48402. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  48403. *
  48404. */
  48405. /**
  48406. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  48407. */
  48408. halfDome: boolean;
  48409. /**
  48410. * Oberserver used in Stereoscopic VR Mode.
  48411. */
  48412. private _onBeforeCameraRenderObserver;
  48413. /**
  48414. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48415. * @param name Element's name, child elements will append suffixes for their own names.
  48416. * @param urlsOrVideo defines the url(s) or the video element to use
  48417. * @param options An object containing optional or exposed sub element properties
  48418. */
  48419. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48420. resolution?: number;
  48421. clickToPlay?: boolean;
  48422. autoPlay?: boolean;
  48423. loop?: boolean;
  48424. size?: number;
  48425. poster?: string;
  48426. faceForward?: boolean;
  48427. useDirectMapping?: boolean;
  48428. halfDomeMode?: boolean;
  48429. }, scene: Scene);
  48430. private _changeVideoMode;
  48431. /**
  48432. * Releases resources associated with this node.
  48433. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48434. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48435. */
  48436. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48437. }
  48438. }
  48439. declare module BABYLON {
  48440. /**
  48441. * This class can be used to get instrumentation data from a Babylon engine
  48442. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48443. */
  48444. export class EngineInstrumentation implements IDisposable {
  48445. /**
  48446. * Define the instrumented engine.
  48447. */
  48448. engine: Engine;
  48449. private _captureGPUFrameTime;
  48450. private _gpuFrameTimeToken;
  48451. private _gpuFrameTime;
  48452. private _captureShaderCompilationTime;
  48453. private _shaderCompilationTime;
  48454. private _onBeginFrameObserver;
  48455. private _onEndFrameObserver;
  48456. private _onBeforeShaderCompilationObserver;
  48457. private _onAfterShaderCompilationObserver;
  48458. /**
  48459. * Gets the perf counter used for GPU frame time
  48460. */
  48461. readonly gpuFrameTimeCounter: PerfCounter;
  48462. /**
  48463. * Gets the GPU frame time capture status
  48464. */
  48465. /**
  48466. * Enable or disable the GPU frame time capture
  48467. */
  48468. captureGPUFrameTime: boolean;
  48469. /**
  48470. * Gets the perf counter used for shader compilation time
  48471. */
  48472. readonly shaderCompilationTimeCounter: PerfCounter;
  48473. /**
  48474. * Gets the shader compilation time capture status
  48475. */
  48476. /**
  48477. * Enable or disable the shader compilation time capture
  48478. */
  48479. captureShaderCompilationTime: boolean;
  48480. /**
  48481. * Instantiates a new engine instrumentation.
  48482. * This class can be used to get instrumentation data from a Babylon engine
  48483. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48484. * @param engine Defines the engine to instrument
  48485. */
  48486. constructor(
  48487. /**
  48488. * Define the instrumented engine.
  48489. */
  48490. engine: Engine);
  48491. /**
  48492. * Dispose and release associated resources.
  48493. */
  48494. dispose(): void;
  48495. }
  48496. }
  48497. declare module BABYLON {
  48498. /**
  48499. * This class can be used to get instrumentation data from a Babylon engine
  48500. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48501. */
  48502. export class SceneInstrumentation implements IDisposable {
  48503. /**
  48504. * Defines the scene to instrument
  48505. */
  48506. scene: Scene;
  48507. private _captureActiveMeshesEvaluationTime;
  48508. private _activeMeshesEvaluationTime;
  48509. private _captureRenderTargetsRenderTime;
  48510. private _renderTargetsRenderTime;
  48511. private _captureFrameTime;
  48512. private _frameTime;
  48513. private _captureRenderTime;
  48514. private _renderTime;
  48515. private _captureInterFrameTime;
  48516. private _interFrameTime;
  48517. private _captureParticlesRenderTime;
  48518. private _particlesRenderTime;
  48519. private _captureSpritesRenderTime;
  48520. private _spritesRenderTime;
  48521. private _capturePhysicsTime;
  48522. private _physicsTime;
  48523. private _captureAnimationsTime;
  48524. private _animationsTime;
  48525. private _captureCameraRenderTime;
  48526. private _cameraRenderTime;
  48527. private _onBeforeActiveMeshesEvaluationObserver;
  48528. private _onAfterActiveMeshesEvaluationObserver;
  48529. private _onBeforeRenderTargetsRenderObserver;
  48530. private _onAfterRenderTargetsRenderObserver;
  48531. private _onAfterRenderObserver;
  48532. private _onBeforeDrawPhaseObserver;
  48533. private _onAfterDrawPhaseObserver;
  48534. private _onBeforeAnimationsObserver;
  48535. private _onBeforeParticlesRenderingObserver;
  48536. private _onAfterParticlesRenderingObserver;
  48537. private _onBeforeSpritesRenderingObserver;
  48538. private _onAfterSpritesRenderingObserver;
  48539. private _onBeforePhysicsObserver;
  48540. private _onAfterPhysicsObserver;
  48541. private _onAfterAnimationsObserver;
  48542. private _onBeforeCameraRenderObserver;
  48543. private _onAfterCameraRenderObserver;
  48544. /**
  48545. * Gets the perf counter used for active meshes evaluation time
  48546. */
  48547. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48548. /**
  48549. * Gets the active meshes evaluation time capture status
  48550. */
  48551. /**
  48552. * Enable or disable the active meshes evaluation time capture
  48553. */
  48554. captureActiveMeshesEvaluationTime: boolean;
  48555. /**
  48556. * Gets the perf counter used for render targets render time
  48557. */
  48558. readonly renderTargetsRenderTimeCounter: PerfCounter;
  48559. /**
  48560. * Gets the render targets render time capture status
  48561. */
  48562. /**
  48563. * Enable or disable the render targets render time capture
  48564. */
  48565. captureRenderTargetsRenderTime: boolean;
  48566. /**
  48567. * Gets the perf counter used for particles render time
  48568. */
  48569. readonly particlesRenderTimeCounter: PerfCounter;
  48570. /**
  48571. * Gets the particles render time capture status
  48572. */
  48573. /**
  48574. * Enable or disable the particles render time capture
  48575. */
  48576. captureParticlesRenderTime: boolean;
  48577. /**
  48578. * Gets the perf counter used for sprites render time
  48579. */
  48580. readonly spritesRenderTimeCounter: PerfCounter;
  48581. /**
  48582. * Gets the sprites render time capture status
  48583. */
  48584. /**
  48585. * Enable or disable the sprites render time capture
  48586. */
  48587. captureSpritesRenderTime: boolean;
  48588. /**
  48589. * Gets the perf counter used for physics time
  48590. */
  48591. readonly physicsTimeCounter: PerfCounter;
  48592. /**
  48593. * Gets the physics time capture status
  48594. */
  48595. /**
  48596. * Enable or disable the physics time capture
  48597. */
  48598. capturePhysicsTime: boolean;
  48599. /**
  48600. * Gets the perf counter used for animations time
  48601. */
  48602. readonly animationsTimeCounter: PerfCounter;
  48603. /**
  48604. * Gets the animations time capture status
  48605. */
  48606. /**
  48607. * Enable or disable the animations time capture
  48608. */
  48609. captureAnimationsTime: boolean;
  48610. /**
  48611. * Gets the perf counter used for frame time capture
  48612. */
  48613. readonly frameTimeCounter: PerfCounter;
  48614. /**
  48615. * Gets the frame time capture status
  48616. */
  48617. /**
  48618. * Enable or disable the frame time capture
  48619. */
  48620. captureFrameTime: boolean;
  48621. /**
  48622. * Gets the perf counter used for inter-frames time capture
  48623. */
  48624. readonly interFrameTimeCounter: PerfCounter;
  48625. /**
  48626. * Gets the inter-frames time capture status
  48627. */
  48628. /**
  48629. * Enable or disable the inter-frames time capture
  48630. */
  48631. captureInterFrameTime: boolean;
  48632. /**
  48633. * Gets the perf counter used for render time capture
  48634. */
  48635. readonly renderTimeCounter: PerfCounter;
  48636. /**
  48637. * Gets the render time capture status
  48638. */
  48639. /**
  48640. * Enable or disable the render time capture
  48641. */
  48642. captureRenderTime: boolean;
  48643. /**
  48644. * Gets the perf counter used for camera render time capture
  48645. */
  48646. readonly cameraRenderTimeCounter: PerfCounter;
  48647. /**
  48648. * Gets the camera render time capture status
  48649. */
  48650. /**
  48651. * Enable or disable the camera render time capture
  48652. */
  48653. captureCameraRenderTime: boolean;
  48654. /**
  48655. * Gets the perf counter used for draw calls
  48656. */
  48657. readonly drawCallsCounter: PerfCounter;
  48658. /**
  48659. * Instantiates a new scene instrumentation.
  48660. * This class can be used to get instrumentation data from a Babylon engine
  48661. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48662. * @param scene Defines the scene to instrument
  48663. */
  48664. constructor(
  48665. /**
  48666. * Defines the scene to instrument
  48667. */
  48668. scene: Scene);
  48669. /**
  48670. * Dispose and release associated resources.
  48671. */
  48672. dispose(): void;
  48673. }
  48674. }
  48675. declare module BABYLON {
  48676. /** @hidden */
  48677. export var glowMapGenerationPixelShader: {
  48678. name: string;
  48679. shader: string;
  48680. };
  48681. }
  48682. declare module BABYLON {
  48683. /** @hidden */
  48684. export var glowMapGenerationVertexShader: {
  48685. name: string;
  48686. shader: string;
  48687. };
  48688. }
  48689. declare module BABYLON {
  48690. /**
  48691. * Effect layer options. This helps customizing the behaviour
  48692. * of the effect layer.
  48693. */
  48694. export interface IEffectLayerOptions {
  48695. /**
  48696. * Multiplication factor apply to the canvas size to compute the render target size
  48697. * used to generated the objects (the smaller the faster).
  48698. */
  48699. mainTextureRatio: number;
  48700. /**
  48701. * Enforces a fixed size texture to ensure effect stability across devices.
  48702. */
  48703. mainTextureFixedSize?: number;
  48704. /**
  48705. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48706. */
  48707. alphaBlendingMode: number;
  48708. /**
  48709. * The camera attached to the layer.
  48710. */
  48711. camera: Nullable<Camera>;
  48712. /**
  48713. * The rendering group to draw the layer in.
  48714. */
  48715. renderingGroupId: number;
  48716. }
  48717. /**
  48718. * The effect layer Helps adding post process effect blended with the main pass.
  48719. *
  48720. * This can be for instance use to generate glow or higlight effects on the scene.
  48721. *
  48722. * The effect layer class can not be used directly and is intented to inherited from to be
  48723. * customized per effects.
  48724. */
  48725. export abstract class EffectLayer {
  48726. private _vertexBuffers;
  48727. private _indexBuffer;
  48728. private _cachedDefines;
  48729. private _effectLayerMapGenerationEffect;
  48730. private _effectLayerOptions;
  48731. private _mergeEffect;
  48732. protected _scene: Scene;
  48733. protected _engine: Engine;
  48734. protected _maxSize: number;
  48735. protected _mainTextureDesiredSize: ISize;
  48736. protected _mainTexture: RenderTargetTexture;
  48737. protected _shouldRender: boolean;
  48738. protected _postProcesses: PostProcess[];
  48739. protected _textures: BaseTexture[];
  48740. protected _emissiveTextureAndColor: {
  48741. texture: Nullable<BaseTexture>;
  48742. color: Color4;
  48743. };
  48744. /**
  48745. * The name of the layer
  48746. */
  48747. name: string;
  48748. /**
  48749. * The clear color of the texture used to generate the glow map.
  48750. */
  48751. neutralColor: Color4;
  48752. /**
  48753. * Specifies wether the highlight layer is enabled or not.
  48754. */
  48755. isEnabled: boolean;
  48756. /**
  48757. * Gets the camera attached to the layer.
  48758. */
  48759. readonly camera: Nullable<Camera>;
  48760. /**
  48761. * Gets the rendering group id the layer should render in.
  48762. */
  48763. renderingGroupId: number;
  48764. /**
  48765. * An event triggered when the effect layer has been disposed.
  48766. */
  48767. onDisposeObservable: Observable<EffectLayer>;
  48768. /**
  48769. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48770. */
  48771. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48772. /**
  48773. * An event triggered when the generated texture is being merged in the scene.
  48774. */
  48775. onBeforeComposeObservable: Observable<EffectLayer>;
  48776. /**
  48777. * An event triggered when the generated texture has been merged in the scene.
  48778. */
  48779. onAfterComposeObservable: Observable<EffectLayer>;
  48780. /**
  48781. * An event triggered when the efffect layer changes its size.
  48782. */
  48783. onSizeChangedObservable: Observable<EffectLayer>;
  48784. /** @hidden */
  48785. static _SceneComponentInitialization: (scene: Scene) => void;
  48786. /**
  48787. * Instantiates a new effect Layer and references it in the scene.
  48788. * @param name The name of the layer
  48789. * @param scene The scene to use the layer in
  48790. */
  48791. constructor(
  48792. /** The Friendly of the effect in the scene */
  48793. name: string, scene: Scene);
  48794. /**
  48795. * Get the effect name of the layer.
  48796. * @return The effect name
  48797. */
  48798. abstract getEffectName(): string;
  48799. /**
  48800. * Checks for the readiness of the element composing the layer.
  48801. * @param subMesh the mesh to check for
  48802. * @param useInstances specify wether or not to use instances to render the mesh
  48803. * @return true if ready otherwise, false
  48804. */
  48805. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48806. /**
  48807. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48808. * @returns true if the effect requires stencil during the main canvas render pass.
  48809. */
  48810. abstract needStencil(): boolean;
  48811. /**
  48812. * Create the merge effect. This is the shader use to blit the information back
  48813. * to the main canvas at the end of the scene rendering.
  48814. * @returns The effect containing the shader used to merge the effect on the main canvas
  48815. */
  48816. protected abstract _createMergeEffect(): Effect;
  48817. /**
  48818. * Creates the render target textures and post processes used in the effect layer.
  48819. */
  48820. protected abstract _createTextureAndPostProcesses(): void;
  48821. /**
  48822. * Implementation specific of rendering the generating effect on the main canvas.
  48823. * @param effect The effect used to render through
  48824. */
  48825. protected abstract _internalRender(effect: Effect): void;
  48826. /**
  48827. * Sets the required values for both the emissive texture and and the main color.
  48828. */
  48829. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48830. /**
  48831. * Free any resources and references associated to a mesh.
  48832. * Internal use
  48833. * @param mesh The mesh to free.
  48834. */
  48835. abstract _disposeMesh(mesh: Mesh): void;
  48836. /**
  48837. * Serializes this layer (Glow or Highlight for example)
  48838. * @returns a serialized layer object
  48839. */
  48840. abstract serialize?(): any;
  48841. /**
  48842. * Initializes the effect layer with the required options.
  48843. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48844. */
  48845. protected _init(options: Partial<IEffectLayerOptions>): void;
  48846. /**
  48847. * Generates the index buffer of the full screen quad blending to the main canvas.
  48848. */
  48849. private _generateIndexBuffer;
  48850. /**
  48851. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48852. */
  48853. private _generateVertexBuffer;
  48854. /**
  48855. * Sets the main texture desired size which is the closest power of two
  48856. * of the engine canvas size.
  48857. */
  48858. private _setMainTextureSize;
  48859. /**
  48860. * Creates the main texture for the effect layer.
  48861. */
  48862. protected _createMainTexture(): void;
  48863. /**
  48864. * Adds specific effects defines.
  48865. * @param defines The defines to add specifics to.
  48866. */
  48867. protected _addCustomEffectDefines(defines: string[]): void;
  48868. /**
  48869. * Checks for the readiness of the element composing the layer.
  48870. * @param subMesh the mesh to check for
  48871. * @param useInstances specify wether or not to use instances to render the mesh
  48872. * @param emissiveTexture the associated emissive texture used to generate the glow
  48873. * @return true if ready otherwise, false
  48874. */
  48875. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48876. /**
  48877. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48878. */
  48879. render(): void;
  48880. /**
  48881. * Determine if a given mesh will be used in the current effect.
  48882. * @param mesh mesh to test
  48883. * @returns true if the mesh will be used
  48884. */
  48885. hasMesh(mesh: AbstractMesh): boolean;
  48886. /**
  48887. * Returns true if the layer contains information to display, otherwise false.
  48888. * @returns true if the glow layer should be rendered
  48889. */
  48890. shouldRender(): boolean;
  48891. /**
  48892. * Returns true if the mesh should render, otherwise false.
  48893. * @param mesh The mesh to render
  48894. * @returns true if it should render otherwise false
  48895. */
  48896. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48897. /**
  48898. * Returns true if the mesh can be rendered, otherwise false.
  48899. * @param mesh The mesh to render
  48900. * @param material The material used on the mesh
  48901. * @returns true if it can be rendered otherwise false
  48902. */
  48903. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48904. /**
  48905. * Returns true if the mesh should render, otherwise false.
  48906. * @param mesh The mesh to render
  48907. * @returns true if it should render otherwise false
  48908. */
  48909. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48910. /**
  48911. * Renders the submesh passed in parameter to the generation map.
  48912. */
  48913. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  48914. /**
  48915. * Rebuild the required buffers.
  48916. * @hidden Internal use only.
  48917. */
  48918. _rebuild(): void;
  48919. /**
  48920. * Dispose only the render target textures and post process.
  48921. */
  48922. private _disposeTextureAndPostProcesses;
  48923. /**
  48924. * Dispose the highlight layer and free resources.
  48925. */
  48926. dispose(): void;
  48927. /**
  48928. * Gets the class name of the effect layer
  48929. * @returns the string with the class name of the effect layer
  48930. */
  48931. getClassName(): string;
  48932. /**
  48933. * Creates an effect layer from parsed effect layer data
  48934. * @param parsedEffectLayer defines effect layer data
  48935. * @param scene defines the current scene
  48936. * @param rootUrl defines the root URL containing the effect layer information
  48937. * @returns a parsed effect Layer
  48938. */
  48939. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  48940. }
  48941. }
  48942. declare module BABYLON {
  48943. interface AbstractScene {
  48944. /**
  48945. * The list of effect layers (highlights/glow) added to the scene
  48946. * @see http://doc.babylonjs.com/how_to/highlight_layer
  48947. * @see http://doc.babylonjs.com/how_to/glow_layer
  48948. */
  48949. effectLayers: Array<EffectLayer>;
  48950. /**
  48951. * Removes the given effect layer from this scene.
  48952. * @param toRemove defines the effect layer to remove
  48953. * @returns the index of the removed effect layer
  48954. */
  48955. removeEffectLayer(toRemove: EffectLayer): number;
  48956. /**
  48957. * Adds the given effect layer to this scene
  48958. * @param newEffectLayer defines the effect layer to add
  48959. */
  48960. addEffectLayer(newEffectLayer: EffectLayer): void;
  48961. }
  48962. /**
  48963. * Defines the layer scene component responsible to manage any effect layers
  48964. * in a given scene.
  48965. */
  48966. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  48967. /**
  48968. * The component name helpfull to identify the component in the list of scene components.
  48969. */
  48970. readonly name: string;
  48971. /**
  48972. * The scene the component belongs to.
  48973. */
  48974. scene: Scene;
  48975. private _engine;
  48976. private _renderEffects;
  48977. private _needStencil;
  48978. private _previousStencilState;
  48979. /**
  48980. * Creates a new instance of the component for the given scene
  48981. * @param scene Defines the scene to register the component in
  48982. */
  48983. constructor(scene: Scene);
  48984. /**
  48985. * Registers the component in a given scene
  48986. */
  48987. register(): void;
  48988. /**
  48989. * Rebuilds the elements related to this component in case of
  48990. * context lost for instance.
  48991. */
  48992. rebuild(): void;
  48993. /**
  48994. * Serializes the component data to the specified json object
  48995. * @param serializationObject The object to serialize to
  48996. */
  48997. serialize(serializationObject: any): void;
  48998. /**
  48999. * Adds all the elements from the container to the scene
  49000. * @param container the container holding the elements
  49001. */
  49002. addFromContainer(container: AbstractScene): void;
  49003. /**
  49004. * Removes all the elements in the container from the scene
  49005. * @param container contains the elements to remove
  49006. * @param dispose if the removed element should be disposed (default: false)
  49007. */
  49008. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49009. /**
  49010. * Disposes the component and the associated ressources.
  49011. */
  49012. dispose(): void;
  49013. private _isReadyForMesh;
  49014. private _renderMainTexture;
  49015. private _setStencil;
  49016. private _setStencilBack;
  49017. private _draw;
  49018. private _drawCamera;
  49019. private _drawRenderingGroup;
  49020. }
  49021. }
  49022. declare module BABYLON {
  49023. /** @hidden */
  49024. export var glowMapMergePixelShader: {
  49025. name: string;
  49026. shader: string;
  49027. };
  49028. }
  49029. declare module BABYLON {
  49030. /** @hidden */
  49031. export var glowMapMergeVertexShader: {
  49032. name: string;
  49033. shader: string;
  49034. };
  49035. }
  49036. declare module BABYLON {
  49037. interface AbstractScene {
  49038. /**
  49039. * Return a the first highlight layer of the scene with a given name.
  49040. * @param name The name of the highlight layer to look for.
  49041. * @return The highlight layer if found otherwise null.
  49042. */
  49043. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49044. }
  49045. /**
  49046. * Glow layer options. This helps customizing the behaviour
  49047. * of the glow layer.
  49048. */
  49049. export interface IGlowLayerOptions {
  49050. /**
  49051. * Multiplication factor apply to the canvas size to compute the render target size
  49052. * used to generated the glowing objects (the smaller the faster).
  49053. */
  49054. mainTextureRatio: number;
  49055. /**
  49056. * Enforces a fixed size texture to ensure resize independant blur.
  49057. */
  49058. mainTextureFixedSize?: number;
  49059. /**
  49060. * How big is the kernel of the blur texture.
  49061. */
  49062. blurKernelSize: number;
  49063. /**
  49064. * The camera attached to the layer.
  49065. */
  49066. camera: Nullable<Camera>;
  49067. /**
  49068. * Enable MSAA by chosing the number of samples.
  49069. */
  49070. mainTextureSamples?: number;
  49071. /**
  49072. * The rendering group to draw the layer in.
  49073. */
  49074. renderingGroupId: number;
  49075. }
  49076. /**
  49077. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49078. *
  49079. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49080. * glowy meshes to your scene.
  49081. *
  49082. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49083. */
  49084. export class GlowLayer extends EffectLayer {
  49085. /**
  49086. * Effect Name of the layer.
  49087. */
  49088. static readonly EffectName: string;
  49089. /**
  49090. * The default blur kernel size used for the glow.
  49091. */
  49092. static DefaultBlurKernelSize: number;
  49093. /**
  49094. * The default texture size ratio used for the glow.
  49095. */
  49096. static DefaultTextureRatio: number;
  49097. /**
  49098. * Sets the kernel size of the blur.
  49099. */
  49100. /**
  49101. * Gets the kernel size of the blur.
  49102. */
  49103. blurKernelSize: number;
  49104. /**
  49105. * Sets the glow intensity.
  49106. */
  49107. /**
  49108. * Gets the glow intensity.
  49109. */
  49110. intensity: number;
  49111. private _options;
  49112. private _intensity;
  49113. private _horizontalBlurPostprocess1;
  49114. private _verticalBlurPostprocess1;
  49115. private _horizontalBlurPostprocess2;
  49116. private _verticalBlurPostprocess2;
  49117. private _blurTexture1;
  49118. private _blurTexture2;
  49119. private _postProcesses1;
  49120. private _postProcesses2;
  49121. private _includedOnlyMeshes;
  49122. private _excludedMeshes;
  49123. /**
  49124. * Callback used to let the user override the color selection on a per mesh basis
  49125. */
  49126. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49127. /**
  49128. * Callback used to let the user override the texture selection on a per mesh basis
  49129. */
  49130. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49131. /**
  49132. * Instantiates a new glow Layer and references it to the scene.
  49133. * @param name The name of the layer
  49134. * @param scene The scene to use the layer in
  49135. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49136. */
  49137. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49138. /**
  49139. * Get the effect name of the layer.
  49140. * @return The effect name
  49141. */
  49142. getEffectName(): string;
  49143. /**
  49144. * Create the merge effect. This is the shader use to blit the information back
  49145. * to the main canvas at the end of the scene rendering.
  49146. */
  49147. protected _createMergeEffect(): Effect;
  49148. /**
  49149. * Creates the render target textures and post processes used in the glow layer.
  49150. */
  49151. protected _createTextureAndPostProcesses(): void;
  49152. /**
  49153. * Checks for the readiness of the element composing the layer.
  49154. * @param subMesh the mesh to check for
  49155. * @param useInstances specify wether or not to use instances to render the mesh
  49156. * @param emissiveTexture the associated emissive texture used to generate the glow
  49157. * @return true if ready otherwise, false
  49158. */
  49159. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49160. /**
  49161. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49162. */
  49163. needStencil(): boolean;
  49164. /**
  49165. * Returns true if the mesh can be rendered, otherwise false.
  49166. * @param mesh The mesh to render
  49167. * @param material The material used on the mesh
  49168. * @returns true if it can be rendered otherwise false
  49169. */
  49170. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49171. /**
  49172. * Implementation specific of rendering the generating effect on the main canvas.
  49173. * @param effect The effect used to render through
  49174. */
  49175. protected _internalRender(effect: Effect): void;
  49176. /**
  49177. * Sets the required values for both the emissive texture and and the main color.
  49178. */
  49179. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49180. /**
  49181. * Returns true if the mesh should render, otherwise false.
  49182. * @param mesh The mesh to render
  49183. * @returns true if it should render otherwise false
  49184. */
  49185. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49186. /**
  49187. * Adds specific effects defines.
  49188. * @param defines The defines to add specifics to.
  49189. */
  49190. protected _addCustomEffectDefines(defines: string[]): void;
  49191. /**
  49192. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49193. * @param mesh The mesh to exclude from the glow layer
  49194. */
  49195. addExcludedMesh(mesh: Mesh): void;
  49196. /**
  49197. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49198. * @param mesh The mesh to remove
  49199. */
  49200. removeExcludedMesh(mesh: Mesh): void;
  49201. /**
  49202. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49203. * @param mesh The mesh to include in the glow layer
  49204. */
  49205. addIncludedOnlyMesh(mesh: Mesh): void;
  49206. /**
  49207. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49208. * @param mesh The mesh to remove
  49209. */
  49210. removeIncludedOnlyMesh(mesh: Mesh): void;
  49211. /**
  49212. * Determine if a given mesh will be used in the glow layer
  49213. * @param mesh The mesh to test
  49214. * @returns true if the mesh will be highlighted by the current glow layer
  49215. */
  49216. hasMesh(mesh: AbstractMesh): boolean;
  49217. /**
  49218. * Free any resources and references associated to a mesh.
  49219. * Internal use
  49220. * @param mesh The mesh to free.
  49221. * @hidden
  49222. */
  49223. _disposeMesh(mesh: Mesh): void;
  49224. /**
  49225. * Gets the class name of the effect layer
  49226. * @returns the string with the class name of the effect layer
  49227. */
  49228. getClassName(): string;
  49229. /**
  49230. * Serializes this glow layer
  49231. * @returns a serialized glow layer object
  49232. */
  49233. serialize(): any;
  49234. /**
  49235. * Creates a Glow Layer from parsed glow layer data
  49236. * @param parsedGlowLayer defines glow layer data
  49237. * @param scene defines the current scene
  49238. * @param rootUrl defines the root URL containing the glow layer information
  49239. * @returns a parsed Glow Layer
  49240. */
  49241. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49242. }
  49243. }
  49244. declare module BABYLON {
  49245. /** @hidden */
  49246. export var glowBlurPostProcessPixelShader: {
  49247. name: string;
  49248. shader: string;
  49249. };
  49250. }
  49251. declare module BABYLON {
  49252. interface AbstractScene {
  49253. /**
  49254. * Return a the first highlight layer of the scene with a given name.
  49255. * @param name The name of the highlight layer to look for.
  49256. * @return The highlight layer if found otherwise null.
  49257. */
  49258. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49259. }
  49260. /**
  49261. * Highlight layer options. This helps customizing the behaviour
  49262. * of the highlight layer.
  49263. */
  49264. export interface IHighlightLayerOptions {
  49265. /**
  49266. * Multiplication factor apply to the canvas size to compute the render target size
  49267. * used to generated the glowing objects (the smaller the faster).
  49268. */
  49269. mainTextureRatio: number;
  49270. /**
  49271. * Enforces a fixed size texture to ensure resize independant blur.
  49272. */
  49273. mainTextureFixedSize?: number;
  49274. /**
  49275. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49276. * of the picture to blur (the smaller the faster).
  49277. */
  49278. blurTextureSizeRatio: number;
  49279. /**
  49280. * How big in texel of the blur texture is the vertical blur.
  49281. */
  49282. blurVerticalSize: number;
  49283. /**
  49284. * How big in texel of the blur texture is the horizontal blur.
  49285. */
  49286. blurHorizontalSize: number;
  49287. /**
  49288. * Alpha blending mode used to apply the blur. Default is combine.
  49289. */
  49290. alphaBlendingMode: number;
  49291. /**
  49292. * The camera attached to the layer.
  49293. */
  49294. camera: Nullable<Camera>;
  49295. /**
  49296. * Should we display highlight as a solid stroke?
  49297. */
  49298. isStroke?: boolean;
  49299. /**
  49300. * The rendering group to draw the layer in.
  49301. */
  49302. renderingGroupId: number;
  49303. }
  49304. /**
  49305. * The highlight layer Helps adding a glow effect around a mesh.
  49306. *
  49307. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49308. * glowy meshes to your scene.
  49309. *
  49310. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49311. */
  49312. export class HighlightLayer extends EffectLayer {
  49313. name: string;
  49314. /**
  49315. * Effect Name of the highlight layer.
  49316. */
  49317. static readonly EffectName: string;
  49318. /**
  49319. * The neutral color used during the preparation of the glow effect.
  49320. * This is black by default as the blend operation is a blend operation.
  49321. */
  49322. static NeutralColor: Color4;
  49323. /**
  49324. * Stencil value used for glowing meshes.
  49325. */
  49326. static GlowingMeshStencilReference: number;
  49327. /**
  49328. * Stencil value used for the other meshes in the scene.
  49329. */
  49330. static NormalMeshStencilReference: number;
  49331. /**
  49332. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49333. */
  49334. innerGlow: boolean;
  49335. /**
  49336. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49337. */
  49338. outerGlow: boolean;
  49339. /**
  49340. * Specifies the horizontal size of the blur.
  49341. */
  49342. /**
  49343. * Gets the horizontal size of the blur.
  49344. */
  49345. blurHorizontalSize: number;
  49346. /**
  49347. * Specifies the vertical size of the blur.
  49348. */
  49349. /**
  49350. * Gets the vertical size of the blur.
  49351. */
  49352. blurVerticalSize: number;
  49353. /**
  49354. * An event triggered when the highlight layer is being blurred.
  49355. */
  49356. onBeforeBlurObservable: Observable<HighlightLayer>;
  49357. /**
  49358. * An event triggered when the highlight layer has been blurred.
  49359. */
  49360. onAfterBlurObservable: Observable<HighlightLayer>;
  49361. private _instanceGlowingMeshStencilReference;
  49362. private _options;
  49363. private _downSamplePostprocess;
  49364. private _horizontalBlurPostprocess;
  49365. private _verticalBlurPostprocess;
  49366. private _blurTexture;
  49367. private _meshes;
  49368. private _excludedMeshes;
  49369. /**
  49370. * Instantiates a new highlight Layer and references it to the scene..
  49371. * @param name The name of the layer
  49372. * @param scene The scene to use the layer in
  49373. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49374. */
  49375. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49376. /**
  49377. * Get the effect name of the layer.
  49378. * @return The effect name
  49379. */
  49380. getEffectName(): string;
  49381. /**
  49382. * Create the merge effect. This is the shader use to blit the information back
  49383. * to the main canvas at the end of the scene rendering.
  49384. */
  49385. protected _createMergeEffect(): Effect;
  49386. /**
  49387. * Creates the render target textures and post processes used in the highlight layer.
  49388. */
  49389. protected _createTextureAndPostProcesses(): void;
  49390. /**
  49391. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49392. */
  49393. needStencil(): boolean;
  49394. /**
  49395. * Checks for the readiness of the element composing the layer.
  49396. * @param subMesh the mesh to check for
  49397. * @param useInstances specify wether or not to use instances to render the mesh
  49398. * @param emissiveTexture the associated emissive texture used to generate the glow
  49399. * @return true if ready otherwise, false
  49400. */
  49401. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49402. /**
  49403. * Implementation specific of rendering the generating effect on the main canvas.
  49404. * @param effect The effect used to render through
  49405. */
  49406. protected _internalRender(effect: Effect): void;
  49407. /**
  49408. * Returns true if the layer contains information to display, otherwise false.
  49409. */
  49410. shouldRender(): boolean;
  49411. /**
  49412. * Returns true if the mesh should render, otherwise false.
  49413. * @param mesh The mesh to render
  49414. * @returns true if it should render otherwise false
  49415. */
  49416. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49417. /**
  49418. * Sets the required values for both the emissive texture and and the main color.
  49419. */
  49420. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49421. /**
  49422. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49423. * @param mesh The mesh to exclude from the highlight layer
  49424. */
  49425. addExcludedMesh(mesh: Mesh): void;
  49426. /**
  49427. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49428. * @param mesh The mesh to highlight
  49429. */
  49430. removeExcludedMesh(mesh: Mesh): void;
  49431. /**
  49432. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49433. * @param mesh mesh to test
  49434. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49435. */
  49436. hasMesh(mesh: AbstractMesh): boolean;
  49437. /**
  49438. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49439. * @param mesh The mesh to highlight
  49440. * @param color The color of the highlight
  49441. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49442. */
  49443. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49444. /**
  49445. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49446. * @param mesh The mesh to highlight
  49447. */
  49448. removeMesh(mesh: Mesh): void;
  49449. /**
  49450. * Force the stencil to the normal expected value for none glowing parts
  49451. */
  49452. private _defaultStencilReference;
  49453. /**
  49454. * Free any resources and references associated to a mesh.
  49455. * Internal use
  49456. * @param mesh The mesh to free.
  49457. * @hidden
  49458. */
  49459. _disposeMesh(mesh: Mesh): void;
  49460. /**
  49461. * Dispose the highlight layer and free resources.
  49462. */
  49463. dispose(): void;
  49464. /**
  49465. * Gets the class name of the effect layer
  49466. * @returns the string with the class name of the effect layer
  49467. */
  49468. getClassName(): string;
  49469. /**
  49470. * Serializes this Highlight layer
  49471. * @returns a serialized Highlight layer object
  49472. */
  49473. serialize(): any;
  49474. /**
  49475. * Creates a Highlight layer from parsed Highlight layer data
  49476. * @param parsedHightlightLayer defines the Highlight layer data
  49477. * @param scene defines the current scene
  49478. * @param rootUrl defines the root URL containing the Highlight layer information
  49479. * @returns a parsed Highlight layer
  49480. */
  49481. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49482. }
  49483. }
  49484. declare module BABYLON {
  49485. interface AbstractScene {
  49486. /**
  49487. * The list of layers (background and foreground) of the scene
  49488. */
  49489. layers: Array<Layer>;
  49490. }
  49491. /**
  49492. * Defines the layer scene component responsible to manage any layers
  49493. * in a given scene.
  49494. */
  49495. export class LayerSceneComponent implements ISceneComponent {
  49496. /**
  49497. * The component name helpfull to identify the component in the list of scene components.
  49498. */
  49499. readonly name: string;
  49500. /**
  49501. * The scene the component belongs to.
  49502. */
  49503. scene: Scene;
  49504. private _engine;
  49505. /**
  49506. * Creates a new instance of the component for the given scene
  49507. * @param scene Defines the scene to register the component in
  49508. */
  49509. constructor(scene: Scene);
  49510. /**
  49511. * Registers the component in a given scene
  49512. */
  49513. register(): void;
  49514. /**
  49515. * Rebuilds the elements related to this component in case of
  49516. * context lost for instance.
  49517. */
  49518. rebuild(): void;
  49519. /**
  49520. * Disposes the component and the associated ressources.
  49521. */
  49522. dispose(): void;
  49523. private _draw;
  49524. private _drawCameraPredicate;
  49525. private _drawCameraBackground;
  49526. private _drawCameraForeground;
  49527. private _drawRenderTargetPredicate;
  49528. private _drawRenderTargetBackground;
  49529. private _drawRenderTargetForeground;
  49530. /**
  49531. * Adds all the elements from the container to the scene
  49532. * @param container the container holding the elements
  49533. */
  49534. addFromContainer(container: AbstractScene): void;
  49535. /**
  49536. * Removes all the elements in the container from the scene
  49537. * @param container contains the elements to remove
  49538. * @param dispose if the removed element should be disposed (default: false)
  49539. */
  49540. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49541. }
  49542. }
  49543. declare module BABYLON {
  49544. /** @hidden */
  49545. export var layerPixelShader: {
  49546. name: string;
  49547. shader: string;
  49548. };
  49549. }
  49550. declare module BABYLON {
  49551. /** @hidden */
  49552. export var layerVertexShader: {
  49553. name: string;
  49554. shader: string;
  49555. };
  49556. }
  49557. declare module BABYLON {
  49558. /**
  49559. * This represents a full screen 2d layer.
  49560. * This can be useful to display a picture in the background of your scene for instance.
  49561. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49562. */
  49563. export class Layer {
  49564. /**
  49565. * Define the name of the layer.
  49566. */
  49567. name: string;
  49568. /**
  49569. * Define the texture the layer should display.
  49570. */
  49571. texture: Nullable<Texture>;
  49572. /**
  49573. * Is the layer in background or foreground.
  49574. */
  49575. isBackground: boolean;
  49576. /**
  49577. * Define the color of the layer (instead of texture).
  49578. */
  49579. color: Color4;
  49580. /**
  49581. * Define the scale of the layer in order to zoom in out of the texture.
  49582. */
  49583. scale: Vector2;
  49584. /**
  49585. * Define an offset for the layer in order to shift the texture.
  49586. */
  49587. offset: Vector2;
  49588. /**
  49589. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  49590. */
  49591. alphaBlendingMode: number;
  49592. /**
  49593. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  49594. * Alpha test will not mix with the background color in case of transparency.
  49595. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  49596. */
  49597. alphaTest: boolean;
  49598. /**
  49599. * Define a mask to restrict the layer to only some of the scene cameras.
  49600. */
  49601. layerMask: number;
  49602. /**
  49603. * Define the list of render target the layer is visible into.
  49604. */
  49605. renderTargetTextures: RenderTargetTexture[];
  49606. /**
  49607. * Define if the layer is only used in renderTarget or if it also
  49608. * renders in the main frame buffer of the canvas.
  49609. */
  49610. renderOnlyInRenderTargetTextures: boolean;
  49611. private _scene;
  49612. private _vertexBuffers;
  49613. private _indexBuffer;
  49614. private _effect;
  49615. private _alphaTestEffect;
  49616. /**
  49617. * An event triggered when the layer is disposed.
  49618. */
  49619. onDisposeObservable: Observable<Layer>;
  49620. private _onDisposeObserver;
  49621. /**
  49622. * Back compatibility with callback before the onDisposeObservable existed.
  49623. * The set callback will be triggered when the layer has been disposed.
  49624. */
  49625. onDispose: () => void;
  49626. /**
  49627. * An event triggered before rendering the scene
  49628. */
  49629. onBeforeRenderObservable: Observable<Layer>;
  49630. private _onBeforeRenderObserver;
  49631. /**
  49632. * Back compatibility with callback before the onBeforeRenderObservable existed.
  49633. * The set callback will be triggered just before rendering the layer.
  49634. */
  49635. onBeforeRender: () => void;
  49636. /**
  49637. * An event triggered after rendering the scene
  49638. */
  49639. onAfterRenderObservable: Observable<Layer>;
  49640. private _onAfterRenderObserver;
  49641. /**
  49642. * Back compatibility with callback before the onAfterRenderObservable existed.
  49643. * The set callback will be triggered just after rendering the layer.
  49644. */
  49645. onAfterRender: () => void;
  49646. /**
  49647. * Instantiates a new layer.
  49648. * This represents a full screen 2d layer.
  49649. * This can be useful to display a picture in the background of your scene for instance.
  49650. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49651. * @param name Define the name of the layer in the scene
  49652. * @param imgUrl Define the url of the texture to display in the layer
  49653. * @param scene Define the scene the layer belongs to
  49654. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  49655. * @param color Defines a color for the layer
  49656. */
  49657. constructor(
  49658. /**
  49659. * Define the name of the layer.
  49660. */
  49661. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  49662. private _createIndexBuffer;
  49663. /** @hidden */
  49664. _rebuild(): void;
  49665. /**
  49666. * Renders the layer in the scene.
  49667. */
  49668. render(): void;
  49669. /**
  49670. * Disposes and releases the associated ressources.
  49671. */
  49672. dispose(): void;
  49673. }
  49674. }
  49675. declare module BABYLON {
  49676. /** @hidden */
  49677. export var lensFlarePixelShader: {
  49678. name: string;
  49679. shader: string;
  49680. };
  49681. }
  49682. declare module BABYLON {
  49683. /** @hidden */
  49684. export var lensFlareVertexShader: {
  49685. name: string;
  49686. shader: string;
  49687. };
  49688. }
  49689. declare module BABYLON {
  49690. /**
  49691. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49692. * It is usually composed of several `lensFlare`.
  49693. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49694. */
  49695. export class LensFlareSystem {
  49696. /**
  49697. * Define the name of the lens flare system
  49698. */
  49699. name: string;
  49700. /**
  49701. * List of lens flares used in this system.
  49702. */
  49703. lensFlares: LensFlare[];
  49704. /**
  49705. * Define a limit from the border the lens flare can be visible.
  49706. */
  49707. borderLimit: number;
  49708. /**
  49709. * Define a viewport border we do not want to see the lens flare in.
  49710. */
  49711. viewportBorder: number;
  49712. /**
  49713. * Define a predicate which could limit the list of meshes able to occlude the effect.
  49714. */
  49715. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49716. /**
  49717. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  49718. */
  49719. layerMask: number;
  49720. /**
  49721. * Define the id of the lens flare system in the scene.
  49722. * (equal to name by default)
  49723. */
  49724. id: string;
  49725. private _scene;
  49726. private _emitter;
  49727. private _vertexBuffers;
  49728. private _indexBuffer;
  49729. private _effect;
  49730. private _positionX;
  49731. private _positionY;
  49732. private _isEnabled;
  49733. /** @hidden */
  49734. static _SceneComponentInitialization: (scene: Scene) => void;
  49735. /**
  49736. * Instantiates a lens flare system.
  49737. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49738. * It is usually composed of several `lensFlare`.
  49739. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49740. * @param name Define the name of the lens flare system in the scene
  49741. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49742. * @param scene Define the scene the lens flare system belongs to
  49743. */
  49744. constructor(
  49745. /**
  49746. * Define the name of the lens flare system
  49747. */
  49748. name: string, emitter: any, scene: Scene);
  49749. /**
  49750. * Define if the lens flare system is enabled.
  49751. */
  49752. isEnabled: boolean;
  49753. /**
  49754. * Get the scene the effects belongs to.
  49755. * @returns the scene holding the lens flare system
  49756. */
  49757. getScene(): Scene;
  49758. /**
  49759. * Get the emitter of the lens flare system.
  49760. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49761. * @returns the emitter of the lens flare system
  49762. */
  49763. getEmitter(): any;
  49764. /**
  49765. * Set the emitter of the lens flare system.
  49766. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49767. * @param newEmitter Define the new emitter of the system
  49768. */
  49769. setEmitter(newEmitter: any): void;
  49770. /**
  49771. * Get the lens flare system emitter position.
  49772. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49773. * @returns the position
  49774. */
  49775. getEmitterPosition(): Vector3;
  49776. /**
  49777. * @hidden
  49778. */
  49779. computeEffectivePosition(globalViewport: Viewport): boolean;
  49780. /** @hidden */
  49781. _isVisible(): boolean;
  49782. /**
  49783. * @hidden
  49784. */
  49785. render(): boolean;
  49786. /**
  49787. * Dispose and release the lens flare with its associated resources.
  49788. */
  49789. dispose(): void;
  49790. /**
  49791. * Parse a lens flare system from a JSON repressentation
  49792. * @param parsedLensFlareSystem Define the JSON to parse
  49793. * @param scene Define the scene the parsed system should be instantiated in
  49794. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49795. * @returns the parsed system
  49796. */
  49797. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49798. /**
  49799. * Serialize the current Lens Flare System into a JSON representation.
  49800. * @returns the serialized JSON
  49801. */
  49802. serialize(): any;
  49803. }
  49804. }
  49805. declare module BABYLON {
  49806. /**
  49807. * This represents one of the lens effect in a `lensFlareSystem`.
  49808. * It controls one of the indiviual texture used in the effect.
  49809. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49810. */
  49811. export class LensFlare {
  49812. /**
  49813. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49814. */
  49815. size: number;
  49816. /**
  49817. * 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.
  49818. */
  49819. position: number;
  49820. /**
  49821. * Define the lens color.
  49822. */
  49823. color: Color3;
  49824. /**
  49825. * Define the lens texture.
  49826. */
  49827. texture: Nullable<Texture>;
  49828. /**
  49829. * Define the alpha mode to render this particular lens.
  49830. */
  49831. alphaMode: number;
  49832. private _system;
  49833. /**
  49834. * Creates a new Lens Flare.
  49835. * This represents one of the lens effect in a `lensFlareSystem`.
  49836. * It controls one of the indiviual texture used in the effect.
  49837. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49838. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49839. * @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.
  49840. * @param color Define the lens color
  49841. * @param imgUrl Define the lens texture url
  49842. * @param system Define the `lensFlareSystem` this flare is part of
  49843. * @returns The newly created Lens Flare
  49844. */
  49845. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49846. /**
  49847. * Instantiates a new Lens Flare.
  49848. * This represents one of the lens effect in a `lensFlareSystem`.
  49849. * It controls one of the indiviual texture used in the effect.
  49850. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49851. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49852. * @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.
  49853. * @param color Define the lens color
  49854. * @param imgUrl Define the lens texture url
  49855. * @param system Define the `lensFlareSystem` this flare is part of
  49856. */
  49857. constructor(
  49858. /**
  49859. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49860. */
  49861. size: number,
  49862. /**
  49863. * 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.
  49864. */
  49865. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49866. /**
  49867. * Dispose and release the lens flare with its associated resources.
  49868. */
  49869. dispose(): void;
  49870. }
  49871. }
  49872. declare module BABYLON {
  49873. interface AbstractScene {
  49874. /**
  49875. * The list of lens flare system added to the scene
  49876. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49877. */
  49878. lensFlareSystems: Array<LensFlareSystem>;
  49879. /**
  49880. * Removes the given lens flare system from this scene.
  49881. * @param toRemove The lens flare system to remove
  49882. * @returns The index of the removed lens flare system
  49883. */
  49884. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49885. /**
  49886. * Adds the given lens flare system to this scene
  49887. * @param newLensFlareSystem The lens flare system to add
  49888. */
  49889. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49890. /**
  49891. * Gets a lens flare system using its name
  49892. * @param name defines the name to look for
  49893. * @returns the lens flare system or null if not found
  49894. */
  49895. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49896. /**
  49897. * Gets a lens flare system using its id
  49898. * @param id defines the id to look for
  49899. * @returns the lens flare system or null if not found
  49900. */
  49901. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49902. }
  49903. /**
  49904. * Defines the lens flare scene component responsible to manage any lens flares
  49905. * in a given scene.
  49906. */
  49907. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49908. /**
  49909. * The component name helpfull to identify the component in the list of scene components.
  49910. */
  49911. readonly name: string;
  49912. /**
  49913. * The scene the component belongs to.
  49914. */
  49915. scene: Scene;
  49916. /**
  49917. * Creates a new instance of the component for the given scene
  49918. * @param scene Defines the scene to register the component in
  49919. */
  49920. constructor(scene: Scene);
  49921. /**
  49922. * Registers the component in a given scene
  49923. */
  49924. register(): void;
  49925. /**
  49926. * Rebuilds the elements related to this component in case of
  49927. * context lost for instance.
  49928. */
  49929. rebuild(): void;
  49930. /**
  49931. * Adds all the elements from the container to the scene
  49932. * @param container the container holding the elements
  49933. */
  49934. addFromContainer(container: AbstractScene): void;
  49935. /**
  49936. * Removes all the elements in the container from the scene
  49937. * @param container contains the elements to remove
  49938. * @param dispose if the removed element should be disposed (default: false)
  49939. */
  49940. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49941. /**
  49942. * Serializes the component data to the specified json object
  49943. * @param serializationObject The object to serialize to
  49944. */
  49945. serialize(serializationObject: any): void;
  49946. /**
  49947. * Disposes the component and the associated ressources.
  49948. */
  49949. dispose(): void;
  49950. private _draw;
  49951. }
  49952. }
  49953. declare module BABYLON {
  49954. /**
  49955. * Defines the shadow generator component responsible to manage any shadow generators
  49956. * in a given scene.
  49957. */
  49958. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49959. /**
  49960. * The component name helpfull to identify the component in the list of scene components.
  49961. */
  49962. readonly name: string;
  49963. /**
  49964. * The scene the component belongs to.
  49965. */
  49966. scene: Scene;
  49967. /**
  49968. * Creates a new instance of the component for the given scene
  49969. * @param scene Defines the scene to register the component in
  49970. */
  49971. constructor(scene: Scene);
  49972. /**
  49973. * Registers the component in a given scene
  49974. */
  49975. register(): void;
  49976. /**
  49977. * Rebuilds the elements related to this component in case of
  49978. * context lost for instance.
  49979. */
  49980. rebuild(): void;
  49981. /**
  49982. * Serializes the component data to the specified json object
  49983. * @param serializationObject The object to serialize to
  49984. */
  49985. serialize(serializationObject: any): void;
  49986. /**
  49987. * Adds all the elements from the container to the scene
  49988. * @param container the container holding the elements
  49989. */
  49990. addFromContainer(container: AbstractScene): void;
  49991. /**
  49992. * Removes all the elements in the container from the scene
  49993. * @param container contains the elements to remove
  49994. * @param dispose if the removed element should be disposed (default: false)
  49995. */
  49996. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49997. /**
  49998. * Rebuilds the elements related to this component in case of
  49999. * context lost for instance.
  50000. */
  50001. dispose(): void;
  50002. private _gatherRenderTargets;
  50003. }
  50004. }
  50005. declare module BABYLON {
  50006. /**
  50007. * A point light is a light defined by an unique point in world space.
  50008. * The light is emitted in every direction from this point.
  50009. * A good example of a point light is a standard light bulb.
  50010. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50011. */
  50012. export class PointLight extends ShadowLight {
  50013. private _shadowAngle;
  50014. /**
  50015. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50016. * This specifies what angle the shadow will use to be created.
  50017. *
  50018. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50019. */
  50020. /**
  50021. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50022. * This specifies what angle the shadow will use to be created.
  50023. *
  50024. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50025. */
  50026. shadowAngle: number;
  50027. /**
  50028. * Gets the direction if it has been set.
  50029. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50030. */
  50031. /**
  50032. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50033. */
  50034. direction: Vector3;
  50035. /**
  50036. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50037. * A PointLight emits the light in every direction.
  50038. * It can cast shadows.
  50039. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50040. * ```javascript
  50041. * var pointLight = new PointLight("pl", camera.position, scene);
  50042. * ```
  50043. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50044. * @param name The light friendly name
  50045. * @param position The position of the point light in the scene
  50046. * @param scene The scene the lights belongs to
  50047. */
  50048. constructor(name: string, position: Vector3, scene: Scene);
  50049. /**
  50050. * Returns the string "PointLight"
  50051. * @returns the class name
  50052. */
  50053. getClassName(): string;
  50054. /**
  50055. * Returns the integer 0.
  50056. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50057. */
  50058. getTypeID(): number;
  50059. /**
  50060. * Specifies wether or not the shadowmap should be a cube texture.
  50061. * @returns true if the shadowmap needs to be a cube texture.
  50062. */
  50063. needCube(): boolean;
  50064. /**
  50065. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50066. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50067. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50068. */
  50069. getShadowDirection(faceIndex?: number): Vector3;
  50070. /**
  50071. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50072. * - fov = PI / 2
  50073. * - aspect ratio : 1.0
  50074. * - z-near and far equal to the active camera minZ and maxZ.
  50075. * Returns the PointLight.
  50076. */
  50077. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50078. protected _buildUniformLayout(): void;
  50079. /**
  50080. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50081. * @param effect The effect to update
  50082. * @param lightIndex The index of the light in the effect to update
  50083. * @returns The point light
  50084. */
  50085. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50086. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  50087. /**
  50088. * Prepares the list of defines specific to the light type.
  50089. * @param defines the list of defines
  50090. * @param lightIndex defines the index of the light for the effect
  50091. */
  50092. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50093. }
  50094. }
  50095. declare module BABYLON {
  50096. /**
  50097. * Header information of HDR texture files.
  50098. */
  50099. export interface HDRInfo {
  50100. /**
  50101. * The height of the texture in pixels.
  50102. */
  50103. height: number;
  50104. /**
  50105. * The width of the texture in pixels.
  50106. */
  50107. width: number;
  50108. /**
  50109. * The index of the beginning of the data in the binary file.
  50110. */
  50111. dataPosition: number;
  50112. }
  50113. /**
  50114. * This groups tools to convert HDR texture to native colors array.
  50115. */
  50116. export class HDRTools {
  50117. private static Ldexp;
  50118. private static Rgbe2float;
  50119. private static readStringLine;
  50120. /**
  50121. * Reads header information from an RGBE texture stored in a native array.
  50122. * More information on this format are available here:
  50123. * https://en.wikipedia.org/wiki/RGBE_image_format
  50124. *
  50125. * @param uint8array The binary file stored in native array.
  50126. * @return The header information.
  50127. */
  50128. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50129. /**
  50130. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50131. * This RGBE texture needs to store the information as a panorama.
  50132. *
  50133. * More information on this format are available here:
  50134. * https://en.wikipedia.org/wiki/RGBE_image_format
  50135. *
  50136. * @param buffer The binary file stored in an array buffer.
  50137. * @param size The expected size of the extracted cubemap.
  50138. * @return The Cube Map information.
  50139. */
  50140. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50141. /**
  50142. * Returns the pixels data extracted from an RGBE texture.
  50143. * This pixels will be stored left to right up to down in the R G B order in one array.
  50144. *
  50145. * More information on this format are available here:
  50146. * https://en.wikipedia.org/wiki/RGBE_image_format
  50147. *
  50148. * @param uint8array The binary file stored in an array buffer.
  50149. * @param hdrInfo The header information of the file.
  50150. * @return The pixels data in RGB right to left up to down order.
  50151. */
  50152. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50153. private static RGBE_ReadPixels_RLE;
  50154. }
  50155. }
  50156. declare module BABYLON {
  50157. /**
  50158. * This represents a texture coming from an HDR input.
  50159. *
  50160. * The only supported format is currently panorama picture stored in RGBE format.
  50161. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50162. */
  50163. export class HDRCubeTexture extends BaseTexture {
  50164. private static _facesMapping;
  50165. private _generateHarmonics;
  50166. private _noMipmap;
  50167. private _textureMatrix;
  50168. private _size;
  50169. private _onLoad;
  50170. private _onError;
  50171. /**
  50172. * The texture URL.
  50173. */
  50174. url: string;
  50175. /**
  50176. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50177. */
  50178. coordinatesMode: number;
  50179. protected _isBlocking: boolean;
  50180. /**
  50181. * Sets wether or not the texture is blocking during loading.
  50182. */
  50183. /**
  50184. * Gets wether or not the texture is blocking during loading.
  50185. */
  50186. isBlocking: boolean;
  50187. protected _rotationY: number;
  50188. /**
  50189. * Sets texture matrix rotation angle around Y axis in radians.
  50190. */
  50191. /**
  50192. * Gets texture matrix rotation angle around Y axis radians.
  50193. */
  50194. rotationY: number;
  50195. /**
  50196. * Gets or sets the center of the bounding box associated with the cube texture
  50197. * It must define where the camera used to render the texture was set
  50198. */
  50199. boundingBoxPosition: Vector3;
  50200. private _boundingBoxSize;
  50201. /**
  50202. * Gets or sets the size of the bounding box associated with the cube texture
  50203. * When defined, the cubemap will switch to local mode
  50204. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50205. * @example https://www.babylonjs-playground.com/#RNASML
  50206. */
  50207. boundingBoxSize: Vector3;
  50208. /**
  50209. * Instantiates an HDRTexture from the following parameters.
  50210. *
  50211. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50212. * @param scene The scene the texture will be used in
  50213. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50214. * @param noMipmap Forces to not generate the mipmap if true
  50215. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50216. * @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)
  50217. * @param reserved Reserved flag for internal use.
  50218. */
  50219. 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>);
  50220. /**
  50221. * Get the current class name of the texture useful for serialization or dynamic coding.
  50222. * @returns "HDRCubeTexture"
  50223. */
  50224. getClassName(): string;
  50225. /**
  50226. * Occurs when the file is raw .hdr file.
  50227. */
  50228. private loadTexture;
  50229. clone(): HDRCubeTexture;
  50230. delayLoad(): void;
  50231. /**
  50232. * Get the texture reflection matrix used to rotate/transform the reflection.
  50233. * @returns the reflection matrix
  50234. */
  50235. getReflectionTextureMatrix(): Matrix;
  50236. /**
  50237. * Set the texture reflection matrix used to rotate/transform the reflection.
  50238. * @param value Define the reflection matrix to set
  50239. */
  50240. setReflectionTextureMatrix(value: Matrix): void;
  50241. /**
  50242. * Parses a JSON representation of an HDR Texture in order to create the texture
  50243. * @param parsedTexture Define the JSON representation
  50244. * @param scene Define the scene the texture should be created in
  50245. * @param rootUrl Define the root url in case we need to load relative dependencies
  50246. * @returns the newly created texture after parsing
  50247. */
  50248. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50249. serialize(): any;
  50250. }
  50251. }
  50252. declare module BABYLON {
  50253. /**
  50254. * Class used to control physics engine
  50255. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50256. */
  50257. export class PhysicsEngine implements IPhysicsEngine {
  50258. private _physicsPlugin;
  50259. /**
  50260. * Global value used to control the smallest number supported by the simulation
  50261. */
  50262. static Epsilon: number;
  50263. private _impostors;
  50264. private _joints;
  50265. /**
  50266. * Gets the gravity vector used by the simulation
  50267. */
  50268. gravity: Vector3;
  50269. /**
  50270. * Factory used to create the default physics plugin.
  50271. * @returns The default physics plugin
  50272. */
  50273. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50274. /**
  50275. * Creates a new Physics Engine
  50276. * @param gravity defines the gravity vector used by the simulation
  50277. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50278. */
  50279. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50280. /**
  50281. * Sets the gravity vector used by the simulation
  50282. * @param gravity defines the gravity vector to use
  50283. */
  50284. setGravity(gravity: Vector3): void;
  50285. /**
  50286. * Set the time step of the physics engine.
  50287. * Default is 1/60.
  50288. * To slow it down, enter 1/600 for example.
  50289. * To speed it up, 1/30
  50290. * @param newTimeStep defines the new timestep to apply to this world.
  50291. */
  50292. setTimeStep(newTimeStep?: number): void;
  50293. /**
  50294. * Get the time step of the physics engine.
  50295. * @returns the current time step
  50296. */
  50297. getTimeStep(): number;
  50298. /**
  50299. * Release all resources
  50300. */
  50301. dispose(): void;
  50302. /**
  50303. * Gets the name of the current physics plugin
  50304. * @returns the name of the plugin
  50305. */
  50306. getPhysicsPluginName(): string;
  50307. /**
  50308. * Adding a new impostor for the impostor tracking.
  50309. * This will be done by the impostor itself.
  50310. * @param impostor the impostor to add
  50311. */
  50312. addImpostor(impostor: PhysicsImpostor): void;
  50313. /**
  50314. * Remove an impostor from the engine.
  50315. * This impostor and its mesh will not longer be updated by the physics engine.
  50316. * @param impostor the impostor to remove
  50317. */
  50318. removeImpostor(impostor: PhysicsImpostor): void;
  50319. /**
  50320. * Add a joint to the physics engine
  50321. * @param mainImpostor defines the main impostor to which the joint is added.
  50322. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50323. * @param joint defines the joint that will connect both impostors.
  50324. */
  50325. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50326. /**
  50327. * Removes a joint from the simulation
  50328. * @param mainImpostor defines the impostor used with the joint
  50329. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50330. * @param joint defines the joint to remove
  50331. */
  50332. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50333. /**
  50334. * Called by the scene. No need to call it.
  50335. * @param delta defines the timespam between frames
  50336. */
  50337. _step(delta: number): void;
  50338. /**
  50339. * Gets the current plugin used to run the simulation
  50340. * @returns current plugin
  50341. */
  50342. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50343. /**
  50344. * Gets the list of physic impostors
  50345. * @returns an array of PhysicsImpostor
  50346. */
  50347. getImpostors(): Array<PhysicsImpostor>;
  50348. /**
  50349. * Gets the impostor for a physics enabled object
  50350. * @param object defines the object impersonated by the impostor
  50351. * @returns the PhysicsImpostor or null if not found
  50352. */
  50353. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50354. /**
  50355. * Gets the impostor for a physics body object
  50356. * @param body defines physics body used by the impostor
  50357. * @returns the PhysicsImpostor or null if not found
  50358. */
  50359. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50360. /**
  50361. * Does a raycast in the physics world
  50362. * @param from when should the ray start?
  50363. * @param to when should the ray end?
  50364. * @returns PhysicsRaycastResult
  50365. */
  50366. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50367. }
  50368. }
  50369. declare module BABYLON {
  50370. /** @hidden */
  50371. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50372. private _useDeltaForWorldStep;
  50373. world: any;
  50374. name: string;
  50375. private _physicsMaterials;
  50376. private _fixedTimeStep;
  50377. private _cannonRaycastResult;
  50378. private _raycastResult;
  50379. private _physicsBodysToRemoveAfterStep;
  50380. BJSCANNON: any;
  50381. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50382. setGravity(gravity: Vector3): void;
  50383. setTimeStep(timeStep: number): void;
  50384. getTimeStep(): number;
  50385. executeStep(delta: number): void;
  50386. private _removeMarkedPhysicsBodiesFromWorld;
  50387. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50388. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50389. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50390. private _processChildMeshes;
  50391. removePhysicsBody(impostor: PhysicsImpostor): void;
  50392. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50393. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50394. private _addMaterial;
  50395. private _checkWithEpsilon;
  50396. private _createShape;
  50397. private _createHeightmap;
  50398. private _minus90X;
  50399. private _plus90X;
  50400. private _tmpPosition;
  50401. private _tmpDeltaPosition;
  50402. private _tmpUnityRotation;
  50403. private _updatePhysicsBodyTransformation;
  50404. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50405. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50406. isSupported(): boolean;
  50407. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50408. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50409. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50410. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50411. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50412. getBodyMass(impostor: PhysicsImpostor): number;
  50413. getBodyFriction(impostor: PhysicsImpostor): number;
  50414. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50415. getBodyRestitution(impostor: PhysicsImpostor): number;
  50416. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50417. sleepBody(impostor: PhysicsImpostor): void;
  50418. wakeUpBody(impostor: PhysicsImpostor): void;
  50419. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  50420. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50421. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50422. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50423. getRadius(impostor: PhysicsImpostor): number;
  50424. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50425. dispose(): void;
  50426. private _extendNamespace;
  50427. /**
  50428. * Does a raycast in the physics world
  50429. * @param from when should the ray start?
  50430. * @param to when should the ray end?
  50431. * @returns PhysicsRaycastResult
  50432. */
  50433. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50434. }
  50435. }
  50436. declare module BABYLON {
  50437. /** @hidden */
  50438. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  50439. world: any;
  50440. name: string;
  50441. BJSOIMO: any;
  50442. private _raycastResult;
  50443. constructor(iterations?: number, oimoInjection?: any);
  50444. setGravity(gravity: Vector3): void;
  50445. setTimeStep(timeStep: number): void;
  50446. getTimeStep(): number;
  50447. private _tmpImpostorsArray;
  50448. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50449. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50450. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50451. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50452. private _tmpPositionVector;
  50453. removePhysicsBody(impostor: PhysicsImpostor): void;
  50454. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50455. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50456. isSupported(): boolean;
  50457. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50458. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50459. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50460. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50461. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50462. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50463. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50464. getBodyMass(impostor: PhysicsImpostor): number;
  50465. getBodyFriction(impostor: PhysicsImpostor): number;
  50466. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50467. getBodyRestitution(impostor: PhysicsImpostor): number;
  50468. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50469. sleepBody(impostor: PhysicsImpostor): void;
  50470. wakeUpBody(impostor: PhysicsImpostor): void;
  50471. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50472. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  50473. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  50474. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50475. getRadius(impostor: PhysicsImpostor): number;
  50476. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50477. dispose(): void;
  50478. /**
  50479. * Does a raycast in the physics world
  50480. * @param from when should the ray start?
  50481. * @param to when should the ray end?
  50482. * @returns PhysicsRaycastResult
  50483. */
  50484. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50485. }
  50486. }
  50487. declare module BABYLON {
  50488. /**
  50489. * Class containing static functions to help procedurally build meshes
  50490. */
  50491. export class RibbonBuilder {
  50492. /**
  50493. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50494. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50495. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50496. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50497. * * 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
  50498. * * 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
  50499. * * 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
  50500. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50501. * * 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
  50502. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50503. * * 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
  50504. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50505. * * 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
  50506. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50507. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50508. * @param name defines the name of the mesh
  50509. * @param options defines the options used to create the mesh
  50510. * @param scene defines the hosting scene
  50511. * @returns the ribbon mesh
  50512. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50513. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50514. */
  50515. static CreateRibbon(name: string, options: {
  50516. pathArray: Vector3[][];
  50517. closeArray?: boolean;
  50518. closePath?: boolean;
  50519. offset?: number;
  50520. updatable?: boolean;
  50521. sideOrientation?: number;
  50522. frontUVs?: Vector4;
  50523. backUVs?: Vector4;
  50524. instance?: Mesh;
  50525. invertUV?: boolean;
  50526. uvs?: Vector2[];
  50527. colors?: Color4[];
  50528. }, scene?: Nullable<Scene>): Mesh;
  50529. }
  50530. }
  50531. declare module BABYLON {
  50532. /**
  50533. * Class containing static functions to help procedurally build meshes
  50534. */
  50535. export class ShapeBuilder {
  50536. /**
  50537. * 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.
  50538. * * 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.
  50539. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50540. * * 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.
  50541. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50542. * * 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
  50543. * * 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
  50544. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50545. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50546. * * 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
  50547. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50548. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50549. * @param name defines the name of the mesh
  50550. * @param options defines the options used to create the mesh
  50551. * @param scene defines the hosting scene
  50552. * @returns the extruded shape mesh
  50553. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50554. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50555. */
  50556. static ExtrudeShape(name: string, options: {
  50557. shape: Vector3[];
  50558. path: Vector3[];
  50559. scale?: number;
  50560. rotation?: number;
  50561. cap?: number;
  50562. updatable?: boolean;
  50563. sideOrientation?: number;
  50564. frontUVs?: Vector4;
  50565. backUVs?: Vector4;
  50566. instance?: Mesh;
  50567. invertUV?: boolean;
  50568. }, scene?: Nullable<Scene>): Mesh;
  50569. /**
  50570. * Creates an custom extruded shape mesh.
  50571. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50572. * * 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.
  50573. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50574. * * 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
  50575. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50576. * * 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
  50577. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50578. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50579. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50580. * * 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
  50581. * * 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
  50582. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50583. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50584. * * 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
  50585. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50586. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50587. * @param name defines the name of the mesh
  50588. * @param options defines the options used to create the mesh
  50589. * @param scene defines the hosting scene
  50590. * @returns the custom extruded shape mesh
  50591. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50592. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50593. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50594. */
  50595. static ExtrudeShapeCustom(name: string, options: {
  50596. shape: Vector3[];
  50597. path: Vector3[];
  50598. scaleFunction?: any;
  50599. rotationFunction?: any;
  50600. ribbonCloseArray?: boolean;
  50601. ribbonClosePath?: boolean;
  50602. cap?: number;
  50603. updatable?: boolean;
  50604. sideOrientation?: number;
  50605. frontUVs?: Vector4;
  50606. backUVs?: Vector4;
  50607. instance?: Mesh;
  50608. invertUV?: boolean;
  50609. }, scene?: Nullable<Scene>): Mesh;
  50610. private static _ExtrudeShapeGeneric;
  50611. }
  50612. }
  50613. declare module BABYLON {
  50614. /**
  50615. * AmmoJS Physics plugin
  50616. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50617. * @see https://github.com/kripken/ammo.js/
  50618. */
  50619. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50620. private _useDeltaForWorldStep;
  50621. /**
  50622. * Reference to the Ammo library
  50623. */
  50624. bjsAMMO: any;
  50625. /**
  50626. * Created ammoJS world which physics bodies are added to
  50627. */
  50628. world: any;
  50629. /**
  50630. * Name of the plugin
  50631. */
  50632. name: string;
  50633. private _timeStep;
  50634. private _fixedTimeStep;
  50635. private _maxSteps;
  50636. private _tmpQuaternion;
  50637. private _tmpAmmoTransform;
  50638. private _tmpAmmoQuaternion;
  50639. private _tmpAmmoConcreteContactResultCallback;
  50640. private _collisionConfiguration;
  50641. private _dispatcher;
  50642. private _overlappingPairCache;
  50643. private _solver;
  50644. private _softBodySolver;
  50645. private _tmpAmmoVectorA;
  50646. private _tmpAmmoVectorB;
  50647. private _tmpAmmoVectorC;
  50648. private _tmpAmmoVectorD;
  50649. private _tmpContactCallbackResult;
  50650. private _tmpAmmoVectorRCA;
  50651. private _tmpAmmoVectorRCB;
  50652. private _raycastResult;
  50653. private static readonly DISABLE_COLLISION_FLAG;
  50654. private static readonly KINEMATIC_FLAG;
  50655. private static readonly DISABLE_DEACTIVATION_FLAG;
  50656. /**
  50657. * Initializes the ammoJS plugin
  50658. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50659. * @param ammoInjection can be used to inject your own ammo reference
  50660. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  50661. */
  50662. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  50663. /**
  50664. * Sets the gravity of the physics world (m/(s^2))
  50665. * @param gravity Gravity to set
  50666. */
  50667. setGravity(gravity: Vector3): void;
  50668. /**
  50669. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50670. * @param timeStep timestep to use in seconds
  50671. */
  50672. setTimeStep(timeStep: number): void;
  50673. /**
  50674. * 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)
  50675. * @param fixedTimeStep fixedTimeStep to use in seconds
  50676. */
  50677. setFixedTimeStep(fixedTimeStep: number): void;
  50678. /**
  50679. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50680. * @param maxSteps the maximum number of steps by the physics engine per frame
  50681. */
  50682. setMaxSteps(maxSteps: number): void;
  50683. /**
  50684. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50685. * @returns the current timestep in seconds
  50686. */
  50687. getTimeStep(): number;
  50688. private _isImpostorInContact;
  50689. private _isImpostorPairInContact;
  50690. private _stepSimulation;
  50691. /**
  50692. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50693. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50694. * After the step the babylon meshes are set to the position of the physics imposters
  50695. * @param delta amount of time to step forward
  50696. * @param impostors array of imposters to update before/after the step
  50697. */
  50698. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50699. /**
  50700. * Update babylon mesh to match physics world object
  50701. * @param impostor imposter to match
  50702. */
  50703. private _afterSoftStep;
  50704. /**
  50705. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50706. * @param impostor imposter to match
  50707. */
  50708. private _ropeStep;
  50709. /**
  50710. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50711. * @param impostor imposter to match
  50712. */
  50713. private _softbodyOrClothStep;
  50714. private _tmpVector;
  50715. private _tmpMatrix;
  50716. /**
  50717. * Applies an impulse on the imposter
  50718. * @param impostor imposter to apply impulse to
  50719. * @param force amount of force to be applied to the imposter
  50720. * @param contactPoint the location to apply the impulse on the imposter
  50721. */
  50722. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50723. /**
  50724. * Applies a force on the imposter
  50725. * @param impostor imposter to apply force
  50726. * @param force amount of force to be applied to the imposter
  50727. * @param contactPoint the location to apply the force on the imposter
  50728. */
  50729. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50730. /**
  50731. * Creates a physics body using the plugin
  50732. * @param impostor the imposter to create the physics body on
  50733. */
  50734. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50735. /**
  50736. * Removes the physics body from the imposter and disposes of the body's memory
  50737. * @param impostor imposter to remove the physics body from
  50738. */
  50739. removePhysicsBody(impostor: PhysicsImpostor): void;
  50740. /**
  50741. * Generates a joint
  50742. * @param impostorJoint the imposter joint to create the joint with
  50743. */
  50744. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50745. /**
  50746. * Removes a joint
  50747. * @param impostorJoint the imposter joint to remove the joint from
  50748. */
  50749. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50750. private _addMeshVerts;
  50751. /**
  50752. * Initialise the soft body vertices to match its object's (mesh) vertices
  50753. * Softbody vertices (nodes) are in world space and to match this
  50754. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50755. * @param impostor to create the softbody for
  50756. */
  50757. private _softVertexData;
  50758. /**
  50759. * Create an impostor's soft body
  50760. * @param impostor to create the softbody for
  50761. */
  50762. private _createSoftbody;
  50763. /**
  50764. * Create cloth for an impostor
  50765. * @param impostor to create the softbody for
  50766. */
  50767. private _createCloth;
  50768. /**
  50769. * Create rope for an impostor
  50770. * @param impostor to create the softbody for
  50771. */
  50772. private _createRope;
  50773. private _addHullVerts;
  50774. private _createShape;
  50775. /**
  50776. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50777. * @param impostor imposter containing the physics body and babylon object
  50778. */
  50779. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50780. /**
  50781. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50782. * @param impostor imposter containing the physics body and babylon object
  50783. * @param newPosition new position
  50784. * @param newRotation new rotation
  50785. */
  50786. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50787. /**
  50788. * If this plugin is supported
  50789. * @returns true if its supported
  50790. */
  50791. isSupported(): boolean;
  50792. /**
  50793. * Sets the linear velocity of the physics body
  50794. * @param impostor imposter to set the velocity on
  50795. * @param velocity velocity to set
  50796. */
  50797. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50798. /**
  50799. * Sets the angular velocity of the physics body
  50800. * @param impostor imposter to set the velocity on
  50801. * @param velocity velocity to set
  50802. */
  50803. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50804. /**
  50805. * gets the linear velocity
  50806. * @param impostor imposter to get linear velocity from
  50807. * @returns linear velocity
  50808. */
  50809. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50810. /**
  50811. * gets the angular velocity
  50812. * @param impostor imposter to get angular velocity from
  50813. * @returns angular velocity
  50814. */
  50815. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50816. /**
  50817. * Sets the mass of physics body
  50818. * @param impostor imposter to set the mass on
  50819. * @param mass mass to set
  50820. */
  50821. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50822. /**
  50823. * Gets the mass of the physics body
  50824. * @param impostor imposter to get the mass from
  50825. * @returns mass
  50826. */
  50827. getBodyMass(impostor: PhysicsImpostor): number;
  50828. /**
  50829. * Gets friction of the impostor
  50830. * @param impostor impostor to get friction from
  50831. * @returns friction value
  50832. */
  50833. getBodyFriction(impostor: PhysicsImpostor): number;
  50834. /**
  50835. * Sets friction of the impostor
  50836. * @param impostor impostor to set friction on
  50837. * @param friction friction value
  50838. */
  50839. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50840. /**
  50841. * Gets restitution of the impostor
  50842. * @param impostor impostor to get restitution from
  50843. * @returns restitution value
  50844. */
  50845. getBodyRestitution(impostor: PhysicsImpostor): number;
  50846. /**
  50847. * Sets resitution of the impostor
  50848. * @param impostor impostor to set resitution on
  50849. * @param restitution resitution value
  50850. */
  50851. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50852. /**
  50853. * Gets pressure inside the impostor
  50854. * @param impostor impostor to get pressure from
  50855. * @returns pressure value
  50856. */
  50857. getBodyPressure(impostor: PhysicsImpostor): number;
  50858. /**
  50859. * Sets pressure inside a soft body impostor
  50860. * Cloth and rope must remain 0 pressure
  50861. * @param impostor impostor to set pressure on
  50862. * @param pressure pressure value
  50863. */
  50864. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50865. /**
  50866. * Gets stiffness of the impostor
  50867. * @param impostor impostor to get stiffness from
  50868. * @returns pressure value
  50869. */
  50870. getBodyStiffness(impostor: PhysicsImpostor): number;
  50871. /**
  50872. * Sets stiffness of the impostor
  50873. * @param impostor impostor to set stiffness on
  50874. * @param stiffness stiffness value from 0 to 1
  50875. */
  50876. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50877. /**
  50878. * Gets velocityIterations of the impostor
  50879. * @param impostor impostor to get velocity iterations from
  50880. * @returns velocityIterations value
  50881. */
  50882. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50883. /**
  50884. * Sets velocityIterations of the impostor
  50885. * @param impostor impostor to set velocity iterations on
  50886. * @param velocityIterations velocityIterations value
  50887. */
  50888. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50889. /**
  50890. * Gets positionIterations of the impostor
  50891. * @param impostor impostor to get position iterations from
  50892. * @returns positionIterations value
  50893. */
  50894. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50895. /**
  50896. * Sets positionIterations of the impostor
  50897. * @param impostor impostor to set position on
  50898. * @param positionIterations positionIterations value
  50899. */
  50900. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50901. /**
  50902. * Append an anchor to a cloth object
  50903. * @param impostor is the cloth impostor to add anchor to
  50904. * @param otherImpostor is the rigid impostor to anchor to
  50905. * @param width ratio across width from 0 to 1
  50906. * @param height ratio up height from 0 to 1
  50907. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50908. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50909. */
  50910. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50911. /**
  50912. * Append an hook to a rope object
  50913. * @param impostor is the rope impostor to add hook to
  50914. * @param otherImpostor is the rigid impostor to hook to
  50915. * @param length ratio along the rope from 0 to 1
  50916. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50917. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50918. */
  50919. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50920. /**
  50921. * Sleeps the physics body and stops it from being active
  50922. * @param impostor impostor to sleep
  50923. */
  50924. sleepBody(impostor: PhysicsImpostor): void;
  50925. /**
  50926. * Activates the physics body
  50927. * @param impostor impostor to activate
  50928. */
  50929. wakeUpBody(impostor: PhysicsImpostor): void;
  50930. /**
  50931. * Updates the distance parameters of the joint
  50932. * @param joint joint to update
  50933. * @param maxDistance maximum distance of the joint
  50934. * @param minDistance minimum distance of the joint
  50935. */
  50936. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50937. /**
  50938. * Sets a motor on the joint
  50939. * @param joint joint to set motor on
  50940. * @param speed speed of the motor
  50941. * @param maxForce maximum force of the motor
  50942. * @param motorIndex index of the motor
  50943. */
  50944. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50945. /**
  50946. * Sets the motors limit
  50947. * @param joint joint to set limit on
  50948. * @param upperLimit upper limit
  50949. * @param lowerLimit lower limit
  50950. */
  50951. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50952. /**
  50953. * Syncs the position and rotation of a mesh with the impostor
  50954. * @param mesh mesh to sync
  50955. * @param impostor impostor to update the mesh with
  50956. */
  50957. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50958. /**
  50959. * Gets the radius of the impostor
  50960. * @param impostor impostor to get radius from
  50961. * @returns the radius
  50962. */
  50963. getRadius(impostor: PhysicsImpostor): number;
  50964. /**
  50965. * Gets the box size of the impostor
  50966. * @param impostor impostor to get box size from
  50967. * @param result the resulting box size
  50968. */
  50969. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50970. /**
  50971. * Disposes of the impostor
  50972. */
  50973. dispose(): void;
  50974. /**
  50975. * Does a raycast in the physics world
  50976. * @param from when should the ray start?
  50977. * @param to when should the ray end?
  50978. * @returns PhysicsRaycastResult
  50979. */
  50980. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50981. }
  50982. }
  50983. declare module BABYLON {
  50984. interface AbstractScene {
  50985. /**
  50986. * The list of reflection probes added to the scene
  50987. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50988. */
  50989. reflectionProbes: Array<ReflectionProbe>;
  50990. /**
  50991. * Removes the given reflection probe from this scene.
  50992. * @param toRemove The reflection probe to remove
  50993. * @returns The index of the removed reflection probe
  50994. */
  50995. removeReflectionProbe(toRemove: ReflectionProbe): number;
  50996. /**
  50997. * Adds the given reflection probe to this scene.
  50998. * @param newReflectionProbe The reflection probe to add
  50999. */
  51000. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51001. }
  51002. /**
  51003. * Class used to generate realtime reflection / refraction cube textures
  51004. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51005. */
  51006. export class ReflectionProbe {
  51007. /** defines the name of the probe */
  51008. name: string;
  51009. private _scene;
  51010. private _renderTargetTexture;
  51011. private _projectionMatrix;
  51012. private _viewMatrix;
  51013. private _target;
  51014. private _add;
  51015. private _attachedMesh;
  51016. private _invertYAxis;
  51017. /** Gets or sets probe position (center of the cube map) */
  51018. position: Vector3;
  51019. /**
  51020. * Creates a new reflection probe
  51021. * @param name defines the name of the probe
  51022. * @param size defines the texture resolution (for each face)
  51023. * @param scene defines the hosting scene
  51024. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51025. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51026. */
  51027. constructor(
  51028. /** defines the name of the probe */
  51029. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51030. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51031. samples: number;
  51032. /** Gets or sets the refresh rate to use (on every frame by default) */
  51033. refreshRate: number;
  51034. /**
  51035. * Gets the hosting scene
  51036. * @returns a Scene
  51037. */
  51038. getScene(): Scene;
  51039. /** Gets the internal CubeTexture used to render to */
  51040. readonly cubeTexture: RenderTargetTexture;
  51041. /** Gets the list of meshes to render */
  51042. readonly renderList: Nullable<AbstractMesh[]>;
  51043. /**
  51044. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51045. * @param mesh defines the mesh to attach to
  51046. */
  51047. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51048. /**
  51049. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51050. * @param renderingGroupId The rendering group id corresponding to its index
  51051. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51052. */
  51053. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51054. /**
  51055. * Clean all associated resources
  51056. */
  51057. dispose(): void;
  51058. /**
  51059. * Converts the reflection probe information to a readable string for debug purpose.
  51060. * @param fullDetails Supports for multiple levels of logging within scene loading
  51061. * @returns the human readable reflection probe info
  51062. */
  51063. toString(fullDetails?: boolean): string;
  51064. /**
  51065. * Get the class name of the relfection probe.
  51066. * @returns "ReflectionProbe"
  51067. */
  51068. getClassName(): string;
  51069. /**
  51070. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51071. * @returns The JSON representation of the texture
  51072. */
  51073. serialize(): any;
  51074. /**
  51075. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51076. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51077. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51078. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51079. * @returns The parsed reflection probe if successful
  51080. */
  51081. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51082. }
  51083. }
  51084. declare module BABYLON {
  51085. /** @hidden */
  51086. export var _BabylonLoaderRegistered: boolean;
  51087. }
  51088. declare module BABYLON {
  51089. /**
  51090. * The Physically based simple base material of BJS.
  51091. *
  51092. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51093. * It is used as the base class for both the specGloss and metalRough conventions.
  51094. */
  51095. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51096. /**
  51097. * Number of Simultaneous lights allowed on the material.
  51098. */
  51099. maxSimultaneousLights: number;
  51100. /**
  51101. * If sets to true, disables all the lights affecting the material.
  51102. */
  51103. disableLighting: boolean;
  51104. /**
  51105. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51106. */
  51107. environmentTexture: BaseTexture;
  51108. /**
  51109. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51110. */
  51111. invertNormalMapX: boolean;
  51112. /**
  51113. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51114. */
  51115. invertNormalMapY: boolean;
  51116. /**
  51117. * Normal map used in the model.
  51118. */
  51119. normalTexture: BaseTexture;
  51120. /**
  51121. * Emissivie color used to self-illuminate the model.
  51122. */
  51123. emissiveColor: Color3;
  51124. /**
  51125. * Emissivie texture used to self-illuminate the model.
  51126. */
  51127. emissiveTexture: BaseTexture;
  51128. /**
  51129. * Occlusion Channel Strenght.
  51130. */
  51131. occlusionStrength: number;
  51132. /**
  51133. * Occlusion Texture of the material (adding extra occlusion effects).
  51134. */
  51135. occlusionTexture: BaseTexture;
  51136. /**
  51137. * Defines the alpha limits in alpha test mode.
  51138. */
  51139. alphaCutOff: number;
  51140. /**
  51141. * Gets the current double sided mode.
  51142. */
  51143. /**
  51144. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51145. */
  51146. doubleSided: boolean;
  51147. /**
  51148. * Stores the pre-calculated light information of a mesh in a texture.
  51149. */
  51150. lightmapTexture: BaseTexture;
  51151. /**
  51152. * If true, the light map contains occlusion information instead of lighting info.
  51153. */
  51154. useLightmapAsShadowmap: boolean;
  51155. /**
  51156. * Instantiates a new PBRMaterial instance.
  51157. *
  51158. * @param name The material name
  51159. * @param scene The scene the material will be use in.
  51160. */
  51161. constructor(name: string, scene: Scene);
  51162. getClassName(): string;
  51163. }
  51164. }
  51165. declare module BABYLON {
  51166. /**
  51167. * The PBR material of BJS following the metal roughness convention.
  51168. *
  51169. * This fits to the PBR convention in the GLTF definition:
  51170. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51171. */
  51172. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51173. /**
  51174. * The base color has two different interpretations depending on the value of metalness.
  51175. * When the material is a metal, the base color is the specific measured reflectance value
  51176. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51177. * of the material.
  51178. */
  51179. baseColor: Color3;
  51180. /**
  51181. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51182. * well as opacity information in the alpha channel.
  51183. */
  51184. baseTexture: BaseTexture;
  51185. /**
  51186. * Specifies the metallic scalar value of the material.
  51187. * Can also be used to scale the metalness values of the metallic texture.
  51188. */
  51189. metallic: number;
  51190. /**
  51191. * Specifies the roughness scalar value of the material.
  51192. * Can also be used to scale the roughness values of the metallic texture.
  51193. */
  51194. roughness: number;
  51195. /**
  51196. * Texture containing both the metallic value in the B channel and the
  51197. * roughness value in the G channel to keep better precision.
  51198. */
  51199. metallicRoughnessTexture: BaseTexture;
  51200. /**
  51201. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51202. *
  51203. * @param name The material name
  51204. * @param scene The scene the material will be use in.
  51205. */
  51206. constructor(name: string, scene: Scene);
  51207. /**
  51208. * Return the currrent class name of the material.
  51209. */
  51210. getClassName(): string;
  51211. /**
  51212. * Makes a duplicate of the current material.
  51213. * @param name - name to use for the new material.
  51214. */
  51215. clone(name: string): PBRMetallicRoughnessMaterial;
  51216. /**
  51217. * Serialize the material to a parsable JSON object.
  51218. */
  51219. serialize(): any;
  51220. /**
  51221. * Parses a JSON object correponding to the serialize function.
  51222. */
  51223. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51224. }
  51225. }
  51226. declare module BABYLON {
  51227. /**
  51228. * The PBR material of BJS following the specular glossiness convention.
  51229. *
  51230. * This fits to the PBR convention in the GLTF definition:
  51231. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51232. */
  51233. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51234. /**
  51235. * Specifies the diffuse color of the material.
  51236. */
  51237. diffuseColor: Color3;
  51238. /**
  51239. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51240. * channel.
  51241. */
  51242. diffuseTexture: BaseTexture;
  51243. /**
  51244. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51245. */
  51246. specularColor: Color3;
  51247. /**
  51248. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51249. */
  51250. glossiness: number;
  51251. /**
  51252. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51253. */
  51254. specularGlossinessTexture: BaseTexture;
  51255. /**
  51256. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51257. *
  51258. * @param name The material name
  51259. * @param scene The scene the material will be use in.
  51260. */
  51261. constructor(name: string, scene: Scene);
  51262. /**
  51263. * Return the currrent class name of the material.
  51264. */
  51265. getClassName(): string;
  51266. /**
  51267. * Makes a duplicate of the current material.
  51268. * @param name - name to use for the new material.
  51269. */
  51270. clone(name: string): PBRSpecularGlossinessMaterial;
  51271. /**
  51272. * Serialize the material to a parsable JSON object.
  51273. */
  51274. serialize(): any;
  51275. /**
  51276. * Parses a JSON object correponding to the serialize function.
  51277. */
  51278. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51279. }
  51280. }
  51281. declare module BABYLON {
  51282. /**
  51283. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  51284. * It can help converting any input color in a desired output one. This can then be used to create effects
  51285. * from sepia, black and white to sixties or futuristic rendering...
  51286. *
  51287. * The only supported format is currently 3dl.
  51288. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  51289. */
  51290. export class ColorGradingTexture extends BaseTexture {
  51291. /**
  51292. * The current texture matrix. (will always be identity in color grading texture)
  51293. */
  51294. private _textureMatrix;
  51295. /**
  51296. * The texture URL.
  51297. */
  51298. url: string;
  51299. /**
  51300. * Empty line regex stored for GC.
  51301. */
  51302. private static _noneEmptyLineRegex;
  51303. private _engine;
  51304. /**
  51305. * Instantiates a ColorGradingTexture from the following parameters.
  51306. *
  51307. * @param url The location of the color gradind data (currently only supporting 3dl)
  51308. * @param scene The scene the texture will be used in
  51309. */
  51310. constructor(url: string, scene: Scene);
  51311. /**
  51312. * Returns the texture matrix used in most of the material.
  51313. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  51314. */
  51315. getTextureMatrix(): Matrix;
  51316. /**
  51317. * Occurs when the file being loaded is a .3dl LUT file.
  51318. */
  51319. private load3dlTexture;
  51320. /**
  51321. * Starts the loading process of the texture.
  51322. */
  51323. private loadTexture;
  51324. /**
  51325. * Clones the color gradind texture.
  51326. */
  51327. clone(): ColorGradingTexture;
  51328. /**
  51329. * Called during delayed load for textures.
  51330. */
  51331. delayLoad(): void;
  51332. /**
  51333. * Parses a color grading texture serialized by Babylon.
  51334. * @param parsedTexture The texture information being parsedTexture
  51335. * @param scene The scene to load the texture in
  51336. * @param rootUrl The root url of the data assets to load
  51337. * @return A color gradind texture
  51338. */
  51339. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51340. /**
  51341. * Serializes the LUT texture to json format.
  51342. */
  51343. serialize(): any;
  51344. }
  51345. }
  51346. declare module BABYLON {
  51347. /**
  51348. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51349. */
  51350. export class EquiRectangularCubeTexture extends BaseTexture {
  51351. /** The six faces of the cube. */
  51352. private static _FacesMapping;
  51353. private _noMipmap;
  51354. private _onLoad;
  51355. private _onError;
  51356. /** The size of the cubemap. */
  51357. private _size;
  51358. /** The buffer of the image. */
  51359. private _buffer;
  51360. /** The width of the input image. */
  51361. private _width;
  51362. /** The height of the input image. */
  51363. private _height;
  51364. /** The URL to the image. */
  51365. url: string;
  51366. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51367. coordinatesMode: number;
  51368. /**
  51369. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51370. * @param url The location of the image
  51371. * @param scene The scene the texture will be used in
  51372. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51373. * @param noMipmap Forces to not generate the mipmap if true
  51374. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  51375. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  51376. * @param onLoad — defines a callback called when texture is loaded
  51377. * @param onError — defines a callback called if there is an error
  51378. */
  51379. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51380. /**
  51381. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51382. */
  51383. private loadImage;
  51384. /**
  51385. * Convert the image buffer into a cubemap and create a CubeTexture.
  51386. */
  51387. private loadTexture;
  51388. /**
  51389. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51390. * @param buffer The ArrayBuffer that should be converted.
  51391. * @returns The buffer as Float32Array.
  51392. */
  51393. private getFloat32ArrayFromArrayBuffer;
  51394. /**
  51395. * Get the current class name of the texture useful for serialization or dynamic coding.
  51396. * @returns "EquiRectangularCubeTexture"
  51397. */
  51398. getClassName(): string;
  51399. /**
  51400. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51401. * @returns A clone of the current EquiRectangularCubeTexture.
  51402. */
  51403. clone(): EquiRectangularCubeTexture;
  51404. }
  51405. }
  51406. declare module BABYLON {
  51407. /**
  51408. * Based on jsTGALoader - Javascript loader for TGA file
  51409. * By Vincent Thibault
  51410. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51411. */
  51412. export class TGATools {
  51413. private static _TYPE_INDEXED;
  51414. private static _TYPE_RGB;
  51415. private static _TYPE_GREY;
  51416. private static _TYPE_RLE_INDEXED;
  51417. private static _TYPE_RLE_RGB;
  51418. private static _TYPE_RLE_GREY;
  51419. private static _ORIGIN_MASK;
  51420. private static _ORIGIN_SHIFT;
  51421. private static _ORIGIN_BL;
  51422. private static _ORIGIN_BR;
  51423. private static _ORIGIN_UL;
  51424. private static _ORIGIN_UR;
  51425. /**
  51426. * Gets the header of a TGA file
  51427. * @param data defines the TGA data
  51428. * @returns the header
  51429. */
  51430. static GetTGAHeader(data: Uint8Array): any;
  51431. /**
  51432. * Uploads TGA content to a Babylon Texture
  51433. * @hidden
  51434. */
  51435. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51436. /** @hidden */
  51437. 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;
  51438. /** @hidden */
  51439. 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;
  51440. /** @hidden */
  51441. 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;
  51442. /** @hidden */
  51443. 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;
  51444. /** @hidden */
  51445. 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;
  51446. /** @hidden */
  51447. 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;
  51448. }
  51449. }
  51450. declare module BABYLON {
  51451. /**
  51452. * Implementation of the TGA Texture Loader.
  51453. * @hidden
  51454. */
  51455. export class _TGATextureLoader implements IInternalTextureLoader {
  51456. /**
  51457. * Defines wether the loader supports cascade loading the different faces.
  51458. */
  51459. readonly supportCascades: boolean;
  51460. /**
  51461. * This returns if the loader support the current file information.
  51462. * @param extension defines the file extension of the file being loaded
  51463. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51464. * @param fallback defines the fallback internal texture if any
  51465. * @param isBase64 defines whether the texture is encoded as a base64
  51466. * @param isBuffer defines whether the texture data are stored as a buffer
  51467. * @returns true if the loader can load the specified file
  51468. */
  51469. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51470. /**
  51471. * Transform the url before loading if required.
  51472. * @param rootUrl the url of the texture
  51473. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51474. * @returns the transformed texture
  51475. */
  51476. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51477. /**
  51478. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51479. * @param rootUrl the url of the texture
  51480. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51481. * @returns the fallback texture
  51482. */
  51483. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51484. /**
  51485. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51486. * @param data contains the texture data
  51487. * @param texture defines the BabylonJS internal texture
  51488. * @param createPolynomials will be true if polynomials have been requested
  51489. * @param onLoad defines the callback to trigger once the texture is ready
  51490. * @param onError defines the callback to trigger in case of error
  51491. */
  51492. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51493. /**
  51494. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51495. * @param data contains the texture data
  51496. * @param texture defines the BabylonJS internal texture
  51497. * @param callback defines the method to call once ready to upload
  51498. */
  51499. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51500. }
  51501. }
  51502. declare module BABYLON {
  51503. /**
  51504. * Info about the .basis files
  51505. */
  51506. class BasisFileInfo {
  51507. /**
  51508. * If the file has alpha
  51509. */
  51510. hasAlpha: boolean;
  51511. /**
  51512. * Info about each image of the basis file
  51513. */
  51514. images: Array<{
  51515. levels: Array<{
  51516. width: number;
  51517. height: number;
  51518. transcodedPixels: ArrayBufferView;
  51519. }>;
  51520. }>;
  51521. }
  51522. /**
  51523. * Result of transcoding a basis file
  51524. */
  51525. class TranscodeResult {
  51526. /**
  51527. * Info about the .basis file
  51528. */
  51529. fileInfo: BasisFileInfo;
  51530. /**
  51531. * Format to use when loading the file
  51532. */
  51533. format: number;
  51534. }
  51535. /**
  51536. * Configuration options for the Basis transcoder
  51537. */
  51538. export class BasisTranscodeConfiguration {
  51539. /**
  51540. * Supported compression formats used to determine the supported output format of the transcoder
  51541. */
  51542. supportedCompressionFormats?: {
  51543. /**
  51544. * etc1 compression format
  51545. */
  51546. etc1?: boolean;
  51547. /**
  51548. * s3tc compression format
  51549. */
  51550. s3tc?: boolean;
  51551. /**
  51552. * pvrtc compression format
  51553. */
  51554. pvrtc?: boolean;
  51555. /**
  51556. * etc2 compression format
  51557. */
  51558. etc2?: boolean;
  51559. };
  51560. /**
  51561. * If mipmap levels should be loaded for transcoded images (Default: true)
  51562. */
  51563. loadMipmapLevels?: boolean;
  51564. /**
  51565. * Index of a single image to load (Default: all images)
  51566. */
  51567. loadSingleImage?: number;
  51568. }
  51569. /**
  51570. * Used to load .Basis files
  51571. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  51572. */
  51573. export class BasisTools {
  51574. private static _IgnoreSupportedFormats;
  51575. /**
  51576. * URL to use when loading the basis transcoder
  51577. */
  51578. static JSModuleURL: string;
  51579. /**
  51580. * URL to use when loading the wasm module for the transcoder
  51581. */
  51582. static WasmModuleURL: string;
  51583. /**
  51584. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  51585. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  51586. * @returns internal format corresponding to the Basis format
  51587. */
  51588. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  51589. private static _WorkerPromise;
  51590. private static _Worker;
  51591. private static _actionId;
  51592. private static _CreateWorkerAsync;
  51593. /**
  51594. * Transcodes a loaded image file to compressed pixel data
  51595. * @param imageData image data to transcode
  51596. * @param config configuration options for the transcoding
  51597. * @returns a promise resulting in the transcoded image
  51598. */
  51599. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  51600. /**
  51601. * Loads a texture from the transcode result
  51602. * @param texture texture load to
  51603. * @param transcodeResult the result of transcoding the basis file to load from
  51604. */
  51605. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  51606. }
  51607. }
  51608. declare module BABYLON {
  51609. /**
  51610. * Loader for .basis file format
  51611. */
  51612. export class _BasisTextureLoader implements IInternalTextureLoader {
  51613. /**
  51614. * Defines whether the loader supports cascade loading the different faces.
  51615. */
  51616. readonly supportCascades: boolean;
  51617. /**
  51618. * This returns if the loader support the current file information.
  51619. * @param extension defines the file extension of the file being loaded
  51620. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51621. * @param fallback defines the fallback internal texture if any
  51622. * @param isBase64 defines whether the texture is encoded as a base64
  51623. * @param isBuffer defines whether the texture data are stored as a buffer
  51624. * @returns true if the loader can load the specified file
  51625. */
  51626. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51627. /**
  51628. * Transform the url before loading if required.
  51629. * @param rootUrl the url of the texture
  51630. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51631. * @returns the transformed texture
  51632. */
  51633. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51634. /**
  51635. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51636. * @param rootUrl the url of the texture
  51637. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51638. * @returns the fallback texture
  51639. */
  51640. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51641. /**
  51642. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  51643. * @param data contains the texture data
  51644. * @param texture defines the BabylonJS internal texture
  51645. * @param createPolynomials will be true if polynomials have been requested
  51646. * @param onLoad defines the callback to trigger once the texture is ready
  51647. * @param onError defines the callback to trigger in case of error
  51648. */
  51649. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51650. /**
  51651. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51652. * @param data contains the texture data
  51653. * @param texture defines the BabylonJS internal texture
  51654. * @param callback defines the method to call once ready to upload
  51655. */
  51656. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51657. }
  51658. }
  51659. declare module BABYLON {
  51660. /**
  51661. * 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.
  51662. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51663. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51664. */
  51665. export class CustomProceduralTexture extends ProceduralTexture {
  51666. private _animate;
  51667. private _time;
  51668. private _config;
  51669. private _texturePath;
  51670. /**
  51671. * Instantiates a new Custom Procedural Texture.
  51672. * 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.
  51673. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51674. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51675. * @param name Define the name of the texture
  51676. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  51677. * @param size Define the size of the texture to create
  51678. * @param scene Define the scene the texture belongs to
  51679. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  51680. * @param generateMipMaps Define if the texture should creates mip maps or not
  51681. */
  51682. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51683. private _loadJson;
  51684. /**
  51685. * Is the texture ready to be used ? (rendered at least once)
  51686. * @returns true if ready, otherwise, false.
  51687. */
  51688. isReady(): boolean;
  51689. /**
  51690. * Render the texture to its associated render target.
  51691. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  51692. */
  51693. render(useCameraPostProcess?: boolean): void;
  51694. /**
  51695. * Update the list of dependant textures samplers in the shader.
  51696. */
  51697. updateTextures(): void;
  51698. /**
  51699. * Update the uniform values of the procedural texture in the shader.
  51700. */
  51701. updateShaderUniforms(): void;
  51702. /**
  51703. * Define if the texture animates or not.
  51704. */
  51705. animate: boolean;
  51706. }
  51707. }
  51708. declare module BABYLON {
  51709. /** @hidden */
  51710. export var noisePixelShader: {
  51711. name: string;
  51712. shader: string;
  51713. };
  51714. }
  51715. declare module BABYLON {
  51716. /**
  51717. * Class used to generate noise procedural textures
  51718. */
  51719. export class NoiseProceduralTexture extends ProceduralTexture {
  51720. private _time;
  51721. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  51722. brightness: number;
  51723. /** Defines the number of octaves to process */
  51724. octaves: number;
  51725. /** Defines the level of persistence (0.8 by default) */
  51726. persistence: number;
  51727. /** Gets or sets animation speed factor (default is 1) */
  51728. animationSpeedFactor: number;
  51729. /**
  51730. * Creates a new NoiseProceduralTexture
  51731. * @param name defines the name fo the texture
  51732. * @param size defines the size of the texture (default is 256)
  51733. * @param scene defines the hosting scene
  51734. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  51735. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  51736. */
  51737. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51738. private _updateShaderUniforms;
  51739. protected _getDefines(): string;
  51740. /** Generate the current state of the procedural texture */
  51741. render(useCameraPostProcess?: boolean): void;
  51742. /**
  51743. * Serializes this noise procedural texture
  51744. * @returns a serialized noise procedural texture object
  51745. */
  51746. serialize(): any;
  51747. /**
  51748. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51749. * @param parsedTexture defines parsed texture data
  51750. * @param scene defines the current scene
  51751. * @param rootUrl defines the root URL containing noise procedural texture information
  51752. * @returns a parsed NoiseProceduralTexture
  51753. */
  51754. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51755. }
  51756. }
  51757. declare module BABYLON {
  51758. /**
  51759. * Raw cube texture where the raw buffers are passed in
  51760. */
  51761. export class RawCubeTexture extends CubeTexture {
  51762. /**
  51763. * Creates a cube texture where the raw buffers are passed in.
  51764. * @param scene defines the scene the texture is attached to
  51765. * @param data defines the array of data to use to create each face
  51766. * @param size defines the size of the textures
  51767. * @param format defines the format of the data
  51768. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51769. * @param generateMipMaps defines if the engine should generate the mip levels
  51770. * @param invertY defines if data must be stored with Y axis inverted
  51771. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51772. * @param compression defines the compression used (null by default)
  51773. */
  51774. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51775. /**
  51776. * Updates the raw cube texture.
  51777. * @param data defines the data to store
  51778. * @param format defines the data format
  51779. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51780. * @param invertY defines if data must be stored with Y axis inverted
  51781. * @param compression defines the compression used (null by default)
  51782. * @param level defines which level of the texture to update
  51783. */
  51784. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51785. /**
  51786. * Updates a raw cube texture with RGBD encoded data.
  51787. * @param data defines the array of data [mipmap][face] to use to create each face
  51788. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51789. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51790. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51791. * @returns a promsie that resolves when the operation is complete
  51792. */
  51793. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51794. /**
  51795. * Clones the raw cube texture.
  51796. * @return a new cube texture
  51797. */
  51798. clone(): CubeTexture;
  51799. /** @hidden */
  51800. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51801. }
  51802. }
  51803. declare module BABYLON {
  51804. /**
  51805. * Class used to store 3D textures containing user data
  51806. */
  51807. export class RawTexture3D extends Texture {
  51808. /** Gets or sets the texture format to use */
  51809. format: number;
  51810. private _engine;
  51811. /**
  51812. * Create a new RawTexture3D
  51813. * @param data defines the data of the texture
  51814. * @param width defines the width of the texture
  51815. * @param height defines the height of the texture
  51816. * @param depth defines the depth of the texture
  51817. * @param format defines the texture format to use
  51818. * @param scene defines the hosting scene
  51819. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51820. * @param invertY defines if texture must be stored with Y axis inverted
  51821. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51822. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51823. */
  51824. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51825. /** Gets or sets the texture format to use */
  51826. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51827. /**
  51828. * Update the texture with new data
  51829. * @param data defines the data to store in the texture
  51830. */
  51831. update(data: ArrayBufferView): void;
  51832. }
  51833. }
  51834. declare module BABYLON {
  51835. /**
  51836. * Creates a refraction texture used by refraction channel of the standard material.
  51837. * It is like a mirror but to see through a material.
  51838. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51839. */
  51840. export class RefractionTexture extends RenderTargetTexture {
  51841. /**
  51842. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51843. * 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.
  51844. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51845. */
  51846. refractionPlane: Plane;
  51847. /**
  51848. * Define how deep under the surface we should see.
  51849. */
  51850. depth: number;
  51851. /**
  51852. * Creates a refraction texture used by refraction channel of the standard material.
  51853. * It is like a mirror but to see through a material.
  51854. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51855. * @param name Define the texture name
  51856. * @param size Define the size of the underlying texture
  51857. * @param scene Define the scene the refraction belongs to
  51858. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51859. */
  51860. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51861. /**
  51862. * Clone the refraction texture.
  51863. * @returns the cloned texture
  51864. */
  51865. clone(): RefractionTexture;
  51866. /**
  51867. * Serialize the texture to a JSON representation you could use in Parse later on
  51868. * @returns the serialized JSON representation
  51869. */
  51870. serialize(): any;
  51871. }
  51872. }
  51873. declare module BABYLON {
  51874. /**
  51875. * Defines the options related to the creation of an HtmlElementTexture
  51876. */
  51877. export interface IHtmlElementTextureOptions {
  51878. /**
  51879. * Defines wether mip maps should be created or not.
  51880. */
  51881. generateMipMaps?: boolean;
  51882. /**
  51883. * Defines the sampling mode of the texture.
  51884. */
  51885. samplingMode?: number;
  51886. /**
  51887. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  51888. */
  51889. engine: Nullable<Engine>;
  51890. /**
  51891. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  51892. */
  51893. scene: Nullable<Scene>;
  51894. }
  51895. /**
  51896. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  51897. * To be as efficient as possible depending on your constraints nothing aside the first upload
  51898. * is automatically managed.
  51899. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  51900. * in your application.
  51901. *
  51902. * As the update is not automatic, you need to call them manually.
  51903. */
  51904. export class HtmlElementTexture extends BaseTexture {
  51905. /**
  51906. * The texture URL.
  51907. */
  51908. element: HTMLVideoElement | HTMLCanvasElement;
  51909. private static readonly DefaultOptions;
  51910. private _textureMatrix;
  51911. private _engine;
  51912. private _isVideo;
  51913. private _generateMipMaps;
  51914. private _samplingMode;
  51915. /**
  51916. * Instantiates a HtmlElementTexture from the following parameters.
  51917. *
  51918. * @param name Defines the name of the texture
  51919. * @param element Defines the video or canvas the texture is filled with
  51920. * @param options Defines the other none mandatory texture creation options
  51921. */
  51922. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  51923. private _createInternalTexture;
  51924. /**
  51925. * Returns the texture matrix used in most of the material.
  51926. */
  51927. getTextureMatrix(): Matrix;
  51928. /**
  51929. * Updates the content of the texture.
  51930. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  51931. */
  51932. update(invertY?: Nullable<boolean>): void;
  51933. }
  51934. }
  51935. declare module BABYLON {
  51936. /**
  51937. * Enum used to define the target of a block
  51938. */
  51939. export enum NodeMaterialBlockTargets {
  51940. /** Vertex shader */
  51941. Vertex = 1,
  51942. /** Fragment shader */
  51943. Fragment = 2,
  51944. /** Neutral */
  51945. Neutral = 4,
  51946. /** Vertex and Fragment */
  51947. VertexAndFragment = 3
  51948. }
  51949. }
  51950. declare module BABYLON {
  51951. /**
  51952. * Defines the kind of connection point for node based material
  51953. */
  51954. export enum NodeMaterialBlockConnectionPointTypes {
  51955. /** Float */
  51956. Float = 1,
  51957. /** Int */
  51958. Int = 2,
  51959. /** Vector2 */
  51960. Vector2 = 4,
  51961. /** Vector3 */
  51962. Vector3 = 8,
  51963. /** Vector4 */
  51964. Vector4 = 16,
  51965. /** Color3 */
  51966. Color3 = 32,
  51967. /** Color4 */
  51968. Color4 = 64,
  51969. /** Matrix */
  51970. Matrix = 128,
  51971. /** Detect type based on connection */
  51972. AutoDetect = 1024,
  51973. /** Output type that will be defined by input type */
  51974. BasedOnInput = 2048
  51975. }
  51976. }
  51977. declare module BABYLON {
  51978. /**
  51979. * Root class for all node material optimizers
  51980. */
  51981. export class NodeMaterialOptimizer {
  51982. /**
  51983. * Function used to optimize a NodeMaterial graph
  51984. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  51985. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  51986. */
  51987. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  51988. }
  51989. }
  51990. declare module BABYLON {
  51991. /**
  51992. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  51993. */
  51994. export class TransformBlock extends NodeMaterialBlock {
  51995. /**
  51996. * Defines the value to use to complement W value to transform it to a Vector4
  51997. */
  51998. complementW: number;
  51999. /**
  52000. * Defines the value to use to complement z value to transform it to a Vector4
  52001. */
  52002. complementZ: number;
  52003. /**
  52004. * Creates a new TransformBlock
  52005. * @param name defines the block name
  52006. */
  52007. constructor(name: string);
  52008. /**
  52009. * Gets the current class name
  52010. * @returns the class name
  52011. */
  52012. getClassName(): string;
  52013. /**
  52014. * Gets the vector input
  52015. */
  52016. readonly vector: NodeMaterialConnectionPoint;
  52017. /**
  52018. * Gets the output component
  52019. */
  52020. readonly output: NodeMaterialConnectionPoint;
  52021. /**
  52022. * Gets the matrix transform input
  52023. */
  52024. readonly transform: NodeMaterialConnectionPoint;
  52025. protected _buildBlock(state: NodeMaterialBuildState): this;
  52026. serialize(): any;
  52027. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52028. protected _dumpPropertiesCode(): string;
  52029. }
  52030. }
  52031. declare module BABYLON {
  52032. /**
  52033. * Block used to output the vertex position
  52034. */
  52035. export class VertexOutputBlock extends NodeMaterialBlock {
  52036. /**
  52037. * Creates a new VertexOutputBlock
  52038. * @param name defines the block name
  52039. */
  52040. constructor(name: string);
  52041. /**
  52042. * Gets the current class name
  52043. * @returns the class name
  52044. */
  52045. getClassName(): string;
  52046. /**
  52047. * Gets the vector input component
  52048. */
  52049. readonly vector: NodeMaterialConnectionPoint;
  52050. protected _buildBlock(state: NodeMaterialBuildState): this;
  52051. }
  52052. }
  52053. declare module BABYLON {
  52054. /**
  52055. * Block used to output the final color
  52056. */
  52057. export class FragmentOutputBlock extends NodeMaterialBlock {
  52058. /**
  52059. * Create a new FragmentOutputBlock
  52060. * @param name defines the block name
  52061. */
  52062. constructor(name: string);
  52063. /**
  52064. * Gets the current class name
  52065. * @returns the class name
  52066. */
  52067. getClassName(): string;
  52068. /**
  52069. * Gets the rgba input component
  52070. */
  52071. readonly rgba: NodeMaterialConnectionPoint;
  52072. /**
  52073. * Gets the rgb input component
  52074. */
  52075. readonly rgb: NodeMaterialConnectionPoint;
  52076. /**
  52077. * Gets the a input component
  52078. */
  52079. readonly a: NodeMaterialConnectionPoint;
  52080. protected _buildBlock(state: NodeMaterialBuildState): this;
  52081. }
  52082. }
  52083. declare module BABYLON {
  52084. /**
  52085. * Enum used to define well known values e.g. values automatically provided by the system
  52086. */
  52087. export enum NodeMaterialWellKnownValues {
  52088. /** World */
  52089. World = 1,
  52090. /** View */
  52091. View = 2,
  52092. /** Projection */
  52093. Projection = 3,
  52094. /** ViewProjection */
  52095. ViewProjection = 4,
  52096. /** WorldView */
  52097. WorldView = 5,
  52098. /** WorldViewProjection */
  52099. WorldViewProjection = 6,
  52100. /** CameraPosition */
  52101. CameraPosition = 7,
  52102. /** Fog Color */
  52103. FogColor = 8
  52104. }
  52105. }
  52106. declare module BABYLON {
  52107. /**
  52108. * Block used to read a reflection texture from a sampler
  52109. */
  52110. export class ReflectionTextureBlock extends NodeMaterialBlock {
  52111. private _define3DName;
  52112. private _defineCubicName;
  52113. private _defineExplicitName;
  52114. private _defineProjectionName;
  52115. private _defineLocalCubicName;
  52116. private _defineSphericalName;
  52117. private _definePlanarName;
  52118. private _defineEquirectangularName;
  52119. private _defineMirroredEquirectangularFixedName;
  52120. private _defineEquirectangularFixedName;
  52121. private _defineSkyboxName;
  52122. private _cubeSamplerName;
  52123. private _2DSamplerName;
  52124. private _positionUVWName;
  52125. private _directionWName;
  52126. private _reflectionCoordsName;
  52127. private _reflection2DCoordsName;
  52128. private _reflectionColorName;
  52129. private _reflectionMatrixName;
  52130. /**
  52131. * Gets or sets the texture associated with the node
  52132. */
  52133. texture: Nullable<BaseTexture>;
  52134. /**
  52135. * Create a new TextureBlock
  52136. * @param name defines the block name
  52137. */
  52138. constructor(name: string);
  52139. /**
  52140. * Gets the current class name
  52141. * @returns the class name
  52142. */
  52143. getClassName(): string;
  52144. /**
  52145. * Gets the world position input component
  52146. */
  52147. readonly position: NodeMaterialConnectionPoint;
  52148. /**
  52149. * Gets the world position input component
  52150. */
  52151. readonly worldPosition: NodeMaterialConnectionPoint;
  52152. /**
  52153. * Gets the world normal input component
  52154. */
  52155. readonly worldNormal: NodeMaterialConnectionPoint;
  52156. /**
  52157. * Gets the world input component
  52158. */
  52159. readonly world: NodeMaterialConnectionPoint;
  52160. /**
  52161. * Gets the camera (or eye) position component
  52162. */
  52163. readonly cameraPosition: NodeMaterialConnectionPoint;
  52164. /**
  52165. * Gets the view input component
  52166. */
  52167. readonly view: NodeMaterialConnectionPoint;
  52168. /**
  52169. * Gets the rgb output component
  52170. */
  52171. readonly rgb: NodeMaterialConnectionPoint;
  52172. /**
  52173. * Gets the r output component
  52174. */
  52175. readonly r: NodeMaterialConnectionPoint;
  52176. /**
  52177. * Gets the g output component
  52178. */
  52179. readonly g: NodeMaterialConnectionPoint;
  52180. /**
  52181. * Gets the b output component
  52182. */
  52183. readonly b: NodeMaterialConnectionPoint;
  52184. autoConfigure(material: NodeMaterial): void;
  52185. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52186. isReady(): boolean;
  52187. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52188. private _injectVertexCode;
  52189. private _writeOutput;
  52190. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52191. serialize(): any;
  52192. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52193. }
  52194. }
  52195. declare module BABYLON {
  52196. /**
  52197. * Interface used to configure the node material editor
  52198. */
  52199. export interface INodeMaterialEditorOptions {
  52200. /** Define the URl to load node editor script */
  52201. editorURL?: string;
  52202. }
  52203. /** @hidden */
  52204. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  52205. /** BONES */
  52206. NUM_BONE_INFLUENCERS: number;
  52207. BonesPerMesh: number;
  52208. BONETEXTURE: boolean;
  52209. /** MORPH TARGETS */
  52210. MORPHTARGETS: boolean;
  52211. MORPHTARGETS_NORMAL: boolean;
  52212. MORPHTARGETS_TANGENT: boolean;
  52213. MORPHTARGETS_UV: boolean;
  52214. NUM_MORPH_INFLUENCERS: number;
  52215. /** IMAGE PROCESSING */
  52216. IMAGEPROCESSING: boolean;
  52217. VIGNETTE: boolean;
  52218. VIGNETTEBLENDMODEMULTIPLY: boolean;
  52219. VIGNETTEBLENDMODEOPAQUE: boolean;
  52220. TONEMAPPING: boolean;
  52221. TONEMAPPING_ACES: boolean;
  52222. CONTRAST: boolean;
  52223. EXPOSURE: boolean;
  52224. COLORCURVES: boolean;
  52225. COLORGRADING: boolean;
  52226. COLORGRADING3D: boolean;
  52227. SAMPLER3DGREENDEPTH: boolean;
  52228. SAMPLER3DBGRMAP: boolean;
  52229. IMAGEPROCESSINGPOSTPROCESS: boolean;
  52230. constructor();
  52231. setValue(name: string, value: boolean): void;
  52232. }
  52233. /**
  52234. * Class used to configure NodeMaterial
  52235. */
  52236. export interface INodeMaterialOptions {
  52237. /**
  52238. * Defines if blocks should emit comments
  52239. */
  52240. emitComments: boolean;
  52241. }
  52242. /**
  52243. * Class used to create a node based material built by assembling shader blocks
  52244. */
  52245. export class NodeMaterial extends PushMaterial {
  52246. private static _BuildIdGenerator;
  52247. private _options;
  52248. private _vertexCompilationState;
  52249. private _fragmentCompilationState;
  52250. private _sharedData;
  52251. private _buildId;
  52252. private _buildWasSuccessful;
  52253. private _cachedWorldViewMatrix;
  52254. private _cachedWorldViewProjectionMatrix;
  52255. private _optimizers;
  52256. private _animationFrame;
  52257. /** Define the URl to load node editor script */
  52258. static EditorURL: string;
  52259. private BJSNODEMATERIALEDITOR;
  52260. /** Get the inspector from bundle or global */
  52261. private _getGlobalNodeMaterialEditor;
  52262. /**
  52263. * 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)
  52264. */
  52265. ignoreAlpha: boolean;
  52266. /**
  52267. * Defines the maximum number of lights that can be used in the material
  52268. */
  52269. maxSimultaneousLights: number;
  52270. /**
  52271. * Observable raised when the material is built
  52272. */
  52273. onBuildObservable: Observable<NodeMaterial>;
  52274. /**
  52275. * Gets or sets the root nodes of the material vertex shader
  52276. */
  52277. _vertexOutputNodes: NodeMaterialBlock[];
  52278. /**
  52279. * Gets or sets the root nodes of the material fragment (pixel) shader
  52280. */
  52281. _fragmentOutputNodes: NodeMaterialBlock[];
  52282. /** Gets or sets options to control the node material overall behavior */
  52283. options: INodeMaterialOptions;
  52284. /**
  52285. * Default configuration related to image processing available in the standard Material.
  52286. */
  52287. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52288. /**
  52289. * Gets the image processing configuration used either in this material.
  52290. */
  52291. /**
  52292. * Sets the Default image processing configuration used either in the this material.
  52293. *
  52294. * If sets to null, the scene one is in use.
  52295. */
  52296. imageProcessingConfiguration: ImageProcessingConfiguration;
  52297. /**
  52298. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  52299. */
  52300. attachedBlocks: NodeMaterialBlock[];
  52301. /**
  52302. * Create a new node based material
  52303. * @param name defines the material name
  52304. * @param scene defines the hosting scene
  52305. * @param options defines creation option
  52306. */
  52307. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  52308. /**
  52309. * Gets the current class name of the material e.g. "NodeMaterial"
  52310. * @returns the class name
  52311. */
  52312. getClassName(): string;
  52313. /**
  52314. * Keep track of the image processing observer to allow dispose and replace.
  52315. */
  52316. private _imageProcessingObserver;
  52317. /**
  52318. * Attaches a new image processing configuration to the Standard Material.
  52319. * @param configuration
  52320. */
  52321. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52322. /**
  52323. * Get a block by its name
  52324. * @param name defines the name of the block to retrieve
  52325. * @returns the required block or null if not found
  52326. */
  52327. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  52328. /**
  52329. * Get a block by its name
  52330. * @param predicate defines the predicate used to find the good candidate
  52331. * @returns the required block or null if not found
  52332. */
  52333. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  52334. /**
  52335. * Get an input block by its name
  52336. * @param predicate defines the predicate used to find the good candidate
  52337. * @returns the required input block or null if not found
  52338. */
  52339. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  52340. /**
  52341. * Gets the list of input blocks attached to this material
  52342. * @returns an array of InputBlocks
  52343. */
  52344. getInputBlocks(): InputBlock[];
  52345. /**
  52346. * Adds a new optimizer to the list of optimizers
  52347. * @param optimizer defines the optimizers to add
  52348. * @returns the current material
  52349. */
  52350. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52351. /**
  52352. * Remove an optimizer from the list of optimizers
  52353. * @param optimizer defines the optimizers to remove
  52354. * @returns the current material
  52355. */
  52356. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52357. /**
  52358. * Add a new block to the list of output nodes
  52359. * @param node defines the node to add
  52360. * @returns the current material
  52361. */
  52362. addOutputNode(node: NodeMaterialBlock): this;
  52363. /**
  52364. * Remove a block from the list of root nodes
  52365. * @param node defines the node to remove
  52366. * @returns the current material
  52367. */
  52368. removeOutputNode(node: NodeMaterialBlock): this;
  52369. private _addVertexOutputNode;
  52370. private _removeVertexOutputNode;
  52371. private _addFragmentOutputNode;
  52372. private _removeFragmentOutputNode;
  52373. /**
  52374. * Specifies if the material will require alpha blending
  52375. * @returns a boolean specifying if alpha blending is needed
  52376. */
  52377. needAlphaBlending(): boolean;
  52378. /**
  52379. * Specifies if this material should be rendered in alpha test mode
  52380. * @returns a boolean specifying if an alpha test is needed.
  52381. */
  52382. needAlphaTesting(): boolean;
  52383. private _initializeBlock;
  52384. private _resetDualBlocks;
  52385. /**
  52386. * Build the material and generates the inner effect
  52387. * @param verbose defines if the build should log activity
  52388. */
  52389. build(verbose?: boolean): void;
  52390. /**
  52391. * Runs an otpimization phase to try to improve the shader code
  52392. */
  52393. optimize(): void;
  52394. private _prepareDefinesForAttributes;
  52395. /**
  52396. * Get if the submesh is ready to be used and all its information available.
  52397. * Child classes can use it to update shaders
  52398. * @param mesh defines the mesh to check
  52399. * @param subMesh defines which submesh to check
  52400. * @param useInstances specifies that instances should be used
  52401. * @returns a boolean indicating that the submesh is ready or not
  52402. */
  52403. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52404. /**
  52405. * Get a string representing the shaders built by the current node graph
  52406. */
  52407. readonly compiledShaders: string;
  52408. /**
  52409. * Binds the world matrix to the material
  52410. * @param world defines the world transformation matrix
  52411. */
  52412. bindOnlyWorldMatrix(world: Matrix): void;
  52413. /**
  52414. * Binds the submesh to this material by preparing the effect and shader to draw
  52415. * @param world defines the world transformation matrix
  52416. * @param mesh defines the mesh containing the submesh
  52417. * @param subMesh defines the submesh to bind the material to
  52418. */
  52419. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52420. /**
  52421. * Gets the active textures from the material
  52422. * @returns an array of textures
  52423. */
  52424. getActiveTextures(): BaseTexture[];
  52425. /**
  52426. * Gets the list of texture blocks
  52427. * @returns an array of texture blocks
  52428. */
  52429. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  52430. /**
  52431. * Specifies if the material uses a texture
  52432. * @param texture defines the texture to check against the material
  52433. * @returns a boolean specifying if the material uses the texture
  52434. */
  52435. hasTexture(texture: BaseTexture): boolean;
  52436. /**
  52437. * Disposes the material
  52438. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  52439. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  52440. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  52441. */
  52442. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  52443. /** Creates the node editor window. */
  52444. private _createNodeEditor;
  52445. /**
  52446. * Launch the node material editor
  52447. * @param config Define the configuration of the editor
  52448. * @return a promise fulfilled when the node editor is visible
  52449. */
  52450. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  52451. /**
  52452. * Clear the current material
  52453. */
  52454. clear(): void;
  52455. /**
  52456. * Clear the current material and set it to a default state
  52457. */
  52458. setToDefault(): void;
  52459. /**
  52460. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  52461. * @param url defines the url to load from
  52462. * @returns a promise that will fullfil when the material is fully loaded
  52463. */
  52464. loadAsync(url: string): Promise<unknown>;
  52465. private _gatherBlocks;
  52466. /**
  52467. * Generate a string containing the code declaration required to create an equivalent of this material
  52468. * @returns a string
  52469. */
  52470. generateCode(): string;
  52471. /**
  52472. * Serializes this material in a JSON representation
  52473. * @returns the serialized material object
  52474. */
  52475. serialize(): any;
  52476. private _restoreConnections;
  52477. /**
  52478. * Clear the current graph and load a new one from a serialization object
  52479. * @param source defines the JSON representation of the material
  52480. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52481. */
  52482. loadFromSerialization(source: any, rootUrl?: string): void;
  52483. /**
  52484. * Creates a node material from parsed material data
  52485. * @param source defines the JSON representation of the material
  52486. * @param scene defines the hosting scene
  52487. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52488. * @returns a new node material
  52489. */
  52490. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  52491. /**
  52492. * Creates a new node material set to default basic configuration
  52493. * @param name defines the name of the material
  52494. * @param scene defines the hosting scene
  52495. * @returns a new NodeMaterial
  52496. */
  52497. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  52498. }
  52499. }
  52500. declare module BABYLON {
  52501. /**
  52502. * Block used to read a texture from a sampler
  52503. */
  52504. export class TextureBlock extends NodeMaterialBlock {
  52505. private _defineName;
  52506. private _samplerName;
  52507. private _transformedUVName;
  52508. private _textureTransformName;
  52509. private _textureInfoName;
  52510. private _mainUVName;
  52511. private _mainUVDefineName;
  52512. /**
  52513. * Gets or sets the texture associated with the node
  52514. */
  52515. texture: Nullable<BaseTexture>;
  52516. /**
  52517. * Create a new TextureBlock
  52518. * @param name defines the block name
  52519. */
  52520. constructor(name: string);
  52521. /**
  52522. * Gets the current class name
  52523. * @returns the class name
  52524. */
  52525. getClassName(): string;
  52526. /**
  52527. * Gets the uv input component
  52528. */
  52529. readonly uv: NodeMaterialConnectionPoint;
  52530. /**
  52531. * Gets the rgba output component
  52532. */
  52533. readonly rgba: NodeMaterialConnectionPoint;
  52534. /**
  52535. * Gets the rgb output component
  52536. */
  52537. readonly rgb: NodeMaterialConnectionPoint;
  52538. /**
  52539. * Gets the r output component
  52540. */
  52541. readonly r: NodeMaterialConnectionPoint;
  52542. /**
  52543. * Gets the g output component
  52544. */
  52545. readonly g: NodeMaterialConnectionPoint;
  52546. /**
  52547. * Gets the b output component
  52548. */
  52549. readonly b: NodeMaterialConnectionPoint;
  52550. /**
  52551. * Gets the a output component
  52552. */
  52553. readonly a: NodeMaterialConnectionPoint;
  52554. readonly target: NodeMaterialBlockTargets;
  52555. autoConfigure(material: NodeMaterial): void;
  52556. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52557. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52558. isReady(): boolean;
  52559. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52560. private readonly _isMixed;
  52561. private _injectVertexCode;
  52562. private _writeOutput;
  52563. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52564. protected _dumpPropertiesCode(): string;
  52565. serialize(): any;
  52566. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52567. }
  52568. }
  52569. declare module BABYLON {
  52570. /**
  52571. * Class used to store shared data between 2 NodeMaterialBuildState
  52572. */
  52573. export class NodeMaterialBuildStateSharedData {
  52574. /**
  52575. * Gets the list of emitted varyings
  52576. */
  52577. temps: string[];
  52578. /**
  52579. * Gets the list of emitted varyings
  52580. */
  52581. varyings: string[];
  52582. /**
  52583. * Gets the varying declaration string
  52584. */
  52585. varyingDeclaration: string;
  52586. /**
  52587. * Input blocks
  52588. */
  52589. inputBlocks: InputBlock[];
  52590. /**
  52591. * Input blocks
  52592. */
  52593. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  52594. /**
  52595. * Bindable blocks (Blocks that need to set data to the effect)
  52596. */
  52597. bindableBlocks: NodeMaterialBlock[];
  52598. /**
  52599. * List of blocks that can provide a compilation fallback
  52600. */
  52601. blocksWithFallbacks: NodeMaterialBlock[];
  52602. /**
  52603. * List of blocks that can provide a define update
  52604. */
  52605. blocksWithDefines: NodeMaterialBlock[];
  52606. /**
  52607. * List of blocks that can provide a repeatable content
  52608. */
  52609. repeatableContentBlocks: NodeMaterialBlock[];
  52610. /**
  52611. * List of blocks that can provide a dynamic list of uniforms
  52612. */
  52613. dynamicUniformBlocks: NodeMaterialBlock[];
  52614. /**
  52615. * List of blocks that can block the isReady function for the material
  52616. */
  52617. blockingBlocks: NodeMaterialBlock[];
  52618. /**
  52619. * Gets the list of animated inputs
  52620. */
  52621. animatedInputs: InputBlock[];
  52622. /**
  52623. * Build Id used to avoid multiple recompilations
  52624. */
  52625. buildId: number;
  52626. /** List of emitted variables */
  52627. variableNames: {
  52628. [key: string]: number;
  52629. };
  52630. /** List of emitted defines */
  52631. defineNames: {
  52632. [key: string]: number;
  52633. };
  52634. /** Should emit comments? */
  52635. emitComments: boolean;
  52636. /** Emit build activity */
  52637. verbose: boolean;
  52638. /**
  52639. * Gets the compilation hints emitted at compilation time
  52640. */
  52641. hints: {
  52642. needWorldViewMatrix: boolean;
  52643. needWorldViewProjectionMatrix: boolean;
  52644. needAlphaBlending: boolean;
  52645. needAlphaTesting: boolean;
  52646. };
  52647. /**
  52648. * List of compilation checks
  52649. */
  52650. checks: {
  52651. emitVertex: boolean;
  52652. emitFragment: boolean;
  52653. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  52654. };
  52655. /** Creates a new shared data */
  52656. constructor();
  52657. /**
  52658. * Emits console errors and exceptions if there is a failing check
  52659. */
  52660. emitErrors(): void;
  52661. }
  52662. }
  52663. declare module BABYLON {
  52664. /**
  52665. * Class used to store node based material build state
  52666. */
  52667. export class NodeMaterialBuildState {
  52668. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  52669. supportUniformBuffers: boolean;
  52670. /**
  52671. * Gets the list of emitted attributes
  52672. */
  52673. attributes: string[];
  52674. /**
  52675. * Gets the list of emitted uniforms
  52676. */
  52677. uniforms: string[];
  52678. /**
  52679. * Gets the list of emitted uniform buffers
  52680. */
  52681. uniformBuffers: string[];
  52682. /**
  52683. * Gets the list of emitted samplers
  52684. */
  52685. samplers: string[];
  52686. /**
  52687. * Gets the list of emitted functions
  52688. */
  52689. functions: {
  52690. [key: string]: string;
  52691. };
  52692. /**
  52693. * Gets the target of the compilation state
  52694. */
  52695. target: NodeMaterialBlockTargets;
  52696. /**
  52697. * Gets the list of emitted counters
  52698. */
  52699. counters: {
  52700. [key: string]: number;
  52701. };
  52702. /**
  52703. * Shared data between multiple NodeMaterialBuildState instances
  52704. */
  52705. sharedData: NodeMaterialBuildStateSharedData;
  52706. /** @hidden */
  52707. _vertexState: NodeMaterialBuildState;
  52708. /** @hidden */
  52709. _attributeDeclaration: string;
  52710. /** @hidden */
  52711. _uniformDeclaration: string;
  52712. /** @hidden */
  52713. _samplerDeclaration: string;
  52714. /** @hidden */
  52715. _varyingTransfer: string;
  52716. private _repeatableContentAnchorIndex;
  52717. /** @hidden */
  52718. _builtCompilationString: string;
  52719. /**
  52720. * Gets the emitted compilation strings
  52721. */
  52722. compilationString: string;
  52723. /**
  52724. * Finalize the compilation strings
  52725. * @param state defines the current compilation state
  52726. */
  52727. finalize(state: NodeMaterialBuildState): void;
  52728. /** @hidden */
  52729. readonly _repeatableContentAnchor: string;
  52730. /** @hidden */
  52731. _getFreeVariableName(prefix: string): string;
  52732. /** @hidden */
  52733. _getFreeDefineName(prefix: string): string;
  52734. /** @hidden */
  52735. _excludeVariableName(name: string): void;
  52736. /** @hidden */
  52737. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  52738. /** @hidden */
  52739. _emitFunction(name: string, code: string, comments: string): void;
  52740. /** @hidden */
  52741. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  52742. replaceStrings?: {
  52743. search: RegExp;
  52744. replace: string;
  52745. }[];
  52746. repeatKey?: string;
  52747. }): string;
  52748. /** @hidden */
  52749. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  52750. repeatKey?: string;
  52751. removeAttributes?: boolean;
  52752. removeUniforms?: boolean;
  52753. removeVaryings?: boolean;
  52754. removeIfDef?: boolean;
  52755. replaceStrings?: {
  52756. search: RegExp;
  52757. replace: string;
  52758. }[];
  52759. }, storeKey?: string): void;
  52760. /** @hidden */
  52761. _registerTempVariable(name: string): boolean;
  52762. /** @hidden */
  52763. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  52764. /** @hidden */
  52765. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  52766. }
  52767. }
  52768. declare module BABYLON {
  52769. /**
  52770. * Defines a block that can be used inside a node based material
  52771. */
  52772. export class NodeMaterialBlock {
  52773. private _buildId;
  52774. private _buildTarget;
  52775. private _target;
  52776. private _isFinalMerger;
  52777. private _isInput;
  52778. /** @hidden */
  52779. _codeVariableName: string;
  52780. /** @hidden */
  52781. _inputs: NodeMaterialConnectionPoint[];
  52782. /** @hidden */
  52783. _outputs: NodeMaterialConnectionPoint[];
  52784. /** @hidden */
  52785. _preparationId: number;
  52786. /**
  52787. * Gets or sets the name of the block
  52788. */
  52789. name: string;
  52790. /**
  52791. * Gets or sets the unique id of the node
  52792. */
  52793. uniqueId: number;
  52794. /**
  52795. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  52796. */
  52797. readonly isFinalMerger: boolean;
  52798. /**
  52799. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  52800. */
  52801. readonly isInput: boolean;
  52802. /**
  52803. * Gets or sets the build Id
  52804. */
  52805. buildId: number;
  52806. /**
  52807. * Gets or sets the target of the block
  52808. */
  52809. target: NodeMaterialBlockTargets;
  52810. /**
  52811. * Gets the list of input points
  52812. */
  52813. readonly inputs: NodeMaterialConnectionPoint[];
  52814. /** Gets the list of output points */
  52815. readonly outputs: NodeMaterialConnectionPoint[];
  52816. /**
  52817. * Find an input by its name
  52818. * @param name defines the name of the input to look for
  52819. * @returns the input or null if not found
  52820. */
  52821. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52822. /**
  52823. * Find an output by its name
  52824. * @param name defines the name of the outputto look for
  52825. * @returns the output or null if not found
  52826. */
  52827. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52828. /**
  52829. * Creates a new NodeMaterialBlock
  52830. * @param name defines the block name
  52831. * @param target defines the target of that block (Vertex by default)
  52832. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  52833. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  52834. */
  52835. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  52836. /**
  52837. * Initialize the block and prepare the context for build
  52838. * @param state defines the state that will be used for the build
  52839. */
  52840. initialize(state: NodeMaterialBuildState): void;
  52841. /**
  52842. * Bind data to effect. Will only be called for blocks with isBindable === true
  52843. * @param effect defines the effect to bind data to
  52844. * @param nodeMaterial defines the hosting NodeMaterial
  52845. * @param mesh defines the mesh that will be rendered
  52846. */
  52847. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52848. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  52849. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  52850. protected _writeFloat(value: number): string;
  52851. /**
  52852. * Gets the current class name e.g. "NodeMaterialBlock"
  52853. * @returns the class name
  52854. */
  52855. getClassName(): string;
  52856. /**
  52857. * Register a new input. Must be called inside a block constructor
  52858. * @param name defines the connection point name
  52859. * @param type defines the connection point type
  52860. * @param isOptional defines a boolean indicating that this input can be omitted
  52861. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  52862. * @returns the current block
  52863. */
  52864. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  52865. /**
  52866. * Register a new output. Must be called inside a block constructor
  52867. * @param name defines the connection point name
  52868. * @param type defines the connection point type
  52869. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  52870. * @returns the current block
  52871. */
  52872. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  52873. /**
  52874. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  52875. * @param forOutput defines an optional connection point to check compatibility with
  52876. * @returns the first available input or null
  52877. */
  52878. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  52879. /**
  52880. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  52881. * @param forBlock defines an optional block to check compatibility with
  52882. * @returns the first available input or null
  52883. */
  52884. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  52885. /**
  52886. * Gets the sibling of the given output
  52887. * @param current defines the current output
  52888. * @returns the next output in the list or null
  52889. */
  52890. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  52891. /**
  52892. * Connect current block with another block
  52893. * @param other defines the block to connect with
  52894. * @param options define the various options to help pick the right connections
  52895. * @returns the current block
  52896. */
  52897. connectTo(other: NodeMaterialBlock, options?: {
  52898. input?: string;
  52899. output?: string;
  52900. outputSwizzle?: string;
  52901. }): this | undefined;
  52902. protected _buildBlock(state: NodeMaterialBuildState): void;
  52903. /**
  52904. * Add uniforms, samplers and uniform buffers at compilation time
  52905. * @param state defines the state to update
  52906. * @param nodeMaterial defines the node material requesting the update
  52907. * @param defines defines the material defines to update
  52908. */
  52909. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52910. /**
  52911. * Add potential fallbacks if shader compilation fails
  52912. * @param mesh defines the mesh to be rendered
  52913. * @param fallbacks defines the current prioritized list of fallbacks
  52914. */
  52915. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  52916. /**
  52917. * Update defines for shader compilation
  52918. * @param mesh defines the mesh to be rendered
  52919. * @param nodeMaterial defines the node material requesting the update
  52920. * @param defines defines the material defines to update
  52921. * @param useInstances specifies that instances should be used
  52922. */
  52923. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52924. /**
  52925. * Initialize defines for shader compilation
  52926. * @param mesh defines the mesh to be rendered
  52927. * @param nodeMaterial defines the node material requesting the update
  52928. * @param defines defines the material defines to be prepared
  52929. * @param useInstances specifies that instances should be used
  52930. */
  52931. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52932. /**
  52933. * Lets the block try to connect some inputs automatically
  52934. * @param material defines the hosting NodeMaterial
  52935. */
  52936. autoConfigure(material: NodeMaterial): void;
  52937. /**
  52938. * Function called when a block is declared as repeatable content generator
  52939. * @param vertexShaderState defines the current compilation state for the vertex shader
  52940. * @param fragmentShaderState defines the current compilation state for the fragment shader
  52941. * @param mesh defines the mesh to be rendered
  52942. * @param defines defines the material defines to update
  52943. */
  52944. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  52945. /**
  52946. * Checks if the block is ready
  52947. * @param mesh defines the mesh to be rendered
  52948. * @param nodeMaterial defines the node material requesting the update
  52949. * @param defines defines the material defines to update
  52950. * @param useInstances specifies that instances should be used
  52951. * @returns true if the block is ready
  52952. */
  52953. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  52954. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  52955. private _processBuild;
  52956. /**
  52957. * Compile the current node and generate the shader code
  52958. * @param state defines the current compilation state (uniforms, samplers, current string)
  52959. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  52960. * @returns true if already built
  52961. */
  52962. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  52963. protected _inputRename(name: string): string;
  52964. protected _outputRename(name: string): string;
  52965. protected _dumpPropertiesCode(): string;
  52966. /** @hidden */
  52967. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  52968. /**
  52969. * Clone the current block to a new identical block
  52970. * @param scene defines the hosting scene
  52971. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52972. * @returns a copy of the current block
  52973. */
  52974. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  52975. /**
  52976. * Serializes this block in a JSON representation
  52977. * @returns the serialized block object
  52978. */
  52979. serialize(): any;
  52980. /** @hidden */
  52981. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52982. }
  52983. }
  52984. declare module BABYLON {
  52985. /**
  52986. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  52987. */
  52988. export enum NodeMaterialBlockConnectionPointMode {
  52989. /** Value is an uniform */
  52990. Uniform = 0,
  52991. /** Value is a mesh attribute */
  52992. Attribute = 1,
  52993. /** Value is a varying between vertex and fragment shaders */
  52994. Varying = 2,
  52995. /** Mode is undefined */
  52996. Undefined = 3
  52997. }
  52998. }
  52999. declare module BABYLON {
  53000. /**
  53001. * Enum defining the type of animations supported by InputBlock
  53002. */
  53003. export enum AnimatedInputBlockTypes {
  53004. /** No animation */
  53005. None = 0,
  53006. /** Time based animation. Will only work for floats */
  53007. Time = 1
  53008. }
  53009. }
  53010. declare module BABYLON {
  53011. /**
  53012. * Block used to expose an input value
  53013. */
  53014. export class InputBlock extends NodeMaterialBlock {
  53015. private _mode;
  53016. private _associatedVariableName;
  53017. private _storedValue;
  53018. private _valueCallback;
  53019. private _type;
  53020. private _animationType;
  53021. /** @hidden */
  53022. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  53023. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  53024. visibleInInspector: boolean;
  53025. /**
  53026. * Gets or sets the connection point type (default is float)
  53027. */
  53028. readonly type: NodeMaterialBlockConnectionPointTypes;
  53029. /**
  53030. * Creates a new InputBlock
  53031. * @param name defines the block name
  53032. * @param target defines the target of that block (Vertex by default)
  53033. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  53034. */
  53035. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  53036. /**
  53037. * Gets the output component
  53038. */
  53039. readonly output: NodeMaterialConnectionPoint;
  53040. /**
  53041. * Set the source of this connection point to a vertex attribute
  53042. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  53043. * @returns the current connection point
  53044. */
  53045. setAsAttribute(attributeName?: string): InputBlock;
  53046. /**
  53047. * Set the source of this connection point to a well known value
  53048. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  53049. * @returns the current connection point
  53050. */
  53051. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  53052. /**
  53053. * Gets or sets the value of that point.
  53054. * Please note that this value will be ignored if valueCallback is defined
  53055. */
  53056. value: any;
  53057. /**
  53058. * Gets or sets a callback used to get the value of that point.
  53059. * Please note that setting this value will force the connection point to ignore the value property
  53060. */
  53061. valueCallback: () => any;
  53062. /**
  53063. * Gets or sets the associated variable name in the shader
  53064. */
  53065. associatedVariableName: string;
  53066. /** Gets or sets the type of animation applied to the input */
  53067. animationType: AnimatedInputBlockTypes;
  53068. /**
  53069. * Gets a boolean indicating that this connection point not defined yet
  53070. */
  53071. readonly isUndefined: boolean;
  53072. /**
  53073. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  53074. * In this case the connection point name must be the name of the uniform to use.
  53075. * Can only be set on inputs
  53076. */
  53077. isUniform: boolean;
  53078. /**
  53079. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  53080. * In this case the connection point name must be the name of the attribute to use
  53081. * Can only be set on inputs
  53082. */
  53083. isAttribute: boolean;
  53084. /**
  53085. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  53086. * Can only be set on exit points
  53087. */
  53088. isVarying: boolean;
  53089. /**
  53090. * Gets a boolean indicating that the current connection point is a well known value
  53091. */
  53092. readonly isWellKnownValue: boolean;
  53093. /**
  53094. * Gets or sets the current well known value or null if not defined as well know value
  53095. */
  53096. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  53097. /**
  53098. * Gets the current class name
  53099. * @returns the class name
  53100. */
  53101. getClassName(): string;
  53102. /**
  53103. * Animate the input if animationType !== None
  53104. * @param scene defines the rendering scene
  53105. */
  53106. animate(scene: Scene): void;
  53107. private _emitDefine;
  53108. /**
  53109. * Set the input block to its default value (based on its type)
  53110. */
  53111. setDefaultValue(): void;
  53112. protected _dumpPropertiesCode(): string;
  53113. private _emit;
  53114. /** @hidden */
  53115. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  53116. /** @hidden */
  53117. _transmit(effect: Effect, scene: Scene): void;
  53118. protected _buildBlock(state: NodeMaterialBuildState): void;
  53119. serialize(): any;
  53120. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53121. }
  53122. }
  53123. declare module BABYLON {
  53124. /**
  53125. * Defines a connection point for a block
  53126. */
  53127. export class NodeMaterialConnectionPoint {
  53128. /** @hidden */
  53129. _ownerBlock: NodeMaterialBlock;
  53130. /** @hidden */
  53131. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53132. private _endpoints;
  53133. private _associatedVariableName;
  53134. /** @hidden */
  53135. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53136. /** @hidden */
  53137. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53138. private _type;
  53139. /** @hidden */
  53140. _enforceAssociatedVariableName: boolean;
  53141. /**
  53142. * Gets or sets the additional types supported byt this connection point
  53143. */
  53144. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  53145. /**
  53146. * Gets or sets the associated variable name in the shader
  53147. */
  53148. associatedVariableName: string;
  53149. /**
  53150. * Gets or sets the connection point type (default is float)
  53151. */
  53152. type: NodeMaterialBlockConnectionPointTypes;
  53153. /**
  53154. * Gets or sets the connection point name
  53155. */
  53156. name: string;
  53157. /**
  53158. * Gets or sets a boolean indicating that this connection point can be omitted
  53159. */
  53160. isOptional: boolean;
  53161. /**
  53162. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  53163. */
  53164. define: string;
  53165. /** Gets or sets the target of that connection point */
  53166. target: NodeMaterialBlockTargets;
  53167. /**
  53168. * Gets a boolean indicating that the current point is connected
  53169. */
  53170. readonly isConnected: boolean;
  53171. /**
  53172. * Gets a boolean indicating that the current point is connected to an input block
  53173. */
  53174. readonly isConnectedToInputBlock: boolean;
  53175. /**
  53176. * Gets a the connected input block (if any)
  53177. */
  53178. readonly connectInputBlock: Nullable<InputBlock>;
  53179. /** Get the other side of the connection (if any) */
  53180. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53181. /** Get the block that owns this connection point */
  53182. readonly ownerBlock: NodeMaterialBlock;
  53183. /** Get the block connected on the other side of this connection (if any) */
  53184. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  53185. /** Get the block connected on the endpoints of this connection (if any) */
  53186. readonly connectedBlocks: Array<NodeMaterialBlock>;
  53187. /** Gets the list of connected endpoints */
  53188. readonly endpoints: NodeMaterialConnectionPoint[];
  53189. /** Gets a boolean indicating if that output point is connected to at least one input */
  53190. readonly hasEndpoints: boolean;
  53191. /**
  53192. * Creates a new connection point
  53193. * @param name defines the connection point name
  53194. * @param ownerBlock defines the block hosting this connection point
  53195. */
  53196. constructor(name: string, ownerBlock: NodeMaterialBlock);
  53197. /**
  53198. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  53199. * @returns the class name
  53200. */
  53201. getClassName(): string;
  53202. /**
  53203. * Gets an boolean indicating if the current point can be connected to another point
  53204. * @param connectionPoint defines the other connection point
  53205. * @returns true if the connection is possible
  53206. */
  53207. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  53208. /**
  53209. * Connect this point to another connection point
  53210. * @param connectionPoint defines the other connection point
  53211. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  53212. * @returns the current connection point
  53213. */
  53214. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  53215. /**
  53216. * Disconnect this point from one of his endpoint
  53217. * @param endpoint defines the other connection point
  53218. * @returns the current connection point
  53219. */
  53220. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53221. /**
  53222. * Serializes this point in a JSON representation
  53223. * @returns the serialized point object
  53224. */
  53225. serialize(): any;
  53226. }
  53227. }
  53228. declare module BABYLON {
  53229. /**
  53230. * Block used to add support for vertex skinning (bones)
  53231. */
  53232. export class BonesBlock extends NodeMaterialBlock {
  53233. /**
  53234. * Creates a new BonesBlock
  53235. * @param name defines the block name
  53236. */
  53237. constructor(name: string);
  53238. /**
  53239. * Initialize the block and prepare the context for build
  53240. * @param state defines the state that will be used for the build
  53241. */
  53242. initialize(state: NodeMaterialBuildState): void;
  53243. /**
  53244. * Gets the current class name
  53245. * @returns the class name
  53246. */
  53247. getClassName(): string;
  53248. /**
  53249. * Gets the matrix indices input component
  53250. */
  53251. readonly matricesIndices: NodeMaterialConnectionPoint;
  53252. /**
  53253. * Gets the matrix weights input component
  53254. */
  53255. readonly matricesWeights: NodeMaterialConnectionPoint;
  53256. /**
  53257. * Gets the extra matrix indices input component
  53258. */
  53259. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  53260. /**
  53261. * Gets the extra matrix weights input component
  53262. */
  53263. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  53264. /**
  53265. * Gets the world input component
  53266. */
  53267. readonly world: NodeMaterialConnectionPoint;
  53268. /**
  53269. * Gets the output component
  53270. */
  53271. readonly output: NodeMaterialConnectionPoint;
  53272. autoConfigure(material: NodeMaterial): void;
  53273. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53274. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53275. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53276. protected _buildBlock(state: NodeMaterialBuildState): this;
  53277. }
  53278. }
  53279. declare module BABYLON {
  53280. /**
  53281. * Block used to add support for instances
  53282. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  53283. */
  53284. export class InstancesBlock extends NodeMaterialBlock {
  53285. /**
  53286. * Creates a new InstancesBlock
  53287. * @param name defines the block name
  53288. */
  53289. constructor(name: string);
  53290. /**
  53291. * Gets the current class name
  53292. * @returns the class name
  53293. */
  53294. getClassName(): string;
  53295. /**
  53296. * Gets the first world row input component
  53297. */
  53298. readonly world0: NodeMaterialConnectionPoint;
  53299. /**
  53300. * Gets the second world row input component
  53301. */
  53302. readonly world1: NodeMaterialConnectionPoint;
  53303. /**
  53304. * Gets the third world row input component
  53305. */
  53306. readonly world2: NodeMaterialConnectionPoint;
  53307. /**
  53308. * Gets the forth world row input component
  53309. */
  53310. readonly world3: NodeMaterialConnectionPoint;
  53311. /**
  53312. * Gets the world input component
  53313. */
  53314. readonly world: NodeMaterialConnectionPoint;
  53315. /**
  53316. * Gets the output component
  53317. */
  53318. readonly output: NodeMaterialConnectionPoint;
  53319. autoConfigure(material: NodeMaterial): void;
  53320. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53321. protected _buildBlock(state: NodeMaterialBuildState): this;
  53322. }
  53323. }
  53324. declare module BABYLON {
  53325. /**
  53326. * Block used to add morph targets support to vertex shader
  53327. */
  53328. export class MorphTargetsBlock extends NodeMaterialBlock {
  53329. private _repeatableContentAnchor;
  53330. private _repeatebleContentGenerated;
  53331. /**
  53332. * Create a new MorphTargetsBlock
  53333. * @param name defines the block name
  53334. */
  53335. constructor(name: string);
  53336. /**
  53337. * Gets the current class name
  53338. * @returns the class name
  53339. */
  53340. getClassName(): string;
  53341. /**
  53342. * Gets the position input component
  53343. */
  53344. readonly position: NodeMaterialConnectionPoint;
  53345. /**
  53346. * Gets the normal input component
  53347. */
  53348. readonly normal: NodeMaterialConnectionPoint;
  53349. /**
  53350. * Gets the tangent input component
  53351. */
  53352. readonly tangent: NodeMaterialConnectionPoint;
  53353. /**
  53354. * Gets the tangent input component
  53355. */
  53356. readonly uv: NodeMaterialConnectionPoint;
  53357. /**
  53358. * Gets the position output component
  53359. */
  53360. readonly positionOutput: NodeMaterialConnectionPoint;
  53361. /**
  53362. * Gets the normal output component
  53363. */
  53364. readonly normalOutput: NodeMaterialConnectionPoint;
  53365. /**
  53366. * Gets the tangent output component
  53367. */
  53368. readonly tangentOutput: NodeMaterialConnectionPoint;
  53369. /**
  53370. * Gets the tangent output component
  53371. */
  53372. readonly uvOutput: NodeMaterialConnectionPoint;
  53373. initialize(state: NodeMaterialBuildState): void;
  53374. autoConfigure(material: NodeMaterial): void;
  53375. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53376. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53377. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53378. protected _buildBlock(state: NodeMaterialBuildState): this;
  53379. }
  53380. }
  53381. declare module BABYLON {
  53382. /**
  53383. * Block used to get data information from a light
  53384. */
  53385. export class LightInformationBlock extends NodeMaterialBlock {
  53386. private _lightDataDefineName;
  53387. private _lightColorDefineName;
  53388. /**
  53389. * Gets or sets the light associated with this block
  53390. */
  53391. light: Nullable<Light>;
  53392. /**
  53393. * Creates a new LightInformationBlock
  53394. * @param name defines the block name
  53395. */
  53396. constructor(name: string);
  53397. /**
  53398. * Gets the current class name
  53399. * @returns the class name
  53400. */
  53401. getClassName(): string;
  53402. /**
  53403. * Gets the world position input component
  53404. */
  53405. readonly worldPosition: NodeMaterialConnectionPoint;
  53406. /**
  53407. * Gets the direction output component
  53408. */
  53409. readonly direction: NodeMaterialConnectionPoint;
  53410. /**
  53411. * Gets the direction output component
  53412. */
  53413. readonly color: NodeMaterialConnectionPoint;
  53414. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53415. protected _buildBlock(state: NodeMaterialBuildState): this;
  53416. serialize(): any;
  53417. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53418. }
  53419. }
  53420. declare module BABYLON {
  53421. /**
  53422. * Block used to add an alpha test in the fragment shader
  53423. */
  53424. export class AlphaTestBlock extends NodeMaterialBlock {
  53425. /**
  53426. * Gets or sets the alpha value where alpha testing happens
  53427. */
  53428. alphaCutOff: number;
  53429. /**
  53430. * Create a new AlphaTestBlock
  53431. * @param name defines the block name
  53432. */
  53433. constructor(name: string);
  53434. /**
  53435. * Gets the current class name
  53436. * @returns the class name
  53437. */
  53438. getClassName(): string;
  53439. /**
  53440. * Gets the color input component
  53441. */
  53442. readonly color: NodeMaterialConnectionPoint;
  53443. /**
  53444. * Gets the alpha input component
  53445. */
  53446. readonly alpha: NodeMaterialConnectionPoint;
  53447. protected _buildBlock(state: NodeMaterialBuildState): this;
  53448. protected _dumpPropertiesCode(): string;
  53449. serialize(): any;
  53450. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53451. }
  53452. }
  53453. declare module BABYLON {
  53454. /**
  53455. * Block used to add image processing support to fragment shader
  53456. */
  53457. export class ImageProcessingBlock extends NodeMaterialBlock {
  53458. /**
  53459. * Create a new ImageProcessingBlock
  53460. * @param name defines the block name
  53461. */
  53462. constructor(name: string);
  53463. /**
  53464. * Gets the current class name
  53465. * @returns the class name
  53466. */
  53467. getClassName(): string;
  53468. /**
  53469. * Gets the color input component
  53470. */
  53471. readonly color: NodeMaterialConnectionPoint;
  53472. /**
  53473. * Gets the output component
  53474. */
  53475. readonly output: NodeMaterialConnectionPoint;
  53476. /**
  53477. * Initialize the block and prepare the context for build
  53478. * @param state defines the state that will be used for the build
  53479. */
  53480. initialize(state: NodeMaterialBuildState): void;
  53481. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  53482. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53483. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53484. protected _buildBlock(state: NodeMaterialBuildState): this;
  53485. }
  53486. }
  53487. declare module BABYLON {
  53488. /**
  53489. * Block used to add support for scene fog
  53490. */
  53491. export class FogBlock extends NodeMaterialBlock {
  53492. private _fogDistanceName;
  53493. private _fogParameters;
  53494. /**
  53495. * Create a new FogBlock
  53496. * @param name defines the block name
  53497. */
  53498. constructor(name: string);
  53499. /**
  53500. * Gets the current class name
  53501. * @returns the class name
  53502. */
  53503. getClassName(): string;
  53504. /**
  53505. * Gets the world position input component
  53506. */
  53507. readonly worldPosition: NodeMaterialConnectionPoint;
  53508. /**
  53509. * Gets the view input component
  53510. */
  53511. readonly view: NodeMaterialConnectionPoint;
  53512. /**
  53513. * Gets the color input component
  53514. */
  53515. readonly input: NodeMaterialConnectionPoint;
  53516. /**
  53517. * Gets the fog color input component
  53518. */
  53519. readonly fogColor: NodeMaterialConnectionPoint;
  53520. /**
  53521. * Gets the output component
  53522. */
  53523. readonly output: NodeMaterialConnectionPoint;
  53524. autoConfigure(material: NodeMaterial): void;
  53525. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53526. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53527. protected _buildBlock(state: NodeMaterialBuildState): this;
  53528. }
  53529. }
  53530. declare module BABYLON {
  53531. /**
  53532. * Block used to add light in the fragment shader
  53533. */
  53534. export class LightBlock extends NodeMaterialBlock {
  53535. private _lightId;
  53536. /**
  53537. * Gets or sets the light associated with this block
  53538. */
  53539. light: Nullable<Light>;
  53540. /**
  53541. * Create a new LightBlock
  53542. * @param name defines the block name
  53543. */
  53544. constructor(name: string);
  53545. /**
  53546. * Gets the current class name
  53547. * @returns the class name
  53548. */
  53549. getClassName(): string;
  53550. /**
  53551. * Gets the world position input component
  53552. */
  53553. readonly worldPosition: NodeMaterialConnectionPoint;
  53554. /**
  53555. * Gets the world normal input component
  53556. */
  53557. readonly worldNormal: NodeMaterialConnectionPoint;
  53558. /**
  53559. * Gets the camera (or eye) position component
  53560. */
  53561. readonly cameraPosition: NodeMaterialConnectionPoint;
  53562. /**
  53563. * Gets the diffuse output component
  53564. */
  53565. readonly diffuseOutput: NodeMaterialConnectionPoint;
  53566. /**
  53567. * Gets the specular output component
  53568. */
  53569. readonly specularOutput: NodeMaterialConnectionPoint;
  53570. autoConfigure(material: NodeMaterial): void;
  53571. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53572. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53573. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53574. private _injectVertexCode;
  53575. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53576. serialize(): any;
  53577. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53578. }
  53579. }
  53580. declare module BABYLON {
  53581. /**
  53582. * Block used to multiply 2 values
  53583. */
  53584. export class MultiplyBlock extends NodeMaterialBlock {
  53585. /**
  53586. * Creates a new MultiplyBlock
  53587. * @param name defines the block name
  53588. */
  53589. constructor(name: string);
  53590. /**
  53591. * Gets the current class name
  53592. * @returns the class name
  53593. */
  53594. getClassName(): string;
  53595. /**
  53596. * Gets the left operand input component
  53597. */
  53598. readonly left: NodeMaterialConnectionPoint;
  53599. /**
  53600. * Gets the right operand input component
  53601. */
  53602. readonly right: NodeMaterialConnectionPoint;
  53603. /**
  53604. * Gets the output component
  53605. */
  53606. readonly output: NodeMaterialConnectionPoint;
  53607. protected _buildBlock(state: NodeMaterialBuildState): this;
  53608. }
  53609. }
  53610. declare module BABYLON {
  53611. /**
  53612. * Block used to add 2 vectors
  53613. */
  53614. export class AddBlock extends NodeMaterialBlock {
  53615. /**
  53616. * Creates a new AddBlock
  53617. * @param name defines the block name
  53618. */
  53619. constructor(name: string);
  53620. /**
  53621. * Gets the current class name
  53622. * @returns the class name
  53623. */
  53624. getClassName(): string;
  53625. /**
  53626. * Gets the left operand input component
  53627. */
  53628. readonly left: NodeMaterialConnectionPoint;
  53629. /**
  53630. * Gets the right operand input component
  53631. */
  53632. readonly right: NodeMaterialConnectionPoint;
  53633. /**
  53634. * Gets the output component
  53635. */
  53636. readonly output: NodeMaterialConnectionPoint;
  53637. protected _buildBlock(state: NodeMaterialBuildState): this;
  53638. }
  53639. }
  53640. declare module BABYLON {
  53641. /**
  53642. * Block used to scale a vector by a float
  53643. */
  53644. export class ScaleBlock extends NodeMaterialBlock {
  53645. /**
  53646. * Creates a new ScaleBlock
  53647. * @param name defines the block name
  53648. */
  53649. constructor(name: string);
  53650. /**
  53651. * Gets the current class name
  53652. * @returns the class name
  53653. */
  53654. getClassName(): string;
  53655. /**
  53656. * Gets the input component
  53657. */
  53658. readonly input: NodeMaterialConnectionPoint;
  53659. /**
  53660. * Gets the factor input component
  53661. */
  53662. readonly factor: NodeMaterialConnectionPoint;
  53663. /**
  53664. * Gets the output component
  53665. */
  53666. readonly output: NodeMaterialConnectionPoint;
  53667. protected _buildBlock(state: NodeMaterialBuildState): this;
  53668. }
  53669. }
  53670. declare module BABYLON {
  53671. /**
  53672. * Block used to clamp a float
  53673. */
  53674. export class ClampBlock extends NodeMaterialBlock {
  53675. /** Gets or sets the minimum range */
  53676. minimum: number;
  53677. /** Gets or sets the maximum range */
  53678. maximum: number;
  53679. /**
  53680. * Creates a new ClampBlock
  53681. * @param name defines the block name
  53682. */
  53683. constructor(name: string);
  53684. /**
  53685. * Gets the current class name
  53686. * @returns the class name
  53687. */
  53688. getClassName(): string;
  53689. /**
  53690. * Gets the value input component
  53691. */
  53692. readonly value: NodeMaterialConnectionPoint;
  53693. /**
  53694. * Gets the output component
  53695. */
  53696. readonly output: NodeMaterialConnectionPoint;
  53697. protected _buildBlock(state: NodeMaterialBuildState): this;
  53698. protected _dumpPropertiesCode(): string;
  53699. serialize(): any;
  53700. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53701. }
  53702. }
  53703. declare module BABYLON {
  53704. /**
  53705. * Block used to apply a cross product between 2 vectors
  53706. */
  53707. export class CrossBlock extends NodeMaterialBlock {
  53708. /**
  53709. * Creates a new CrossBlock
  53710. * @param name defines the block name
  53711. */
  53712. constructor(name: string);
  53713. /**
  53714. * Gets the current class name
  53715. * @returns the class name
  53716. */
  53717. getClassName(): string;
  53718. /**
  53719. * Gets the left operand input component
  53720. */
  53721. readonly left: NodeMaterialConnectionPoint;
  53722. /**
  53723. * Gets the right operand input component
  53724. */
  53725. readonly right: NodeMaterialConnectionPoint;
  53726. /**
  53727. * Gets the output component
  53728. */
  53729. readonly output: NodeMaterialConnectionPoint;
  53730. protected _buildBlock(state: NodeMaterialBuildState): this;
  53731. }
  53732. }
  53733. declare module BABYLON {
  53734. /**
  53735. * Block used to apply a dot product between 2 vectors
  53736. */
  53737. export class DotBlock extends NodeMaterialBlock {
  53738. /**
  53739. * Creates a new DotBlock
  53740. * @param name defines the block name
  53741. */
  53742. constructor(name: string);
  53743. /**
  53744. * Gets the current class name
  53745. * @returns the class name
  53746. */
  53747. getClassName(): string;
  53748. /**
  53749. * Gets the left operand input component
  53750. */
  53751. readonly left: NodeMaterialConnectionPoint;
  53752. /**
  53753. * Gets the right operand input component
  53754. */
  53755. readonly right: NodeMaterialConnectionPoint;
  53756. /**
  53757. * Gets the output component
  53758. */
  53759. readonly output: NodeMaterialConnectionPoint;
  53760. protected _buildBlock(state: NodeMaterialBuildState): this;
  53761. }
  53762. }
  53763. declare module BABYLON {
  53764. /**
  53765. * Block used to remap a float from a range to a new one
  53766. */
  53767. export class RemapBlock extends NodeMaterialBlock {
  53768. /**
  53769. * Gets or sets the source range
  53770. */
  53771. sourceRange: Vector2;
  53772. /**
  53773. * Gets or sets the target range
  53774. */
  53775. targetRange: Vector2;
  53776. /**
  53777. * Creates a new RemapBlock
  53778. * @param name defines the block name
  53779. */
  53780. constructor(name: string);
  53781. /**
  53782. * Gets the current class name
  53783. * @returns the class name
  53784. */
  53785. getClassName(): string;
  53786. /**
  53787. * Gets the input component
  53788. */
  53789. readonly input: NodeMaterialConnectionPoint;
  53790. /**
  53791. * Gets the output component
  53792. */
  53793. readonly output: NodeMaterialConnectionPoint;
  53794. protected _buildBlock(state: NodeMaterialBuildState): this;
  53795. protected _dumpPropertiesCode(): string;
  53796. serialize(): any;
  53797. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53798. }
  53799. }
  53800. declare module BABYLON {
  53801. /**
  53802. * Block used to normalize a vector
  53803. */
  53804. export class NormalizeBlock extends NodeMaterialBlock {
  53805. /**
  53806. * Creates a new NormalizeBlock
  53807. * @param name defines the block name
  53808. */
  53809. constructor(name: string);
  53810. /**
  53811. * Gets the current class name
  53812. * @returns the class name
  53813. */
  53814. getClassName(): string;
  53815. /**
  53816. * Gets the input component
  53817. */
  53818. readonly input: NodeMaterialConnectionPoint;
  53819. /**
  53820. * Gets the output component
  53821. */
  53822. readonly output: NodeMaterialConnectionPoint;
  53823. protected _buildBlock(state: NodeMaterialBuildState): this;
  53824. }
  53825. }
  53826. declare module BABYLON {
  53827. /**
  53828. * Operations supported by the Trigonometry block
  53829. */
  53830. export enum TrigonometryBlockOperations {
  53831. /** Cos */
  53832. Cos = 0,
  53833. /** Sin */
  53834. Sin = 1,
  53835. /** Abs */
  53836. Abs = 2,
  53837. /** Exp */
  53838. Exp = 3,
  53839. /** Exp2 */
  53840. Exp2 = 4,
  53841. /** Round */
  53842. Round = 5,
  53843. /** Floor */
  53844. Floor = 6,
  53845. /** Ceiling */
  53846. Ceiling = 7
  53847. }
  53848. /**
  53849. * Block used to apply trigonometry operation to floats
  53850. */
  53851. export class TrigonometryBlock extends NodeMaterialBlock {
  53852. /**
  53853. * Gets or sets the operation applied by the block
  53854. */
  53855. operation: TrigonometryBlockOperations;
  53856. /**
  53857. * Creates a new TrigonometryBlock
  53858. * @param name defines the block name
  53859. */
  53860. constructor(name: string);
  53861. /**
  53862. * Gets the current class name
  53863. * @returns the class name
  53864. */
  53865. getClassName(): string;
  53866. /**
  53867. * Gets the input component
  53868. */
  53869. readonly input: NodeMaterialConnectionPoint;
  53870. /**
  53871. * Gets the output component
  53872. */
  53873. readonly output: NodeMaterialConnectionPoint;
  53874. protected _buildBlock(state: NodeMaterialBuildState): this;
  53875. serialize(): any;
  53876. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53877. }
  53878. }
  53879. declare module BABYLON {
  53880. /**
  53881. * Block used to create a Color3/4 out of individual inputs (one for each component)
  53882. */
  53883. export class ColorMergerBlock extends NodeMaterialBlock {
  53884. /**
  53885. * Create a new ColorMergerBlock
  53886. * @param name defines the block name
  53887. */
  53888. constructor(name: string);
  53889. /**
  53890. * Gets the current class name
  53891. * @returns the class name
  53892. */
  53893. getClassName(): string;
  53894. /**
  53895. * Gets the r component (input)
  53896. */
  53897. readonly r: NodeMaterialConnectionPoint;
  53898. /**
  53899. * Gets the g component (input)
  53900. */
  53901. readonly g: NodeMaterialConnectionPoint;
  53902. /**
  53903. * Gets the b component (input)
  53904. */
  53905. readonly b: NodeMaterialConnectionPoint;
  53906. /**
  53907. * Gets the a component (input)
  53908. */
  53909. readonly a: NodeMaterialConnectionPoint;
  53910. /**
  53911. * Gets the rgba component (output)
  53912. */
  53913. readonly rgba: NodeMaterialConnectionPoint;
  53914. /**
  53915. * Gets the rgb component (output)
  53916. */
  53917. readonly rgb: NodeMaterialConnectionPoint;
  53918. protected _buildBlock(state: NodeMaterialBuildState): this;
  53919. }
  53920. }
  53921. declare module BABYLON {
  53922. /**
  53923. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  53924. */
  53925. export class VectorMergerBlock extends NodeMaterialBlock {
  53926. /**
  53927. * Create a new VectorMergerBlock
  53928. * @param name defines the block name
  53929. */
  53930. constructor(name: string);
  53931. /**
  53932. * Gets the current class name
  53933. * @returns the class name
  53934. */
  53935. getClassName(): string;
  53936. /**
  53937. * Gets the x component (input)
  53938. */
  53939. readonly x: NodeMaterialConnectionPoint;
  53940. /**
  53941. * Gets the y component (input)
  53942. */
  53943. readonly y: NodeMaterialConnectionPoint;
  53944. /**
  53945. * Gets the z component (input)
  53946. */
  53947. readonly z: NodeMaterialConnectionPoint;
  53948. /**
  53949. * Gets the w component (input)
  53950. */
  53951. readonly w: NodeMaterialConnectionPoint;
  53952. /**
  53953. * Gets the xyzw component (output)
  53954. */
  53955. readonly xyzw: NodeMaterialConnectionPoint;
  53956. /**
  53957. * Gets the xyz component (output)
  53958. */
  53959. readonly xyz: NodeMaterialConnectionPoint;
  53960. /**
  53961. * Gets the xy component (output)
  53962. */
  53963. readonly xy: NodeMaterialConnectionPoint;
  53964. protected _buildBlock(state: NodeMaterialBuildState): this;
  53965. }
  53966. }
  53967. declare module BABYLON {
  53968. /**
  53969. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  53970. */
  53971. export class ColorSplitterBlock extends NodeMaterialBlock {
  53972. /**
  53973. * Create a new ColorSplitterBlock
  53974. * @param name defines the block name
  53975. */
  53976. constructor(name: string);
  53977. /**
  53978. * Gets the current class name
  53979. * @returns the class name
  53980. */
  53981. getClassName(): string;
  53982. /**
  53983. * Gets the rgba component (input)
  53984. */
  53985. readonly rgba: NodeMaterialConnectionPoint;
  53986. /**
  53987. * Gets the rgb component (input)
  53988. */
  53989. readonly rgbIn: NodeMaterialConnectionPoint;
  53990. /**
  53991. * Gets the rgb component (output)
  53992. */
  53993. readonly rgbOut: NodeMaterialConnectionPoint;
  53994. /**
  53995. * Gets the r component (output)
  53996. */
  53997. readonly r: NodeMaterialConnectionPoint;
  53998. /**
  53999. * Gets the g component (output)
  54000. */
  54001. readonly g: NodeMaterialConnectionPoint;
  54002. /**
  54003. * Gets the b component (output)
  54004. */
  54005. readonly b: NodeMaterialConnectionPoint;
  54006. /**
  54007. * Gets the a component (output)
  54008. */
  54009. readonly a: NodeMaterialConnectionPoint;
  54010. protected _inputRename(name: string): string;
  54011. protected _outputRename(name: string): string;
  54012. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54013. }
  54014. }
  54015. declare module BABYLON {
  54016. /**
  54017. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  54018. */
  54019. export class VectorSplitterBlock extends NodeMaterialBlock {
  54020. /**
  54021. * Create a new VectorSplitterBlock
  54022. * @param name defines the block name
  54023. */
  54024. constructor(name: string);
  54025. /**
  54026. * Gets the current class name
  54027. * @returns the class name
  54028. */
  54029. getClassName(): string;
  54030. /**
  54031. * Gets the xyzw component (input)
  54032. */
  54033. readonly xyzw: NodeMaterialConnectionPoint;
  54034. /**
  54035. * Gets the xyz component (input)
  54036. */
  54037. readonly xyzIn: NodeMaterialConnectionPoint;
  54038. /**
  54039. * Gets the xy component (input)
  54040. */
  54041. readonly xyIn: NodeMaterialConnectionPoint;
  54042. /**
  54043. * Gets the xyz component (output)
  54044. */
  54045. readonly xyzOut: NodeMaterialConnectionPoint;
  54046. /**
  54047. * Gets the xy component (output)
  54048. */
  54049. readonly xyOut: NodeMaterialConnectionPoint;
  54050. /**
  54051. * Gets the x component (output)
  54052. */
  54053. readonly x: NodeMaterialConnectionPoint;
  54054. /**
  54055. * Gets the y component (output)
  54056. */
  54057. readonly y: NodeMaterialConnectionPoint;
  54058. /**
  54059. * Gets the z component (output)
  54060. */
  54061. readonly z: NodeMaterialConnectionPoint;
  54062. /**
  54063. * Gets the w component (output)
  54064. */
  54065. readonly w: NodeMaterialConnectionPoint;
  54066. protected _inputRename(name: string): string;
  54067. protected _outputRename(name: string): string;
  54068. protected _buildBlock(state: NodeMaterialBuildState): this;
  54069. }
  54070. }
  54071. declare module BABYLON {
  54072. /**
  54073. * Block used to lerp 2 values
  54074. */
  54075. export class LerpBlock extends NodeMaterialBlock {
  54076. /**
  54077. * Creates a new LerpBlock
  54078. * @param name defines the block name
  54079. */
  54080. constructor(name: string);
  54081. /**
  54082. * Gets the current class name
  54083. * @returns the class name
  54084. */
  54085. getClassName(): string;
  54086. /**
  54087. * Gets the left operand input component
  54088. */
  54089. readonly left: NodeMaterialConnectionPoint;
  54090. /**
  54091. * Gets the right operand input component
  54092. */
  54093. readonly right: NodeMaterialConnectionPoint;
  54094. /**
  54095. * Gets the gradient operand input component
  54096. */
  54097. readonly gradient: NodeMaterialConnectionPoint;
  54098. /**
  54099. * Gets the output component
  54100. */
  54101. readonly output: NodeMaterialConnectionPoint;
  54102. protected _buildBlock(state: NodeMaterialBuildState): this;
  54103. }
  54104. }
  54105. declare module BABYLON {
  54106. /**
  54107. * Block used to divide 2 vectors
  54108. */
  54109. export class DivideBlock extends NodeMaterialBlock {
  54110. /**
  54111. * Creates a new DivideBlock
  54112. * @param name defines the block name
  54113. */
  54114. constructor(name: string);
  54115. /**
  54116. * Gets the current class name
  54117. * @returns the class name
  54118. */
  54119. getClassName(): string;
  54120. /**
  54121. * Gets the left operand input component
  54122. */
  54123. readonly left: NodeMaterialConnectionPoint;
  54124. /**
  54125. * Gets the right operand input component
  54126. */
  54127. readonly right: NodeMaterialConnectionPoint;
  54128. /**
  54129. * Gets the output component
  54130. */
  54131. readonly output: NodeMaterialConnectionPoint;
  54132. protected _buildBlock(state: NodeMaterialBuildState): this;
  54133. }
  54134. }
  54135. declare module BABYLON {
  54136. /**
  54137. * Block used to subtract 2 vectors
  54138. */
  54139. export class SubtractBlock extends NodeMaterialBlock {
  54140. /**
  54141. * Creates a new SubtractBlock
  54142. * @param name defines the block name
  54143. */
  54144. constructor(name: string);
  54145. /**
  54146. * Gets the current class name
  54147. * @returns the class name
  54148. */
  54149. getClassName(): string;
  54150. /**
  54151. * Gets the left operand input component
  54152. */
  54153. readonly left: NodeMaterialConnectionPoint;
  54154. /**
  54155. * Gets the right operand input component
  54156. */
  54157. readonly right: NodeMaterialConnectionPoint;
  54158. /**
  54159. * Gets the output component
  54160. */
  54161. readonly output: NodeMaterialConnectionPoint;
  54162. protected _buildBlock(state: NodeMaterialBuildState): this;
  54163. }
  54164. }
  54165. declare module BABYLON {
  54166. /**
  54167. * Block used to step a value
  54168. */
  54169. export class StepBlock extends NodeMaterialBlock {
  54170. /**
  54171. * Creates a new AddBlock
  54172. * @param name defines the block name
  54173. */
  54174. constructor(name: string);
  54175. /**
  54176. * Gets the current class name
  54177. * @returns the class name
  54178. */
  54179. getClassName(): string;
  54180. /**
  54181. * Gets the value operand input component
  54182. */
  54183. readonly value: NodeMaterialConnectionPoint;
  54184. /**
  54185. * Gets the edge operand input component
  54186. */
  54187. readonly edge: NodeMaterialConnectionPoint;
  54188. /**
  54189. * Gets the output component
  54190. */
  54191. readonly output: NodeMaterialConnectionPoint;
  54192. protected _buildBlock(state: NodeMaterialBuildState): this;
  54193. }
  54194. }
  54195. declare module BABYLON {
  54196. /**
  54197. * Block used to get the opposite of a value
  54198. */
  54199. export class OppositeBlock extends NodeMaterialBlock {
  54200. /**
  54201. * Creates a new OppositeBlock
  54202. * @param name defines the block name
  54203. */
  54204. constructor(name: string);
  54205. /**
  54206. * Gets the current class name
  54207. * @returns the class name
  54208. */
  54209. getClassName(): string;
  54210. /**
  54211. * Gets the input component
  54212. */
  54213. readonly input: NodeMaterialConnectionPoint;
  54214. /**
  54215. * Gets the output component
  54216. */
  54217. readonly output: NodeMaterialConnectionPoint;
  54218. protected _buildBlock(state: NodeMaterialBuildState): this;
  54219. }
  54220. }
  54221. declare module BABYLON {
  54222. /**
  54223. * Block used to get the view direction
  54224. */
  54225. export class ViewDirectionBlock extends NodeMaterialBlock {
  54226. /**
  54227. * Creates a new ViewDirectionBlock
  54228. * @param name defines the block name
  54229. */
  54230. constructor(name: string);
  54231. /**
  54232. * Gets the current class name
  54233. * @returns the class name
  54234. */
  54235. getClassName(): string;
  54236. /**
  54237. * Gets the world position component
  54238. */
  54239. readonly worldPosition: NodeMaterialConnectionPoint;
  54240. /**
  54241. * Gets the camera position component
  54242. */
  54243. readonly cameraPosition: NodeMaterialConnectionPoint;
  54244. /**
  54245. * Gets the output component
  54246. */
  54247. readonly output: NodeMaterialConnectionPoint;
  54248. autoConfigure(material: NodeMaterial): void;
  54249. protected _buildBlock(state: NodeMaterialBuildState): this;
  54250. }
  54251. }
  54252. declare module BABYLON {
  54253. /**
  54254. * Block used to compute fresnel value
  54255. */
  54256. export class FresnelBlock extends NodeMaterialBlock {
  54257. /**
  54258. * Create a new FresnelBlock
  54259. * @param name defines the block name
  54260. */
  54261. constructor(name: string);
  54262. /**
  54263. * Gets the current class name
  54264. * @returns the class name
  54265. */
  54266. getClassName(): string;
  54267. /**
  54268. * Gets the world normal input component
  54269. */
  54270. readonly worldNormal: NodeMaterialConnectionPoint;
  54271. /**
  54272. * Gets the view direction input component
  54273. */
  54274. readonly viewDirection: NodeMaterialConnectionPoint;
  54275. /**
  54276. * Gets the bias input component
  54277. */
  54278. readonly bias: NodeMaterialConnectionPoint;
  54279. /**
  54280. * Gets the camera (or eye) position component
  54281. */
  54282. readonly power: NodeMaterialConnectionPoint;
  54283. /**
  54284. * Gets the fresnel output component
  54285. */
  54286. readonly fresnel: NodeMaterialConnectionPoint;
  54287. autoConfigure(material: NodeMaterial): void;
  54288. protected _buildBlock(state: NodeMaterialBuildState): this;
  54289. }
  54290. }
  54291. declare module BABYLON {
  54292. /**
  54293. * Block used to get the max of 2 values
  54294. */
  54295. export class MaxBlock extends NodeMaterialBlock {
  54296. /**
  54297. * Creates a new MaxBlock
  54298. * @param name defines the block name
  54299. */
  54300. constructor(name: string);
  54301. /**
  54302. * Gets the current class name
  54303. * @returns the class name
  54304. */
  54305. getClassName(): string;
  54306. /**
  54307. * Gets the left operand input component
  54308. */
  54309. readonly left: NodeMaterialConnectionPoint;
  54310. /**
  54311. * Gets the right operand input component
  54312. */
  54313. readonly right: NodeMaterialConnectionPoint;
  54314. /**
  54315. * Gets the output component
  54316. */
  54317. readonly output: NodeMaterialConnectionPoint;
  54318. protected _buildBlock(state: NodeMaterialBuildState): this;
  54319. }
  54320. }
  54321. declare module BABYLON {
  54322. /**
  54323. * Block used to get the min of 2 values
  54324. */
  54325. export class MinBlock extends NodeMaterialBlock {
  54326. /**
  54327. * Creates a new MinBlock
  54328. * @param name defines the block name
  54329. */
  54330. constructor(name: string);
  54331. /**
  54332. * Gets the current class name
  54333. * @returns the class name
  54334. */
  54335. getClassName(): string;
  54336. /**
  54337. * Gets the left operand input component
  54338. */
  54339. readonly left: NodeMaterialConnectionPoint;
  54340. /**
  54341. * Gets the right operand input component
  54342. */
  54343. readonly right: NodeMaterialConnectionPoint;
  54344. /**
  54345. * Gets the output component
  54346. */
  54347. readonly output: NodeMaterialConnectionPoint;
  54348. protected _buildBlock(state: NodeMaterialBuildState): this;
  54349. }
  54350. }
  54351. declare module BABYLON {
  54352. /**
  54353. * Effect Render Options
  54354. */
  54355. export interface IEffectRendererOptions {
  54356. /**
  54357. * Defines the vertices positions.
  54358. */
  54359. positions?: number[];
  54360. /**
  54361. * Defines the indices.
  54362. */
  54363. indices?: number[];
  54364. }
  54365. /**
  54366. * Helper class to render one or more effects
  54367. */
  54368. export class EffectRenderer {
  54369. private engine;
  54370. private static _DefaultOptions;
  54371. private _vertexBuffers;
  54372. private _indexBuffer;
  54373. private _ringBufferIndex;
  54374. private _ringScreenBuffer;
  54375. private _fullscreenViewport;
  54376. private _getNextFrameBuffer;
  54377. /**
  54378. * Creates an effect renderer
  54379. * @param engine the engine to use for rendering
  54380. * @param options defines the options of the effect renderer
  54381. */
  54382. constructor(engine: Engine, options?: IEffectRendererOptions);
  54383. /**
  54384. * Sets the current viewport in normalized coordinates 0-1
  54385. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  54386. */
  54387. setViewport(viewport?: Viewport): void;
  54388. /**
  54389. * Sets the current effect wrapper to use during draw.
  54390. * The effect needs to be ready before calling this api.
  54391. * This also sets the default full screen position attribute.
  54392. * @param effectWrapper Defines the effect to draw with
  54393. */
  54394. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  54395. /**
  54396. * Draws a full screen quad.
  54397. */
  54398. draw(): void;
  54399. /**
  54400. * renders one or more effects to a specified texture
  54401. * @param effectWrappers list of effects to renderer
  54402. * @param outputTexture texture to draw to, if null it will render to the screen
  54403. */
  54404. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  54405. /**
  54406. * Disposes of the effect renderer
  54407. */
  54408. dispose(): void;
  54409. }
  54410. /**
  54411. * Options to create an EffectWrapper
  54412. */
  54413. interface EffectWrapperCreationOptions {
  54414. /**
  54415. * Engine to use to create the effect
  54416. */
  54417. engine: Engine;
  54418. /**
  54419. * Fragment shader for the effect
  54420. */
  54421. fragmentShader: string;
  54422. /**
  54423. * Vertex shader for the effect
  54424. */
  54425. vertexShader?: string;
  54426. /**
  54427. * Attributes to use in the shader
  54428. */
  54429. attributeNames?: Array<string>;
  54430. /**
  54431. * Uniforms to use in the shader
  54432. */
  54433. uniformNames?: Array<string>;
  54434. /**
  54435. * Texture sampler names to use in the shader
  54436. */
  54437. samplerNames?: Array<string>;
  54438. /**
  54439. * The friendly name of the effect displayed in Spector.
  54440. */
  54441. name?: string;
  54442. }
  54443. /**
  54444. * Wraps an effect to be used for rendering
  54445. */
  54446. export class EffectWrapper {
  54447. /**
  54448. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  54449. */
  54450. onApplyObservable: Observable<{}>;
  54451. /**
  54452. * The underlying effect
  54453. */
  54454. effect: Effect;
  54455. /**
  54456. * Creates an effect to be renderer
  54457. * @param creationOptions options to create the effect
  54458. */
  54459. constructor(creationOptions: EffectWrapperCreationOptions);
  54460. /**
  54461. * Disposes of the effect wrapper
  54462. */
  54463. dispose(): void;
  54464. }
  54465. }
  54466. declare module BABYLON {
  54467. /**
  54468. * Helper class to push actions to a pool of workers.
  54469. */
  54470. export class WorkerPool implements IDisposable {
  54471. private _workerInfos;
  54472. private _pendingActions;
  54473. /**
  54474. * Constructor
  54475. * @param workers Array of workers to use for actions
  54476. */
  54477. constructor(workers: Array<Worker>);
  54478. /**
  54479. * Terminates all workers and clears any pending actions.
  54480. */
  54481. dispose(): void;
  54482. /**
  54483. * Pushes an action to the worker pool. If all the workers are active, the action will be
  54484. * pended until a worker has completed its action.
  54485. * @param action The action to perform. Call onComplete when the action is complete.
  54486. */
  54487. push(action: (worker: Worker, onComplete: () => void) => void): void;
  54488. private _execute;
  54489. }
  54490. }
  54491. declare module BABYLON {
  54492. /**
  54493. * Configuration for Draco compression
  54494. */
  54495. export interface IDracoCompressionConfiguration {
  54496. /**
  54497. * Configuration for the decoder.
  54498. */
  54499. decoder: {
  54500. /**
  54501. * The url to the WebAssembly module.
  54502. */
  54503. wasmUrl?: string;
  54504. /**
  54505. * The url to the WebAssembly binary.
  54506. */
  54507. wasmBinaryUrl?: string;
  54508. /**
  54509. * The url to the fallback JavaScript module.
  54510. */
  54511. fallbackUrl?: string;
  54512. };
  54513. }
  54514. /**
  54515. * Draco compression (https://google.github.io/draco/)
  54516. *
  54517. * This class wraps the Draco module.
  54518. *
  54519. * **Encoder**
  54520. *
  54521. * The encoder is not currently implemented.
  54522. *
  54523. * **Decoder**
  54524. *
  54525. * 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.
  54526. *
  54527. * To update the configuration, use the following code:
  54528. * ```javascript
  54529. * DracoCompression.Configuration = {
  54530. * decoder: {
  54531. * wasmUrl: "<url to the WebAssembly library>",
  54532. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  54533. * fallbackUrl: "<url to the fallback JavaScript library>",
  54534. * }
  54535. * };
  54536. * ```
  54537. *
  54538. * 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.
  54539. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  54540. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  54541. *
  54542. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  54543. * ```javascript
  54544. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  54545. * ```
  54546. *
  54547. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  54548. */
  54549. export class DracoCompression implements IDisposable {
  54550. private _workerPoolPromise?;
  54551. private _decoderModulePromise?;
  54552. /**
  54553. * The configuration. Defaults to the following urls:
  54554. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  54555. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  54556. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  54557. */
  54558. static Configuration: IDracoCompressionConfiguration;
  54559. /**
  54560. * Returns true if the decoder configuration is available.
  54561. */
  54562. static readonly DecoderAvailable: boolean;
  54563. /**
  54564. * Default number of workers to create when creating the draco compression object.
  54565. */
  54566. static DefaultNumWorkers: number;
  54567. private static GetDefaultNumWorkers;
  54568. private static _Default;
  54569. /**
  54570. * Default instance for the draco compression object.
  54571. */
  54572. static readonly Default: DracoCompression;
  54573. /**
  54574. * Constructor
  54575. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  54576. */
  54577. constructor(numWorkers?: number);
  54578. /**
  54579. * Stop all async operations and release resources.
  54580. */
  54581. dispose(): void;
  54582. /**
  54583. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  54584. * @returns a promise that resolves when ready
  54585. */
  54586. whenReadyAsync(): Promise<void>;
  54587. /**
  54588. * Decode Draco compressed mesh data to vertex data.
  54589. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  54590. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  54591. * @returns A promise that resolves with the decoded vertex data
  54592. */
  54593. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  54594. [kind: string]: number;
  54595. }): Promise<VertexData>;
  54596. }
  54597. }
  54598. declare module BABYLON {
  54599. /**
  54600. * Class for building Constructive Solid Geometry
  54601. */
  54602. export class CSG {
  54603. private polygons;
  54604. /**
  54605. * The world matrix
  54606. */
  54607. matrix: Matrix;
  54608. /**
  54609. * Stores the position
  54610. */
  54611. position: Vector3;
  54612. /**
  54613. * Stores the rotation
  54614. */
  54615. rotation: Vector3;
  54616. /**
  54617. * Stores the rotation quaternion
  54618. */
  54619. rotationQuaternion: Nullable<Quaternion>;
  54620. /**
  54621. * Stores the scaling vector
  54622. */
  54623. scaling: Vector3;
  54624. /**
  54625. * Convert the Mesh to CSG
  54626. * @param mesh The Mesh to convert to CSG
  54627. * @returns A new CSG from the Mesh
  54628. */
  54629. static FromMesh(mesh: Mesh): CSG;
  54630. /**
  54631. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  54632. * @param polygons Polygons used to construct a CSG solid
  54633. */
  54634. private static FromPolygons;
  54635. /**
  54636. * Clones, or makes a deep copy, of the CSG
  54637. * @returns A new CSG
  54638. */
  54639. clone(): CSG;
  54640. /**
  54641. * Unions this CSG with another CSG
  54642. * @param csg The CSG to union against this CSG
  54643. * @returns The unioned CSG
  54644. */
  54645. union(csg: CSG): CSG;
  54646. /**
  54647. * Unions this CSG with another CSG in place
  54648. * @param csg The CSG to union against this CSG
  54649. */
  54650. unionInPlace(csg: CSG): void;
  54651. /**
  54652. * Subtracts this CSG with another CSG
  54653. * @param csg The CSG to subtract against this CSG
  54654. * @returns A new CSG
  54655. */
  54656. subtract(csg: CSG): CSG;
  54657. /**
  54658. * Subtracts this CSG with another CSG in place
  54659. * @param csg The CSG to subtact against this CSG
  54660. */
  54661. subtractInPlace(csg: CSG): void;
  54662. /**
  54663. * Intersect this CSG with another CSG
  54664. * @param csg The CSG to intersect against this CSG
  54665. * @returns A new CSG
  54666. */
  54667. intersect(csg: CSG): CSG;
  54668. /**
  54669. * Intersects this CSG with another CSG in place
  54670. * @param csg The CSG to intersect against this CSG
  54671. */
  54672. intersectInPlace(csg: CSG): void;
  54673. /**
  54674. * Return a new CSG solid with solid and empty space switched. This solid is
  54675. * not modified.
  54676. * @returns A new CSG solid with solid and empty space switched
  54677. */
  54678. inverse(): CSG;
  54679. /**
  54680. * Inverses the CSG in place
  54681. */
  54682. inverseInPlace(): void;
  54683. /**
  54684. * This is used to keep meshes transformations so they can be restored
  54685. * when we build back a Babylon Mesh
  54686. * NB : All CSG operations are performed in world coordinates
  54687. * @param csg The CSG to copy the transform attributes from
  54688. * @returns This CSG
  54689. */
  54690. copyTransformAttributes(csg: CSG): CSG;
  54691. /**
  54692. * Build Raw mesh from CSG
  54693. * Coordinates here are in world space
  54694. * @param name The name of the mesh geometry
  54695. * @param scene The Scene
  54696. * @param keepSubMeshes Specifies if the submeshes should be kept
  54697. * @returns A new Mesh
  54698. */
  54699. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  54700. /**
  54701. * Build Mesh from CSG taking material and transforms into account
  54702. * @param name The name of the Mesh
  54703. * @param material The material of the Mesh
  54704. * @param scene The Scene
  54705. * @param keepSubMeshes Specifies if submeshes should be kept
  54706. * @returns The new Mesh
  54707. */
  54708. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  54709. }
  54710. }
  54711. declare module BABYLON {
  54712. /**
  54713. * Class used to create a trail following a mesh
  54714. */
  54715. export class TrailMesh extends Mesh {
  54716. private _generator;
  54717. private _autoStart;
  54718. private _running;
  54719. private _diameter;
  54720. private _length;
  54721. private _sectionPolygonPointsCount;
  54722. private _sectionVectors;
  54723. private _sectionNormalVectors;
  54724. private _beforeRenderObserver;
  54725. /**
  54726. * @constructor
  54727. * @param name The value used by scene.getMeshByName() to do a lookup.
  54728. * @param generator The mesh to generate a trail.
  54729. * @param scene The scene to add this mesh to.
  54730. * @param diameter Diameter of trailing mesh. Default is 1.
  54731. * @param length Length of trailing mesh. Default is 60.
  54732. * @param autoStart Automatically start trailing mesh. Default true.
  54733. */
  54734. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  54735. /**
  54736. * "TrailMesh"
  54737. * @returns "TrailMesh"
  54738. */
  54739. getClassName(): string;
  54740. private _createMesh;
  54741. /**
  54742. * Start trailing mesh.
  54743. */
  54744. start(): void;
  54745. /**
  54746. * Stop trailing mesh.
  54747. */
  54748. stop(): void;
  54749. /**
  54750. * Update trailing mesh geometry.
  54751. */
  54752. update(): void;
  54753. /**
  54754. * Returns a new TrailMesh object.
  54755. * @param name is a string, the name given to the new mesh
  54756. * @param newGenerator use new generator object for cloned trail mesh
  54757. * @returns a new mesh
  54758. */
  54759. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  54760. /**
  54761. * Serializes this trail mesh
  54762. * @param serializationObject object to write serialization to
  54763. */
  54764. serialize(serializationObject: any): void;
  54765. /**
  54766. * Parses a serialized trail mesh
  54767. * @param parsedMesh the serialized mesh
  54768. * @param scene the scene to create the trail mesh in
  54769. * @returns the created trail mesh
  54770. */
  54771. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  54772. }
  54773. }
  54774. declare module BABYLON {
  54775. /**
  54776. * Class containing static functions to help procedurally build meshes
  54777. */
  54778. export class TiledBoxBuilder {
  54779. /**
  54780. * Creates a box mesh
  54781. * 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)
  54782. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54783. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54784. * * 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
  54785. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54786. * @param name defines the name of the mesh
  54787. * @param options defines the options used to create the mesh
  54788. * @param scene defines the hosting scene
  54789. * @returns the box mesh
  54790. */
  54791. static CreateTiledBox(name: string, options: {
  54792. pattern?: number;
  54793. width?: number;
  54794. height?: number;
  54795. depth?: number;
  54796. tileSize?: number;
  54797. tileWidth?: number;
  54798. tileHeight?: number;
  54799. alignHorizontal?: number;
  54800. alignVertical?: number;
  54801. faceUV?: Vector4[];
  54802. faceColors?: Color4[];
  54803. sideOrientation?: number;
  54804. updatable?: boolean;
  54805. }, scene?: Nullable<Scene>): Mesh;
  54806. }
  54807. }
  54808. declare module BABYLON {
  54809. /**
  54810. * Class containing static functions to help procedurally build meshes
  54811. */
  54812. export class TorusKnotBuilder {
  54813. /**
  54814. * Creates a torus knot mesh
  54815. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  54816. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  54817. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  54818. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  54819. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54820. * * 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
  54821. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54822. * @param name defines the name of the mesh
  54823. * @param options defines the options used to create the mesh
  54824. * @param scene defines the hosting scene
  54825. * @returns the torus knot mesh
  54826. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  54827. */
  54828. static CreateTorusKnot(name: string, options: {
  54829. radius?: number;
  54830. tube?: number;
  54831. radialSegments?: number;
  54832. tubularSegments?: number;
  54833. p?: number;
  54834. q?: number;
  54835. updatable?: boolean;
  54836. sideOrientation?: number;
  54837. frontUVs?: Vector4;
  54838. backUVs?: Vector4;
  54839. }, scene: any): Mesh;
  54840. }
  54841. }
  54842. declare module BABYLON {
  54843. /**
  54844. * Polygon
  54845. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  54846. */
  54847. export class Polygon {
  54848. /**
  54849. * Creates a rectangle
  54850. * @param xmin bottom X coord
  54851. * @param ymin bottom Y coord
  54852. * @param xmax top X coord
  54853. * @param ymax top Y coord
  54854. * @returns points that make the resulting rectation
  54855. */
  54856. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  54857. /**
  54858. * Creates a circle
  54859. * @param radius radius of circle
  54860. * @param cx scale in x
  54861. * @param cy scale in y
  54862. * @param numberOfSides number of sides that make up the circle
  54863. * @returns points that make the resulting circle
  54864. */
  54865. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  54866. /**
  54867. * Creates a polygon from input string
  54868. * @param input Input polygon data
  54869. * @returns the parsed points
  54870. */
  54871. static Parse(input: string): Vector2[];
  54872. /**
  54873. * Starts building a polygon from x and y coordinates
  54874. * @param x x coordinate
  54875. * @param y y coordinate
  54876. * @returns the started path2
  54877. */
  54878. static StartingAt(x: number, y: number): Path2;
  54879. }
  54880. /**
  54881. * Builds a polygon
  54882. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  54883. */
  54884. export class PolygonMeshBuilder {
  54885. private _points;
  54886. private _outlinepoints;
  54887. private _holes;
  54888. private _name;
  54889. private _scene;
  54890. private _epoints;
  54891. private _eholes;
  54892. private _addToepoint;
  54893. /**
  54894. * Babylon reference to the earcut plugin.
  54895. */
  54896. bjsEarcut: any;
  54897. /**
  54898. * Creates a PolygonMeshBuilder
  54899. * @param name name of the builder
  54900. * @param contours Path of the polygon
  54901. * @param scene scene to add to when creating the mesh
  54902. * @param earcutInjection can be used to inject your own earcut reference
  54903. */
  54904. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  54905. /**
  54906. * Adds a whole within the polygon
  54907. * @param hole Array of points defining the hole
  54908. * @returns this
  54909. */
  54910. addHole(hole: Vector2[]): PolygonMeshBuilder;
  54911. /**
  54912. * Creates the polygon
  54913. * @param updatable If the mesh should be updatable
  54914. * @param depth The depth of the mesh created
  54915. * @returns the created mesh
  54916. */
  54917. build(updatable?: boolean, depth?: number): Mesh;
  54918. /**
  54919. * Creates the polygon
  54920. * @param depth The depth of the mesh created
  54921. * @returns the created VertexData
  54922. */
  54923. buildVertexData(depth?: number): VertexData;
  54924. /**
  54925. * Adds a side to the polygon
  54926. * @param positions points that make the polygon
  54927. * @param normals normals of the polygon
  54928. * @param uvs uvs of the polygon
  54929. * @param indices indices of the polygon
  54930. * @param bounds bounds of the polygon
  54931. * @param points points of the polygon
  54932. * @param depth depth of the polygon
  54933. * @param flip flip of the polygon
  54934. */
  54935. private addSide;
  54936. }
  54937. }
  54938. declare module BABYLON {
  54939. /**
  54940. * Class containing static functions to help procedurally build meshes
  54941. */
  54942. export class PolygonBuilder {
  54943. /**
  54944. * Creates a polygon mesh
  54945. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  54946. * * 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
  54947. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54948. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54949. * * 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)
  54950. * * Remember you can only change the shape positions, not their number when updating a polygon
  54951. * @param name defines the name of the mesh
  54952. * @param options defines the options used to create the mesh
  54953. * @param scene defines the hosting scene
  54954. * @param earcutInjection can be used to inject your own earcut reference
  54955. * @returns the polygon mesh
  54956. */
  54957. static CreatePolygon(name: string, options: {
  54958. shape: Vector3[];
  54959. holes?: Vector3[][];
  54960. depth?: number;
  54961. faceUV?: Vector4[];
  54962. faceColors?: Color4[];
  54963. updatable?: boolean;
  54964. sideOrientation?: number;
  54965. frontUVs?: Vector4;
  54966. backUVs?: Vector4;
  54967. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54968. /**
  54969. * Creates an extruded polygon mesh, with depth in the Y direction.
  54970. * * 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)
  54971. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54972. * @param name defines the name of the mesh
  54973. * @param options defines the options used to create the mesh
  54974. * @param scene defines the hosting scene
  54975. * @param earcutInjection can be used to inject your own earcut reference
  54976. * @returns the polygon mesh
  54977. */
  54978. static ExtrudePolygon(name: string, options: {
  54979. shape: Vector3[];
  54980. holes?: Vector3[][];
  54981. depth?: number;
  54982. faceUV?: Vector4[];
  54983. faceColors?: Color4[];
  54984. updatable?: boolean;
  54985. sideOrientation?: number;
  54986. frontUVs?: Vector4;
  54987. backUVs?: Vector4;
  54988. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54989. }
  54990. }
  54991. declare module BABYLON {
  54992. /**
  54993. * Class containing static functions to help procedurally build meshes
  54994. */
  54995. export class LatheBuilder {
  54996. /**
  54997. * Creates lathe mesh.
  54998. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  54999. * * 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
  55000. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55001. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55002. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55003. * * 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
  55004. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55005. * * 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
  55006. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55007. * * 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
  55008. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55009. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55010. * @param name defines the name of the mesh
  55011. * @param options defines the options used to create the mesh
  55012. * @param scene defines the hosting scene
  55013. * @returns the lathe mesh
  55014. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55015. */
  55016. static CreateLathe(name: string, options: {
  55017. shape: Vector3[];
  55018. radius?: number;
  55019. tessellation?: number;
  55020. clip?: number;
  55021. arc?: number;
  55022. closed?: boolean;
  55023. updatable?: boolean;
  55024. sideOrientation?: number;
  55025. frontUVs?: Vector4;
  55026. backUVs?: Vector4;
  55027. cap?: number;
  55028. invertUV?: boolean;
  55029. }, scene?: Nullable<Scene>): Mesh;
  55030. }
  55031. }
  55032. declare module BABYLON {
  55033. /**
  55034. * Class containing static functions to help procedurally build meshes
  55035. */
  55036. export class TiledPlaneBuilder {
  55037. /**
  55038. * Creates a tiled plane mesh
  55039. * * The parameter `pattern` will, depending on value, do nothing or
  55040. * * * flip (reflect about central vertical) alternate tiles across and up
  55041. * * * flip every tile on alternate rows
  55042. * * * rotate (180 degs) alternate tiles across and up
  55043. * * * rotate every tile on alternate rows
  55044. * * * flip and rotate alternate tiles across and up
  55045. * * * flip and rotate every tile on alternate rows
  55046. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  55047. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  55048. * * 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
  55049. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55050. * * 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)
  55051. * * 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)
  55052. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55053. * @param name defines the name of the mesh
  55054. * @param options defines the options used to create the mesh
  55055. * @param scene defines the hosting scene
  55056. * @returns the box mesh
  55057. */
  55058. static CreateTiledPlane(name: string, options: {
  55059. pattern?: number;
  55060. tileSize?: number;
  55061. tileWidth?: number;
  55062. tileHeight?: number;
  55063. size?: number;
  55064. width?: number;
  55065. height?: number;
  55066. alignHorizontal?: number;
  55067. alignVertical?: number;
  55068. sideOrientation?: number;
  55069. frontUVs?: Vector4;
  55070. backUVs?: Vector4;
  55071. updatable?: boolean;
  55072. }, scene?: Nullable<Scene>): Mesh;
  55073. }
  55074. }
  55075. declare module BABYLON {
  55076. /**
  55077. * Class containing static functions to help procedurally build meshes
  55078. */
  55079. export class TubeBuilder {
  55080. /**
  55081. * Creates a tube mesh.
  55082. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55083. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55084. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55085. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55086. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55087. * * 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)
  55088. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55089. * * 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
  55090. * * 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
  55091. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55092. * * 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
  55093. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55094. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55095. * @param name defines the name of the mesh
  55096. * @param options defines the options used to create the mesh
  55097. * @param scene defines the hosting scene
  55098. * @returns the tube mesh
  55099. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55100. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55101. */
  55102. static CreateTube(name: string, options: {
  55103. path: Vector3[];
  55104. radius?: number;
  55105. tessellation?: number;
  55106. radiusFunction?: {
  55107. (i: number, distance: number): number;
  55108. };
  55109. cap?: number;
  55110. arc?: number;
  55111. updatable?: boolean;
  55112. sideOrientation?: number;
  55113. frontUVs?: Vector4;
  55114. backUVs?: Vector4;
  55115. instance?: Mesh;
  55116. invertUV?: boolean;
  55117. }, scene?: Nullable<Scene>): Mesh;
  55118. }
  55119. }
  55120. declare module BABYLON {
  55121. /**
  55122. * Class containing static functions to help procedurally build meshes
  55123. */
  55124. export class IcoSphereBuilder {
  55125. /**
  55126. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55127. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55128. * * 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`)
  55129. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55130. * * 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
  55131. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55132. * * 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
  55133. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55134. * @param name defines the name of the mesh
  55135. * @param options defines the options used to create the mesh
  55136. * @param scene defines the hosting scene
  55137. * @returns the icosahedron mesh
  55138. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55139. */
  55140. static CreateIcoSphere(name: string, options: {
  55141. radius?: number;
  55142. radiusX?: number;
  55143. radiusY?: number;
  55144. radiusZ?: number;
  55145. flat?: boolean;
  55146. subdivisions?: number;
  55147. sideOrientation?: number;
  55148. frontUVs?: Vector4;
  55149. backUVs?: Vector4;
  55150. updatable?: boolean;
  55151. }, scene?: Nullable<Scene>): Mesh;
  55152. }
  55153. }
  55154. declare module BABYLON {
  55155. /**
  55156. * Class containing static functions to help procedurally build meshes
  55157. */
  55158. export class DecalBuilder {
  55159. /**
  55160. * Creates a decal mesh.
  55161. * 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
  55162. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55163. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55164. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55165. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55166. * @param name defines the name of the mesh
  55167. * @param sourceMesh defines the mesh where the decal must be applied
  55168. * @param options defines the options used to create the mesh
  55169. * @param scene defines the hosting scene
  55170. * @returns the decal mesh
  55171. * @see https://doc.babylonjs.com/how_to/decals
  55172. */
  55173. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55174. position?: Vector3;
  55175. normal?: Vector3;
  55176. size?: Vector3;
  55177. angle?: number;
  55178. }): Mesh;
  55179. }
  55180. }
  55181. declare module BABYLON {
  55182. /**
  55183. * Class containing static functions to help procedurally build meshes
  55184. */
  55185. export class MeshBuilder {
  55186. /**
  55187. * Creates a box mesh
  55188. * * The parameter `size` sets the size (float) of each box side (default 1)
  55189. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  55190. * * 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)
  55191. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55192. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55193. * * 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
  55194. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55195. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55196. * @param name defines the name of the mesh
  55197. * @param options defines the options used to create the mesh
  55198. * @param scene defines the hosting scene
  55199. * @returns the box mesh
  55200. */
  55201. static CreateBox(name: string, options: {
  55202. size?: number;
  55203. width?: number;
  55204. height?: number;
  55205. depth?: number;
  55206. faceUV?: Vector4[];
  55207. faceColors?: Color4[];
  55208. sideOrientation?: number;
  55209. frontUVs?: Vector4;
  55210. backUVs?: Vector4;
  55211. updatable?: boolean;
  55212. }, scene?: Nullable<Scene>): Mesh;
  55213. /**
  55214. * Creates a tiled box mesh
  55215. * * faceTiles sets the pattern, tile size and number of tiles for a face
  55216. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55217. * @param name defines the name of the mesh
  55218. * @param options defines the options used to create the mesh
  55219. * @param scene defines the hosting scene
  55220. * @returns the tiled box mesh
  55221. */
  55222. static CreateTiledBox(name: string, options: {
  55223. pattern?: number;
  55224. size?: number;
  55225. width?: number;
  55226. height?: number;
  55227. depth: number;
  55228. tileSize?: number;
  55229. tileWidth?: number;
  55230. tileHeight?: number;
  55231. faceUV?: Vector4[];
  55232. faceColors?: Color4[];
  55233. alignHorizontal?: number;
  55234. alignVertical?: number;
  55235. sideOrientation?: number;
  55236. updatable?: boolean;
  55237. }, scene?: Nullable<Scene>): Mesh;
  55238. /**
  55239. * Creates a sphere mesh
  55240. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  55241. * * 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`)
  55242. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  55243. * * 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
  55244. * * 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)
  55245. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55246. * * 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
  55247. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55248. * @param name defines the name of the mesh
  55249. * @param options defines the options used to create the mesh
  55250. * @param scene defines the hosting scene
  55251. * @returns the sphere mesh
  55252. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  55253. */
  55254. static CreateSphere(name: string, options: {
  55255. segments?: number;
  55256. diameter?: number;
  55257. diameterX?: number;
  55258. diameterY?: number;
  55259. diameterZ?: number;
  55260. arc?: number;
  55261. slice?: number;
  55262. sideOrientation?: number;
  55263. frontUVs?: Vector4;
  55264. backUVs?: Vector4;
  55265. updatable?: boolean;
  55266. }, scene?: Nullable<Scene>): Mesh;
  55267. /**
  55268. * Creates a plane polygonal mesh. By default, this is a disc
  55269. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  55270. * * 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
  55271. * * 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
  55272. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55273. * * 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
  55274. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55275. * @param name defines the name of the mesh
  55276. * @param options defines the options used to create the mesh
  55277. * @param scene defines the hosting scene
  55278. * @returns the plane polygonal mesh
  55279. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  55280. */
  55281. static CreateDisc(name: string, options: {
  55282. radius?: number;
  55283. tessellation?: number;
  55284. arc?: number;
  55285. updatable?: boolean;
  55286. sideOrientation?: number;
  55287. frontUVs?: Vector4;
  55288. backUVs?: Vector4;
  55289. }, scene?: Nullable<Scene>): Mesh;
  55290. /**
  55291. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55292. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55293. * * 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`)
  55294. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55295. * * 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
  55296. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55297. * * 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
  55298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55299. * @param name defines the name of the mesh
  55300. * @param options defines the options used to create the mesh
  55301. * @param scene defines the hosting scene
  55302. * @returns the icosahedron mesh
  55303. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55304. */
  55305. static CreateIcoSphere(name: string, options: {
  55306. radius?: number;
  55307. radiusX?: number;
  55308. radiusY?: number;
  55309. radiusZ?: number;
  55310. flat?: boolean;
  55311. subdivisions?: number;
  55312. sideOrientation?: number;
  55313. frontUVs?: Vector4;
  55314. backUVs?: Vector4;
  55315. updatable?: boolean;
  55316. }, scene?: Nullable<Scene>): Mesh;
  55317. /**
  55318. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55319. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55320. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55321. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55322. * * 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
  55323. * * 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
  55324. * * 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
  55325. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55326. * * 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
  55327. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55328. * * 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
  55329. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55330. * * 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
  55331. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55332. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55333. * @param name defines the name of the mesh
  55334. * @param options defines the options used to create the mesh
  55335. * @param scene defines the hosting scene
  55336. * @returns the ribbon mesh
  55337. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55338. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55339. */
  55340. static CreateRibbon(name: string, options: {
  55341. pathArray: Vector3[][];
  55342. closeArray?: boolean;
  55343. closePath?: boolean;
  55344. offset?: number;
  55345. updatable?: boolean;
  55346. sideOrientation?: number;
  55347. frontUVs?: Vector4;
  55348. backUVs?: Vector4;
  55349. instance?: Mesh;
  55350. invertUV?: boolean;
  55351. uvs?: Vector2[];
  55352. colors?: Color4[];
  55353. }, scene?: Nullable<Scene>): Mesh;
  55354. /**
  55355. * Creates a cylinder or a cone mesh
  55356. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  55357. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  55358. * * 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.
  55359. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  55360. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  55361. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  55362. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  55363. * * 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).
  55364. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  55365. * * 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).
  55366. * * 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
  55367. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  55368. * * 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
  55369. * * 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.
  55370. * * If `enclose` is false, a ring surface is one element.
  55371. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  55372. * * 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
  55373. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55374. * * 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
  55375. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55376. * @param name defines the name of the mesh
  55377. * @param options defines the options used to create the mesh
  55378. * @param scene defines the hosting scene
  55379. * @returns the cylinder mesh
  55380. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  55381. */
  55382. static CreateCylinder(name: string, options: {
  55383. height?: number;
  55384. diameterTop?: number;
  55385. diameterBottom?: number;
  55386. diameter?: number;
  55387. tessellation?: number;
  55388. subdivisions?: number;
  55389. arc?: number;
  55390. faceColors?: Color4[];
  55391. faceUV?: Vector4[];
  55392. updatable?: boolean;
  55393. hasRings?: boolean;
  55394. enclose?: boolean;
  55395. cap?: number;
  55396. sideOrientation?: number;
  55397. frontUVs?: Vector4;
  55398. backUVs?: Vector4;
  55399. }, scene?: Nullable<Scene>): Mesh;
  55400. /**
  55401. * Creates a torus mesh
  55402. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  55403. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  55404. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  55405. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55406. * * 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
  55407. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55408. * @param name defines the name of the mesh
  55409. * @param options defines the options used to create the mesh
  55410. * @param scene defines the hosting scene
  55411. * @returns the torus mesh
  55412. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  55413. */
  55414. static CreateTorus(name: string, options: {
  55415. diameter?: number;
  55416. thickness?: number;
  55417. tessellation?: number;
  55418. updatable?: boolean;
  55419. sideOrientation?: number;
  55420. frontUVs?: Vector4;
  55421. backUVs?: Vector4;
  55422. }, scene?: Nullable<Scene>): Mesh;
  55423. /**
  55424. * Creates a torus knot mesh
  55425. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55426. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55427. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55428. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55429. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55430. * * 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
  55431. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55432. * @param name defines the name of the mesh
  55433. * @param options defines the options used to create the mesh
  55434. * @param scene defines the hosting scene
  55435. * @returns the torus knot mesh
  55436. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55437. */
  55438. static CreateTorusKnot(name: string, options: {
  55439. radius?: number;
  55440. tube?: number;
  55441. radialSegments?: number;
  55442. tubularSegments?: number;
  55443. p?: number;
  55444. q?: number;
  55445. updatable?: boolean;
  55446. sideOrientation?: number;
  55447. frontUVs?: Vector4;
  55448. backUVs?: Vector4;
  55449. }, scene?: Nullable<Scene>): Mesh;
  55450. /**
  55451. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  55452. * * 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
  55453. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  55454. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  55455. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  55456. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  55457. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55458. * * 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
  55459. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  55460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55461. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  55462. * @param name defines the name of the new line system
  55463. * @param options defines the options used to create the line system
  55464. * @param scene defines the hosting scene
  55465. * @returns a new line system mesh
  55466. */
  55467. static CreateLineSystem(name: string, options: {
  55468. lines: Vector3[][];
  55469. updatable?: boolean;
  55470. instance?: Nullable<LinesMesh>;
  55471. colors?: Nullable<Color4[][]>;
  55472. useVertexAlpha?: boolean;
  55473. }, scene: Nullable<Scene>): LinesMesh;
  55474. /**
  55475. * Creates a line mesh
  55476. * 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
  55477. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55478. * * The parameter `points` is an array successive Vector3
  55479. * * 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
  55480. * * The optional parameter `colors` is an array of successive Color4, one per line point
  55481. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  55482. * * When updating an instance, remember that only point positions can change, not the number of points
  55483. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55484. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  55485. * @param name defines the name of the new line system
  55486. * @param options defines the options used to create the line system
  55487. * @param scene defines the hosting scene
  55488. * @returns a new line mesh
  55489. */
  55490. static CreateLines(name: string, options: {
  55491. points: Vector3[];
  55492. updatable?: boolean;
  55493. instance?: Nullable<LinesMesh>;
  55494. colors?: Color4[];
  55495. useVertexAlpha?: boolean;
  55496. }, scene?: Nullable<Scene>): LinesMesh;
  55497. /**
  55498. * Creates a dashed line mesh
  55499. * * 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
  55500. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55501. * * The parameter `points` is an array successive Vector3
  55502. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  55503. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  55504. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  55505. * * 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
  55506. * * When updating an instance, remember that only point positions can change, not the number of points
  55507. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55508. * @param name defines the name of the mesh
  55509. * @param options defines the options used to create the mesh
  55510. * @param scene defines the hosting scene
  55511. * @returns the dashed line mesh
  55512. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  55513. */
  55514. static CreateDashedLines(name: string, options: {
  55515. points: Vector3[];
  55516. dashSize?: number;
  55517. gapSize?: number;
  55518. dashNb?: number;
  55519. updatable?: boolean;
  55520. instance?: LinesMesh;
  55521. }, scene?: Nullable<Scene>): LinesMesh;
  55522. /**
  55523. * 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.
  55524. * * 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.
  55525. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55526. * * 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.
  55527. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55528. * * 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
  55529. * * 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
  55530. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55531. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55532. * * 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
  55533. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55535. * @param name defines the name of the mesh
  55536. * @param options defines the options used to create the mesh
  55537. * @param scene defines the hosting scene
  55538. * @returns the extruded shape mesh
  55539. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55540. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55541. */
  55542. static ExtrudeShape(name: string, options: {
  55543. shape: Vector3[];
  55544. path: Vector3[];
  55545. scale?: number;
  55546. rotation?: number;
  55547. cap?: number;
  55548. updatable?: boolean;
  55549. sideOrientation?: number;
  55550. frontUVs?: Vector4;
  55551. backUVs?: Vector4;
  55552. instance?: Mesh;
  55553. invertUV?: boolean;
  55554. }, scene?: Nullable<Scene>): Mesh;
  55555. /**
  55556. * Creates an custom extruded shape mesh.
  55557. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55558. * * 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.
  55559. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55560. * * 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
  55561. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55562. * * 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
  55563. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55564. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55565. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55566. * * 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
  55567. * * 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
  55568. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55569. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55570. * * 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
  55571. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55572. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55573. * @param name defines the name of the mesh
  55574. * @param options defines the options used to create the mesh
  55575. * @param scene defines the hosting scene
  55576. * @returns the custom extruded shape mesh
  55577. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55578. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55579. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55580. */
  55581. static ExtrudeShapeCustom(name: string, options: {
  55582. shape: Vector3[];
  55583. path: Vector3[];
  55584. scaleFunction?: any;
  55585. rotationFunction?: any;
  55586. ribbonCloseArray?: boolean;
  55587. ribbonClosePath?: boolean;
  55588. cap?: number;
  55589. updatable?: boolean;
  55590. sideOrientation?: number;
  55591. frontUVs?: Vector4;
  55592. backUVs?: Vector4;
  55593. instance?: Mesh;
  55594. invertUV?: boolean;
  55595. }, scene?: Nullable<Scene>): Mesh;
  55596. /**
  55597. * Creates lathe mesh.
  55598. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55599. * * 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
  55600. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55601. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55602. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55603. * * 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
  55604. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55605. * * 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
  55606. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55607. * * 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
  55608. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55609. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55610. * @param name defines the name of the mesh
  55611. * @param options defines the options used to create the mesh
  55612. * @param scene defines the hosting scene
  55613. * @returns the lathe mesh
  55614. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55615. */
  55616. static CreateLathe(name: string, options: {
  55617. shape: Vector3[];
  55618. radius?: number;
  55619. tessellation?: number;
  55620. clip?: number;
  55621. arc?: number;
  55622. closed?: boolean;
  55623. updatable?: boolean;
  55624. sideOrientation?: number;
  55625. frontUVs?: Vector4;
  55626. backUVs?: Vector4;
  55627. cap?: number;
  55628. invertUV?: boolean;
  55629. }, scene?: Nullable<Scene>): Mesh;
  55630. /**
  55631. * Creates a tiled plane mesh
  55632. * * You can set a limited pattern arrangement with the tiles
  55633. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55634. * * 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
  55635. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55636. * @param name defines the name of the mesh
  55637. * @param options defines the options used to create the mesh
  55638. * @param scene defines the hosting scene
  55639. * @returns the plane mesh
  55640. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55641. */
  55642. static CreateTiledPlane(name: string, options: {
  55643. pattern?: number;
  55644. tileSize?: number;
  55645. tileWidth?: number;
  55646. tileHeight?: number;
  55647. size?: number;
  55648. width?: number;
  55649. height?: number;
  55650. alignHorizontal?: number;
  55651. alignVertical?: number;
  55652. sideOrientation?: number;
  55653. frontUVs?: Vector4;
  55654. backUVs?: Vector4;
  55655. updatable?: boolean;
  55656. }, scene?: Nullable<Scene>): Mesh;
  55657. /**
  55658. * Creates a plane mesh
  55659. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  55660. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  55661. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  55662. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55663. * * 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
  55664. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55665. * @param name defines the name of the mesh
  55666. * @param options defines the options used to create the mesh
  55667. * @param scene defines the hosting scene
  55668. * @returns the plane mesh
  55669. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55670. */
  55671. static CreatePlane(name: string, options: {
  55672. size?: number;
  55673. width?: number;
  55674. height?: number;
  55675. sideOrientation?: number;
  55676. frontUVs?: Vector4;
  55677. backUVs?: Vector4;
  55678. updatable?: boolean;
  55679. sourcePlane?: Plane;
  55680. }, scene?: Nullable<Scene>): Mesh;
  55681. /**
  55682. * Creates a ground mesh
  55683. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  55684. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  55685. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55686. * @param name defines the name of the mesh
  55687. * @param options defines the options used to create the mesh
  55688. * @param scene defines the hosting scene
  55689. * @returns the ground mesh
  55690. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  55691. */
  55692. static CreateGround(name: string, options: {
  55693. width?: number;
  55694. height?: number;
  55695. subdivisions?: number;
  55696. subdivisionsX?: number;
  55697. subdivisionsY?: number;
  55698. updatable?: boolean;
  55699. }, scene?: Nullable<Scene>): Mesh;
  55700. /**
  55701. * Creates a tiled ground mesh
  55702. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  55703. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  55704. * * 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
  55705. * * 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
  55706. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55707. * @param name defines the name of the mesh
  55708. * @param options defines the options used to create the mesh
  55709. * @param scene defines the hosting scene
  55710. * @returns the tiled ground mesh
  55711. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  55712. */
  55713. static CreateTiledGround(name: string, options: {
  55714. xmin: number;
  55715. zmin: number;
  55716. xmax: number;
  55717. zmax: number;
  55718. subdivisions?: {
  55719. w: number;
  55720. h: number;
  55721. };
  55722. precision?: {
  55723. w: number;
  55724. h: number;
  55725. };
  55726. updatable?: boolean;
  55727. }, scene?: Nullable<Scene>): Mesh;
  55728. /**
  55729. * Creates a ground mesh from a height map
  55730. * * The parameter `url` sets the URL of the height map image resource.
  55731. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  55732. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  55733. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  55734. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  55735. * * 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.
  55736. * * 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).
  55737. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  55738. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55739. * @param name defines the name of the mesh
  55740. * @param url defines the url to the height map
  55741. * @param options defines the options used to create the mesh
  55742. * @param scene defines the hosting scene
  55743. * @returns the ground mesh
  55744. * @see https://doc.babylonjs.com/babylon101/height_map
  55745. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  55746. */
  55747. static CreateGroundFromHeightMap(name: string, url: string, options: {
  55748. width?: number;
  55749. height?: number;
  55750. subdivisions?: number;
  55751. minHeight?: number;
  55752. maxHeight?: number;
  55753. colorFilter?: Color3;
  55754. alphaFilter?: number;
  55755. updatable?: boolean;
  55756. onReady?: (mesh: GroundMesh) => void;
  55757. }, scene?: Nullable<Scene>): GroundMesh;
  55758. /**
  55759. * Creates a polygon mesh
  55760. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55761. * * 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
  55762. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55763. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55764. * * 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)
  55765. * * Remember you can only change the shape positions, not their number when updating a polygon
  55766. * @param name defines the name of the mesh
  55767. * @param options defines the options used to create the mesh
  55768. * @param scene defines the hosting scene
  55769. * @param earcutInjection can be used to inject your own earcut reference
  55770. * @returns the polygon mesh
  55771. */
  55772. static CreatePolygon(name: string, options: {
  55773. shape: Vector3[];
  55774. holes?: Vector3[][];
  55775. depth?: number;
  55776. faceUV?: Vector4[];
  55777. faceColors?: Color4[];
  55778. updatable?: boolean;
  55779. sideOrientation?: number;
  55780. frontUVs?: Vector4;
  55781. backUVs?: Vector4;
  55782. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55783. /**
  55784. * Creates an extruded polygon mesh, with depth in the Y direction.
  55785. * * 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)
  55786. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55787. * @param name defines the name of the mesh
  55788. * @param options defines the options used to create the mesh
  55789. * @param scene defines the hosting scene
  55790. * @param earcutInjection can be used to inject your own earcut reference
  55791. * @returns the polygon mesh
  55792. */
  55793. static ExtrudePolygon(name: string, options: {
  55794. shape: Vector3[];
  55795. holes?: Vector3[][];
  55796. depth?: number;
  55797. faceUV?: Vector4[];
  55798. faceColors?: Color4[];
  55799. updatable?: boolean;
  55800. sideOrientation?: number;
  55801. frontUVs?: Vector4;
  55802. backUVs?: Vector4;
  55803. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55804. /**
  55805. * Creates a tube mesh.
  55806. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55807. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55808. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55809. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55810. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55811. * * 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)
  55812. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55813. * * 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
  55814. * * 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
  55815. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55816. * * 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
  55817. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55818. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55819. * @param name defines the name of the mesh
  55820. * @param options defines the options used to create the mesh
  55821. * @param scene defines the hosting scene
  55822. * @returns the tube mesh
  55823. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55824. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55825. */
  55826. static CreateTube(name: string, options: {
  55827. path: Vector3[];
  55828. radius?: number;
  55829. tessellation?: number;
  55830. radiusFunction?: {
  55831. (i: number, distance: number): number;
  55832. };
  55833. cap?: number;
  55834. arc?: number;
  55835. updatable?: boolean;
  55836. sideOrientation?: number;
  55837. frontUVs?: Vector4;
  55838. backUVs?: Vector4;
  55839. instance?: Mesh;
  55840. invertUV?: boolean;
  55841. }, scene?: Nullable<Scene>): Mesh;
  55842. /**
  55843. * Creates a polyhedron mesh
  55844. * * 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
  55845. * * The parameter `size` (positive float, default 1) sets the polygon size
  55846. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55847. * * 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`
  55848. * * 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
  55849. * * 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)`)
  55850. * * 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
  55851. * * 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
  55852. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55853. * * 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
  55854. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55855. * @param name defines the name of the mesh
  55856. * @param options defines the options used to create the mesh
  55857. * @param scene defines the hosting scene
  55858. * @returns the polyhedron mesh
  55859. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55860. */
  55861. static CreatePolyhedron(name: string, options: {
  55862. type?: number;
  55863. size?: number;
  55864. sizeX?: number;
  55865. sizeY?: number;
  55866. sizeZ?: number;
  55867. custom?: any;
  55868. faceUV?: Vector4[];
  55869. faceColors?: Color4[];
  55870. flat?: boolean;
  55871. updatable?: boolean;
  55872. sideOrientation?: number;
  55873. frontUVs?: Vector4;
  55874. backUVs?: Vector4;
  55875. }, scene?: Nullable<Scene>): Mesh;
  55876. /**
  55877. * Creates a decal mesh.
  55878. * 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
  55879. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55880. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55881. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55882. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55883. * @param name defines the name of the mesh
  55884. * @param sourceMesh defines the mesh where the decal must be applied
  55885. * @param options defines the options used to create the mesh
  55886. * @param scene defines the hosting scene
  55887. * @returns the decal mesh
  55888. * @see https://doc.babylonjs.com/how_to/decals
  55889. */
  55890. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55891. position?: Vector3;
  55892. normal?: Vector3;
  55893. size?: Vector3;
  55894. angle?: number;
  55895. }): Mesh;
  55896. }
  55897. }
  55898. declare module BABYLON {
  55899. /**
  55900. * A simplifier interface for future simplification implementations
  55901. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55902. */
  55903. export interface ISimplifier {
  55904. /**
  55905. * Simplification of a given mesh according to the given settings.
  55906. * Since this requires computation, it is assumed that the function runs async.
  55907. * @param settings The settings of the simplification, including quality and distance
  55908. * @param successCallback A callback that will be called after the mesh was simplified.
  55909. * @param errorCallback in case of an error, this callback will be called. optional.
  55910. */
  55911. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  55912. }
  55913. /**
  55914. * Expected simplification settings.
  55915. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  55916. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55917. */
  55918. export interface ISimplificationSettings {
  55919. /**
  55920. * Gets or sets the expected quality
  55921. */
  55922. quality: number;
  55923. /**
  55924. * Gets or sets the distance when this optimized version should be used
  55925. */
  55926. distance: number;
  55927. /**
  55928. * Gets an already optimized mesh
  55929. */
  55930. optimizeMesh?: boolean;
  55931. }
  55932. /**
  55933. * Class used to specify simplification options
  55934. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55935. */
  55936. export class SimplificationSettings implements ISimplificationSettings {
  55937. /** expected quality */
  55938. quality: number;
  55939. /** distance when this optimized version should be used */
  55940. distance: number;
  55941. /** already optimized mesh */
  55942. optimizeMesh?: boolean | undefined;
  55943. /**
  55944. * Creates a SimplificationSettings
  55945. * @param quality expected quality
  55946. * @param distance distance when this optimized version should be used
  55947. * @param optimizeMesh already optimized mesh
  55948. */
  55949. constructor(
  55950. /** expected quality */
  55951. quality: number,
  55952. /** distance when this optimized version should be used */
  55953. distance: number,
  55954. /** already optimized mesh */
  55955. optimizeMesh?: boolean | undefined);
  55956. }
  55957. /**
  55958. * Interface used to define a simplification task
  55959. */
  55960. export interface ISimplificationTask {
  55961. /**
  55962. * Array of settings
  55963. */
  55964. settings: Array<ISimplificationSettings>;
  55965. /**
  55966. * Simplification type
  55967. */
  55968. simplificationType: SimplificationType;
  55969. /**
  55970. * Mesh to simplify
  55971. */
  55972. mesh: Mesh;
  55973. /**
  55974. * Callback called on success
  55975. */
  55976. successCallback?: () => void;
  55977. /**
  55978. * Defines if parallel processing can be used
  55979. */
  55980. parallelProcessing: boolean;
  55981. }
  55982. /**
  55983. * Queue used to order the simplification tasks
  55984. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55985. */
  55986. export class SimplificationQueue {
  55987. private _simplificationArray;
  55988. /**
  55989. * Gets a boolean indicating that the process is still running
  55990. */
  55991. running: boolean;
  55992. /**
  55993. * Creates a new queue
  55994. */
  55995. constructor();
  55996. /**
  55997. * Adds a new simplification task
  55998. * @param task defines a task to add
  55999. */
  56000. addTask(task: ISimplificationTask): void;
  56001. /**
  56002. * Execute next task
  56003. */
  56004. executeNext(): void;
  56005. /**
  56006. * Execute a simplification task
  56007. * @param task defines the task to run
  56008. */
  56009. runSimplification(task: ISimplificationTask): void;
  56010. private getSimplifier;
  56011. }
  56012. /**
  56013. * The implemented types of simplification
  56014. * At the moment only Quadratic Error Decimation is implemented
  56015. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56016. */
  56017. export enum SimplificationType {
  56018. /** Quadratic error decimation */
  56019. QUADRATIC = 0
  56020. }
  56021. }
  56022. declare module BABYLON {
  56023. interface Scene {
  56024. /** @hidden (Backing field) */
  56025. _simplificationQueue: SimplificationQueue;
  56026. /**
  56027. * Gets or sets the simplification queue attached to the scene
  56028. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56029. */
  56030. simplificationQueue: SimplificationQueue;
  56031. }
  56032. interface Mesh {
  56033. /**
  56034. * Simplify the mesh according to the given array of settings.
  56035. * Function will return immediately and will simplify async
  56036. * @param settings a collection of simplification settings
  56037. * @param parallelProcessing should all levels calculate parallel or one after the other
  56038. * @param simplificationType the type of simplification to run
  56039. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  56040. * @returns the current mesh
  56041. */
  56042. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  56043. }
  56044. /**
  56045. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  56046. * created in a scene
  56047. */
  56048. export class SimplicationQueueSceneComponent implements ISceneComponent {
  56049. /**
  56050. * The component name helpfull to identify the component in the list of scene components.
  56051. */
  56052. readonly name: string;
  56053. /**
  56054. * The scene the component belongs to.
  56055. */
  56056. scene: Scene;
  56057. /**
  56058. * Creates a new instance of the component for the given scene
  56059. * @param scene Defines the scene to register the component in
  56060. */
  56061. constructor(scene: Scene);
  56062. /**
  56063. * Registers the component in a given scene
  56064. */
  56065. register(): void;
  56066. /**
  56067. * Rebuilds the elements related to this component in case of
  56068. * context lost for instance.
  56069. */
  56070. rebuild(): void;
  56071. /**
  56072. * Disposes the component and the associated ressources
  56073. */
  56074. dispose(): void;
  56075. private _beforeCameraUpdate;
  56076. }
  56077. }
  56078. declare module BABYLON {
  56079. /**
  56080. * Navigation plugin interface to add navigation constrained by a navigation mesh
  56081. */
  56082. export interface INavigationEnginePlugin {
  56083. /**
  56084. * plugin name
  56085. */
  56086. name: string;
  56087. /**
  56088. * Creates a navigation mesh
  56089. * @param meshes array of all the geometry used to compute the navigatio mesh
  56090. * @param parameters bunch of parameters used to filter geometry
  56091. */
  56092. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  56093. /**
  56094. * Create a navigation mesh debug mesh
  56095. * @param scene is where the mesh will be added
  56096. * @returns debug display mesh
  56097. */
  56098. createDebugNavMesh(scene: Scene): Mesh;
  56099. /**
  56100. * Get a navigation mesh constrained position, closest to the parameter position
  56101. * @param position world position
  56102. * @returns the closest point to position constrained by the navigation mesh
  56103. */
  56104. getClosestPoint(position: Vector3): Vector3;
  56105. /**
  56106. * Get a navigation mesh constrained position, within a particular radius
  56107. * @param position world position
  56108. * @param maxRadius the maximum distance to the constrained world position
  56109. * @returns the closest point to position constrained by the navigation mesh
  56110. */
  56111. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  56112. /**
  56113. * Compute the final position from a segment made of destination-position
  56114. * @param position world position
  56115. * @param destination world position
  56116. * @returns the resulting point along the navmesh
  56117. */
  56118. moveAlong(position: Vector3, destination: Vector3): Vector3;
  56119. /**
  56120. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  56121. * @param start world position
  56122. * @param end world position
  56123. * @returns array containing world position composing the path
  56124. */
  56125. computePath(start: Vector3, end: Vector3): Vector3[];
  56126. /**
  56127. * If this plugin is supported
  56128. * @returns true if plugin is supported
  56129. */
  56130. isSupported(): boolean;
  56131. /**
  56132. * Create a new Crowd so you can add agents
  56133. * @param maxAgents the maximum agent count in the crowd
  56134. * @param maxAgentRadius the maximum radius an agent can have
  56135. * @param scene to attach the crowd to
  56136. * @returns the crowd you can add agents to
  56137. */
  56138. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  56139. /**
  56140. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56141. * The queries will try to find a solution within those bounds
  56142. * default is (1,1,1)
  56143. * @param extent x,y,z value that define the extent around the queries point of reference
  56144. */
  56145. setDefaultQueryExtent(extent: Vector3): void;
  56146. /**
  56147. * Get the Bounding box extent specified by setDefaultQueryExtent
  56148. * @returns the box extent values
  56149. */
  56150. getDefaultQueryExtent(): Vector3;
  56151. /**
  56152. * Release all resources
  56153. */
  56154. dispose(): void;
  56155. }
  56156. /**
  56157. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  56158. */
  56159. export interface ICrowd {
  56160. /**
  56161. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  56162. * You can attach anything to that node. The node position is updated in the scene update tick.
  56163. * @param pos world position that will be constrained by the navigation mesh
  56164. * @param parameters agent parameters
  56165. * @param transform hooked to the agent that will be update by the scene
  56166. * @returns agent index
  56167. */
  56168. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  56169. /**
  56170. * Returns the agent position in world space
  56171. * @param index agent index returned by addAgent
  56172. * @returns world space position
  56173. */
  56174. getAgentPosition(index: number): Vector3;
  56175. /**
  56176. * Gets the agent velocity in world space
  56177. * @param index agent index returned by addAgent
  56178. * @returns world space velocity
  56179. */
  56180. getAgentVelocity(index: number): Vector3;
  56181. /**
  56182. * remove a particular agent previously created
  56183. * @param index agent index returned by addAgent
  56184. */
  56185. removeAgent(index: number): void;
  56186. /**
  56187. * get the list of all agents attached to this crowd
  56188. * @returns list of agent indices
  56189. */
  56190. getAgents(): number[];
  56191. /**
  56192. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  56193. * @param deltaTime in seconds
  56194. */
  56195. update(deltaTime: number): void;
  56196. /**
  56197. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  56198. * @param index agent index returned by addAgent
  56199. * @param destination targeted world position
  56200. */
  56201. agentGoto(index: number, destination: Vector3): void;
  56202. /**
  56203. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56204. * The queries will try to find a solution within those bounds
  56205. * default is (1,1,1)
  56206. * @param extent x,y,z value that define the extent around the queries point of reference
  56207. */
  56208. setDefaultQueryExtent(extent: Vector3): void;
  56209. /**
  56210. * Get the Bounding box extent specified by setDefaultQueryExtent
  56211. * @returns the box extent values
  56212. */
  56213. getDefaultQueryExtent(): Vector3;
  56214. /**
  56215. * Release all resources
  56216. */
  56217. dispose(): void;
  56218. }
  56219. /**
  56220. * Configures an agent
  56221. */
  56222. export interface IAgentParameters {
  56223. /**
  56224. * Agent radius. [Limit: >= 0]
  56225. */
  56226. radius: number;
  56227. /**
  56228. * Agent height. [Limit: > 0]
  56229. */
  56230. height: number;
  56231. /**
  56232. * Maximum allowed acceleration. [Limit: >= 0]
  56233. */
  56234. maxAcceleration: number;
  56235. /**
  56236. * Maximum allowed speed. [Limit: >= 0]
  56237. */
  56238. maxSpeed: number;
  56239. /**
  56240. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  56241. */
  56242. collisionQueryRange: number;
  56243. /**
  56244. * The path visibility optimization range. [Limit: > 0]
  56245. */
  56246. pathOptimizationRange: number;
  56247. /**
  56248. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  56249. */
  56250. separationWeight: number;
  56251. }
  56252. /**
  56253. * Configures the navigation mesh creation
  56254. */
  56255. export interface INavMeshParameters {
  56256. /**
  56257. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  56258. */
  56259. cs: number;
  56260. /**
  56261. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  56262. */
  56263. ch: number;
  56264. /**
  56265. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  56266. */
  56267. walkableSlopeAngle: number;
  56268. /**
  56269. * Minimum floor to 'ceiling' height that will still allow the floor area to
  56270. * be considered walkable. [Limit: >= 3] [Units: vx]
  56271. */
  56272. walkableHeight: number;
  56273. /**
  56274. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  56275. */
  56276. walkableClimb: number;
  56277. /**
  56278. * The distance to erode/shrink the walkable area of the heightfield away from
  56279. * obstructions. [Limit: >=0] [Units: vx]
  56280. */
  56281. walkableRadius: number;
  56282. /**
  56283. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  56284. */
  56285. maxEdgeLen: number;
  56286. /**
  56287. * The maximum distance a simplfied contour's border edges should deviate
  56288. * the original raw contour. [Limit: >=0] [Units: vx]
  56289. */
  56290. maxSimplificationError: number;
  56291. /**
  56292. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  56293. */
  56294. minRegionArea: number;
  56295. /**
  56296. * Any regions with a span count smaller than this value will, if possible,
  56297. * be merged with larger regions. [Limit: >=0] [Units: vx]
  56298. */
  56299. mergeRegionArea: number;
  56300. /**
  56301. * The maximum number of vertices allowed for polygons generated during the
  56302. * contour to polygon conversion process. [Limit: >= 3]
  56303. */
  56304. maxVertsPerPoly: number;
  56305. /**
  56306. * Sets the sampling distance to use when generating the detail mesh.
  56307. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  56308. */
  56309. detailSampleDist: number;
  56310. /**
  56311. * The maximum distance the detail mesh surface should deviate from heightfield
  56312. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  56313. */
  56314. detailSampleMaxError: number;
  56315. }
  56316. }
  56317. declare module BABYLON {
  56318. /**
  56319. * RecastJS navigation plugin
  56320. */
  56321. export class RecastJSPlugin implements INavigationEnginePlugin {
  56322. /**
  56323. * Reference to the Recast library
  56324. */
  56325. bjsRECAST: any;
  56326. /**
  56327. * plugin name
  56328. */
  56329. name: string;
  56330. /**
  56331. * the first navmesh created. We might extend this to support multiple navmeshes
  56332. */
  56333. navMesh: any;
  56334. /**
  56335. * Initializes the recastJS plugin
  56336. * @param recastInjection can be used to inject your own recast reference
  56337. */
  56338. constructor(recastInjection?: any);
  56339. /**
  56340. * Creates a navigation mesh
  56341. * @param meshes array of all the geometry used to compute the navigatio mesh
  56342. * @param parameters bunch of parameters used to filter geometry
  56343. */
  56344. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  56345. /**
  56346. * Create a navigation mesh debug mesh
  56347. * @param scene is where the mesh will be added
  56348. * @returns debug display mesh
  56349. */
  56350. createDebugNavMesh(scene: Scene): Mesh;
  56351. /**
  56352. * Get a navigation mesh constrained position, closest to the parameter position
  56353. * @param position world position
  56354. * @returns the closest point to position constrained by the navigation mesh
  56355. */
  56356. getClosestPoint(position: Vector3): Vector3;
  56357. /**
  56358. * Get a navigation mesh constrained position, within a particular radius
  56359. * @param position world position
  56360. * @param maxRadius the maximum distance to the constrained world position
  56361. * @returns the closest point to position constrained by the navigation mesh
  56362. */
  56363. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  56364. /**
  56365. * Compute the final position from a segment made of destination-position
  56366. * @param position world position
  56367. * @param destination world position
  56368. * @returns the resulting point along the navmesh
  56369. */
  56370. moveAlong(position: Vector3, destination: Vector3): Vector3;
  56371. /**
  56372. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  56373. * @param start world position
  56374. * @param end world position
  56375. * @returns array containing world position composing the path
  56376. */
  56377. computePath(start: Vector3, end: Vector3): Vector3[];
  56378. /**
  56379. * Create a new Crowd so you can add agents
  56380. * @param maxAgents the maximum agent count in the crowd
  56381. * @param maxAgentRadius the maximum radius an agent can have
  56382. * @param scene to attach the crowd to
  56383. * @returns the crowd you can add agents to
  56384. */
  56385. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  56386. /**
  56387. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56388. * The queries will try to find a solution within those bounds
  56389. * default is (1,1,1)
  56390. * @param extent x,y,z value that define the extent around the queries point of reference
  56391. */
  56392. setDefaultQueryExtent(extent: Vector3): void;
  56393. /**
  56394. * Get the Bounding box extent specified by setDefaultQueryExtent
  56395. * @returns the box extent values
  56396. */
  56397. getDefaultQueryExtent(): Vector3;
  56398. /**
  56399. * Disposes
  56400. */
  56401. dispose(): void;
  56402. /**
  56403. * If this plugin is supported
  56404. * @returns true if plugin is supported
  56405. */
  56406. isSupported(): boolean;
  56407. }
  56408. /**
  56409. * Recast detour crowd implementation
  56410. */
  56411. export class RecastJSCrowd implements ICrowd {
  56412. /**
  56413. * Recast/detour plugin
  56414. */
  56415. bjsRECASTPlugin: RecastJSPlugin;
  56416. /**
  56417. * Link to the detour crowd
  56418. */
  56419. recastCrowd: any;
  56420. /**
  56421. * One transform per agent
  56422. */
  56423. transforms: TransformNode[];
  56424. /**
  56425. * All agents created
  56426. */
  56427. agents: number[];
  56428. /**
  56429. * Link to the scene is kept to unregister the crowd from the scene
  56430. */
  56431. private _scene;
  56432. /**
  56433. * Observer for crowd updates
  56434. */
  56435. private _onBeforeAnimationsObserver;
  56436. /**
  56437. * Constructor
  56438. * @param plugin recastJS plugin
  56439. * @param maxAgents the maximum agent count in the crowd
  56440. * @param maxAgentRadius the maximum radius an agent can have
  56441. * @param scene to attach the crowd to
  56442. * @returns the crowd you can add agents to
  56443. */
  56444. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  56445. /**
  56446. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  56447. * You can attach anything to that node. The node position is updated in the scene update tick.
  56448. * @param pos world position that will be constrained by the navigation mesh
  56449. * @param parameters agent parameters
  56450. * @param transform hooked to the agent that will be update by the scene
  56451. * @returns agent index
  56452. */
  56453. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  56454. /**
  56455. * Returns the agent position in world space
  56456. * @param index agent index returned by addAgent
  56457. * @returns world space position
  56458. */
  56459. getAgentPosition(index: number): Vector3;
  56460. /**
  56461. * Returns the agent velocity in world space
  56462. * @param index agent index returned by addAgent
  56463. * @returns world space velocity
  56464. */
  56465. getAgentVelocity(index: number): Vector3;
  56466. /**
  56467. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  56468. * @param index agent index returned by addAgent
  56469. * @param destination targeted world position
  56470. */
  56471. agentGoto(index: number, destination: Vector3): void;
  56472. /**
  56473. * remove a particular agent previously created
  56474. * @param index agent index returned by addAgent
  56475. */
  56476. removeAgent(index: number): void;
  56477. /**
  56478. * get the list of all agents attached to this crowd
  56479. * @returns list of agent indices
  56480. */
  56481. getAgents(): number[];
  56482. /**
  56483. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  56484. * @param deltaTime in seconds
  56485. */
  56486. update(deltaTime: number): void;
  56487. /**
  56488. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56489. * The queries will try to find a solution within those bounds
  56490. * default is (1,1,1)
  56491. * @param extent x,y,z value that define the extent around the queries point of reference
  56492. */
  56493. setDefaultQueryExtent(extent: Vector3): void;
  56494. /**
  56495. * Get the Bounding box extent specified by setDefaultQueryExtent
  56496. * @returns the box extent values
  56497. */
  56498. getDefaultQueryExtent(): Vector3;
  56499. /**
  56500. * Release all resources
  56501. */
  56502. dispose(): void;
  56503. }
  56504. }
  56505. declare module BABYLON {
  56506. /**
  56507. * Class used to enable access to IndexedDB
  56508. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  56509. */
  56510. export class Database implements IOfflineProvider {
  56511. private _callbackManifestChecked;
  56512. private _currentSceneUrl;
  56513. private _db;
  56514. private _enableSceneOffline;
  56515. private _enableTexturesOffline;
  56516. private _manifestVersionFound;
  56517. private _mustUpdateRessources;
  56518. private _hasReachedQuota;
  56519. private _isSupported;
  56520. private _idbFactory;
  56521. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  56522. private static IsUASupportingBlobStorage;
  56523. /**
  56524. * Gets a boolean indicating if Database storate is enabled (off by default)
  56525. */
  56526. static IDBStorageEnabled: boolean;
  56527. /**
  56528. * Gets a boolean indicating if scene must be saved in the database
  56529. */
  56530. readonly enableSceneOffline: boolean;
  56531. /**
  56532. * Gets a boolean indicating if textures must be saved in the database
  56533. */
  56534. readonly enableTexturesOffline: boolean;
  56535. /**
  56536. * Creates a new Database
  56537. * @param urlToScene defines the url to load the scene
  56538. * @param callbackManifestChecked defines the callback to use when manifest is checked
  56539. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  56540. */
  56541. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  56542. private static _ParseURL;
  56543. private static _ReturnFullUrlLocation;
  56544. private _checkManifestFile;
  56545. /**
  56546. * Open the database and make it available
  56547. * @param successCallback defines the callback to call on success
  56548. * @param errorCallback defines the callback to call on error
  56549. */
  56550. open(successCallback: () => void, errorCallback: () => void): void;
  56551. /**
  56552. * Loads an image from the database
  56553. * @param url defines the url to load from
  56554. * @param image defines the target DOM image
  56555. */
  56556. loadImage(url: string, image: HTMLImageElement): void;
  56557. private _loadImageFromDBAsync;
  56558. private _saveImageIntoDBAsync;
  56559. private _checkVersionFromDB;
  56560. private _loadVersionFromDBAsync;
  56561. private _saveVersionIntoDBAsync;
  56562. /**
  56563. * Loads a file from database
  56564. * @param url defines the URL to load from
  56565. * @param sceneLoaded defines a callback to call on success
  56566. * @param progressCallBack defines a callback to call when progress changed
  56567. * @param errorCallback defines a callback to call on error
  56568. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  56569. */
  56570. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  56571. private _loadFileAsync;
  56572. private _saveFileAsync;
  56573. /**
  56574. * Validates if xhr data is correct
  56575. * @param xhr defines the request to validate
  56576. * @param dataType defines the expected data type
  56577. * @returns true if data is correct
  56578. */
  56579. private static _ValidateXHRData;
  56580. }
  56581. }
  56582. declare module BABYLON {
  56583. /** @hidden */
  56584. export var gpuUpdateParticlesPixelShader: {
  56585. name: string;
  56586. shader: string;
  56587. };
  56588. }
  56589. declare module BABYLON {
  56590. /** @hidden */
  56591. export var gpuUpdateParticlesVertexShader: {
  56592. name: string;
  56593. shader: string;
  56594. };
  56595. }
  56596. declare module BABYLON {
  56597. /** @hidden */
  56598. export var clipPlaneFragmentDeclaration2: {
  56599. name: string;
  56600. shader: string;
  56601. };
  56602. }
  56603. declare module BABYLON {
  56604. /** @hidden */
  56605. export var gpuRenderParticlesPixelShader: {
  56606. name: string;
  56607. shader: string;
  56608. };
  56609. }
  56610. declare module BABYLON {
  56611. /** @hidden */
  56612. export var clipPlaneVertexDeclaration2: {
  56613. name: string;
  56614. shader: string;
  56615. };
  56616. }
  56617. declare module BABYLON {
  56618. /** @hidden */
  56619. export var gpuRenderParticlesVertexShader: {
  56620. name: string;
  56621. shader: string;
  56622. };
  56623. }
  56624. declare module BABYLON {
  56625. /**
  56626. * This represents a GPU particle system in Babylon
  56627. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  56628. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  56629. */
  56630. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  56631. /**
  56632. * The layer mask we are rendering the particles through.
  56633. */
  56634. layerMask: number;
  56635. private _capacity;
  56636. private _activeCount;
  56637. private _currentActiveCount;
  56638. private _accumulatedCount;
  56639. private _renderEffect;
  56640. private _updateEffect;
  56641. private _buffer0;
  56642. private _buffer1;
  56643. private _spriteBuffer;
  56644. private _updateVAO;
  56645. private _renderVAO;
  56646. private _targetIndex;
  56647. private _sourceBuffer;
  56648. private _targetBuffer;
  56649. private _engine;
  56650. private _currentRenderId;
  56651. private _started;
  56652. private _stopped;
  56653. private _timeDelta;
  56654. private _randomTexture;
  56655. private _randomTexture2;
  56656. private _attributesStrideSize;
  56657. private _updateEffectOptions;
  56658. private _randomTextureSize;
  56659. private _actualFrame;
  56660. private readonly _rawTextureWidth;
  56661. /**
  56662. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  56663. */
  56664. static readonly IsSupported: boolean;
  56665. /**
  56666. * An event triggered when the system is disposed.
  56667. */
  56668. onDisposeObservable: Observable<GPUParticleSystem>;
  56669. /**
  56670. * Gets the maximum number of particles active at the same time.
  56671. * @returns The max number of active particles.
  56672. */
  56673. getCapacity(): number;
  56674. /**
  56675. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  56676. * to override the particles.
  56677. */
  56678. forceDepthWrite: boolean;
  56679. /**
  56680. * Gets or set the number of active particles
  56681. */
  56682. activeParticleCount: number;
  56683. private _preWarmDone;
  56684. /**
  56685. * Is this system ready to be used/rendered
  56686. * @return true if the system is ready
  56687. */
  56688. isReady(): boolean;
  56689. /**
  56690. * Gets if the system has been started. (Note: this will still be true after stop is called)
  56691. * @returns True if it has been started, otherwise false.
  56692. */
  56693. isStarted(): boolean;
  56694. /**
  56695. * Starts the particle system and begins to emit
  56696. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  56697. */
  56698. start(delay?: number): void;
  56699. /**
  56700. * Stops the particle system.
  56701. */
  56702. stop(): void;
  56703. /**
  56704. * Remove all active particles
  56705. */
  56706. reset(): void;
  56707. /**
  56708. * Returns the string "GPUParticleSystem"
  56709. * @returns a string containing the class name
  56710. */
  56711. getClassName(): string;
  56712. private _colorGradientsTexture;
  56713. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  56714. /**
  56715. * Adds a new color gradient
  56716. * @param gradient defines the gradient to use (between 0 and 1)
  56717. * @param color1 defines the color to affect to the specified gradient
  56718. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  56719. * @returns the current particle system
  56720. */
  56721. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  56722. /**
  56723. * Remove a specific color gradient
  56724. * @param gradient defines the gradient to remove
  56725. * @returns the current particle system
  56726. */
  56727. removeColorGradient(gradient: number): GPUParticleSystem;
  56728. private _angularSpeedGradientsTexture;
  56729. private _sizeGradientsTexture;
  56730. private _velocityGradientsTexture;
  56731. private _limitVelocityGradientsTexture;
  56732. private _dragGradientsTexture;
  56733. private _addFactorGradient;
  56734. /**
  56735. * Adds a new size gradient
  56736. * @param gradient defines the gradient to use (between 0 and 1)
  56737. * @param factor defines the size factor to affect to the specified gradient
  56738. * @returns the current particle system
  56739. */
  56740. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  56741. /**
  56742. * Remove a specific size gradient
  56743. * @param gradient defines the gradient to remove
  56744. * @returns the current particle system
  56745. */
  56746. removeSizeGradient(gradient: number): GPUParticleSystem;
  56747. /**
  56748. * Adds a new angular speed gradient
  56749. * @param gradient defines the gradient to use (between 0 and 1)
  56750. * @param factor defines the angular speed to affect to the specified gradient
  56751. * @returns the current particle system
  56752. */
  56753. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  56754. /**
  56755. * Remove a specific angular speed gradient
  56756. * @param gradient defines the gradient to remove
  56757. * @returns the current particle system
  56758. */
  56759. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  56760. /**
  56761. * Adds a new velocity gradient
  56762. * @param gradient defines the gradient to use (between 0 and 1)
  56763. * @param factor defines the velocity to affect to the specified gradient
  56764. * @returns the current particle system
  56765. */
  56766. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56767. /**
  56768. * Remove a specific velocity gradient
  56769. * @param gradient defines the gradient to remove
  56770. * @returns the current particle system
  56771. */
  56772. removeVelocityGradient(gradient: number): GPUParticleSystem;
  56773. /**
  56774. * Adds a new limit velocity gradient
  56775. * @param gradient defines the gradient to use (between 0 and 1)
  56776. * @param factor defines the limit velocity value to affect to the specified gradient
  56777. * @returns the current particle system
  56778. */
  56779. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56780. /**
  56781. * Remove a specific limit velocity gradient
  56782. * @param gradient defines the gradient to remove
  56783. * @returns the current particle system
  56784. */
  56785. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  56786. /**
  56787. * Adds a new drag gradient
  56788. * @param gradient defines the gradient to use (between 0 and 1)
  56789. * @param factor defines the drag value to affect to the specified gradient
  56790. * @returns the current particle system
  56791. */
  56792. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  56793. /**
  56794. * Remove a specific drag gradient
  56795. * @param gradient defines the gradient to remove
  56796. * @returns the current particle system
  56797. */
  56798. removeDragGradient(gradient: number): GPUParticleSystem;
  56799. /**
  56800. * Not supported by GPUParticleSystem
  56801. * @param gradient defines the gradient to use (between 0 and 1)
  56802. * @param factor defines the emit rate value to affect to the specified gradient
  56803. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56804. * @returns the current particle system
  56805. */
  56806. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56807. /**
  56808. * Not supported by GPUParticleSystem
  56809. * @param gradient defines the gradient to remove
  56810. * @returns the current particle system
  56811. */
  56812. removeEmitRateGradient(gradient: number): IParticleSystem;
  56813. /**
  56814. * Not supported by GPUParticleSystem
  56815. * @param gradient defines the gradient to use (between 0 and 1)
  56816. * @param factor defines the start size value to affect to the specified gradient
  56817. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56818. * @returns the current particle system
  56819. */
  56820. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56821. /**
  56822. * Not supported by GPUParticleSystem
  56823. * @param gradient defines the gradient to remove
  56824. * @returns the current particle system
  56825. */
  56826. removeStartSizeGradient(gradient: number): IParticleSystem;
  56827. /**
  56828. * Not supported by GPUParticleSystem
  56829. * @param gradient defines the gradient to use (between 0 and 1)
  56830. * @param min defines the color remap minimal range
  56831. * @param max defines the color remap maximal range
  56832. * @returns the current particle system
  56833. */
  56834. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56835. /**
  56836. * Not supported by GPUParticleSystem
  56837. * @param gradient defines the gradient to remove
  56838. * @returns the current particle system
  56839. */
  56840. removeColorRemapGradient(): IParticleSystem;
  56841. /**
  56842. * Not supported by GPUParticleSystem
  56843. * @param gradient defines the gradient to use (between 0 and 1)
  56844. * @param min defines the alpha remap minimal range
  56845. * @param max defines the alpha remap maximal range
  56846. * @returns the current particle system
  56847. */
  56848. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56849. /**
  56850. * Not supported by GPUParticleSystem
  56851. * @param gradient defines the gradient to remove
  56852. * @returns the current particle system
  56853. */
  56854. removeAlphaRemapGradient(): IParticleSystem;
  56855. /**
  56856. * Not supported by GPUParticleSystem
  56857. * @param gradient defines the gradient to use (between 0 and 1)
  56858. * @param color defines the color to affect to the specified gradient
  56859. * @returns the current particle system
  56860. */
  56861. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  56862. /**
  56863. * Not supported by GPUParticleSystem
  56864. * @param gradient defines the gradient to remove
  56865. * @returns the current particle system
  56866. */
  56867. removeRampGradient(): IParticleSystem;
  56868. /**
  56869. * Not supported by GPUParticleSystem
  56870. * @returns the list of ramp gradients
  56871. */
  56872. getRampGradients(): Nullable<Array<Color3Gradient>>;
  56873. /**
  56874. * Not supported by GPUParticleSystem
  56875. * Gets or sets a boolean indicating that ramp gradients must be used
  56876. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  56877. */
  56878. useRampGradients: boolean;
  56879. /**
  56880. * Not supported by GPUParticleSystem
  56881. * @param gradient defines the gradient to use (between 0 and 1)
  56882. * @param factor defines the life time factor to affect to the specified gradient
  56883. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56884. * @returns the current particle system
  56885. */
  56886. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56887. /**
  56888. * Not supported by GPUParticleSystem
  56889. * @param gradient defines the gradient to remove
  56890. * @returns the current particle system
  56891. */
  56892. removeLifeTimeGradient(gradient: number): IParticleSystem;
  56893. /**
  56894. * Instantiates a GPU particle system.
  56895. * 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.
  56896. * @param name The name of the particle system
  56897. * @param options The options used to create the system
  56898. * @param scene The scene the particle system belongs to
  56899. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  56900. */
  56901. constructor(name: string, options: Partial<{
  56902. capacity: number;
  56903. randomTextureSize: number;
  56904. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  56905. protected _reset(): void;
  56906. private _createUpdateVAO;
  56907. private _createRenderVAO;
  56908. private _initialize;
  56909. /** @hidden */
  56910. _recreateUpdateEffect(): void;
  56911. /** @hidden */
  56912. _recreateRenderEffect(): void;
  56913. /**
  56914. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  56915. * @param preWarm defines if we are in the pre-warmimg phase
  56916. */
  56917. animate(preWarm?: boolean): void;
  56918. private _createFactorGradientTexture;
  56919. private _createSizeGradientTexture;
  56920. private _createAngularSpeedGradientTexture;
  56921. private _createVelocityGradientTexture;
  56922. private _createLimitVelocityGradientTexture;
  56923. private _createDragGradientTexture;
  56924. private _createColorGradientTexture;
  56925. /**
  56926. * Renders the particle system in its current state
  56927. * @param preWarm defines if the system should only update the particles but not render them
  56928. * @returns the current number of particles
  56929. */
  56930. render(preWarm?: boolean): number;
  56931. /**
  56932. * Rebuilds the particle system
  56933. */
  56934. rebuild(): void;
  56935. private _releaseBuffers;
  56936. private _releaseVAOs;
  56937. /**
  56938. * Disposes the particle system and free the associated resources
  56939. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  56940. */
  56941. dispose(disposeTexture?: boolean): void;
  56942. /**
  56943. * Clones the particle system.
  56944. * @param name The name of the cloned object
  56945. * @param newEmitter The new emitter to use
  56946. * @returns the cloned particle system
  56947. */
  56948. clone(name: string, newEmitter: any): GPUParticleSystem;
  56949. /**
  56950. * Serializes the particle system to a JSON object.
  56951. * @returns the JSON object
  56952. */
  56953. serialize(): any;
  56954. /**
  56955. * Parses a JSON object to create a GPU particle system.
  56956. * @param parsedParticleSystem The JSON object to parse
  56957. * @param scene The scene to create the particle system in
  56958. * @param rootUrl The root url to use to load external dependencies like texture
  56959. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  56960. * @returns the parsed GPU particle system
  56961. */
  56962. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  56963. }
  56964. }
  56965. declare module BABYLON {
  56966. /**
  56967. * Represents a set of particle systems working together to create a specific effect
  56968. */
  56969. export class ParticleSystemSet implements IDisposable {
  56970. private _emitterCreationOptions;
  56971. private _emitterNode;
  56972. /**
  56973. * Gets the particle system list
  56974. */
  56975. systems: IParticleSystem[];
  56976. /**
  56977. * Gets the emitter node used with this set
  56978. */
  56979. readonly emitterNode: Nullable<TransformNode>;
  56980. /**
  56981. * Creates a new emitter mesh as a sphere
  56982. * @param options defines the options used to create the sphere
  56983. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  56984. * @param scene defines the hosting scene
  56985. */
  56986. setEmitterAsSphere(options: {
  56987. diameter: number;
  56988. segments: number;
  56989. color: Color3;
  56990. }, renderingGroupId: number, scene: Scene): void;
  56991. /**
  56992. * Starts all particle systems of the set
  56993. * @param emitter defines an optional mesh to use as emitter for the particle systems
  56994. */
  56995. start(emitter?: AbstractMesh): void;
  56996. /**
  56997. * Release all associated resources
  56998. */
  56999. dispose(): void;
  57000. /**
  57001. * Serialize the set into a JSON compatible object
  57002. * @returns a JSON compatible representation of the set
  57003. */
  57004. serialize(): any;
  57005. /**
  57006. * Parse a new ParticleSystemSet from a serialized source
  57007. * @param data defines a JSON compatible representation of the set
  57008. * @param scene defines the hosting scene
  57009. * @param gpu defines if we want GPU particles or CPU particles
  57010. * @returns a new ParticleSystemSet
  57011. */
  57012. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  57013. }
  57014. }
  57015. declare module BABYLON {
  57016. /**
  57017. * This class is made for on one-liner static method to help creating particle system set.
  57018. */
  57019. export class ParticleHelper {
  57020. /**
  57021. * Gets or sets base Assets URL
  57022. */
  57023. static BaseAssetsUrl: string;
  57024. /**
  57025. * Create a default particle system that you can tweak
  57026. * @param emitter defines the emitter to use
  57027. * @param capacity defines the system capacity (default is 500 particles)
  57028. * @param scene defines the hosting scene
  57029. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  57030. * @returns the new Particle system
  57031. */
  57032. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  57033. /**
  57034. * This is the main static method (one-liner) of this helper to create different particle systems
  57035. * @param type This string represents the type to the particle system to create
  57036. * @param scene The scene where the particle system should live
  57037. * @param gpu If the system will use gpu
  57038. * @returns the ParticleSystemSet created
  57039. */
  57040. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  57041. /**
  57042. * Static function used to export a particle system to a ParticleSystemSet variable.
  57043. * Please note that the emitter shape is not exported
  57044. * @param systems defines the particle systems to export
  57045. * @returns the created particle system set
  57046. */
  57047. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  57048. }
  57049. }
  57050. declare module BABYLON {
  57051. interface Engine {
  57052. /**
  57053. * Create an effect to use with particle systems.
  57054. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  57055. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  57056. * @param uniformsNames defines a list of attribute names
  57057. * @param samplers defines an array of string used to represent textures
  57058. * @param defines defines the string containing the defines to use to compile the shaders
  57059. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  57060. * @param onCompiled defines a function to call when the effect creation is successful
  57061. * @param onError defines a function to call when the effect creation has failed
  57062. * @returns the new Effect
  57063. */
  57064. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  57065. }
  57066. interface Mesh {
  57067. /**
  57068. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  57069. * @returns an array of IParticleSystem
  57070. */
  57071. getEmittedParticleSystems(): IParticleSystem[];
  57072. /**
  57073. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  57074. * @returns an array of IParticleSystem
  57075. */
  57076. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  57077. }
  57078. /**
  57079. * @hidden
  57080. */
  57081. export var _IDoNeedToBeInTheBuild: number;
  57082. }
  57083. declare module BABYLON {
  57084. interface Scene {
  57085. /** @hidden (Backing field) */
  57086. _physicsEngine: Nullable<IPhysicsEngine>;
  57087. /**
  57088. * Gets the current physics engine
  57089. * @returns a IPhysicsEngine or null if none attached
  57090. */
  57091. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  57092. /**
  57093. * Enables physics to the current scene
  57094. * @param gravity defines the scene's gravity for the physics engine
  57095. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  57096. * @return a boolean indicating if the physics engine was initialized
  57097. */
  57098. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  57099. /**
  57100. * Disables and disposes the physics engine associated with the scene
  57101. */
  57102. disablePhysicsEngine(): void;
  57103. /**
  57104. * Gets a boolean indicating if there is an active physics engine
  57105. * @returns a boolean indicating if there is an active physics engine
  57106. */
  57107. isPhysicsEnabled(): boolean;
  57108. /**
  57109. * Deletes a physics compound impostor
  57110. * @param compound defines the compound to delete
  57111. */
  57112. deleteCompoundImpostor(compound: any): void;
  57113. /**
  57114. * An event triggered when physic simulation is about to be run
  57115. */
  57116. onBeforePhysicsObservable: Observable<Scene>;
  57117. /**
  57118. * An event triggered when physic simulation has been done
  57119. */
  57120. onAfterPhysicsObservable: Observable<Scene>;
  57121. }
  57122. interface AbstractMesh {
  57123. /** @hidden */
  57124. _physicsImpostor: Nullable<PhysicsImpostor>;
  57125. /**
  57126. * Gets or sets impostor used for physic simulation
  57127. * @see http://doc.babylonjs.com/features/physics_engine
  57128. */
  57129. physicsImpostor: Nullable<PhysicsImpostor>;
  57130. /**
  57131. * Gets the current physics impostor
  57132. * @see http://doc.babylonjs.com/features/physics_engine
  57133. * @returns a physics impostor or null
  57134. */
  57135. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  57136. /** Apply a physic impulse to the mesh
  57137. * @param force defines the force to apply
  57138. * @param contactPoint defines where to apply the force
  57139. * @returns the current mesh
  57140. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57141. */
  57142. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  57143. /**
  57144. * Creates a physic joint between two meshes
  57145. * @param otherMesh defines the other mesh to use
  57146. * @param pivot1 defines the pivot to use on this mesh
  57147. * @param pivot2 defines the pivot to use on the other mesh
  57148. * @param options defines additional options (can be plugin dependent)
  57149. * @returns the current mesh
  57150. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  57151. */
  57152. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  57153. /** @hidden */
  57154. _disposePhysicsObserver: Nullable<Observer<Node>>;
  57155. }
  57156. /**
  57157. * Defines the physics engine scene component responsible to manage a physics engine
  57158. */
  57159. export class PhysicsEngineSceneComponent implements ISceneComponent {
  57160. /**
  57161. * The component name helpful to identify the component in the list of scene components.
  57162. */
  57163. readonly name: string;
  57164. /**
  57165. * The scene the component belongs to.
  57166. */
  57167. scene: Scene;
  57168. /**
  57169. * Creates a new instance of the component for the given scene
  57170. * @param scene Defines the scene to register the component in
  57171. */
  57172. constructor(scene: Scene);
  57173. /**
  57174. * Registers the component in a given scene
  57175. */
  57176. register(): void;
  57177. /**
  57178. * Rebuilds the elements related to this component in case of
  57179. * context lost for instance.
  57180. */
  57181. rebuild(): void;
  57182. /**
  57183. * Disposes the component and the associated ressources
  57184. */
  57185. dispose(): void;
  57186. }
  57187. }
  57188. declare module BABYLON {
  57189. /**
  57190. * A helper for physics simulations
  57191. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57192. */
  57193. export class PhysicsHelper {
  57194. private _scene;
  57195. private _physicsEngine;
  57196. /**
  57197. * Initializes the Physics helper
  57198. * @param scene Babylon.js scene
  57199. */
  57200. constructor(scene: Scene);
  57201. /**
  57202. * Applies a radial explosion impulse
  57203. * @param origin the origin of the explosion
  57204. * @param radiusOrEventOptions the radius or the options of radial explosion
  57205. * @param strength the explosion strength
  57206. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57207. * @returns A physics radial explosion event, or null
  57208. */
  57209. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57210. /**
  57211. * Applies a radial explosion force
  57212. * @param origin the origin of the explosion
  57213. * @param radiusOrEventOptions the radius or the options of radial explosion
  57214. * @param strength the explosion strength
  57215. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57216. * @returns A physics radial explosion event, or null
  57217. */
  57218. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57219. /**
  57220. * Creates a gravitational field
  57221. * @param origin the origin of the explosion
  57222. * @param radiusOrEventOptions the radius or the options of radial explosion
  57223. * @param strength the explosion strength
  57224. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57225. * @returns A physics gravitational field event, or null
  57226. */
  57227. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  57228. /**
  57229. * Creates a physics updraft event
  57230. * @param origin the origin of the updraft
  57231. * @param radiusOrEventOptions the radius or the options of the updraft
  57232. * @param strength the strength of the updraft
  57233. * @param height the height of the updraft
  57234. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  57235. * @returns A physics updraft event, or null
  57236. */
  57237. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  57238. /**
  57239. * Creates a physics vortex event
  57240. * @param origin the of the vortex
  57241. * @param radiusOrEventOptions the radius or the options of the vortex
  57242. * @param strength the strength of the vortex
  57243. * @param height the height of the vortex
  57244. * @returns a Physics vortex event, or null
  57245. * A physics vortex event or null
  57246. */
  57247. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  57248. }
  57249. /**
  57250. * Represents a physics radial explosion event
  57251. */
  57252. class PhysicsRadialExplosionEvent {
  57253. private _scene;
  57254. private _options;
  57255. private _sphere;
  57256. private _dataFetched;
  57257. /**
  57258. * Initializes a radial explosioin event
  57259. * @param _scene BabylonJS scene
  57260. * @param _options The options for the vortex event
  57261. */
  57262. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  57263. /**
  57264. * Returns the data related to the radial explosion event (sphere).
  57265. * @returns The radial explosion event data
  57266. */
  57267. getData(): PhysicsRadialExplosionEventData;
  57268. /**
  57269. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  57270. * @param impostor A physics imposter
  57271. * @param origin the origin of the explosion
  57272. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  57273. */
  57274. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  57275. /**
  57276. * Triggers affecterd impostors callbacks
  57277. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  57278. */
  57279. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  57280. /**
  57281. * Disposes the sphere.
  57282. * @param force Specifies if the sphere should be disposed by force
  57283. */
  57284. dispose(force?: boolean): void;
  57285. /*** Helpers ***/
  57286. private _prepareSphere;
  57287. private _intersectsWithSphere;
  57288. }
  57289. /**
  57290. * Represents a gravitational field event
  57291. */
  57292. class PhysicsGravitationalFieldEvent {
  57293. private _physicsHelper;
  57294. private _scene;
  57295. private _origin;
  57296. private _options;
  57297. private _tickCallback;
  57298. private _sphere;
  57299. private _dataFetched;
  57300. /**
  57301. * Initializes the physics gravitational field event
  57302. * @param _physicsHelper A physics helper
  57303. * @param _scene BabylonJS scene
  57304. * @param _origin The origin position of the gravitational field event
  57305. * @param _options The options for the vortex event
  57306. */
  57307. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  57308. /**
  57309. * Returns the data related to the gravitational field event (sphere).
  57310. * @returns A gravitational field event
  57311. */
  57312. getData(): PhysicsGravitationalFieldEventData;
  57313. /**
  57314. * Enables the gravitational field.
  57315. */
  57316. enable(): void;
  57317. /**
  57318. * Disables the gravitational field.
  57319. */
  57320. disable(): void;
  57321. /**
  57322. * Disposes the sphere.
  57323. * @param force The force to dispose from the gravitational field event
  57324. */
  57325. dispose(force?: boolean): void;
  57326. private _tick;
  57327. }
  57328. /**
  57329. * Represents a physics updraft event
  57330. */
  57331. class PhysicsUpdraftEvent {
  57332. private _scene;
  57333. private _origin;
  57334. private _options;
  57335. private _physicsEngine;
  57336. private _originTop;
  57337. private _originDirection;
  57338. private _tickCallback;
  57339. private _cylinder;
  57340. private _cylinderPosition;
  57341. private _dataFetched;
  57342. /**
  57343. * Initializes the physics updraft event
  57344. * @param _scene BabylonJS scene
  57345. * @param _origin The origin position of the updraft
  57346. * @param _options The options for the updraft event
  57347. */
  57348. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  57349. /**
  57350. * Returns the data related to the updraft event (cylinder).
  57351. * @returns A physics updraft event
  57352. */
  57353. getData(): PhysicsUpdraftEventData;
  57354. /**
  57355. * Enables the updraft.
  57356. */
  57357. enable(): void;
  57358. /**
  57359. * Disables the updraft.
  57360. */
  57361. disable(): void;
  57362. /**
  57363. * Disposes the cylinder.
  57364. * @param force Specifies if the updraft should be disposed by force
  57365. */
  57366. dispose(force?: boolean): void;
  57367. private getImpostorHitData;
  57368. private _tick;
  57369. /*** Helpers ***/
  57370. private _prepareCylinder;
  57371. private _intersectsWithCylinder;
  57372. }
  57373. /**
  57374. * Represents a physics vortex event
  57375. */
  57376. class PhysicsVortexEvent {
  57377. private _scene;
  57378. private _origin;
  57379. private _options;
  57380. private _physicsEngine;
  57381. private _originTop;
  57382. private _tickCallback;
  57383. private _cylinder;
  57384. private _cylinderPosition;
  57385. private _dataFetched;
  57386. /**
  57387. * Initializes the physics vortex event
  57388. * @param _scene The BabylonJS scene
  57389. * @param _origin The origin position of the vortex
  57390. * @param _options The options for the vortex event
  57391. */
  57392. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  57393. /**
  57394. * Returns the data related to the vortex event (cylinder).
  57395. * @returns The physics vortex event data
  57396. */
  57397. getData(): PhysicsVortexEventData;
  57398. /**
  57399. * Enables the vortex.
  57400. */
  57401. enable(): void;
  57402. /**
  57403. * Disables the cortex.
  57404. */
  57405. disable(): void;
  57406. /**
  57407. * Disposes the sphere.
  57408. * @param force
  57409. */
  57410. dispose(force?: boolean): void;
  57411. private getImpostorHitData;
  57412. private _tick;
  57413. /*** Helpers ***/
  57414. private _prepareCylinder;
  57415. private _intersectsWithCylinder;
  57416. }
  57417. /**
  57418. * Options fot the radial explosion event
  57419. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57420. */
  57421. export class PhysicsRadialExplosionEventOptions {
  57422. /**
  57423. * The radius of the sphere for the radial explosion.
  57424. */
  57425. radius: number;
  57426. /**
  57427. * The strenth of the explosion.
  57428. */
  57429. strength: number;
  57430. /**
  57431. * The strenght of the force in correspondence to the distance of the affected object
  57432. */
  57433. falloff: PhysicsRadialImpulseFalloff;
  57434. /**
  57435. * Sphere options for the radial explosion.
  57436. */
  57437. sphere: {
  57438. segments: number;
  57439. diameter: number;
  57440. };
  57441. /**
  57442. * Sphere options for the radial explosion.
  57443. */
  57444. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  57445. }
  57446. /**
  57447. * Options fot the updraft event
  57448. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57449. */
  57450. export class PhysicsUpdraftEventOptions {
  57451. /**
  57452. * The radius of the cylinder for the vortex
  57453. */
  57454. radius: number;
  57455. /**
  57456. * The strenth of the updraft.
  57457. */
  57458. strength: number;
  57459. /**
  57460. * The height of the cylinder for the updraft.
  57461. */
  57462. height: number;
  57463. /**
  57464. * The mode for the the updraft.
  57465. */
  57466. updraftMode: PhysicsUpdraftMode;
  57467. }
  57468. /**
  57469. * Options fot the vortex event
  57470. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57471. */
  57472. export class PhysicsVortexEventOptions {
  57473. /**
  57474. * The radius of the cylinder for the vortex
  57475. */
  57476. radius: number;
  57477. /**
  57478. * The strenth of the vortex.
  57479. */
  57480. strength: number;
  57481. /**
  57482. * The height of the cylinder for the vortex.
  57483. */
  57484. height: number;
  57485. /**
  57486. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  57487. */
  57488. centripetalForceThreshold: number;
  57489. /**
  57490. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  57491. */
  57492. centripetalForceMultiplier: number;
  57493. /**
  57494. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  57495. */
  57496. centrifugalForceMultiplier: number;
  57497. /**
  57498. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  57499. */
  57500. updraftForceMultiplier: number;
  57501. }
  57502. /**
  57503. * The strenght of the force in correspondence to the distance of the affected object
  57504. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57505. */
  57506. export enum PhysicsRadialImpulseFalloff {
  57507. /** Defines that impulse is constant in strength across it's whole radius */
  57508. Constant = 0,
  57509. /** Defines that impulse gets weaker if it's further from the origin */
  57510. Linear = 1
  57511. }
  57512. /**
  57513. * The strength of the force in correspondence to the distance of the affected object
  57514. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57515. */
  57516. export enum PhysicsUpdraftMode {
  57517. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  57518. Center = 0,
  57519. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  57520. Perpendicular = 1
  57521. }
  57522. /**
  57523. * Interface for a physics hit data
  57524. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57525. */
  57526. export interface PhysicsHitData {
  57527. /**
  57528. * The force applied at the contact point
  57529. */
  57530. force: Vector3;
  57531. /**
  57532. * The contact point
  57533. */
  57534. contactPoint: Vector3;
  57535. /**
  57536. * The distance from the origin to the contact point
  57537. */
  57538. distanceFromOrigin: number;
  57539. }
  57540. /**
  57541. * Interface for radial explosion event data
  57542. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57543. */
  57544. export interface PhysicsRadialExplosionEventData {
  57545. /**
  57546. * A sphere used for the radial explosion event
  57547. */
  57548. sphere: Mesh;
  57549. }
  57550. /**
  57551. * Interface for gravitational field event data
  57552. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57553. */
  57554. export interface PhysicsGravitationalFieldEventData {
  57555. /**
  57556. * A sphere mesh used for the gravitational field event
  57557. */
  57558. sphere: Mesh;
  57559. }
  57560. /**
  57561. * Interface for updraft event data
  57562. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57563. */
  57564. export interface PhysicsUpdraftEventData {
  57565. /**
  57566. * A cylinder used for the updraft event
  57567. */
  57568. cylinder: Mesh;
  57569. }
  57570. /**
  57571. * Interface for vortex event data
  57572. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57573. */
  57574. export interface PhysicsVortexEventData {
  57575. /**
  57576. * A cylinder used for the vortex event
  57577. */
  57578. cylinder: Mesh;
  57579. }
  57580. /**
  57581. * Interface for an affected physics impostor
  57582. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57583. */
  57584. export interface PhysicsAffectedImpostorWithData {
  57585. /**
  57586. * The impostor affected by the effect
  57587. */
  57588. impostor: PhysicsImpostor;
  57589. /**
  57590. * The data about the hit/horce from the explosion
  57591. */
  57592. hitData: PhysicsHitData;
  57593. }
  57594. }
  57595. declare module BABYLON {
  57596. /** @hidden */
  57597. export var blackAndWhitePixelShader: {
  57598. name: string;
  57599. shader: string;
  57600. };
  57601. }
  57602. declare module BABYLON {
  57603. /**
  57604. * Post process used to render in black and white
  57605. */
  57606. export class BlackAndWhitePostProcess extends PostProcess {
  57607. /**
  57608. * Linear about to convert he result to black and white (default: 1)
  57609. */
  57610. degree: number;
  57611. /**
  57612. * Creates a black and white post process
  57613. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  57614. * @param name The name of the effect.
  57615. * @param options The required width/height ratio to downsize to before computing the render pass.
  57616. * @param camera The camera to apply the render pass to.
  57617. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57618. * @param engine The engine which the post process will be applied. (default: current engine)
  57619. * @param reusable If the post process can be reused on the same frame. (default: false)
  57620. */
  57621. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57622. }
  57623. }
  57624. declare module BABYLON {
  57625. /**
  57626. * This represents a set of one or more post processes in Babylon.
  57627. * A post process can be used to apply a shader to a texture after it is rendered.
  57628. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57629. */
  57630. export class PostProcessRenderEffect {
  57631. private _postProcesses;
  57632. private _getPostProcesses;
  57633. private _singleInstance;
  57634. private _cameras;
  57635. private _indicesForCamera;
  57636. /**
  57637. * Name of the effect
  57638. * @hidden
  57639. */
  57640. _name: string;
  57641. /**
  57642. * Instantiates a post process render effect.
  57643. * A post process can be used to apply a shader to a texture after it is rendered.
  57644. * @param engine The engine the effect is tied to
  57645. * @param name The name of the effect
  57646. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  57647. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  57648. */
  57649. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  57650. /**
  57651. * Checks if all the post processes in the effect are supported.
  57652. */
  57653. readonly isSupported: boolean;
  57654. /**
  57655. * Updates the current state of the effect
  57656. * @hidden
  57657. */
  57658. _update(): void;
  57659. /**
  57660. * Attaches the effect on cameras
  57661. * @param cameras The camera to attach to.
  57662. * @hidden
  57663. */
  57664. _attachCameras(cameras: Camera): void;
  57665. /**
  57666. * Attaches the effect on cameras
  57667. * @param cameras The camera to attach to.
  57668. * @hidden
  57669. */
  57670. _attachCameras(cameras: Camera[]): void;
  57671. /**
  57672. * Detaches the effect on cameras
  57673. * @param cameras The camera to detatch from.
  57674. * @hidden
  57675. */
  57676. _detachCameras(cameras: Camera): void;
  57677. /**
  57678. * Detatches the effect on cameras
  57679. * @param cameras The camera to detatch from.
  57680. * @hidden
  57681. */
  57682. _detachCameras(cameras: Camera[]): void;
  57683. /**
  57684. * Enables the effect on given cameras
  57685. * @param cameras The camera to enable.
  57686. * @hidden
  57687. */
  57688. _enable(cameras: Camera): void;
  57689. /**
  57690. * Enables the effect on given cameras
  57691. * @param cameras The camera to enable.
  57692. * @hidden
  57693. */
  57694. _enable(cameras: Nullable<Camera[]>): void;
  57695. /**
  57696. * Disables the effect on the given cameras
  57697. * @param cameras The camera to disable.
  57698. * @hidden
  57699. */
  57700. _disable(cameras: Camera): void;
  57701. /**
  57702. * Disables the effect on the given cameras
  57703. * @param cameras The camera to disable.
  57704. * @hidden
  57705. */
  57706. _disable(cameras: Nullable<Camera[]>): void;
  57707. /**
  57708. * Gets a list of the post processes contained in the effect.
  57709. * @param camera The camera to get the post processes on.
  57710. * @returns The list of the post processes in the effect.
  57711. */
  57712. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  57713. }
  57714. }
  57715. declare module BABYLON {
  57716. /** @hidden */
  57717. export var extractHighlightsPixelShader: {
  57718. name: string;
  57719. shader: string;
  57720. };
  57721. }
  57722. declare module BABYLON {
  57723. /**
  57724. * 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.
  57725. */
  57726. export class ExtractHighlightsPostProcess extends PostProcess {
  57727. /**
  57728. * The luminance threshold, pixels below this value will be set to black.
  57729. */
  57730. threshold: number;
  57731. /** @hidden */
  57732. _exposure: number;
  57733. /**
  57734. * Post process which has the input texture to be used when performing highlight extraction
  57735. * @hidden
  57736. */
  57737. _inputPostProcess: Nullable<PostProcess>;
  57738. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57739. }
  57740. }
  57741. declare module BABYLON {
  57742. /** @hidden */
  57743. export var bloomMergePixelShader: {
  57744. name: string;
  57745. shader: string;
  57746. };
  57747. }
  57748. declare module BABYLON {
  57749. /**
  57750. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57751. */
  57752. export class BloomMergePostProcess extends PostProcess {
  57753. /** Weight of the bloom to be added to the original input. */
  57754. weight: number;
  57755. /**
  57756. * Creates a new instance of @see BloomMergePostProcess
  57757. * @param name The name of the effect.
  57758. * @param originalFromInput Post process which's input will be used for the merge.
  57759. * @param blurred Blurred highlights post process which's output will be used.
  57760. * @param weight Weight of the bloom to be added to the original input.
  57761. * @param options The required width/height ratio to downsize to before computing the render pass.
  57762. * @param camera The camera to apply the render pass to.
  57763. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57764. * @param engine The engine which the post process will be applied. (default: current engine)
  57765. * @param reusable If the post process can be reused on the same frame. (default: false)
  57766. * @param textureType Type of textures used when performing the post process. (default: 0)
  57767. * @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)
  57768. */
  57769. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  57770. /** Weight of the bloom to be added to the original input. */
  57771. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57772. }
  57773. }
  57774. declare module BABYLON {
  57775. /**
  57776. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  57777. */
  57778. export class BloomEffect extends PostProcessRenderEffect {
  57779. private bloomScale;
  57780. /**
  57781. * @hidden Internal
  57782. */
  57783. _effects: Array<PostProcess>;
  57784. /**
  57785. * @hidden Internal
  57786. */
  57787. _downscale: ExtractHighlightsPostProcess;
  57788. private _blurX;
  57789. private _blurY;
  57790. private _merge;
  57791. /**
  57792. * The luminance threshold to find bright areas of the image to bloom.
  57793. */
  57794. threshold: number;
  57795. /**
  57796. * The strength of the bloom.
  57797. */
  57798. weight: number;
  57799. /**
  57800. * Specifies the size of the bloom blur kernel, relative to the final output size
  57801. */
  57802. kernel: number;
  57803. /**
  57804. * Creates a new instance of @see BloomEffect
  57805. * @param scene The scene the effect belongs to.
  57806. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  57807. * @param bloomKernel The size of the kernel to be used when applying the blur.
  57808. * @param bloomWeight The the strength of bloom.
  57809. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57810. * @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)
  57811. */
  57812. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  57813. /**
  57814. * Disposes each of the internal effects for a given camera.
  57815. * @param camera The camera to dispose the effect on.
  57816. */
  57817. disposeEffects(camera: Camera): void;
  57818. /**
  57819. * @hidden Internal
  57820. */
  57821. _updateEffects(): void;
  57822. /**
  57823. * Internal
  57824. * @returns if all the contained post processes are ready.
  57825. * @hidden
  57826. */
  57827. _isReady(): boolean;
  57828. }
  57829. }
  57830. declare module BABYLON {
  57831. /** @hidden */
  57832. export var chromaticAberrationPixelShader: {
  57833. name: string;
  57834. shader: string;
  57835. };
  57836. }
  57837. declare module BABYLON {
  57838. /**
  57839. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  57840. */
  57841. export class ChromaticAberrationPostProcess extends PostProcess {
  57842. /**
  57843. * The amount of seperation of rgb channels (default: 30)
  57844. */
  57845. aberrationAmount: number;
  57846. /**
  57847. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  57848. */
  57849. radialIntensity: number;
  57850. /**
  57851. * 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))
  57852. */
  57853. direction: Vector2;
  57854. /**
  57855. * 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))
  57856. */
  57857. centerPosition: Vector2;
  57858. /**
  57859. * Creates a new instance ChromaticAberrationPostProcess
  57860. * @param name The name of the effect.
  57861. * @param screenWidth The width of the screen to apply the effect on.
  57862. * @param screenHeight The height of the screen to apply the effect on.
  57863. * @param options The required width/height ratio to downsize to before computing the render pass.
  57864. * @param camera The camera to apply the render pass to.
  57865. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57866. * @param engine The engine which the post process will be applied. (default: current engine)
  57867. * @param reusable If the post process can be reused on the same frame. (default: false)
  57868. * @param textureType Type of textures used when performing the post process. (default: 0)
  57869. * @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)
  57870. */
  57871. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57872. }
  57873. }
  57874. declare module BABYLON {
  57875. /** @hidden */
  57876. export var circleOfConfusionPixelShader: {
  57877. name: string;
  57878. shader: string;
  57879. };
  57880. }
  57881. declare module BABYLON {
  57882. /**
  57883. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  57884. */
  57885. export class CircleOfConfusionPostProcess extends PostProcess {
  57886. /**
  57887. * 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.
  57888. */
  57889. lensSize: number;
  57890. /**
  57891. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  57892. */
  57893. fStop: number;
  57894. /**
  57895. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  57896. */
  57897. focusDistance: number;
  57898. /**
  57899. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  57900. */
  57901. focalLength: number;
  57902. private _depthTexture;
  57903. /**
  57904. * Creates a new instance CircleOfConfusionPostProcess
  57905. * @param name The name of the effect.
  57906. * @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.
  57907. * @param options The required width/height ratio to downsize to before computing the render pass.
  57908. * @param camera The camera to apply the render pass to.
  57909. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57910. * @param engine The engine which the post process will be applied. (default: current engine)
  57911. * @param reusable If the post process can be reused on the same frame. (default: false)
  57912. * @param textureType Type of textures used when performing the post process. (default: 0)
  57913. * @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)
  57914. */
  57915. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57916. /**
  57917. * 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.
  57918. */
  57919. depthTexture: RenderTargetTexture;
  57920. }
  57921. }
  57922. declare module BABYLON {
  57923. /** @hidden */
  57924. export var colorCorrectionPixelShader: {
  57925. name: string;
  57926. shader: string;
  57927. };
  57928. }
  57929. declare module BABYLON {
  57930. /**
  57931. *
  57932. * This post-process allows the modification of rendered colors by using
  57933. * a 'look-up table' (LUT). This effect is also called Color Grading.
  57934. *
  57935. * The object needs to be provided an url to a texture containing the color
  57936. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  57937. * Use an image editing software to tweak the LUT to match your needs.
  57938. *
  57939. * For an example of a color LUT, see here:
  57940. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  57941. * For explanations on color grading, see here:
  57942. * @see http://udn.epicgames.com/Three/ColorGrading.html
  57943. *
  57944. */
  57945. export class ColorCorrectionPostProcess extends PostProcess {
  57946. private _colorTableTexture;
  57947. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57948. }
  57949. }
  57950. declare module BABYLON {
  57951. /** @hidden */
  57952. export var convolutionPixelShader: {
  57953. name: string;
  57954. shader: string;
  57955. };
  57956. }
  57957. declare module BABYLON {
  57958. /**
  57959. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  57960. * input texture to perform effects such as edge detection or sharpening
  57961. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  57962. */
  57963. export class ConvolutionPostProcess extends PostProcess {
  57964. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  57965. kernel: number[];
  57966. /**
  57967. * Creates a new instance ConvolutionPostProcess
  57968. * @param name The name of the effect.
  57969. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  57970. * @param options The required width/height ratio to downsize to before computing the render pass.
  57971. * @param camera The camera to apply the render pass to.
  57972. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57973. * @param engine The engine which the post process will be applied. (default: current engine)
  57974. * @param reusable If the post process can be reused on the same frame. (default: false)
  57975. * @param textureType Type of textures used when performing the post process. (default: 0)
  57976. */
  57977. constructor(name: string,
  57978. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  57979. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57980. /**
  57981. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57982. */
  57983. static EdgeDetect0Kernel: number[];
  57984. /**
  57985. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57986. */
  57987. static EdgeDetect1Kernel: number[];
  57988. /**
  57989. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57990. */
  57991. static EdgeDetect2Kernel: number[];
  57992. /**
  57993. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57994. */
  57995. static SharpenKernel: number[];
  57996. /**
  57997. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57998. */
  57999. static EmbossKernel: number[];
  58000. /**
  58001. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58002. */
  58003. static GaussianKernel: number[];
  58004. }
  58005. }
  58006. declare module BABYLON {
  58007. /**
  58008. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  58009. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  58010. * based on samples that have a large difference in distance than the center pixel.
  58011. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  58012. */
  58013. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  58014. direction: Vector2;
  58015. /**
  58016. * Creates a new instance CircleOfConfusionPostProcess
  58017. * @param name The name of the effect.
  58018. * @param scene The scene the effect belongs to.
  58019. * @param direction The direction the blur should be applied.
  58020. * @param kernel The size of the kernel used to blur.
  58021. * @param options The required width/height ratio to downsize to before computing the render pass.
  58022. * @param camera The camera to apply the render pass to.
  58023. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  58024. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  58025. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58026. * @param engine The engine which the post process will be applied. (default: current engine)
  58027. * @param reusable If the post process can be reused on the same frame. (default: false)
  58028. * @param textureType Type of textures used when performing the post process. (default: 0)
  58029. * @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)
  58030. */
  58031. 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);
  58032. }
  58033. }
  58034. declare module BABYLON {
  58035. /** @hidden */
  58036. export var depthOfFieldMergePixelShader: {
  58037. name: string;
  58038. shader: string;
  58039. };
  58040. }
  58041. declare module BABYLON {
  58042. /**
  58043. * Options to be set when merging outputs from the default pipeline.
  58044. */
  58045. export class DepthOfFieldMergePostProcessOptions {
  58046. /**
  58047. * The original image to merge on top of
  58048. */
  58049. originalFromInput: PostProcess;
  58050. /**
  58051. * Parameters to perform the merge of the depth of field effect
  58052. */
  58053. depthOfField?: {
  58054. circleOfConfusion: PostProcess;
  58055. blurSteps: Array<PostProcess>;
  58056. };
  58057. /**
  58058. * Parameters to perform the merge of bloom effect
  58059. */
  58060. bloom?: {
  58061. blurred: PostProcess;
  58062. weight: number;
  58063. };
  58064. }
  58065. /**
  58066. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58067. */
  58068. export class DepthOfFieldMergePostProcess extends PostProcess {
  58069. private blurSteps;
  58070. /**
  58071. * Creates a new instance of DepthOfFieldMergePostProcess
  58072. * @param name The name of the effect.
  58073. * @param originalFromInput Post process which's input will be used for the merge.
  58074. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  58075. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  58076. * @param options The required width/height ratio to downsize to before computing the render pass.
  58077. * @param camera The camera to apply the render pass to.
  58078. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58079. * @param engine The engine which the post process will be applied. (default: current engine)
  58080. * @param reusable If the post process can be reused on the same frame. (default: false)
  58081. * @param textureType Type of textures used when performing the post process. (default: 0)
  58082. * @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)
  58083. */
  58084. 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);
  58085. /**
  58086. * Updates the effect with the current post process compile time values and recompiles the shader.
  58087. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  58088. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  58089. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  58090. * @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
  58091. * @param onCompiled Called when the shader has been compiled.
  58092. * @param onError Called if there is an error when compiling a shader.
  58093. */
  58094. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  58095. }
  58096. }
  58097. declare module BABYLON {
  58098. /**
  58099. * Specifies the level of max blur that should be applied when using the depth of field effect
  58100. */
  58101. export enum DepthOfFieldEffectBlurLevel {
  58102. /**
  58103. * Subtle blur
  58104. */
  58105. Low = 0,
  58106. /**
  58107. * Medium blur
  58108. */
  58109. Medium = 1,
  58110. /**
  58111. * Large blur
  58112. */
  58113. High = 2
  58114. }
  58115. /**
  58116. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  58117. */
  58118. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  58119. private _circleOfConfusion;
  58120. /**
  58121. * @hidden Internal, blurs from high to low
  58122. */
  58123. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  58124. private _depthOfFieldBlurY;
  58125. private _dofMerge;
  58126. /**
  58127. * @hidden Internal post processes in depth of field effect
  58128. */
  58129. _effects: Array<PostProcess>;
  58130. /**
  58131. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  58132. */
  58133. focalLength: number;
  58134. /**
  58135. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58136. */
  58137. fStop: number;
  58138. /**
  58139. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58140. */
  58141. focusDistance: number;
  58142. /**
  58143. * 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.
  58144. */
  58145. lensSize: number;
  58146. /**
  58147. * Creates a new instance DepthOfFieldEffect
  58148. * @param scene The scene the effect belongs to.
  58149. * @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.
  58150. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58151. * @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)
  58152. */
  58153. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  58154. /**
  58155. * Get the current class name of the current effet
  58156. * @returns "DepthOfFieldEffect"
  58157. */
  58158. getClassName(): string;
  58159. /**
  58160. * 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.
  58161. */
  58162. depthTexture: RenderTargetTexture;
  58163. /**
  58164. * Disposes each of the internal effects for a given camera.
  58165. * @param camera The camera to dispose the effect on.
  58166. */
  58167. disposeEffects(camera: Camera): void;
  58168. /**
  58169. * @hidden Internal
  58170. */
  58171. _updateEffects(): void;
  58172. /**
  58173. * Internal
  58174. * @returns if all the contained post processes are ready.
  58175. * @hidden
  58176. */
  58177. _isReady(): boolean;
  58178. }
  58179. }
  58180. declare module BABYLON {
  58181. /** @hidden */
  58182. export var displayPassPixelShader: {
  58183. name: string;
  58184. shader: string;
  58185. };
  58186. }
  58187. declare module BABYLON {
  58188. /**
  58189. * DisplayPassPostProcess which produces an output the same as it's input
  58190. */
  58191. export class DisplayPassPostProcess extends PostProcess {
  58192. /**
  58193. * Creates the DisplayPassPostProcess
  58194. * @param name The name of the effect.
  58195. * @param options The required width/height ratio to downsize to before computing the render pass.
  58196. * @param camera The camera to apply the render pass to.
  58197. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58198. * @param engine The engine which the post process will be applied. (default: current engine)
  58199. * @param reusable If the post process can be reused on the same frame. (default: false)
  58200. */
  58201. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58202. }
  58203. }
  58204. declare module BABYLON {
  58205. /** @hidden */
  58206. export var filterPixelShader: {
  58207. name: string;
  58208. shader: string;
  58209. };
  58210. }
  58211. declare module BABYLON {
  58212. /**
  58213. * Applies a kernel filter to the image
  58214. */
  58215. export class FilterPostProcess extends PostProcess {
  58216. /** The matrix to be applied to the image */
  58217. kernelMatrix: Matrix;
  58218. /**
  58219. *
  58220. * @param name The name of the effect.
  58221. * @param kernelMatrix The matrix to be applied to the image
  58222. * @param options The required width/height ratio to downsize to before computing the render pass.
  58223. * @param camera The camera to apply the render pass to.
  58224. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58225. * @param engine The engine which the post process will be applied. (default: current engine)
  58226. * @param reusable If the post process can be reused on the same frame. (default: false)
  58227. */
  58228. constructor(name: string,
  58229. /** The matrix to be applied to the image */
  58230. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58231. }
  58232. }
  58233. declare module BABYLON {
  58234. /** @hidden */
  58235. export var fxaaPixelShader: {
  58236. name: string;
  58237. shader: string;
  58238. };
  58239. }
  58240. declare module BABYLON {
  58241. /** @hidden */
  58242. export var fxaaVertexShader: {
  58243. name: string;
  58244. shader: string;
  58245. };
  58246. }
  58247. declare module BABYLON {
  58248. /**
  58249. * Fxaa post process
  58250. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  58251. */
  58252. export class FxaaPostProcess extends PostProcess {
  58253. /** @hidden */
  58254. texelWidth: number;
  58255. /** @hidden */
  58256. texelHeight: number;
  58257. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58258. private _getDefines;
  58259. }
  58260. }
  58261. declare module BABYLON {
  58262. /** @hidden */
  58263. export var grainPixelShader: {
  58264. name: string;
  58265. shader: string;
  58266. };
  58267. }
  58268. declare module BABYLON {
  58269. /**
  58270. * The GrainPostProcess adds noise to the image at mid luminance levels
  58271. */
  58272. export class GrainPostProcess extends PostProcess {
  58273. /**
  58274. * The intensity of the grain added (default: 30)
  58275. */
  58276. intensity: number;
  58277. /**
  58278. * If the grain should be randomized on every frame
  58279. */
  58280. animated: boolean;
  58281. /**
  58282. * Creates a new instance of @see GrainPostProcess
  58283. * @param name The name of the effect.
  58284. * @param options The required width/height ratio to downsize to before computing the render pass.
  58285. * @param camera The camera to apply the render pass to.
  58286. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58287. * @param engine The engine which the post process will be applied. (default: current engine)
  58288. * @param reusable If the post process can be reused on the same frame. (default: false)
  58289. * @param textureType Type of textures used when performing the post process. (default: 0)
  58290. * @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)
  58291. */
  58292. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58293. }
  58294. }
  58295. declare module BABYLON {
  58296. /** @hidden */
  58297. export var highlightsPixelShader: {
  58298. name: string;
  58299. shader: string;
  58300. };
  58301. }
  58302. declare module BABYLON {
  58303. /**
  58304. * Extracts highlights from the image
  58305. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58306. */
  58307. export class HighlightsPostProcess extends PostProcess {
  58308. /**
  58309. * Extracts highlights from the image
  58310. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58311. * @param name The name of the effect.
  58312. * @param options The required width/height ratio to downsize to before computing the render pass.
  58313. * @param camera The camera to apply the render pass to.
  58314. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58315. * @param engine The engine which the post process will be applied. (default: current engine)
  58316. * @param reusable If the post process can be reused on the same frame. (default: false)
  58317. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  58318. */
  58319. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58320. }
  58321. }
  58322. declare module BABYLON {
  58323. /** @hidden */
  58324. export var mrtFragmentDeclaration: {
  58325. name: string;
  58326. shader: string;
  58327. };
  58328. }
  58329. declare module BABYLON {
  58330. /** @hidden */
  58331. export var geometryPixelShader: {
  58332. name: string;
  58333. shader: string;
  58334. };
  58335. }
  58336. declare module BABYLON {
  58337. /** @hidden */
  58338. export var geometryVertexShader: {
  58339. name: string;
  58340. shader: string;
  58341. };
  58342. }
  58343. declare module BABYLON {
  58344. /** @hidden */
  58345. interface ISavedTransformationMatrix {
  58346. world: Matrix;
  58347. viewProjection: Matrix;
  58348. }
  58349. /**
  58350. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  58351. */
  58352. export class GeometryBufferRenderer {
  58353. /**
  58354. * Constant used to retrieve the position texture index in the G-Buffer textures array
  58355. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  58356. */
  58357. static readonly POSITION_TEXTURE_TYPE: number;
  58358. /**
  58359. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  58360. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  58361. */
  58362. static readonly VELOCITY_TEXTURE_TYPE: number;
  58363. /**
  58364. * Dictionary used to store the previous transformation matrices of each rendered mesh
  58365. * in order to compute objects velocities when enableVelocity is set to "true"
  58366. * @hidden
  58367. */
  58368. _previousTransformationMatrices: {
  58369. [index: number]: ISavedTransformationMatrix;
  58370. };
  58371. /**
  58372. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  58373. * in order to compute objects velocities when enableVelocity is set to "true"
  58374. * @hidden
  58375. */
  58376. _previousBonesTransformationMatrices: {
  58377. [index: number]: Float32Array;
  58378. };
  58379. /**
  58380. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  58381. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  58382. */
  58383. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  58384. private _scene;
  58385. private _multiRenderTarget;
  58386. private _ratio;
  58387. private _enablePosition;
  58388. private _enableVelocity;
  58389. private _positionIndex;
  58390. private _velocityIndex;
  58391. protected _effect: Effect;
  58392. protected _cachedDefines: string;
  58393. /**
  58394. * Set the render list (meshes to be rendered) used in the G buffer.
  58395. */
  58396. renderList: Mesh[];
  58397. /**
  58398. * Gets wether or not G buffer are supported by the running hardware.
  58399. * This requires draw buffer supports
  58400. */
  58401. readonly isSupported: boolean;
  58402. /**
  58403. * Returns the index of the given texture type in the G-Buffer textures array
  58404. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  58405. * @returns the index of the given texture type in the G-Buffer textures array
  58406. */
  58407. getTextureIndex(textureType: number): number;
  58408. /**
  58409. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  58410. */
  58411. /**
  58412. * Sets whether or not objects positions are enabled for the G buffer.
  58413. */
  58414. enablePosition: boolean;
  58415. /**
  58416. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  58417. */
  58418. /**
  58419. * Sets wether or not objects velocities are enabled for the G buffer.
  58420. */
  58421. enableVelocity: boolean;
  58422. /**
  58423. * Gets the scene associated with the buffer.
  58424. */
  58425. readonly scene: Scene;
  58426. /**
  58427. * Gets the ratio used by the buffer during its creation.
  58428. * How big is the buffer related to the main canvas.
  58429. */
  58430. readonly ratio: number;
  58431. /** @hidden */
  58432. static _SceneComponentInitialization: (scene: Scene) => void;
  58433. /**
  58434. * Creates a new G Buffer for the scene
  58435. * @param scene The scene the buffer belongs to
  58436. * @param ratio How big is the buffer related to the main canvas.
  58437. */
  58438. constructor(scene: Scene, ratio?: number);
  58439. /**
  58440. * Checks wether everything is ready to render a submesh to the G buffer.
  58441. * @param subMesh the submesh to check readiness for
  58442. * @param useInstances is the mesh drawn using instance or not
  58443. * @returns true if ready otherwise false
  58444. */
  58445. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58446. /**
  58447. * Gets the current underlying G Buffer.
  58448. * @returns the buffer
  58449. */
  58450. getGBuffer(): MultiRenderTarget;
  58451. /**
  58452. * Gets the number of samples used to render the buffer (anti aliasing).
  58453. */
  58454. /**
  58455. * Sets the number of samples used to render the buffer (anti aliasing).
  58456. */
  58457. samples: number;
  58458. /**
  58459. * Disposes the renderer and frees up associated resources.
  58460. */
  58461. dispose(): void;
  58462. protected _createRenderTargets(): void;
  58463. private _copyBonesTransformationMatrices;
  58464. }
  58465. }
  58466. declare module BABYLON {
  58467. interface Scene {
  58468. /** @hidden (Backing field) */
  58469. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58470. /**
  58471. * Gets or Sets the current geometry buffer associated to the scene.
  58472. */
  58473. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58474. /**
  58475. * Enables a GeometryBufferRender and associates it with the scene
  58476. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  58477. * @returns the GeometryBufferRenderer
  58478. */
  58479. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  58480. /**
  58481. * Disables the GeometryBufferRender associated with the scene
  58482. */
  58483. disableGeometryBufferRenderer(): void;
  58484. }
  58485. /**
  58486. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  58487. * in several rendering techniques.
  58488. */
  58489. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  58490. /**
  58491. * The component name helpful to identify the component in the list of scene components.
  58492. */
  58493. readonly name: string;
  58494. /**
  58495. * The scene the component belongs to.
  58496. */
  58497. scene: Scene;
  58498. /**
  58499. * Creates a new instance of the component for the given scene
  58500. * @param scene Defines the scene to register the component in
  58501. */
  58502. constructor(scene: Scene);
  58503. /**
  58504. * Registers the component in a given scene
  58505. */
  58506. register(): void;
  58507. /**
  58508. * Rebuilds the elements related to this component in case of
  58509. * context lost for instance.
  58510. */
  58511. rebuild(): void;
  58512. /**
  58513. * Disposes the component and the associated ressources
  58514. */
  58515. dispose(): void;
  58516. private _gatherRenderTargets;
  58517. }
  58518. }
  58519. declare module BABYLON {
  58520. /** @hidden */
  58521. export var motionBlurPixelShader: {
  58522. name: string;
  58523. shader: string;
  58524. };
  58525. }
  58526. declare module BABYLON {
  58527. /**
  58528. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  58529. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  58530. * As an example, all you have to do is to create the post-process:
  58531. * var mb = new BABYLON.MotionBlurPostProcess(
  58532. * 'mb', // The name of the effect.
  58533. * scene, // The scene containing the objects to blur according to their velocity.
  58534. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  58535. * camera // The camera to apply the render pass to.
  58536. * );
  58537. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  58538. */
  58539. export class MotionBlurPostProcess extends PostProcess {
  58540. /**
  58541. * Defines how much the image is blurred by the movement. Default value is equal to 1
  58542. */
  58543. motionStrength: number;
  58544. /**
  58545. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  58546. */
  58547. /**
  58548. * Sets the number of iterations to be used for motion blur quality
  58549. */
  58550. motionBlurSamples: number;
  58551. private _motionBlurSamples;
  58552. private _geometryBufferRenderer;
  58553. /**
  58554. * Creates a new instance MotionBlurPostProcess
  58555. * @param name The name of the effect.
  58556. * @param scene The scene containing the objects to blur according to their velocity.
  58557. * @param options The required width/height ratio to downsize to before computing the render pass.
  58558. * @param camera The camera to apply the render pass to.
  58559. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58560. * @param engine The engine which the post process will be applied. (default: current engine)
  58561. * @param reusable If the post process can be reused on the same frame. (default: false)
  58562. * @param textureType Type of textures used when performing the post process. (default: 0)
  58563. * @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)
  58564. */
  58565. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58566. /**
  58567. * Excludes the given skinned mesh from computing bones velocities.
  58568. * 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.
  58569. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  58570. */
  58571. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58572. /**
  58573. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  58574. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  58575. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  58576. */
  58577. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58578. /**
  58579. * Disposes the post process.
  58580. * @param camera The camera to dispose the post process on.
  58581. */
  58582. dispose(camera?: Camera): void;
  58583. }
  58584. }
  58585. declare module BABYLON {
  58586. /** @hidden */
  58587. export var refractionPixelShader: {
  58588. name: string;
  58589. shader: string;
  58590. };
  58591. }
  58592. declare module BABYLON {
  58593. /**
  58594. * Post process which applies a refractin texture
  58595. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58596. */
  58597. export class RefractionPostProcess extends PostProcess {
  58598. /** the base color of the refraction (used to taint the rendering) */
  58599. color: Color3;
  58600. /** simulated refraction depth */
  58601. depth: number;
  58602. /** the coefficient of the base color (0 to remove base color tainting) */
  58603. colorLevel: number;
  58604. private _refTexture;
  58605. private _ownRefractionTexture;
  58606. /**
  58607. * Gets or sets the refraction texture
  58608. * Please note that you are responsible for disposing the texture if you set it manually
  58609. */
  58610. refractionTexture: Texture;
  58611. /**
  58612. * Initializes the RefractionPostProcess
  58613. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58614. * @param name The name of the effect.
  58615. * @param refractionTextureUrl Url of the refraction texture to use
  58616. * @param color the base color of the refraction (used to taint the rendering)
  58617. * @param depth simulated refraction depth
  58618. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  58619. * @param camera The camera to apply the render pass to.
  58620. * @param options The required width/height ratio to downsize to before computing the render pass.
  58621. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58622. * @param engine The engine which the post process will be applied. (default: current engine)
  58623. * @param reusable If the post process can be reused on the same frame. (default: false)
  58624. */
  58625. constructor(name: string, refractionTextureUrl: string,
  58626. /** the base color of the refraction (used to taint the rendering) */
  58627. color: Color3,
  58628. /** simulated refraction depth */
  58629. depth: number,
  58630. /** the coefficient of the base color (0 to remove base color tainting) */
  58631. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58632. /**
  58633. * Disposes of the post process
  58634. * @param camera Camera to dispose post process on
  58635. */
  58636. dispose(camera: Camera): void;
  58637. }
  58638. }
  58639. declare module BABYLON {
  58640. /** @hidden */
  58641. export var sharpenPixelShader: {
  58642. name: string;
  58643. shader: string;
  58644. };
  58645. }
  58646. declare module BABYLON {
  58647. /**
  58648. * The SharpenPostProcess applies a sharpen kernel to every pixel
  58649. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58650. */
  58651. export class SharpenPostProcess extends PostProcess {
  58652. /**
  58653. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  58654. */
  58655. colorAmount: number;
  58656. /**
  58657. * How much sharpness should be applied (default: 0.3)
  58658. */
  58659. edgeAmount: number;
  58660. /**
  58661. * Creates a new instance ConvolutionPostProcess
  58662. * @param name The name of the effect.
  58663. * @param options The required width/height ratio to downsize to before computing the render pass.
  58664. * @param camera The camera to apply the render pass to.
  58665. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58666. * @param engine The engine which the post process will be applied. (default: current engine)
  58667. * @param reusable If the post process can be reused on the same frame. (default: false)
  58668. * @param textureType Type of textures used when performing the post process. (default: 0)
  58669. * @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)
  58670. */
  58671. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58672. }
  58673. }
  58674. declare module BABYLON {
  58675. /**
  58676. * PostProcessRenderPipeline
  58677. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58678. */
  58679. export class PostProcessRenderPipeline {
  58680. private engine;
  58681. private _renderEffects;
  58682. private _renderEffectsForIsolatedPass;
  58683. /**
  58684. * List of inspectable custom properties (used by the Inspector)
  58685. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  58686. */
  58687. inspectableCustomProperties: IInspectable[];
  58688. /**
  58689. * @hidden
  58690. */
  58691. protected _cameras: Camera[];
  58692. /** @hidden */
  58693. _name: string;
  58694. /**
  58695. * Gets pipeline name
  58696. */
  58697. readonly name: string;
  58698. /**
  58699. * Initializes a PostProcessRenderPipeline
  58700. * @param engine engine to add the pipeline to
  58701. * @param name name of the pipeline
  58702. */
  58703. constructor(engine: Engine, name: string);
  58704. /**
  58705. * Gets the class name
  58706. * @returns "PostProcessRenderPipeline"
  58707. */
  58708. getClassName(): string;
  58709. /**
  58710. * If all the render effects in the pipeline are supported
  58711. */
  58712. readonly isSupported: boolean;
  58713. /**
  58714. * Adds an effect to the pipeline
  58715. * @param renderEffect the effect to add
  58716. */
  58717. addEffect(renderEffect: PostProcessRenderEffect): void;
  58718. /** @hidden */
  58719. _rebuild(): void;
  58720. /** @hidden */
  58721. _enableEffect(renderEffectName: string, cameras: Camera): void;
  58722. /** @hidden */
  58723. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  58724. /** @hidden */
  58725. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58726. /** @hidden */
  58727. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58728. /** @hidden */
  58729. _attachCameras(cameras: Camera, unique: boolean): void;
  58730. /** @hidden */
  58731. _attachCameras(cameras: Camera[], unique: boolean): void;
  58732. /** @hidden */
  58733. _detachCameras(cameras: Camera): void;
  58734. /** @hidden */
  58735. _detachCameras(cameras: Nullable<Camera[]>): void;
  58736. /** @hidden */
  58737. _update(): void;
  58738. /** @hidden */
  58739. _reset(): void;
  58740. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  58741. /**
  58742. * Disposes of the pipeline
  58743. */
  58744. dispose(): void;
  58745. }
  58746. }
  58747. declare module BABYLON {
  58748. /**
  58749. * PostProcessRenderPipelineManager class
  58750. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58751. */
  58752. export class PostProcessRenderPipelineManager {
  58753. private _renderPipelines;
  58754. /**
  58755. * Initializes a PostProcessRenderPipelineManager
  58756. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58757. */
  58758. constructor();
  58759. /**
  58760. * Gets the list of supported render pipelines
  58761. */
  58762. readonly supportedPipelines: PostProcessRenderPipeline[];
  58763. /**
  58764. * Adds a pipeline to the manager
  58765. * @param renderPipeline The pipeline to add
  58766. */
  58767. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  58768. /**
  58769. * Attaches a camera to the pipeline
  58770. * @param renderPipelineName The name of the pipeline to attach to
  58771. * @param cameras the camera to attach
  58772. * @param unique if the camera can be attached multiple times to the pipeline
  58773. */
  58774. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  58775. /**
  58776. * Detaches a camera from the pipeline
  58777. * @param renderPipelineName The name of the pipeline to detach from
  58778. * @param cameras the camera to detach
  58779. */
  58780. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  58781. /**
  58782. * Enables an effect by name on a pipeline
  58783. * @param renderPipelineName the name of the pipeline to enable the effect in
  58784. * @param renderEffectName the name of the effect to enable
  58785. * @param cameras the cameras that the effect should be enabled on
  58786. */
  58787. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58788. /**
  58789. * Disables an effect by name on a pipeline
  58790. * @param renderPipelineName the name of the pipeline to disable the effect in
  58791. * @param renderEffectName the name of the effect to disable
  58792. * @param cameras the cameras that the effect should be disabled on
  58793. */
  58794. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58795. /**
  58796. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  58797. */
  58798. update(): void;
  58799. /** @hidden */
  58800. _rebuild(): void;
  58801. /**
  58802. * Disposes of the manager and pipelines
  58803. */
  58804. dispose(): void;
  58805. }
  58806. }
  58807. declare module BABYLON {
  58808. interface Scene {
  58809. /** @hidden (Backing field) */
  58810. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58811. /**
  58812. * Gets the postprocess render pipeline manager
  58813. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58814. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  58815. */
  58816. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58817. }
  58818. /**
  58819. * Defines the Render Pipeline scene component responsible to rendering pipelines
  58820. */
  58821. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  58822. /**
  58823. * The component name helpfull to identify the component in the list of scene components.
  58824. */
  58825. readonly name: string;
  58826. /**
  58827. * The scene the component belongs to.
  58828. */
  58829. scene: Scene;
  58830. /**
  58831. * Creates a new instance of the component for the given scene
  58832. * @param scene Defines the scene to register the component in
  58833. */
  58834. constructor(scene: Scene);
  58835. /**
  58836. * Registers the component in a given scene
  58837. */
  58838. register(): void;
  58839. /**
  58840. * Rebuilds the elements related to this component in case of
  58841. * context lost for instance.
  58842. */
  58843. rebuild(): void;
  58844. /**
  58845. * Disposes the component and the associated ressources
  58846. */
  58847. dispose(): void;
  58848. private _gatherRenderTargets;
  58849. }
  58850. }
  58851. declare module BABYLON {
  58852. /**
  58853. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  58854. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  58855. */
  58856. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  58857. private _scene;
  58858. private _camerasToBeAttached;
  58859. /**
  58860. * ID of the sharpen post process,
  58861. */
  58862. private readonly SharpenPostProcessId;
  58863. /**
  58864. * @ignore
  58865. * ID of the image processing post process;
  58866. */
  58867. readonly ImageProcessingPostProcessId: string;
  58868. /**
  58869. * @ignore
  58870. * ID of the Fast Approximate Anti-Aliasing post process;
  58871. */
  58872. readonly FxaaPostProcessId: string;
  58873. /**
  58874. * ID of the chromatic aberration post process,
  58875. */
  58876. private readonly ChromaticAberrationPostProcessId;
  58877. /**
  58878. * ID of the grain post process
  58879. */
  58880. private readonly GrainPostProcessId;
  58881. /**
  58882. * Sharpen post process which will apply a sharpen convolution to enhance edges
  58883. */
  58884. sharpen: SharpenPostProcess;
  58885. private _sharpenEffect;
  58886. private bloom;
  58887. /**
  58888. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  58889. */
  58890. depthOfField: DepthOfFieldEffect;
  58891. /**
  58892. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  58893. */
  58894. fxaa: FxaaPostProcess;
  58895. /**
  58896. * Image post processing pass used to perform operations such as tone mapping or color grading.
  58897. */
  58898. imageProcessing: ImageProcessingPostProcess;
  58899. /**
  58900. * Chromatic aberration post process which will shift rgb colors in the image
  58901. */
  58902. chromaticAberration: ChromaticAberrationPostProcess;
  58903. private _chromaticAberrationEffect;
  58904. /**
  58905. * Grain post process which add noise to the image
  58906. */
  58907. grain: GrainPostProcess;
  58908. private _grainEffect;
  58909. /**
  58910. * Glow post process which adds a glow to emissive areas of the image
  58911. */
  58912. private _glowLayer;
  58913. /**
  58914. * Animations which can be used to tweak settings over a period of time
  58915. */
  58916. animations: Animation[];
  58917. private _imageProcessingConfigurationObserver;
  58918. private _sharpenEnabled;
  58919. private _bloomEnabled;
  58920. private _depthOfFieldEnabled;
  58921. private _depthOfFieldBlurLevel;
  58922. private _fxaaEnabled;
  58923. private _imageProcessingEnabled;
  58924. private _defaultPipelineTextureType;
  58925. private _bloomScale;
  58926. private _chromaticAberrationEnabled;
  58927. private _grainEnabled;
  58928. private _buildAllowed;
  58929. /**
  58930. * Gets active scene
  58931. */
  58932. readonly scene: Scene;
  58933. /**
  58934. * Enable or disable the sharpen process from the pipeline
  58935. */
  58936. sharpenEnabled: boolean;
  58937. private _resizeObserver;
  58938. private _hardwareScaleLevel;
  58939. private _bloomKernel;
  58940. /**
  58941. * Specifies the size of the bloom blur kernel, relative to the final output size
  58942. */
  58943. bloomKernel: number;
  58944. /**
  58945. * Specifies the weight of the bloom in the final rendering
  58946. */
  58947. private _bloomWeight;
  58948. /**
  58949. * Specifies the luma threshold for the area that will be blurred by the bloom
  58950. */
  58951. private _bloomThreshold;
  58952. private _hdr;
  58953. /**
  58954. * The strength of the bloom.
  58955. */
  58956. bloomWeight: number;
  58957. /**
  58958. * The strength of the bloom.
  58959. */
  58960. bloomThreshold: number;
  58961. /**
  58962. * The scale of the bloom, lower value will provide better performance.
  58963. */
  58964. bloomScale: number;
  58965. /**
  58966. * Enable or disable the bloom from the pipeline
  58967. */
  58968. bloomEnabled: boolean;
  58969. private _rebuildBloom;
  58970. /**
  58971. * If the depth of field is enabled.
  58972. */
  58973. depthOfFieldEnabled: boolean;
  58974. /**
  58975. * Blur level of the depth of field effect. (Higher blur will effect performance)
  58976. */
  58977. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  58978. /**
  58979. * If the anti aliasing is enabled.
  58980. */
  58981. fxaaEnabled: boolean;
  58982. private _samples;
  58983. /**
  58984. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  58985. */
  58986. samples: number;
  58987. /**
  58988. * If image processing is enabled.
  58989. */
  58990. imageProcessingEnabled: boolean;
  58991. /**
  58992. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  58993. */
  58994. glowLayerEnabled: boolean;
  58995. /**
  58996. * Gets the glow layer (or null if not defined)
  58997. */
  58998. readonly glowLayer: Nullable<GlowLayer>;
  58999. /**
  59000. * Enable or disable the chromaticAberration process from the pipeline
  59001. */
  59002. chromaticAberrationEnabled: boolean;
  59003. /**
  59004. * Enable or disable the grain process from the pipeline
  59005. */
  59006. grainEnabled: boolean;
  59007. /**
  59008. * @constructor
  59009. * @param name - The rendering pipeline name (default: "")
  59010. * @param hdr - If high dynamic range textures should be used (default: true)
  59011. * @param scene - The scene linked to this pipeline (default: the last created scene)
  59012. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  59013. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  59014. */
  59015. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  59016. /**
  59017. * Get the class name
  59018. * @returns "DefaultRenderingPipeline"
  59019. */
  59020. getClassName(): string;
  59021. /**
  59022. * Force the compilation of the entire pipeline.
  59023. */
  59024. prepare(): void;
  59025. private _hasCleared;
  59026. private _prevPostProcess;
  59027. private _prevPrevPostProcess;
  59028. private _setAutoClearAndTextureSharing;
  59029. private _depthOfFieldSceneObserver;
  59030. private _buildPipeline;
  59031. private _disposePostProcesses;
  59032. /**
  59033. * Adds a camera to the pipeline
  59034. * @param camera the camera to be added
  59035. */
  59036. addCamera(camera: Camera): void;
  59037. /**
  59038. * Removes a camera from the pipeline
  59039. * @param camera the camera to remove
  59040. */
  59041. removeCamera(camera: Camera): void;
  59042. /**
  59043. * Dispose of the pipeline and stop all post processes
  59044. */
  59045. dispose(): void;
  59046. /**
  59047. * Serialize the rendering pipeline (Used when exporting)
  59048. * @returns the serialized object
  59049. */
  59050. serialize(): any;
  59051. /**
  59052. * Parse the serialized pipeline
  59053. * @param source Source pipeline.
  59054. * @param scene The scene to load the pipeline to.
  59055. * @param rootUrl The URL of the serialized pipeline.
  59056. * @returns An instantiated pipeline from the serialized object.
  59057. */
  59058. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  59059. }
  59060. }
  59061. declare module BABYLON {
  59062. /** @hidden */
  59063. export var lensHighlightsPixelShader: {
  59064. name: string;
  59065. shader: string;
  59066. };
  59067. }
  59068. declare module BABYLON {
  59069. /** @hidden */
  59070. export var depthOfFieldPixelShader: {
  59071. name: string;
  59072. shader: string;
  59073. };
  59074. }
  59075. declare module BABYLON {
  59076. /**
  59077. * BABYLON.JS Chromatic Aberration GLSL Shader
  59078. * Author: Olivier Guyot
  59079. * Separates very slightly R, G and B colors on the edges of the screen
  59080. * Inspired by Francois Tarlier & Martins Upitis
  59081. */
  59082. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  59083. /**
  59084. * @ignore
  59085. * The chromatic aberration PostProcess id in the pipeline
  59086. */
  59087. LensChromaticAberrationEffect: string;
  59088. /**
  59089. * @ignore
  59090. * The highlights enhancing PostProcess id in the pipeline
  59091. */
  59092. HighlightsEnhancingEffect: string;
  59093. /**
  59094. * @ignore
  59095. * The depth-of-field PostProcess id in the pipeline
  59096. */
  59097. LensDepthOfFieldEffect: string;
  59098. private _scene;
  59099. private _depthTexture;
  59100. private _grainTexture;
  59101. private _chromaticAberrationPostProcess;
  59102. private _highlightsPostProcess;
  59103. private _depthOfFieldPostProcess;
  59104. private _edgeBlur;
  59105. private _grainAmount;
  59106. private _chromaticAberration;
  59107. private _distortion;
  59108. private _highlightsGain;
  59109. private _highlightsThreshold;
  59110. private _dofDistance;
  59111. private _dofAperture;
  59112. private _dofDarken;
  59113. private _dofPentagon;
  59114. private _blurNoise;
  59115. /**
  59116. * @constructor
  59117. *
  59118. * Effect parameters are as follow:
  59119. * {
  59120. * chromatic_aberration: number; // from 0 to x (1 for realism)
  59121. * edge_blur: number; // from 0 to x (1 for realism)
  59122. * distortion: number; // from 0 to x (1 for realism)
  59123. * grain_amount: number; // from 0 to 1
  59124. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  59125. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  59126. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  59127. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  59128. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  59129. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  59130. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  59131. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  59132. * }
  59133. * Note: if an effect parameter is unset, effect is disabled
  59134. *
  59135. * @param name The rendering pipeline name
  59136. * @param parameters - An object containing all parameters (see above)
  59137. * @param scene The scene linked to this pipeline
  59138. * @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)
  59139. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59140. */
  59141. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  59142. /**
  59143. * Get the class name
  59144. * @returns "LensRenderingPipeline"
  59145. */
  59146. getClassName(): string;
  59147. /**
  59148. * Gets associated scene
  59149. */
  59150. readonly scene: Scene;
  59151. /**
  59152. * Gets or sets the edge blur
  59153. */
  59154. edgeBlur: number;
  59155. /**
  59156. * Gets or sets the grain amount
  59157. */
  59158. grainAmount: number;
  59159. /**
  59160. * Gets or sets the chromatic aberration amount
  59161. */
  59162. chromaticAberration: number;
  59163. /**
  59164. * Gets or sets the depth of field aperture
  59165. */
  59166. dofAperture: number;
  59167. /**
  59168. * Gets or sets the edge distortion
  59169. */
  59170. edgeDistortion: number;
  59171. /**
  59172. * Gets or sets the depth of field distortion
  59173. */
  59174. dofDistortion: number;
  59175. /**
  59176. * Gets or sets the darken out of focus amount
  59177. */
  59178. darkenOutOfFocus: number;
  59179. /**
  59180. * Gets or sets a boolean indicating if blur noise is enabled
  59181. */
  59182. blurNoise: boolean;
  59183. /**
  59184. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  59185. */
  59186. pentagonBokeh: boolean;
  59187. /**
  59188. * Gets or sets the highlight grain amount
  59189. */
  59190. highlightsGain: number;
  59191. /**
  59192. * Gets or sets the highlight threshold
  59193. */
  59194. highlightsThreshold: number;
  59195. /**
  59196. * Sets the amount of blur at the edges
  59197. * @param amount blur amount
  59198. */
  59199. setEdgeBlur(amount: number): void;
  59200. /**
  59201. * Sets edge blur to 0
  59202. */
  59203. disableEdgeBlur(): void;
  59204. /**
  59205. * Sets the amout of grain
  59206. * @param amount Amount of grain
  59207. */
  59208. setGrainAmount(amount: number): void;
  59209. /**
  59210. * Set grain amount to 0
  59211. */
  59212. disableGrain(): void;
  59213. /**
  59214. * Sets the chromatic aberration amount
  59215. * @param amount amount of chromatic aberration
  59216. */
  59217. setChromaticAberration(amount: number): void;
  59218. /**
  59219. * Sets chromatic aberration amount to 0
  59220. */
  59221. disableChromaticAberration(): void;
  59222. /**
  59223. * Sets the EdgeDistortion amount
  59224. * @param amount amount of EdgeDistortion
  59225. */
  59226. setEdgeDistortion(amount: number): void;
  59227. /**
  59228. * Sets edge distortion to 0
  59229. */
  59230. disableEdgeDistortion(): void;
  59231. /**
  59232. * Sets the FocusDistance amount
  59233. * @param amount amount of FocusDistance
  59234. */
  59235. setFocusDistance(amount: number): void;
  59236. /**
  59237. * Disables depth of field
  59238. */
  59239. disableDepthOfField(): void;
  59240. /**
  59241. * Sets the Aperture amount
  59242. * @param amount amount of Aperture
  59243. */
  59244. setAperture(amount: number): void;
  59245. /**
  59246. * Sets the DarkenOutOfFocus amount
  59247. * @param amount amount of DarkenOutOfFocus
  59248. */
  59249. setDarkenOutOfFocus(amount: number): void;
  59250. private _pentagonBokehIsEnabled;
  59251. /**
  59252. * Creates a pentagon bokeh effect
  59253. */
  59254. enablePentagonBokeh(): void;
  59255. /**
  59256. * Disables the pentagon bokeh effect
  59257. */
  59258. disablePentagonBokeh(): void;
  59259. /**
  59260. * Enables noise blur
  59261. */
  59262. enableNoiseBlur(): void;
  59263. /**
  59264. * Disables noise blur
  59265. */
  59266. disableNoiseBlur(): void;
  59267. /**
  59268. * Sets the HighlightsGain amount
  59269. * @param amount amount of HighlightsGain
  59270. */
  59271. setHighlightsGain(amount: number): void;
  59272. /**
  59273. * Sets the HighlightsThreshold amount
  59274. * @param amount amount of HighlightsThreshold
  59275. */
  59276. setHighlightsThreshold(amount: number): void;
  59277. /**
  59278. * Disables highlights
  59279. */
  59280. disableHighlights(): void;
  59281. /**
  59282. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  59283. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  59284. */
  59285. dispose(disableDepthRender?: boolean): void;
  59286. private _createChromaticAberrationPostProcess;
  59287. private _createHighlightsPostProcess;
  59288. private _createDepthOfFieldPostProcess;
  59289. private _createGrainTexture;
  59290. }
  59291. }
  59292. declare module BABYLON {
  59293. /** @hidden */
  59294. export var ssao2PixelShader: {
  59295. name: string;
  59296. shader: string;
  59297. };
  59298. }
  59299. declare module BABYLON {
  59300. /** @hidden */
  59301. export var ssaoCombinePixelShader: {
  59302. name: string;
  59303. shader: string;
  59304. };
  59305. }
  59306. declare module BABYLON {
  59307. /**
  59308. * Render pipeline to produce ssao effect
  59309. */
  59310. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  59311. /**
  59312. * @ignore
  59313. * The PassPostProcess id in the pipeline that contains the original scene color
  59314. */
  59315. SSAOOriginalSceneColorEffect: string;
  59316. /**
  59317. * @ignore
  59318. * The SSAO PostProcess id in the pipeline
  59319. */
  59320. SSAORenderEffect: string;
  59321. /**
  59322. * @ignore
  59323. * The horizontal blur PostProcess id in the pipeline
  59324. */
  59325. SSAOBlurHRenderEffect: string;
  59326. /**
  59327. * @ignore
  59328. * The vertical blur PostProcess id in the pipeline
  59329. */
  59330. SSAOBlurVRenderEffect: string;
  59331. /**
  59332. * @ignore
  59333. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59334. */
  59335. SSAOCombineRenderEffect: string;
  59336. /**
  59337. * The output strength of the SSAO post-process. Default value is 1.0.
  59338. */
  59339. totalStrength: number;
  59340. /**
  59341. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  59342. */
  59343. maxZ: number;
  59344. /**
  59345. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  59346. */
  59347. minZAspect: number;
  59348. private _samples;
  59349. /**
  59350. * Number of samples used for the SSAO calculations. Default value is 8
  59351. */
  59352. samples: number;
  59353. private _textureSamples;
  59354. /**
  59355. * Number of samples to use for antialiasing
  59356. */
  59357. textureSamples: number;
  59358. /**
  59359. * Ratio object used for SSAO ratio and blur ratio
  59360. */
  59361. private _ratio;
  59362. /**
  59363. * Dynamically generated sphere sampler.
  59364. */
  59365. private _sampleSphere;
  59366. /**
  59367. * Blur filter offsets
  59368. */
  59369. private _samplerOffsets;
  59370. private _expensiveBlur;
  59371. /**
  59372. * If bilateral blur should be used
  59373. */
  59374. expensiveBlur: boolean;
  59375. /**
  59376. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  59377. */
  59378. radius: number;
  59379. /**
  59380. * The base color of the SSAO post-process
  59381. * The final result is "base + ssao" between [0, 1]
  59382. */
  59383. base: number;
  59384. /**
  59385. * Support test.
  59386. */
  59387. static readonly IsSupported: boolean;
  59388. private _scene;
  59389. private _depthTexture;
  59390. private _normalTexture;
  59391. private _randomTexture;
  59392. private _originalColorPostProcess;
  59393. private _ssaoPostProcess;
  59394. private _blurHPostProcess;
  59395. private _blurVPostProcess;
  59396. private _ssaoCombinePostProcess;
  59397. private _firstUpdate;
  59398. /**
  59399. * Gets active scene
  59400. */
  59401. readonly scene: Scene;
  59402. /**
  59403. * @constructor
  59404. * @param name The rendering pipeline name
  59405. * @param scene The scene linked to this pipeline
  59406. * @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 }
  59407. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59408. */
  59409. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59410. /**
  59411. * Get the class name
  59412. * @returns "SSAO2RenderingPipeline"
  59413. */
  59414. getClassName(): string;
  59415. /**
  59416. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59417. */
  59418. dispose(disableGeometryBufferRenderer?: boolean): void;
  59419. private _createBlurPostProcess;
  59420. /** @hidden */
  59421. _rebuild(): void;
  59422. private _bits;
  59423. private _radicalInverse_VdC;
  59424. private _hammersley;
  59425. private _hemisphereSample_uniform;
  59426. private _generateHemisphere;
  59427. private _createSSAOPostProcess;
  59428. private _createSSAOCombinePostProcess;
  59429. private _createRandomTexture;
  59430. /**
  59431. * Serialize the rendering pipeline (Used when exporting)
  59432. * @returns the serialized object
  59433. */
  59434. serialize(): any;
  59435. /**
  59436. * Parse the serialized pipeline
  59437. * @param source Source pipeline.
  59438. * @param scene The scene to load the pipeline to.
  59439. * @param rootUrl The URL of the serialized pipeline.
  59440. * @returns An instantiated pipeline from the serialized object.
  59441. */
  59442. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  59443. }
  59444. }
  59445. declare module BABYLON {
  59446. /** @hidden */
  59447. export var ssaoPixelShader: {
  59448. name: string;
  59449. shader: string;
  59450. };
  59451. }
  59452. declare module BABYLON {
  59453. /**
  59454. * Render pipeline to produce ssao effect
  59455. */
  59456. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  59457. /**
  59458. * @ignore
  59459. * The PassPostProcess id in the pipeline that contains the original scene color
  59460. */
  59461. SSAOOriginalSceneColorEffect: string;
  59462. /**
  59463. * @ignore
  59464. * The SSAO PostProcess id in the pipeline
  59465. */
  59466. SSAORenderEffect: string;
  59467. /**
  59468. * @ignore
  59469. * The horizontal blur PostProcess id in the pipeline
  59470. */
  59471. SSAOBlurHRenderEffect: string;
  59472. /**
  59473. * @ignore
  59474. * The vertical blur PostProcess id in the pipeline
  59475. */
  59476. SSAOBlurVRenderEffect: string;
  59477. /**
  59478. * @ignore
  59479. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59480. */
  59481. SSAOCombineRenderEffect: string;
  59482. /**
  59483. * The output strength of the SSAO post-process. Default value is 1.0.
  59484. */
  59485. totalStrength: number;
  59486. /**
  59487. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  59488. */
  59489. radius: number;
  59490. /**
  59491. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  59492. * Must not be equal to fallOff and superior to fallOff.
  59493. * Default value is 0.0075
  59494. */
  59495. area: number;
  59496. /**
  59497. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  59498. * Must not be equal to area and inferior to area.
  59499. * Default value is 0.000001
  59500. */
  59501. fallOff: number;
  59502. /**
  59503. * The base color of the SSAO post-process
  59504. * The final result is "base + ssao" between [0, 1]
  59505. */
  59506. base: number;
  59507. private _scene;
  59508. private _depthTexture;
  59509. private _randomTexture;
  59510. private _originalColorPostProcess;
  59511. private _ssaoPostProcess;
  59512. private _blurHPostProcess;
  59513. private _blurVPostProcess;
  59514. private _ssaoCombinePostProcess;
  59515. private _firstUpdate;
  59516. /**
  59517. * Gets active scene
  59518. */
  59519. readonly scene: Scene;
  59520. /**
  59521. * @constructor
  59522. * @param name - The rendering pipeline name
  59523. * @param scene - The scene linked to this pipeline
  59524. * @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 }
  59525. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  59526. */
  59527. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59528. /**
  59529. * Get the class name
  59530. * @returns "SSAORenderingPipeline"
  59531. */
  59532. getClassName(): string;
  59533. /**
  59534. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59535. */
  59536. dispose(disableDepthRender?: boolean): void;
  59537. private _createBlurPostProcess;
  59538. /** @hidden */
  59539. _rebuild(): void;
  59540. private _createSSAOPostProcess;
  59541. private _createSSAOCombinePostProcess;
  59542. private _createRandomTexture;
  59543. }
  59544. }
  59545. declare module BABYLON {
  59546. /** @hidden */
  59547. export var standardPixelShader: {
  59548. name: string;
  59549. shader: string;
  59550. };
  59551. }
  59552. declare module BABYLON {
  59553. /**
  59554. * Standard rendering pipeline
  59555. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59556. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  59557. */
  59558. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59559. /**
  59560. * Public members
  59561. */
  59562. /**
  59563. * Post-process which contains the original scene color before the pipeline applies all the effects
  59564. */
  59565. originalPostProcess: Nullable<PostProcess>;
  59566. /**
  59567. * Post-process used to down scale an image x4
  59568. */
  59569. downSampleX4PostProcess: Nullable<PostProcess>;
  59570. /**
  59571. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  59572. */
  59573. brightPassPostProcess: Nullable<PostProcess>;
  59574. /**
  59575. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  59576. */
  59577. blurHPostProcesses: PostProcess[];
  59578. /**
  59579. * Post-process array storing all the vertical blur post-processes used by the pipeline
  59580. */
  59581. blurVPostProcesses: PostProcess[];
  59582. /**
  59583. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  59584. */
  59585. textureAdderPostProcess: Nullable<PostProcess>;
  59586. /**
  59587. * Post-process used to create volumetric lighting effect
  59588. */
  59589. volumetricLightPostProcess: Nullable<PostProcess>;
  59590. /**
  59591. * Post-process used to smooth the previous volumetric light post-process on the X axis
  59592. */
  59593. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  59594. /**
  59595. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  59596. */
  59597. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  59598. /**
  59599. * Post-process used to merge the volumetric light effect and the real scene color
  59600. */
  59601. volumetricLightMergePostProces: Nullable<PostProcess>;
  59602. /**
  59603. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  59604. */
  59605. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  59606. /**
  59607. * Base post-process used to calculate the average luminance of the final image for HDR
  59608. */
  59609. luminancePostProcess: Nullable<PostProcess>;
  59610. /**
  59611. * Post-processes used to create down sample post-processes in order to get
  59612. * the average luminance of the final image for HDR
  59613. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  59614. */
  59615. luminanceDownSamplePostProcesses: PostProcess[];
  59616. /**
  59617. * Post-process used to create a HDR effect (light adaptation)
  59618. */
  59619. hdrPostProcess: Nullable<PostProcess>;
  59620. /**
  59621. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  59622. */
  59623. textureAdderFinalPostProcess: Nullable<PostProcess>;
  59624. /**
  59625. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  59626. */
  59627. lensFlareFinalPostProcess: Nullable<PostProcess>;
  59628. /**
  59629. * Post-process used to merge the final HDR post-process and the real scene color
  59630. */
  59631. hdrFinalPostProcess: Nullable<PostProcess>;
  59632. /**
  59633. * Post-process used to create a lens flare effect
  59634. */
  59635. lensFlarePostProcess: Nullable<PostProcess>;
  59636. /**
  59637. * Post-process that merges the result of the lens flare post-process and the real scene color
  59638. */
  59639. lensFlareComposePostProcess: Nullable<PostProcess>;
  59640. /**
  59641. * Post-process used to create a motion blur effect
  59642. */
  59643. motionBlurPostProcess: Nullable<PostProcess>;
  59644. /**
  59645. * Post-process used to create a depth of field effect
  59646. */
  59647. depthOfFieldPostProcess: Nullable<PostProcess>;
  59648. /**
  59649. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59650. */
  59651. fxaaPostProcess: Nullable<FxaaPostProcess>;
  59652. /**
  59653. * Represents the brightness threshold in order to configure the illuminated surfaces
  59654. */
  59655. brightThreshold: number;
  59656. /**
  59657. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  59658. */
  59659. blurWidth: number;
  59660. /**
  59661. * Sets if the blur for highlighted surfaces must be only horizontal
  59662. */
  59663. horizontalBlur: boolean;
  59664. /**
  59665. * Gets the overall exposure used by the pipeline
  59666. */
  59667. /**
  59668. * Sets the overall exposure used by the pipeline
  59669. */
  59670. exposure: number;
  59671. /**
  59672. * Texture used typically to simulate "dirty" on camera lens
  59673. */
  59674. lensTexture: Nullable<Texture>;
  59675. /**
  59676. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  59677. */
  59678. volumetricLightCoefficient: number;
  59679. /**
  59680. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  59681. */
  59682. volumetricLightPower: number;
  59683. /**
  59684. * Used the set the blur intensity to smooth the volumetric lights
  59685. */
  59686. volumetricLightBlurScale: number;
  59687. /**
  59688. * Light (spot or directional) used to generate the volumetric lights rays
  59689. * The source light must have a shadow generate so the pipeline can get its
  59690. * depth map
  59691. */
  59692. sourceLight: Nullable<SpotLight | DirectionalLight>;
  59693. /**
  59694. * For eye adaptation, represents the minimum luminance the eye can see
  59695. */
  59696. hdrMinimumLuminance: number;
  59697. /**
  59698. * For eye adaptation, represents the decrease luminance speed
  59699. */
  59700. hdrDecreaseRate: number;
  59701. /**
  59702. * For eye adaptation, represents the increase luminance speed
  59703. */
  59704. hdrIncreaseRate: number;
  59705. /**
  59706. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59707. */
  59708. /**
  59709. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59710. */
  59711. hdrAutoExposure: boolean;
  59712. /**
  59713. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  59714. */
  59715. lensColorTexture: Nullable<Texture>;
  59716. /**
  59717. * The overall strengh for the lens flare effect
  59718. */
  59719. lensFlareStrength: number;
  59720. /**
  59721. * Dispersion coefficient for lens flare ghosts
  59722. */
  59723. lensFlareGhostDispersal: number;
  59724. /**
  59725. * Main lens flare halo width
  59726. */
  59727. lensFlareHaloWidth: number;
  59728. /**
  59729. * Based on the lens distortion effect, defines how much the lens flare result
  59730. * is distorted
  59731. */
  59732. lensFlareDistortionStrength: number;
  59733. /**
  59734. * Configures the blur intensity used for for lens flare (halo)
  59735. */
  59736. lensFlareBlurWidth: number;
  59737. /**
  59738. * Lens star texture must be used to simulate rays on the flares and is available
  59739. * in the documentation
  59740. */
  59741. lensStarTexture: Nullable<Texture>;
  59742. /**
  59743. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  59744. * flare effect by taking account of the dirt texture
  59745. */
  59746. lensFlareDirtTexture: Nullable<Texture>;
  59747. /**
  59748. * Represents the focal length for the depth of field effect
  59749. */
  59750. depthOfFieldDistance: number;
  59751. /**
  59752. * Represents the blur intensity for the blurred part of the depth of field effect
  59753. */
  59754. depthOfFieldBlurWidth: number;
  59755. /**
  59756. * Gets how much the image is blurred by the movement while using the motion blur post-process
  59757. */
  59758. /**
  59759. * Sets how much the image is blurred by the movement while using the motion blur post-process
  59760. */
  59761. motionStrength: number;
  59762. /**
  59763. * Gets wether or not the motion blur post-process is object based or screen based.
  59764. */
  59765. /**
  59766. * Sets wether or not the motion blur post-process should be object based or screen based
  59767. */
  59768. objectBasedMotionBlur: boolean;
  59769. /**
  59770. * List of animations for the pipeline (IAnimatable implementation)
  59771. */
  59772. animations: Animation[];
  59773. /**
  59774. * Private members
  59775. */
  59776. private _scene;
  59777. private _currentDepthOfFieldSource;
  59778. private _basePostProcess;
  59779. private _fixedExposure;
  59780. private _currentExposure;
  59781. private _hdrAutoExposure;
  59782. private _hdrCurrentLuminance;
  59783. private _motionStrength;
  59784. private _isObjectBasedMotionBlur;
  59785. private _floatTextureType;
  59786. private _camerasToBeAttached;
  59787. private _ratio;
  59788. private _bloomEnabled;
  59789. private _depthOfFieldEnabled;
  59790. private _vlsEnabled;
  59791. private _lensFlareEnabled;
  59792. private _hdrEnabled;
  59793. private _motionBlurEnabled;
  59794. private _fxaaEnabled;
  59795. private _motionBlurSamples;
  59796. private _volumetricLightStepsCount;
  59797. private _samples;
  59798. /**
  59799. * @ignore
  59800. * Specifies if the bloom pipeline is enabled
  59801. */
  59802. BloomEnabled: boolean;
  59803. /**
  59804. * @ignore
  59805. * Specifies if the depth of field pipeline is enabed
  59806. */
  59807. DepthOfFieldEnabled: boolean;
  59808. /**
  59809. * @ignore
  59810. * Specifies if the lens flare pipeline is enabed
  59811. */
  59812. LensFlareEnabled: boolean;
  59813. /**
  59814. * @ignore
  59815. * Specifies if the HDR pipeline is enabled
  59816. */
  59817. HDREnabled: boolean;
  59818. /**
  59819. * @ignore
  59820. * Specifies if the volumetric lights scattering effect is enabled
  59821. */
  59822. VLSEnabled: boolean;
  59823. /**
  59824. * @ignore
  59825. * Specifies if the motion blur effect is enabled
  59826. */
  59827. MotionBlurEnabled: boolean;
  59828. /**
  59829. * Specifies if anti-aliasing is enabled
  59830. */
  59831. fxaaEnabled: boolean;
  59832. /**
  59833. * Specifies the number of steps used to calculate the volumetric lights
  59834. * Typically in interval [50, 200]
  59835. */
  59836. volumetricLightStepsCount: number;
  59837. /**
  59838. * Specifies the number of samples used for the motion blur effect
  59839. * Typically in interval [16, 64]
  59840. */
  59841. motionBlurSamples: number;
  59842. /**
  59843. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  59844. */
  59845. samples: number;
  59846. /**
  59847. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59848. * @constructor
  59849. * @param name The rendering pipeline name
  59850. * @param scene The scene linked to this pipeline
  59851. * @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)
  59852. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  59853. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59854. */
  59855. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  59856. private _buildPipeline;
  59857. private _createDownSampleX4PostProcess;
  59858. private _createBrightPassPostProcess;
  59859. private _createBlurPostProcesses;
  59860. private _createTextureAdderPostProcess;
  59861. private _createVolumetricLightPostProcess;
  59862. private _createLuminancePostProcesses;
  59863. private _createHdrPostProcess;
  59864. private _createLensFlarePostProcess;
  59865. private _createDepthOfFieldPostProcess;
  59866. private _createMotionBlurPostProcess;
  59867. private _getDepthTexture;
  59868. private _disposePostProcesses;
  59869. /**
  59870. * Dispose of the pipeline and stop all post processes
  59871. */
  59872. dispose(): void;
  59873. /**
  59874. * Serialize the rendering pipeline (Used when exporting)
  59875. * @returns the serialized object
  59876. */
  59877. serialize(): any;
  59878. /**
  59879. * Parse the serialized pipeline
  59880. * @param source Source pipeline.
  59881. * @param scene The scene to load the pipeline to.
  59882. * @param rootUrl The URL of the serialized pipeline.
  59883. * @returns An instantiated pipeline from the serialized object.
  59884. */
  59885. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  59886. /**
  59887. * Luminance steps
  59888. */
  59889. static LuminanceSteps: number;
  59890. }
  59891. }
  59892. declare module BABYLON {
  59893. /** @hidden */
  59894. export var tonemapPixelShader: {
  59895. name: string;
  59896. shader: string;
  59897. };
  59898. }
  59899. declare module BABYLON {
  59900. /** Defines operator used for tonemapping */
  59901. export enum TonemappingOperator {
  59902. /** Hable */
  59903. Hable = 0,
  59904. /** Reinhard */
  59905. Reinhard = 1,
  59906. /** HejiDawson */
  59907. HejiDawson = 2,
  59908. /** Photographic */
  59909. Photographic = 3
  59910. }
  59911. /**
  59912. * Defines a post process to apply tone mapping
  59913. */
  59914. export class TonemapPostProcess extends PostProcess {
  59915. private _operator;
  59916. /** Defines the required exposure adjustement */
  59917. exposureAdjustment: number;
  59918. /**
  59919. * Creates a new TonemapPostProcess
  59920. * @param name defines the name of the postprocess
  59921. * @param _operator defines the operator to use
  59922. * @param exposureAdjustment defines the required exposure adjustement
  59923. * @param camera defines the camera to use (can be null)
  59924. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  59925. * @param engine defines the hosting engine (can be ignore if camera is set)
  59926. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  59927. */
  59928. constructor(name: string, _operator: TonemappingOperator,
  59929. /** Defines the required exposure adjustement */
  59930. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  59931. }
  59932. }
  59933. declare module BABYLON {
  59934. /** @hidden */
  59935. export var depthVertexShader: {
  59936. name: string;
  59937. shader: string;
  59938. };
  59939. }
  59940. declare module BABYLON {
  59941. /** @hidden */
  59942. export var volumetricLightScatteringPixelShader: {
  59943. name: string;
  59944. shader: string;
  59945. };
  59946. }
  59947. declare module BABYLON {
  59948. /** @hidden */
  59949. export var volumetricLightScatteringPassVertexShader: {
  59950. name: string;
  59951. shader: string;
  59952. };
  59953. }
  59954. declare module BABYLON {
  59955. /** @hidden */
  59956. export var volumetricLightScatteringPassPixelShader: {
  59957. name: string;
  59958. shader: string;
  59959. };
  59960. }
  59961. declare module BABYLON {
  59962. /**
  59963. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  59964. */
  59965. export class VolumetricLightScatteringPostProcess extends PostProcess {
  59966. private _volumetricLightScatteringPass;
  59967. private _volumetricLightScatteringRTT;
  59968. private _viewPort;
  59969. private _screenCoordinates;
  59970. private _cachedDefines;
  59971. /**
  59972. * If not undefined, the mesh position is computed from the attached node position
  59973. */
  59974. attachedNode: {
  59975. position: Vector3;
  59976. };
  59977. /**
  59978. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  59979. */
  59980. customMeshPosition: Vector3;
  59981. /**
  59982. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  59983. */
  59984. useCustomMeshPosition: boolean;
  59985. /**
  59986. * If the post-process should inverse the light scattering direction
  59987. */
  59988. invert: boolean;
  59989. /**
  59990. * The internal mesh used by the post-process
  59991. */
  59992. mesh: Mesh;
  59993. /**
  59994. * @hidden
  59995. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  59996. */
  59997. useDiffuseColor: boolean;
  59998. /**
  59999. * Array containing the excluded meshes not rendered in the internal pass
  60000. */
  60001. excludedMeshes: AbstractMesh[];
  60002. /**
  60003. * Controls the overall intensity of the post-process
  60004. */
  60005. exposure: number;
  60006. /**
  60007. * Dissipates each sample's contribution in range [0, 1]
  60008. */
  60009. decay: number;
  60010. /**
  60011. * Controls the overall intensity of each sample
  60012. */
  60013. weight: number;
  60014. /**
  60015. * Controls the density of each sample
  60016. */
  60017. density: number;
  60018. /**
  60019. * @constructor
  60020. * @param name The post-process name
  60021. * @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)
  60022. * @param camera The camera that the post-process will be attached to
  60023. * @param mesh The mesh used to create the light scattering
  60024. * @param samples The post-process quality, default 100
  60025. * @param samplingModeThe post-process filtering mode
  60026. * @param engine The babylon engine
  60027. * @param reusable If the post-process is reusable
  60028. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  60029. */
  60030. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  60031. /**
  60032. * Returns the string "VolumetricLightScatteringPostProcess"
  60033. * @returns "VolumetricLightScatteringPostProcess"
  60034. */
  60035. getClassName(): string;
  60036. private _isReady;
  60037. /**
  60038. * Sets the new light position for light scattering effect
  60039. * @param position The new custom light position
  60040. */
  60041. setCustomMeshPosition(position: Vector3): void;
  60042. /**
  60043. * Returns the light position for light scattering effect
  60044. * @return Vector3 The custom light position
  60045. */
  60046. getCustomMeshPosition(): Vector3;
  60047. /**
  60048. * Disposes the internal assets and detaches the post-process from the camera
  60049. */
  60050. dispose(camera: Camera): void;
  60051. /**
  60052. * Returns the render target texture used by the post-process
  60053. * @return the render target texture used by the post-process
  60054. */
  60055. getPass(): RenderTargetTexture;
  60056. private _meshExcluded;
  60057. private _createPass;
  60058. private _updateMeshScreenCoordinates;
  60059. /**
  60060. * Creates a default mesh for the Volumeric Light Scattering post-process
  60061. * @param name The mesh name
  60062. * @param scene The scene where to create the mesh
  60063. * @return the default mesh
  60064. */
  60065. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  60066. }
  60067. }
  60068. declare module BABYLON {
  60069. interface Scene {
  60070. /** @hidden (Backing field) */
  60071. _boundingBoxRenderer: BoundingBoxRenderer;
  60072. /** @hidden (Backing field) */
  60073. _forceShowBoundingBoxes: boolean;
  60074. /**
  60075. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  60076. */
  60077. forceShowBoundingBoxes: boolean;
  60078. /**
  60079. * Gets the bounding box renderer associated with the scene
  60080. * @returns a BoundingBoxRenderer
  60081. */
  60082. getBoundingBoxRenderer(): BoundingBoxRenderer;
  60083. }
  60084. interface AbstractMesh {
  60085. /** @hidden (Backing field) */
  60086. _showBoundingBox: boolean;
  60087. /**
  60088. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  60089. */
  60090. showBoundingBox: boolean;
  60091. }
  60092. /**
  60093. * Component responsible of rendering the bounding box of the meshes in a scene.
  60094. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  60095. */
  60096. export class BoundingBoxRenderer implements ISceneComponent {
  60097. /**
  60098. * The component name helpfull to identify the component in the list of scene components.
  60099. */
  60100. readonly name: string;
  60101. /**
  60102. * The scene the component belongs to.
  60103. */
  60104. scene: Scene;
  60105. /**
  60106. * Color of the bounding box lines placed in front of an object
  60107. */
  60108. frontColor: Color3;
  60109. /**
  60110. * Color of the bounding box lines placed behind an object
  60111. */
  60112. backColor: Color3;
  60113. /**
  60114. * Defines if the renderer should show the back lines or not
  60115. */
  60116. showBackLines: boolean;
  60117. /**
  60118. * @hidden
  60119. */
  60120. renderList: SmartArray<BoundingBox>;
  60121. private _colorShader;
  60122. private _vertexBuffers;
  60123. private _indexBuffer;
  60124. private _fillIndexBuffer;
  60125. private _fillIndexData;
  60126. /**
  60127. * Instantiates a new bounding box renderer in a scene.
  60128. * @param scene the scene the renderer renders in
  60129. */
  60130. constructor(scene: Scene);
  60131. /**
  60132. * Registers the component in a given scene
  60133. */
  60134. register(): void;
  60135. private _evaluateSubMesh;
  60136. private _activeMesh;
  60137. private _prepareRessources;
  60138. private _createIndexBuffer;
  60139. /**
  60140. * Rebuilds the elements related to this component in case of
  60141. * context lost for instance.
  60142. */
  60143. rebuild(): void;
  60144. /**
  60145. * @hidden
  60146. */
  60147. reset(): void;
  60148. /**
  60149. * Render the bounding boxes of a specific rendering group
  60150. * @param renderingGroupId defines the rendering group to render
  60151. */
  60152. render(renderingGroupId: number): void;
  60153. /**
  60154. * In case of occlusion queries, we can render the occlusion bounding box through this method
  60155. * @param mesh Define the mesh to render the occlusion bounding box for
  60156. */
  60157. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  60158. /**
  60159. * Dispose and release the resources attached to this renderer.
  60160. */
  60161. dispose(): void;
  60162. }
  60163. }
  60164. declare module BABYLON {
  60165. /** @hidden */
  60166. export var depthPixelShader: {
  60167. name: string;
  60168. shader: string;
  60169. };
  60170. }
  60171. declare module BABYLON {
  60172. /**
  60173. * This represents a depth renderer in Babylon.
  60174. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60175. */
  60176. export class DepthRenderer {
  60177. private _scene;
  60178. private _depthMap;
  60179. private _effect;
  60180. private readonly _storeNonLinearDepth;
  60181. private readonly _clearColor;
  60182. /** Get if the depth renderer is using packed depth or not */
  60183. readonly isPacked: boolean;
  60184. private _cachedDefines;
  60185. private _camera;
  60186. /**
  60187. * Specifiess that the depth renderer will only be used within
  60188. * the camera it is created for.
  60189. * This can help forcing its rendering during the camera processing.
  60190. */
  60191. useOnlyInActiveCamera: boolean;
  60192. /** @hidden */
  60193. static _SceneComponentInitialization: (scene: Scene) => void;
  60194. /**
  60195. * Instantiates a depth renderer
  60196. * @param scene The scene the renderer belongs to
  60197. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60198. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60199. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60200. */
  60201. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60202. /**
  60203. * Creates the depth rendering effect and checks if the effect is ready.
  60204. * @param subMesh The submesh to be used to render the depth map of
  60205. * @param useInstances If multiple world instances should be used
  60206. * @returns if the depth renderer is ready to render the depth map
  60207. */
  60208. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60209. /**
  60210. * Gets the texture which the depth map will be written to.
  60211. * @returns The depth map texture
  60212. */
  60213. getDepthMap(): RenderTargetTexture;
  60214. /**
  60215. * Disposes of the depth renderer.
  60216. */
  60217. dispose(): void;
  60218. }
  60219. }
  60220. declare module BABYLON {
  60221. interface Scene {
  60222. /** @hidden (Backing field) */
  60223. _depthRenderer: {
  60224. [id: string]: DepthRenderer;
  60225. };
  60226. /**
  60227. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  60228. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  60229. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60230. * @returns the created depth renderer
  60231. */
  60232. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  60233. /**
  60234. * Disables a depth renderer for a given camera
  60235. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  60236. */
  60237. disableDepthRenderer(camera?: Nullable<Camera>): void;
  60238. }
  60239. /**
  60240. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  60241. * in several rendering techniques.
  60242. */
  60243. export class DepthRendererSceneComponent implements ISceneComponent {
  60244. /**
  60245. * The component name helpfull to identify the component in the list of scene components.
  60246. */
  60247. readonly name: string;
  60248. /**
  60249. * The scene the component belongs to.
  60250. */
  60251. scene: Scene;
  60252. /**
  60253. * Creates a new instance of the component for the given scene
  60254. * @param scene Defines the scene to register the component in
  60255. */
  60256. constructor(scene: Scene);
  60257. /**
  60258. * Registers the component in a given scene
  60259. */
  60260. register(): void;
  60261. /**
  60262. * Rebuilds the elements related to this component in case of
  60263. * context lost for instance.
  60264. */
  60265. rebuild(): void;
  60266. /**
  60267. * Disposes the component and the associated ressources
  60268. */
  60269. dispose(): void;
  60270. private _gatherRenderTargets;
  60271. private _gatherActiveCameraRenderTargets;
  60272. }
  60273. }
  60274. declare module BABYLON {
  60275. /** @hidden */
  60276. export var outlinePixelShader: {
  60277. name: string;
  60278. shader: string;
  60279. };
  60280. }
  60281. declare module BABYLON {
  60282. /** @hidden */
  60283. export var outlineVertexShader: {
  60284. name: string;
  60285. shader: string;
  60286. };
  60287. }
  60288. declare module BABYLON {
  60289. interface Scene {
  60290. /** @hidden */
  60291. _outlineRenderer: OutlineRenderer;
  60292. /**
  60293. * Gets the outline renderer associated with the scene
  60294. * @returns a OutlineRenderer
  60295. */
  60296. getOutlineRenderer(): OutlineRenderer;
  60297. }
  60298. interface AbstractMesh {
  60299. /** @hidden (Backing field) */
  60300. _renderOutline: boolean;
  60301. /**
  60302. * Gets or sets a boolean indicating if the outline must be rendered as well
  60303. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  60304. */
  60305. renderOutline: boolean;
  60306. /** @hidden (Backing field) */
  60307. _renderOverlay: boolean;
  60308. /**
  60309. * Gets or sets a boolean indicating if the overlay must be rendered as well
  60310. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  60311. */
  60312. renderOverlay: boolean;
  60313. }
  60314. /**
  60315. * This class is responsible to draw bothe outline/overlay of meshes.
  60316. * It should not be used directly but through the available method on mesh.
  60317. */
  60318. export class OutlineRenderer implements ISceneComponent {
  60319. /**
  60320. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  60321. */
  60322. private static _StencilReference;
  60323. /**
  60324. * The name of the component. Each component must have a unique name.
  60325. */
  60326. name: string;
  60327. /**
  60328. * The scene the component belongs to.
  60329. */
  60330. scene: Scene;
  60331. /**
  60332. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  60333. */
  60334. zOffset: number;
  60335. private _engine;
  60336. private _effect;
  60337. private _cachedDefines;
  60338. private _savedDepthWrite;
  60339. /**
  60340. * Instantiates a new outline renderer. (There could be only one per scene).
  60341. * @param scene Defines the scene it belongs to
  60342. */
  60343. constructor(scene: Scene);
  60344. /**
  60345. * Register the component to one instance of a scene.
  60346. */
  60347. register(): void;
  60348. /**
  60349. * Rebuilds the elements related to this component in case of
  60350. * context lost for instance.
  60351. */
  60352. rebuild(): void;
  60353. /**
  60354. * Disposes the component and the associated ressources.
  60355. */
  60356. dispose(): void;
  60357. /**
  60358. * Renders the outline in the canvas.
  60359. * @param subMesh Defines the sumesh to render
  60360. * @param batch Defines the batch of meshes in case of instances
  60361. * @param useOverlay Defines if the rendering is for the overlay or the outline
  60362. */
  60363. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  60364. /**
  60365. * Returns whether or not the outline renderer is ready for a given submesh.
  60366. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  60367. * @param subMesh Defines the submesh to check readyness for
  60368. * @param useInstances Defines wheter wee are trying to render instances or not
  60369. * @returns true if ready otherwise false
  60370. */
  60371. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60372. private _beforeRenderingMesh;
  60373. private _afterRenderingMesh;
  60374. }
  60375. }
  60376. declare module BABYLON {
  60377. /**
  60378. * Class used to manage multiple sprites of different sizes on the same spritesheet
  60379. * @see http://doc.babylonjs.com/babylon101/sprites
  60380. */
  60381. export class SpritePackedManager extends SpriteManager {
  60382. /** defines the packed manager's name */
  60383. name: string;
  60384. /**
  60385. * Creates a new sprite manager from a packed sprite sheet
  60386. * @param name defines the manager's name
  60387. * @param imgUrl defines the sprite sheet url
  60388. * @param capacity defines the maximum allowed number of sprites
  60389. * @param scene defines the hosting scene
  60390. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  60391. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  60392. * @param samplingMode defines the smapling mode to use with spritesheet
  60393. * @param fromPacked set to true; do not alter
  60394. */
  60395. constructor(
  60396. /** defines the packed manager's name */
  60397. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  60398. }
  60399. }
  60400. declare module BABYLON {
  60401. /**
  60402. * Defines the list of states available for a task inside a AssetsManager
  60403. */
  60404. export enum AssetTaskState {
  60405. /**
  60406. * Initialization
  60407. */
  60408. INIT = 0,
  60409. /**
  60410. * Running
  60411. */
  60412. RUNNING = 1,
  60413. /**
  60414. * Done
  60415. */
  60416. DONE = 2,
  60417. /**
  60418. * Error
  60419. */
  60420. ERROR = 3
  60421. }
  60422. /**
  60423. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  60424. */
  60425. export abstract class AbstractAssetTask {
  60426. /**
  60427. * Task name
  60428. */ name: string;
  60429. /**
  60430. * Callback called when the task is successful
  60431. */
  60432. onSuccess: (task: any) => void;
  60433. /**
  60434. * Callback called when the task is not successful
  60435. */
  60436. onError: (task: any, message?: string, exception?: any) => void;
  60437. /**
  60438. * Creates a new AssetsManager
  60439. * @param name defines the name of the task
  60440. */
  60441. constructor(
  60442. /**
  60443. * Task name
  60444. */ name: string);
  60445. private _isCompleted;
  60446. private _taskState;
  60447. private _errorObject;
  60448. /**
  60449. * Get if the task is completed
  60450. */
  60451. readonly isCompleted: boolean;
  60452. /**
  60453. * Gets the current state of the task
  60454. */
  60455. readonly taskState: AssetTaskState;
  60456. /**
  60457. * Gets the current error object (if task is in error)
  60458. */
  60459. readonly errorObject: {
  60460. message?: string;
  60461. exception?: any;
  60462. };
  60463. /**
  60464. * Internal only
  60465. * @hidden
  60466. */
  60467. _setErrorObject(message?: string, exception?: any): void;
  60468. /**
  60469. * Execute the current task
  60470. * @param scene defines the scene where you want your assets to be loaded
  60471. * @param onSuccess is a callback called when the task is successfully executed
  60472. * @param onError is a callback called if an error occurs
  60473. */
  60474. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60475. /**
  60476. * Execute the current task
  60477. * @param scene defines the scene where you want your assets to be loaded
  60478. * @param onSuccess is a callback called when the task is successfully executed
  60479. * @param onError is a callback called if an error occurs
  60480. */
  60481. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60482. /**
  60483. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  60484. * This can be used with failed tasks that have the reason for failure fixed.
  60485. */
  60486. reset(): void;
  60487. private onErrorCallback;
  60488. private onDoneCallback;
  60489. }
  60490. /**
  60491. * Define the interface used by progress events raised during assets loading
  60492. */
  60493. export interface IAssetsProgressEvent {
  60494. /**
  60495. * Defines the number of remaining tasks to process
  60496. */
  60497. remainingCount: number;
  60498. /**
  60499. * Defines the total number of tasks
  60500. */
  60501. totalCount: number;
  60502. /**
  60503. * Defines the task that was just processed
  60504. */
  60505. task: AbstractAssetTask;
  60506. }
  60507. /**
  60508. * Class used to share progress information about assets loading
  60509. */
  60510. export class AssetsProgressEvent implements IAssetsProgressEvent {
  60511. /**
  60512. * Defines the number of remaining tasks to process
  60513. */
  60514. remainingCount: number;
  60515. /**
  60516. * Defines the total number of tasks
  60517. */
  60518. totalCount: number;
  60519. /**
  60520. * Defines the task that was just processed
  60521. */
  60522. task: AbstractAssetTask;
  60523. /**
  60524. * Creates a AssetsProgressEvent
  60525. * @param remainingCount defines the number of remaining tasks to process
  60526. * @param totalCount defines the total number of tasks
  60527. * @param task defines the task that was just processed
  60528. */
  60529. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  60530. }
  60531. /**
  60532. * Define a task used by AssetsManager to load meshes
  60533. */
  60534. export class MeshAssetTask extends AbstractAssetTask {
  60535. /**
  60536. * Defines the name of the task
  60537. */
  60538. name: string;
  60539. /**
  60540. * Defines the list of mesh's names you want to load
  60541. */
  60542. meshesNames: any;
  60543. /**
  60544. * Defines the root url to use as a base to load your meshes and associated resources
  60545. */
  60546. rootUrl: string;
  60547. /**
  60548. * Defines the filename of the scene to load from
  60549. */
  60550. sceneFilename: string;
  60551. /**
  60552. * Gets the list of loaded meshes
  60553. */
  60554. loadedMeshes: Array<AbstractMesh>;
  60555. /**
  60556. * Gets the list of loaded particle systems
  60557. */
  60558. loadedParticleSystems: Array<IParticleSystem>;
  60559. /**
  60560. * Gets the list of loaded skeletons
  60561. */
  60562. loadedSkeletons: Array<Skeleton>;
  60563. /**
  60564. * Gets the list of loaded animation groups
  60565. */
  60566. loadedAnimationGroups: Array<AnimationGroup>;
  60567. /**
  60568. * Callback called when the task is successful
  60569. */
  60570. onSuccess: (task: MeshAssetTask) => void;
  60571. /**
  60572. * Callback called when the task is successful
  60573. */
  60574. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  60575. /**
  60576. * Creates a new MeshAssetTask
  60577. * @param name defines the name of the task
  60578. * @param meshesNames defines the list of mesh's names you want to load
  60579. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  60580. * @param sceneFilename defines the filename of the scene to load from
  60581. */
  60582. constructor(
  60583. /**
  60584. * Defines the name of the task
  60585. */
  60586. name: string,
  60587. /**
  60588. * Defines the list of mesh's names you want to load
  60589. */
  60590. meshesNames: any,
  60591. /**
  60592. * Defines the root url to use as a base to load your meshes and associated resources
  60593. */
  60594. rootUrl: string,
  60595. /**
  60596. * Defines the filename of the scene to load from
  60597. */
  60598. sceneFilename: string);
  60599. /**
  60600. * Execute the current task
  60601. * @param scene defines the scene where you want your assets to be loaded
  60602. * @param onSuccess is a callback called when the task is successfully executed
  60603. * @param onError is a callback called if an error occurs
  60604. */
  60605. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60606. }
  60607. /**
  60608. * Define a task used by AssetsManager to load text content
  60609. */
  60610. export class TextFileAssetTask extends AbstractAssetTask {
  60611. /**
  60612. * Defines the name of the task
  60613. */
  60614. name: string;
  60615. /**
  60616. * Defines the location of the file to load
  60617. */
  60618. url: string;
  60619. /**
  60620. * Gets the loaded text string
  60621. */
  60622. text: string;
  60623. /**
  60624. * Callback called when the task is successful
  60625. */
  60626. onSuccess: (task: TextFileAssetTask) => void;
  60627. /**
  60628. * Callback called when the task is successful
  60629. */
  60630. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  60631. /**
  60632. * Creates a new TextFileAssetTask object
  60633. * @param name defines the name of the task
  60634. * @param url defines the location of the file to load
  60635. */
  60636. constructor(
  60637. /**
  60638. * Defines the name of the task
  60639. */
  60640. name: string,
  60641. /**
  60642. * Defines the location of the file to load
  60643. */
  60644. url: string);
  60645. /**
  60646. * Execute the current task
  60647. * @param scene defines the scene where you want your assets to be loaded
  60648. * @param onSuccess is a callback called when the task is successfully executed
  60649. * @param onError is a callback called if an error occurs
  60650. */
  60651. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60652. }
  60653. /**
  60654. * Define a task used by AssetsManager to load binary data
  60655. */
  60656. export class BinaryFileAssetTask extends AbstractAssetTask {
  60657. /**
  60658. * Defines the name of the task
  60659. */
  60660. name: string;
  60661. /**
  60662. * Defines the location of the file to load
  60663. */
  60664. url: string;
  60665. /**
  60666. * Gets the lodaded data (as an array buffer)
  60667. */
  60668. data: ArrayBuffer;
  60669. /**
  60670. * Callback called when the task is successful
  60671. */
  60672. onSuccess: (task: BinaryFileAssetTask) => void;
  60673. /**
  60674. * Callback called when the task is successful
  60675. */
  60676. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  60677. /**
  60678. * Creates a new BinaryFileAssetTask object
  60679. * @param name defines the name of the new task
  60680. * @param url defines the location of the file to load
  60681. */
  60682. constructor(
  60683. /**
  60684. * Defines the name of the task
  60685. */
  60686. name: string,
  60687. /**
  60688. * Defines the location of the file to load
  60689. */
  60690. url: string);
  60691. /**
  60692. * Execute the current task
  60693. * @param scene defines the scene where you want your assets to be loaded
  60694. * @param onSuccess is a callback called when the task is successfully executed
  60695. * @param onError is a callback called if an error occurs
  60696. */
  60697. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60698. }
  60699. /**
  60700. * Define a task used by AssetsManager to load images
  60701. */
  60702. export class ImageAssetTask extends AbstractAssetTask {
  60703. /**
  60704. * Defines the name of the task
  60705. */
  60706. name: string;
  60707. /**
  60708. * Defines the location of the image to load
  60709. */
  60710. url: string;
  60711. /**
  60712. * Gets the loaded images
  60713. */
  60714. image: HTMLImageElement;
  60715. /**
  60716. * Callback called when the task is successful
  60717. */
  60718. onSuccess: (task: ImageAssetTask) => void;
  60719. /**
  60720. * Callback called when the task is successful
  60721. */
  60722. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  60723. /**
  60724. * Creates a new ImageAssetTask
  60725. * @param name defines the name of the task
  60726. * @param url defines the location of the image to load
  60727. */
  60728. constructor(
  60729. /**
  60730. * Defines the name of the task
  60731. */
  60732. name: string,
  60733. /**
  60734. * Defines the location of the image to load
  60735. */
  60736. url: string);
  60737. /**
  60738. * Execute the current task
  60739. * @param scene defines the scene where you want your assets to be loaded
  60740. * @param onSuccess is a callback called when the task is successfully executed
  60741. * @param onError is a callback called if an error occurs
  60742. */
  60743. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60744. }
  60745. /**
  60746. * Defines the interface used by texture loading tasks
  60747. */
  60748. export interface ITextureAssetTask<TEX extends BaseTexture> {
  60749. /**
  60750. * Gets the loaded texture
  60751. */
  60752. texture: TEX;
  60753. }
  60754. /**
  60755. * Define a task used by AssetsManager to load 2D textures
  60756. */
  60757. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  60758. /**
  60759. * Defines the name of the task
  60760. */
  60761. name: string;
  60762. /**
  60763. * Defines the location of the file to load
  60764. */
  60765. url: string;
  60766. /**
  60767. * Defines if mipmap should not be generated (default is false)
  60768. */
  60769. noMipmap?: boolean | undefined;
  60770. /**
  60771. * Defines if texture must be inverted on Y axis (default is false)
  60772. */
  60773. invertY?: boolean | undefined;
  60774. /**
  60775. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60776. */
  60777. samplingMode: number;
  60778. /**
  60779. * Gets the loaded texture
  60780. */
  60781. texture: Texture;
  60782. /**
  60783. * Callback called when the task is successful
  60784. */
  60785. onSuccess: (task: TextureAssetTask) => void;
  60786. /**
  60787. * Callback called when the task is successful
  60788. */
  60789. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  60790. /**
  60791. * Creates a new TextureAssetTask object
  60792. * @param name defines the name of the task
  60793. * @param url defines the location of the file to load
  60794. * @param noMipmap defines if mipmap should not be generated (default is false)
  60795. * @param invertY defines if texture must be inverted on Y axis (default is false)
  60796. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60797. */
  60798. constructor(
  60799. /**
  60800. * Defines the name of the task
  60801. */
  60802. name: string,
  60803. /**
  60804. * Defines the location of the file to load
  60805. */
  60806. url: string,
  60807. /**
  60808. * Defines if mipmap should not be generated (default is false)
  60809. */
  60810. noMipmap?: boolean | undefined,
  60811. /**
  60812. * Defines if texture must be inverted on Y axis (default is false)
  60813. */
  60814. invertY?: boolean | undefined,
  60815. /**
  60816. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60817. */
  60818. samplingMode?: number);
  60819. /**
  60820. * Execute the current task
  60821. * @param scene defines the scene where you want your assets to be loaded
  60822. * @param onSuccess is a callback called when the task is successfully executed
  60823. * @param onError is a callback called if an error occurs
  60824. */
  60825. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60826. }
  60827. /**
  60828. * Define a task used by AssetsManager to load cube textures
  60829. */
  60830. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  60831. /**
  60832. * Defines the name of the task
  60833. */
  60834. name: string;
  60835. /**
  60836. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60837. */
  60838. url: string;
  60839. /**
  60840. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60841. */
  60842. extensions?: string[] | undefined;
  60843. /**
  60844. * Defines if mipmaps should not be generated (default is false)
  60845. */
  60846. noMipmap?: boolean | undefined;
  60847. /**
  60848. * Defines the explicit list of files (undefined by default)
  60849. */
  60850. files?: string[] | undefined;
  60851. /**
  60852. * Gets the loaded texture
  60853. */
  60854. texture: CubeTexture;
  60855. /**
  60856. * Callback called when the task is successful
  60857. */
  60858. onSuccess: (task: CubeTextureAssetTask) => void;
  60859. /**
  60860. * Callback called when the task is successful
  60861. */
  60862. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  60863. /**
  60864. * Creates a new CubeTextureAssetTask
  60865. * @param name defines the name of the task
  60866. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60867. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60868. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60869. * @param files defines the explicit list of files (undefined by default)
  60870. */
  60871. constructor(
  60872. /**
  60873. * Defines the name of the task
  60874. */
  60875. name: string,
  60876. /**
  60877. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60878. */
  60879. url: string,
  60880. /**
  60881. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60882. */
  60883. extensions?: string[] | undefined,
  60884. /**
  60885. * Defines if mipmaps should not be generated (default is false)
  60886. */
  60887. noMipmap?: boolean | undefined,
  60888. /**
  60889. * Defines the explicit list of files (undefined by default)
  60890. */
  60891. files?: string[] | undefined);
  60892. /**
  60893. * Execute the current task
  60894. * @param scene defines the scene where you want your assets to be loaded
  60895. * @param onSuccess is a callback called when the task is successfully executed
  60896. * @param onError is a callback called if an error occurs
  60897. */
  60898. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60899. }
  60900. /**
  60901. * Define a task used by AssetsManager to load HDR cube textures
  60902. */
  60903. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  60904. /**
  60905. * Defines the name of the task
  60906. */
  60907. name: string;
  60908. /**
  60909. * Defines the location of the file to load
  60910. */
  60911. url: string;
  60912. /**
  60913. * Defines the desired size (the more it increases the longer the generation will be)
  60914. */
  60915. size: number;
  60916. /**
  60917. * Defines if mipmaps should not be generated (default is false)
  60918. */
  60919. noMipmap: boolean;
  60920. /**
  60921. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60922. */
  60923. generateHarmonics: boolean;
  60924. /**
  60925. * 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)
  60926. */
  60927. gammaSpace: boolean;
  60928. /**
  60929. * Internal Use Only
  60930. */
  60931. reserved: boolean;
  60932. /**
  60933. * Gets the loaded texture
  60934. */
  60935. texture: HDRCubeTexture;
  60936. /**
  60937. * Callback called when the task is successful
  60938. */
  60939. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  60940. /**
  60941. * Callback called when the task is successful
  60942. */
  60943. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  60944. /**
  60945. * Creates a new HDRCubeTextureAssetTask object
  60946. * @param name defines the name of the task
  60947. * @param url defines the location of the file to load
  60948. * @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.
  60949. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60950. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60951. * @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)
  60952. * @param reserved Internal use only
  60953. */
  60954. constructor(
  60955. /**
  60956. * Defines the name of the task
  60957. */
  60958. name: string,
  60959. /**
  60960. * Defines the location of the file to load
  60961. */
  60962. url: string,
  60963. /**
  60964. * Defines the desired size (the more it increases the longer the generation will be)
  60965. */
  60966. size: number,
  60967. /**
  60968. * Defines if mipmaps should not be generated (default is false)
  60969. */
  60970. noMipmap?: boolean,
  60971. /**
  60972. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60973. */
  60974. generateHarmonics?: boolean,
  60975. /**
  60976. * 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)
  60977. */
  60978. gammaSpace?: boolean,
  60979. /**
  60980. * Internal Use Only
  60981. */
  60982. reserved?: boolean);
  60983. /**
  60984. * Execute the current task
  60985. * @param scene defines the scene where you want your assets to be loaded
  60986. * @param onSuccess is a callback called when the task is successfully executed
  60987. * @param onError is a callback called if an error occurs
  60988. */
  60989. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60990. }
  60991. /**
  60992. * Define a task used by AssetsManager to load Equirectangular cube textures
  60993. */
  60994. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  60995. /**
  60996. * Defines the name of the task
  60997. */
  60998. name: string;
  60999. /**
  61000. * Defines the location of the file to load
  61001. */
  61002. url: string;
  61003. /**
  61004. * Defines the desired size (the more it increases the longer the generation will be)
  61005. */
  61006. size: number;
  61007. /**
  61008. * Defines if mipmaps should not be generated (default is false)
  61009. */
  61010. noMipmap: boolean;
  61011. /**
  61012. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61013. * but the standard material would require them in Gamma space) (default is true)
  61014. */
  61015. gammaSpace: boolean;
  61016. /**
  61017. * Gets the loaded texture
  61018. */
  61019. texture: EquiRectangularCubeTexture;
  61020. /**
  61021. * Callback called when the task is successful
  61022. */
  61023. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  61024. /**
  61025. * Callback called when the task is successful
  61026. */
  61027. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  61028. /**
  61029. * Creates a new EquiRectangularCubeTextureAssetTask object
  61030. * @param name defines the name of the task
  61031. * @param url defines the location of the file to load
  61032. * @param size defines the desired size (the more it increases the longer the generation will be)
  61033. * If the size is omitted this implies you are using a preprocessed cubemap.
  61034. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61035. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  61036. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  61037. * (default is true)
  61038. */
  61039. constructor(
  61040. /**
  61041. * Defines the name of the task
  61042. */
  61043. name: string,
  61044. /**
  61045. * Defines the location of the file to load
  61046. */
  61047. url: string,
  61048. /**
  61049. * Defines the desired size (the more it increases the longer the generation will be)
  61050. */
  61051. size: number,
  61052. /**
  61053. * Defines if mipmaps should not be generated (default is false)
  61054. */
  61055. noMipmap?: boolean,
  61056. /**
  61057. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61058. * but the standard material would require them in Gamma space) (default is true)
  61059. */
  61060. gammaSpace?: boolean);
  61061. /**
  61062. * Execute the current task
  61063. * @param scene defines the scene where you want your assets to be loaded
  61064. * @param onSuccess is a callback called when the task is successfully executed
  61065. * @param onError is a callback called if an error occurs
  61066. */
  61067. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61068. }
  61069. /**
  61070. * This class can be used to easily import assets into a scene
  61071. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  61072. */
  61073. export class AssetsManager {
  61074. private _scene;
  61075. private _isLoading;
  61076. protected _tasks: AbstractAssetTask[];
  61077. protected _waitingTasksCount: number;
  61078. protected _totalTasksCount: number;
  61079. /**
  61080. * Callback called when all tasks are processed
  61081. */
  61082. onFinish: (tasks: AbstractAssetTask[]) => void;
  61083. /**
  61084. * Callback called when a task is successful
  61085. */
  61086. onTaskSuccess: (task: AbstractAssetTask) => void;
  61087. /**
  61088. * Callback called when a task had an error
  61089. */
  61090. onTaskError: (task: AbstractAssetTask) => void;
  61091. /**
  61092. * Callback called when a task is done (whatever the result is)
  61093. */
  61094. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  61095. /**
  61096. * Observable called when all tasks are processed
  61097. */
  61098. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  61099. /**
  61100. * Observable called when a task had an error
  61101. */
  61102. onTaskErrorObservable: Observable<AbstractAssetTask>;
  61103. /**
  61104. * Observable called when all tasks were executed
  61105. */
  61106. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  61107. /**
  61108. * Observable called when a task is done (whatever the result is)
  61109. */
  61110. onProgressObservable: Observable<IAssetsProgressEvent>;
  61111. /**
  61112. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  61113. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  61114. */
  61115. useDefaultLoadingScreen: boolean;
  61116. /**
  61117. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  61118. * when all assets have been downloaded.
  61119. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  61120. */
  61121. autoHideLoadingUI: boolean;
  61122. /**
  61123. * Creates a new AssetsManager
  61124. * @param scene defines the scene to work on
  61125. */
  61126. constructor(scene: Scene);
  61127. /**
  61128. * Add a MeshAssetTask to the list of active tasks
  61129. * @param taskName defines the name of the new task
  61130. * @param meshesNames defines the name of meshes to load
  61131. * @param rootUrl defines the root url to use to locate files
  61132. * @param sceneFilename defines the filename of the scene file
  61133. * @returns a new MeshAssetTask object
  61134. */
  61135. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  61136. /**
  61137. * Add a TextFileAssetTask to the list of active tasks
  61138. * @param taskName defines the name of the new task
  61139. * @param url defines the url of the file to load
  61140. * @returns a new TextFileAssetTask object
  61141. */
  61142. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  61143. /**
  61144. * Add a BinaryFileAssetTask to the list of active tasks
  61145. * @param taskName defines the name of the new task
  61146. * @param url defines the url of the file to load
  61147. * @returns a new BinaryFileAssetTask object
  61148. */
  61149. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  61150. /**
  61151. * Add a ImageAssetTask to the list of active tasks
  61152. * @param taskName defines the name of the new task
  61153. * @param url defines the url of the file to load
  61154. * @returns a new ImageAssetTask object
  61155. */
  61156. addImageTask(taskName: string, url: string): ImageAssetTask;
  61157. /**
  61158. * Add a TextureAssetTask to the list of active tasks
  61159. * @param taskName defines the name of the new task
  61160. * @param url defines the url of the file to load
  61161. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61162. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  61163. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61164. * @returns a new TextureAssetTask object
  61165. */
  61166. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  61167. /**
  61168. * Add a CubeTextureAssetTask to the list of active tasks
  61169. * @param taskName defines the name of the new task
  61170. * @param url defines the url of the file to load
  61171. * @param extensions defines the extension to use to load the cube map (can be null)
  61172. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61173. * @param files defines the list of files to load (can be null)
  61174. * @returns a new CubeTextureAssetTask object
  61175. */
  61176. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  61177. /**
  61178. *
  61179. * Add a HDRCubeTextureAssetTask to the list of active tasks
  61180. * @param taskName defines the name of the new task
  61181. * @param url defines the url of the file to load
  61182. * @param size defines the size you want for the cubemap (can be null)
  61183. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61184. * @param generateHarmonics defines if you want to automatically generate (true by default)
  61185. * @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)
  61186. * @param reserved Internal use only
  61187. * @returns a new HDRCubeTextureAssetTask object
  61188. */
  61189. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  61190. /**
  61191. *
  61192. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  61193. * @param taskName defines the name of the new task
  61194. * @param url defines the url of the file to load
  61195. * @param size defines the size you want for the cubemap (can be null)
  61196. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61197. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61198. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61199. * @returns a new EquiRectangularCubeTextureAssetTask object
  61200. */
  61201. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  61202. /**
  61203. * Remove a task from the assets manager.
  61204. * @param task the task to remove
  61205. */
  61206. removeTask(task: AbstractAssetTask): void;
  61207. private _decreaseWaitingTasksCount;
  61208. private _runTask;
  61209. /**
  61210. * Reset the AssetsManager and remove all tasks
  61211. * @return the current instance of the AssetsManager
  61212. */
  61213. reset(): AssetsManager;
  61214. /**
  61215. * Start the loading process
  61216. * @return the current instance of the AssetsManager
  61217. */
  61218. load(): AssetsManager;
  61219. /**
  61220. * Start the loading process as an async operation
  61221. * @return a promise returning the list of failed tasks
  61222. */
  61223. loadAsync(): Promise<void>;
  61224. }
  61225. }
  61226. declare module BABYLON {
  61227. /**
  61228. * Wrapper class for promise with external resolve and reject.
  61229. */
  61230. export class Deferred<T> {
  61231. /**
  61232. * The promise associated with this deferred object.
  61233. */
  61234. readonly promise: Promise<T>;
  61235. private _resolve;
  61236. private _reject;
  61237. /**
  61238. * The resolve method of the promise associated with this deferred object.
  61239. */
  61240. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  61241. /**
  61242. * The reject method of the promise associated with this deferred object.
  61243. */
  61244. readonly reject: (reason?: any) => void;
  61245. /**
  61246. * Constructor for this deferred object.
  61247. */
  61248. constructor();
  61249. }
  61250. }
  61251. declare module BABYLON {
  61252. /**
  61253. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  61254. */
  61255. export class MeshExploder {
  61256. private _centerMesh;
  61257. private _meshes;
  61258. private _meshesOrigins;
  61259. private _toCenterVectors;
  61260. private _scaledDirection;
  61261. private _newPosition;
  61262. private _centerPosition;
  61263. /**
  61264. * Explodes meshes from a center mesh.
  61265. * @param meshes The meshes to explode.
  61266. * @param centerMesh The mesh to be center of explosion.
  61267. */
  61268. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  61269. private _setCenterMesh;
  61270. /**
  61271. * Get class name
  61272. * @returns "MeshExploder"
  61273. */
  61274. getClassName(): string;
  61275. /**
  61276. * "Exploded meshes"
  61277. * @returns Array of meshes with the centerMesh at index 0.
  61278. */
  61279. getMeshes(): Array<Mesh>;
  61280. /**
  61281. * Explodes meshes giving a specific direction
  61282. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  61283. */
  61284. explode(direction?: number): void;
  61285. }
  61286. }
  61287. declare module BABYLON {
  61288. /**
  61289. * Class used to help managing file picking and drag'n'drop
  61290. */
  61291. export class FilesInput {
  61292. /**
  61293. * List of files ready to be loaded
  61294. */
  61295. static readonly FilesToLoad: {
  61296. [key: string]: File;
  61297. };
  61298. /**
  61299. * Callback called when a file is processed
  61300. */
  61301. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  61302. private _engine;
  61303. private _currentScene;
  61304. private _sceneLoadedCallback;
  61305. private _progressCallback;
  61306. private _additionalRenderLoopLogicCallback;
  61307. private _textureLoadingCallback;
  61308. private _startingProcessingFilesCallback;
  61309. private _onReloadCallback;
  61310. private _errorCallback;
  61311. private _elementToMonitor;
  61312. private _sceneFileToLoad;
  61313. private _filesToLoad;
  61314. /**
  61315. * Creates a new FilesInput
  61316. * @param engine defines the rendering engine
  61317. * @param scene defines the hosting scene
  61318. * @param sceneLoadedCallback callback called when scene is loaded
  61319. * @param progressCallback callback called to track progress
  61320. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  61321. * @param textureLoadingCallback callback called when a texture is loading
  61322. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  61323. * @param onReloadCallback callback called when a reload is requested
  61324. * @param errorCallback callback call if an error occurs
  61325. */
  61326. 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);
  61327. private _dragEnterHandler;
  61328. private _dragOverHandler;
  61329. private _dropHandler;
  61330. /**
  61331. * Calls this function to listen to drag'n'drop events on a specific DOM element
  61332. * @param elementToMonitor defines the DOM element to track
  61333. */
  61334. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  61335. /**
  61336. * Release all associated resources
  61337. */
  61338. dispose(): void;
  61339. private renderFunction;
  61340. private drag;
  61341. private drop;
  61342. private _traverseFolder;
  61343. private _processFiles;
  61344. /**
  61345. * Load files from a drop event
  61346. * @param event defines the drop event to use as source
  61347. */
  61348. loadFiles(event: any): void;
  61349. private _processReload;
  61350. /**
  61351. * Reload the current scene from the loaded files
  61352. */
  61353. reload(): void;
  61354. }
  61355. }
  61356. declare module BABYLON {
  61357. /**
  61358. * Defines the root class used to create scene optimization to use with SceneOptimizer
  61359. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61360. */
  61361. export class SceneOptimization {
  61362. /**
  61363. * Defines the priority of this optimization (0 by default which means first in the list)
  61364. */
  61365. priority: number;
  61366. /**
  61367. * Gets a string describing the action executed by the current optimization
  61368. * @returns description string
  61369. */
  61370. getDescription(): string;
  61371. /**
  61372. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61373. * @param scene defines the current scene where to apply this optimization
  61374. * @param optimizer defines the current optimizer
  61375. * @returns true if everything that can be done was applied
  61376. */
  61377. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61378. /**
  61379. * Creates the SceneOptimization object
  61380. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61381. * @param desc defines the description associated with the optimization
  61382. */
  61383. constructor(
  61384. /**
  61385. * Defines the priority of this optimization (0 by default which means first in the list)
  61386. */
  61387. priority?: number);
  61388. }
  61389. /**
  61390. * Defines an optimization used to reduce the size of render target textures
  61391. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61392. */
  61393. export class TextureOptimization extends SceneOptimization {
  61394. /**
  61395. * Defines the priority of this optimization (0 by default which means first in the list)
  61396. */
  61397. priority: number;
  61398. /**
  61399. * 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
  61400. */
  61401. maximumSize: number;
  61402. /**
  61403. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61404. */
  61405. step: number;
  61406. /**
  61407. * Gets a string describing the action executed by the current optimization
  61408. * @returns description string
  61409. */
  61410. getDescription(): string;
  61411. /**
  61412. * Creates the TextureOptimization object
  61413. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61414. * @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
  61415. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61416. */
  61417. constructor(
  61418. /**
  61419. * Defines the priority of this optimization (0 by default which means first in the list)
  61420. */
  61421. priority?: number,
  61422. /**
  61423. * 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
  61424. */
  61425. maximumSize?: number,
  61426. /**
  61427. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61428. */
  61429. step?: number);
  61430. /**
  61431. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61432. * @param scene defines the current scene where to apply this optimization
  61433. * @param optimizer defines the current optimizer
  61434. * @returns true if everything that can be done was applied
  61435. */
  61436. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61437. }
  61438. /**
  61439. * Defines an optimization used to increase or decrease the rendering resolution
  61440. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61441. */
  61442. export class HardwareScalingOptimization extends SceneOptimization {
  61443. /**
  61444. * Defines the priority of this optimization (0 by default which means first in the list)
  61445. */
  61446. priority: number;
  61447. /**
  61448. * Defines the maximum scale to use (2 by default)
  61449. */
  61450. maximumScale: number;
  61451. /**
  61452. * Defines the step to use between two passes (0.5 by default)
  61453. */
  61454. step: number;
  61455. private _currentScale;
  61456. private _directionOffset;
  61457. /**
  61458. * Gets a string describing the action executed by the current optimization
  61459. * @return description string
  61460. */
  61461. getDescription(): string;
  61462. /**
  61463. * Creates the HardwareScalingOptimization object
  61464. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61465. * @param maximumScale defines the maximum scale to use (2 by default)
  61466. * @param step defines the step to use between two passes (0.5 by default)
  61467. */
  61468. constructor(
  61469. /**
  61470. * Defines the priority of this optimization (0 by default which means first in the list)
  61471. */
  61472. priority?: number,
  61473. /**
  61474. * Defines the maximum scale to use (2 by default)
  61475. */
  61476. maximumScale?: number,
  61477. /**
  61478. * Defines the step to use between two passes (0.5 by default)
  61479. */
  61480. step?: number);
  61481. /**
  61482. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61483. * @param scene defines the current scene where to apply this optimization
  61484. * @param optimizer defines the current optimizer
  61485. * @returns true if everything that can be done was applied
  61486. */
  61487. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61488. }
  61489. /**
  61490. * Defines an optimization used to remove shadows
  61491. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61492. */
  61493. export class ShadowsOptimization extends SceneOptimization {
  61494. /**
  61495. * Gets a string describing the action executed by the current optimization
  61496. * @return description string
  61497. */
  61498. getDescription(): string;
  61499. /**
  61500. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61501. * @param scene defines the current scene where to apply this optimization
  61502. * @param optimizer defines the current optimizer
  61503. * @returns true if everything that can be done was applied
  61504. */
  61505. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61506. }
  61507. /**
  61508. * Defines an optimization used to turn post-processes off
  61509. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61510. */
  61511. export class PostProcessesOptimization extends SceneOptimization {
  61512. /**
  61513. * Gets a string describing the action executed by the current optimization
  61514. * @return description string
  61515. */
  61516. getDescription(): string;
  61517. /**
  61518. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61519. * @param scene defines the current scene where to apply this optimization
  61520. * @param optimizer defines the current optimizer
  61521. * @returns true if everything that can be done was applied
  61522. */
  61523. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61524. }
  61525. /**
  61526. * Defines an optimization used to turn lens flares off
  61527. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61528. */
  61529. export class LensFlaresOptimization extends SceneOptimization {
  61530. /**
  61531. * Gets a string describing the action executed by the current optimization
  61532. * @return description string
  61533. */
  61534. getDescription(): string;
  61535. /**
  61536. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61537. * @param scene defines the current scene where to apply this optimization
  61538. * @param optimizer defines the current optimizer
  61539. * @returns true if everything that can be done was applied
  61540. */
  61541. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61542. }
  61543. /**
  61544. * Defines an optimization based on user defined callback.
  61545. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61546. */
  61547. export class CustomOptimization extends SceneOptimization {
  61548. /**
  61549. * Callback called to apply the custom optimization.
  61550. */
  61551. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  61552. /**
  61553. * Callback called to get custom description
  61554. */
  61555. onGetDescription: () => string;
  61556. /**
  61557. * Gets a string describing the action executed by the current optimization
  61558. * @returns description string
  61559. */
  61560. getDescription(): string;
  61561. /**
  61562. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61563. * @param scene defines the current scene where to apply this optimization
  61564. * @param optimizer defines the current optimizer
  61565. * @returns true if everything that can be done was applied
  61566. */
  61567. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61568. }
  61569. /**
  61570. * Defines an optimization used to turn particles off
  61571. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61572. */
  61573. export class ParticlesOptimization extends SceneOptimization {
  61574. /**
  61575. * Gets a string describing the action executed by the current optimization
  61576. * @return description string
  61577. */
  61578. getDescription(): string;
  61579. /**
  61580. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61581. * @param scene defines the current scene where to apply this optimization
  61582. * @param optimizer defines the current optimizer
  61583. * @returns true if everything that can be done was applied
  61584. */
  61585. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61586. }
  61587. /**
  61588. * Defines an optimization used to turn render targets off
  61589. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61590. */
  61591. export class RenderTargetsOptimization extends SceneOptimization {
  61592. /**
  61593. * Gets a string describing the action executed by the current optimization
  61594. * @return description string
  61595. */
  61596. getDescription(): string;
  61597. /**
  61598. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61599. * @param scene defines the current scene where to apply this optimization
  61600. * @param optimizer defines the current optimizer
  61601. * @returns true if everything that can be done was applied
  61602. */
  61603. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61604. }
  61605. /**
  61606. * Defines an optimization used to merge meshes with compatible materials
  61607. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61608. */
  61609. export class MergeMeshesOptimization extends SceneOptimization {
  61610. private static _UpdateSelectionTree;
  61611. /**
  61612. * Gets or sets a boolean which defines if optimization octree has to be updated
  61613. */
  61614. /**
  61615. * Gets or sets a boolean which defines if optimization octree has to be updated
  61616. */
  61617. static UpdateSelectionTree: boolean;
  61618. /**
  61619. * Gets a string describing the action executed by the current optimization
  61620. * @return description string
  61621. */
  61622. getDescription(): string;
  61623. private _canBeMerged;
  61624. /**
  61625. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61626. * @param scene defines the current scene where to apply this optimization
  61627. * @param optimizer defines the current optimizer
  61628. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  61629. * @returns true if everything that can be done was applied
  61630. */
  61631. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  61632. }
  61633. /**
  61634. * Defines a list of options used by SceneOptimizer
  61635. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61636. */
  61637. export class SceneOptimizerOptions {
  61638. /**
  61639. * Defines the target frame rate to reach (60 by default)
  61640. */
  61641. targetFrameRate: number;
  61642. /**
  61643. * Defines the interval between two checkes (2000ms by default)
  61644. */
  61645. trackerDuration: number;
  61646. /**
  61647. * Gets the list of optimizations to apply
  61648. */
  61649. optimizations: SceneOptimization[];
  61650. /**
  61651. * Creates a new list of options used by SceneOptimizer
  61652. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  61653. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  61654. */
  61655. constructor(
  61656. /**
  61657. * Defines the target frame rate to reach (60 by default)
  61658. */
  61659. targetFrameRate?: number,
  61660. /**
  61661. * Defines the interval between two checkes (2000ms by default)
  61662. */
  61663. trackerDuration?: number);
  61664. /**
  61665. * Add a new optimization
  61666. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  61667. * @returns the current SceneOptimizerOptions
  61668. */
  61669. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  61670. /**
  61671. * Add a new custom optimization
  61672. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  61673. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  61674. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61675. * @returns the current SceneOptimizerOptions
  61676. */
  61677. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  61678. /**
  61679. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  61680. * @param targetFrameRate defines the target frame rate (60 by default)
  61681. * @returns a SceneOptimizerOptions object
  61682. */
  61683. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61684. /**
  61685. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  61686. * @param targetFrameRate defines the target frame rate (60 by default)
  61687. * @returns a SceneOptimizerOptions object
  61688. */
  61689. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61690. /**
  61691. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  61692. * @param targetFrameRate defines the target frame rate (60 by default)
  61693. * @returns a SceneOptimizerOptions object
  61694. */
  61695. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61696. }
  61697. /**
  61698. * Class used to run optimizations in order to reach a target frame rate
  61699. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61700. */
  61701. export class SceneOptimizer implements IDisposable {
  61702. private _isRunning;
  61703. private _options;
  61704. private _scene;
  61705. private _currentPriorityLevel;
  61706. private _targetFrameRate;
  61707. private _trackerDuration;
  61708. private _currentFrameRate;
  61709. private _sceneDisposeObserver;
  61710. private _improvementMode;
  61711. /**
  61712. * Defines an observable called when the optimizer reaches the target frame rate
  61713. */
  61714. onSuccessObservable: Observable<SceneOptimizer>;
  61715. /**
  61716. * Defines an observable called when the optimizer enables an optimization
  61717. */
  61718. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  61719. /**
  61720. * Defines an observable called when the optimizer is not able to reach the target frame rate
  61721. */
  61722. onFailureObservable: Observable<SceneOptimizer>;
  61723. /**
  61724. * Gets a boolean indicating if the optimizer is in improvement mode
  61725. */
  61726. readonly isInImprovementMode: boolean;
  61727. /**
  61728. * Gets the current priority level (0 at start)
  61729. */
  61730. readonly currentPriorityLevel: number;
  61731. /**
  61732. * Gets the current frame rate checked by the SceneOptimizer
  61733. */
  61734. readonly currentFrameRate: number;
  61735. /**
  61736. * Gets or sets the current target frame rate (60 by default)
  61737. */
  61738. /**
  61739. * Gets or sets the current target frame rate (60 by default)
  61740. */
  61741. targetFrameRate: number;
  61742. /**
  61743. * Gets or sets the current interval between two checks (every 2000ms by default)
  61744. */
  61745. /**
  61746. * Gets or sets the current interval between two checks (every 2000ms by default)
  61747. */
  61748. trackerDuration: number;
  61749. /**
  61750. * Gets the list of active optimizations
  61751. */
  61752. readonly optimizations: SceneOptimization[];
  61753. /**
  61754. * Creates a new SceneOptimizer
  61755. * @param scene defines the scene to work on
  61756. * @param options defines the options to use with the SceneOptimizer
  61757. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  61758. * @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)
  61759. */
  61760. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  61761. /**
  61762. * Stops the current optimizer
  61763. */
  61764. stop(): void;
  61765. /**
  61766. * Reset the optimizer to initial step (current priority level = 0)
  61767. */
  61768. reset(): void;
  61769. /**
  61770. * Start the optimizer. By default it will try to reach a specific framerate
  61771. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  61772. */
  61773. start(): void;
  61774. private _checkCurrentState;
  61775. /**
  61776. * Release all resources
  61777. */
  61778. dispose(): void;
  61779. /**
  61780. * Helper function to create a SceneOptimizer with one single line of code
  61781. * @param scene defines the scene to work on
  61782. * @param options defines the options to use with the SceneOptimizer
  61783. * @param onSuccess defines a callback to call on success
  61784. * @param onFailure defines a callback to call on failure
  61785. * @returns the new SceneOptimizer object
  61786. */
  61787. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  61788. }
  61789. }
  61790. declare module BABYLON {
  61791. /**
  61792. * Class used to serialize a scene into a string
  61793. */
  61794. export class SceneSerializer {
  61795. /**
  61796. * Clear cache used by a previous serialization
  61797. */
  61798. static ClearCache(): void;
  61799. /**
  61800. * Serialize a scene into a JSON compatible object
  61801. * @param scene defines the scene to serialize
  61802. * @returns a JSON compatible object
  61803. */
  61804. static Serialize(scene: Scene): any;
  61805. /**
  61806. * Serialize a mesh into a JSON compatible object
  61807. * @param toSerialize defines the mesh to serialize
  61808. * @param withParents defines if parents must be serialized as well
  61809. * @param withChildren defines if children must be serialized as well
  61810. * @returns a JSON compatible object
  61811. */
  61812. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  61813. }
  61814. }
  61815. declare module BABYLON {
  61816. /**
  61817. * Class used to host texture specific utilities
  61818. */
  61819. export class TextureTools {
  61820. /**
  61821. * Uses the GPU to create a copy texture rescaled at a given size
  61822. * @param texture Texture to copy from
  61823. * @param width defines the desired width
  61824. * @param height defines the desired height
  61825. * @param useBilinearMode defines if bilinear mode has to be used
  61826. * @return the generated texture
  61827. */
  61828. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  61829. }
  61830. }
  61831. declare module BABYLON {
  61832. /**
  61833. * This represents the different options available for the video capture.
  61834. */
  61835. export interface VideoRecorderOptions {
  61836. /** Defines the mime type of the video. */
  61837. mimeType: string;
  61838. /** Defines the FPS the video should be recorded at. */
  61839. fps: number;
  61840. /** Defines the chunk size for the recording data. */
  61841. recordChunckSize: number;
  61842. /** The audio tracks to attach to the recording. */
  61843. audioTracks?: MediaStreamTrack[];
  61844. }
  61845. /**
  61846. * This can help with recording videos from BabylonJS.
  61847. * This is based on the available WebRTC functionalities of the browser.
  61848. *
  61849. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  61850. */
  61851. export class VideoRecorder {
  61852. private static readonly _defaultOptions;
  61853. /**
  61854. * Returns whether or not the VideoRecorder is available in your browser.
  61855. * @param engine Defines the Babylon Engine.
  61856. * @returns true if supported otherwise false.
  61857. */
  61858. static IsSupported(engine: Engine): boolean;
  61859. private readonly _options;
  61860. private _canvas;
  61861. private _mediaRecorder;
  61862. private _recordedChunks;
  61863. private _fileName;
  61864. private _resolve;
  61865. private _reject;
  61866. /**
  61867. * True when a recording is already in progress.
  61868. */
  61869. readonly isRecording: boolean;
  61870. /**
  61871. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  61872. * @param engine Defines the BabylonJS Engine you wish to record.
  61873. * @param options Defines options that can be used to customize the capture.
  61874. */
  61875. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  61876. /**
  61877. * Stops the current recording before the default capture timeout passed in the startRecording function.
  61878. */
  61879. stopRecording(): void;
  61880. /**
  61881. * Starts recording the canvas for a max duration specified in parameters.
  61882. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  61883. * If null no automatic download will start and you can rely on the promise to get the data back.
  61884. * @param maxDuration Defines the maximum recording time in seconds.
  61885. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  61886. * @return A promise callback at the end of the recording with the video data in Blob.
  61887. */
  61888. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  61889. /**
  61890. * Releases internal resources used during the recording.
  61891. */
  61892. dispose(): void;
  61893. private _handleDataAvailable;
  61894. private _handleError;
  61895. private _handleStop;
  61896. }
  61897. }
  61898. declare module BABYLON {
  61899. /**
  61900. * Class containing a set of static utilities functions for screenshots
  61901. */
  61902. export class ScreenshotTools {
  61903. /**
  61904. * Captures a screenshot of the current rendering
  61905. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61906. * @param engine defines the rendering engine
  61907. * @param camera defines the source camera
  61908. * @param size This parameter can be set to a single number or to an object with the
  61909. * following (optional) properties: precision, width, height. If a single number is passed,
  61910. * it will be used for both width and height. If an object is passed, the screenshot size
  61911. * will be derived from the parameters. The precision property is a multiplier allowing
  61912. * rendering at a higher or lower resolution
  61913. * @param successCallback defines the callback receives a single parameter which contains the
  61914. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  61915. * src parameter of an <img> to display it
  61916. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  61917. * Check your browser for supported MIME types
  61918. */
  61919. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  61920. /**
  61921. * Captures a screenshot of the current rendering
  61922. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61923. * @param engine defines the rendering engine
  61924. * @param camera defines the source camera
  61925. * @param size This parameter can be set to a single number or to an object with the
  61926. * following (optional) properties: precision, width, height. If a single number is passed,
  61927. * it will be used for both width and height. If an object is passed, the screenshot size
  61928. * will be derived from the parameters. The precision property is a multiplier allowing
  61929. * rendering at a higher or lower resolution
  61930. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  61931. * Check your browser for supported MIME types
  61932. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  61933. * to the src parameter of an <img> to display it
  61934. */
  61935. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  61936. /**
  61937. * Generates an image screenshot from the specified camera.
  61938. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61939. * @param engine The engine to use for rendering
  61940. * @param camera The camera to use for rendering
  61941. * @param size This parameter can be set to a single number or to an object with the
  61942. * following (optional) properties: precision, width, height. If a single number is passed,
  61943. * it will be used for both width and height. If an object is passed, the screenshot size
  61944. * will be derived from the parameters. The precision property is a multiplier allowing
  61945. * rendering at a higher or lower resolution
  61946. * @param successCallback The callback receives a single parameter which contains the
  61947. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  61948. * src parameter of an <img> to display it
  61949. * @param mimeType The MIME type of the screenshot image (default: image/png).
  61950. * Check your browser for supported MIME types
  61951. * @param samples Texture samples (default: 1)
  61952. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  61953. * @param fileName A name for for the downloaded file.
  61954. */
  61955. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  61956. /**
  61957. * Generates an image screenshot from the specified camera.
  61958. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61959. * @param engine The engine to use for rendering
  61960. * @param camera The camera to use for rendering
  61961. * @param size This parameter can be set to a single number or to an object with the
  61962. * following (optional) properties: precision, width, height. If a single number is passed,
  61963. * it will be used for both width and height. If an object is passed, the screenshot size
  61964. * will be derived from the parameters. The precision property is a multiplier allowing
  61965. * rendering at a higher or lower resolution
  61966. * @param mimeType The MIME type of the screenshot image (default: image/png).
  61967. * Check your browser for supported MIME types
  61968. * @param samples Texture samples (default: 1)
  61969. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  61970. * @param fileName A name for for the downloaded file.
  61971. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  61972. * to the src parameter of an <img> to display it
  61973. */
  61974. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  61975. /**
  61976. * Gets height and width for screenshot size
  61977. * @private
  61978. */
  61979. private static _getScreenshotSize;
  61980. }
  61981. }
  61982. declare module BABYLON {
  61983. /**
  61984. * A cursor which tracks a point on a path
  61985. */
  61986. export class PathCursor {
  61987. private path;
  61988. /**
  61989. * Stores path cursor callbacks for when an onchange event is triggered
  61990. */
  61991. private _onchange;
  61992. /**
  61993. * The value of the path cursor
  61994. */
  61995. value: number;
  61996. /**
  61997. * The animation array of the path cursor
  61998. */
  61999. animations: Animation[];
  62000. /**
  62001. * Initializes the path cursor
  62002. * @param path The path to track
  62003. */
  62004. constructor(path: Path2);
  62005. /**
  62006. * Gets the cursor point on the path
  62007. * @returns A point on the path cursor at the cursor location
  62008. */
  62009. getPoint(): Vector3;
  62010. /**
  62011. * Moves the cursor ahead by the step amount
  62012. * @param step The amount to move the cursor forward
  62013. * @returns This path cursor
  62014. */
  62015. moveAhead(step?: number): PathCursor;
  62016. /**
  62017. * Moves the cursor behind by the step amount
  62018. * @param step The amount to move the cursor back
  62019. * @returns This path cursor
  62020. */
  62021. moveBack(step?: number): PathCursor;
  62022. /**
  62023. * Moves the cursor by the step amount
  62024. * If the step amount is greater than one, an exception is thrown
  62025. * @param step The amount to move the cursor
  62026. * @returns This path cursor
  62027. */
  62028. move(step: number): PathCursor;
  62029. /**
  62030. * Ensures that the value is limited between zero and one
  62031. * @returns This path cursor
  62032. */
  62033. private ensureLimits;
  62034. /**
  62035. * Runs onchange callbacks on change (used by the animation engine)
  62036. * @returns This path cursor
  62037. */
  62038. private raiseOnChange;
  62039. /**
  62040. * Executes a function on change
  62041. * @param f A path cursor onchange callback
  62042. * @returns This path cursor
  62043. */
  62044. onchange(f: (cursor: PathCursor) => void): PathCursor;
  62045. }
  62046. }
  62047. declare module BABYLON {
  62048. /** @hidden */
  62049. export var blurPixelShader: {
  62050. name: string;
  62051. shader: string;
  62052. };
  62053. }
  62054. declare module BABYLON {
  62055. /** @hidden */
  62056. export var pointCloudVertexDeclaration: {
  62057. name: string;
  62058. shader: string;
  62059. };
  62060. }
  62061. // Mixins
  62062. interface Window {
  62063. mozIndexedDB: IDBFactory;
  62064. webkitIndexedDB: IDBFactory;
  62065. msIndexedDB: IDBFactory;
  62066. webkitURL: typeof URL;
  62067. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  62068. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  62069. WebGLRenderingContext: WebGLRenderingContext;
  62070. MSGesture: MSGesture;
  62071. CANNON: any;
  62072. AudioContext: AudioContext;
  62073. webkitAudioContext: AudioContext;
  62074. PointerEvent: any;
  62075. Math: Math;
  62076. Uint8Array: Uint8ArrayConstructor;
  62077. Float32Array: Float32ArrayConstructor;
  62078. mozURL: typeof URL;
  62079. msURL: typeof URL;
  62080. VRFrameData: any; // WebVR, from specs 1.1
  62081. DracoDecoderModule: any;
  62082. setImmediate(handler: (...args: any[]) => void): number;
  62083. }
  62084. interface HTMLCanvasElement {
  62085. requestPointerLock(): void;
  62086. msRequestPointerLock?(): void;
  62087. mozRequestPointerLock?(): void;
  62088. webkitRequestPointerLock?(): void;
  62089. /** Track wether a record is in progress */
  62090. isRecording: boolean;
  62091. /** Capture Stream method defined by some browsers */
  62092. captureStream(fps?: number): MediaStream;
  62093. }
  62094. interface CanvasRenderingContext2D {
  62095. msImageSmoothingEnabled: boolean;
  62096. }
  62097. interface MouseEvent {
  62098. mozMovementX: number;
  62099. mozMovementY: number;
  62100. webkitMovementX: number;
  62101. webkitMovementY: number;
  62102. msMovementX: number;
  62103. msMovementY: number;
  62104. }
  62105. interface Navigator {
  62106. mozGetVRDevices: (any: any) => any;
  62107. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62108. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62109. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62110. webkitGetGamepads(): Gamepad[];
  62111. msGetGamepads(): Gamepad[];
  62112. webkitGamepads(): Gamepad[];
  62113. }
  62114. interface HTMLVideoElement {
  62115. mozSrcObject: any;
  62116. }
  62117. interface Math {
  62118. fround(x: number): number;
  62119. imul(a: number, b: number): number;
  62120. }
  62121. interface WebGLRenderingContext {
  62122. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  62123. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  62124. vertexAttribDivisor(index: number, divisor: number): void;
  62125. createVertexArray(): any;
  62126. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  62127. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  62128. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  62129. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  62130. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  62131. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  62132. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  62133. // Queries
  62134. createQuery(): WebGLQuery;
  62135. deleteQuery(query: WebGLQuery): void;
  62136. beginQuery(target: number, query: WebGLQuery): void;
  62137. endQuery(target: number): void;
  62138. getQueryParameter(query: WebGLQuery, pname: number): any;
  62139. getQuery(target: number, pname: number): any;
  62140. MAX_SAMPLES: number;
  62141. RGBA8: number;
  62142. READ_FRAMEBUFFER: number;
  62143. DRAW_FRAMEBUFFER: number;
  62144. UNIFORM_BUFFER: number;
  62145. HALF_FLOAT_OES: number;
  62146. RGBA16F: number;
  62147. RGBA32F: number;
  62148. R32F: number;
  62149. RG32F: number;
  62150. RGB32F: number;
  62151. R16F: number;
  62152. RG16F: number;
  62153. RGB16F: number;
  62154. RED: number;
  62155. RG: number;
  62156. R8: number;
  62157. RG8: number;
  62158. UNSIGNED_INT_24_8: number;
  62159. DEPTH24_STENCIL8: number;
  62160. /* Multiple Render Targets */
  62161. drawBuffers(buffers: number[]): void;
  62162. readBuffer(src: number): void;
  62163. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  62164. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  62165. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  62166. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  62167. // Occlusion Query
  62168. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  62169. ANY_SAMPLES_PASSED: number;
  62170. QUERY_RESULT_AVAILABLE: number;
  62171. QUERY_RESULT: number;
  62172. }
  62173. interface WebGLProgram {
  62174. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  62175. }
  62176. interface EXT_disjoint_timer_query {
  62177. QUERY_COUNTER_BITS_EXT: number;
  62178. TIME_ELAPSED_EXT: number;
  62179. TIMESTAMP_EXT: number;
  62180. GPU_DISJOINT_EXT: number;
  62181. QUERY_RESULT_EXT: number;
  62182. QUERY_RESULT_AVAILABLE_EXT: number;
  62183. queryCounterEXT(query: WebGLQuery, target: number): void;
  62184. createQueryEXT(): WebGLQuery;
  62185. beginQueryEXT(target: number, query: WebGLQuery): void;
  62186. endQueryEXT(target: number): void;
  62187. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  62188. deleteQueryEXT(query: WebGLQuery): void;
  62189. }
  62190. interface WebGLUniformLocation {
  62191. _currentState: any;
  62192. }
  62193. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  62194. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  62195. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  62196. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62197. interface WebGLRenderingContext {
  62198. readonly RASTERIZER_DISCARD: number;
  62199. readonly DEPTH_COMPONENT24: number;
  62200. readonly TEXTURE_3D: number;
  62201. readonly TEXTURE_2D_ARRAY: number;
  62202. readonly TEXTURE_COMPARE_FUNC: number;
  62203. readonly TEXTURE_COMPARE_MODE: number;
  62204. readonly COMPARE_REF_TO_TEXTURE: number;
  62205. readonly TEXTURE_WRAP_R: number;
  62206. readonly HALF_FLOAT: number;
  62207. readonly RGB8: number;
  62208. readonly RED_INTEGER: number;
  62209. readonly RG_INTEGER: number;
  62210. readonly RGB_INTEGER: number;
  62211. readonly RGBA_INTEGER: number;
  62212. readonly R8_SNORM: number;
  62213. readonly RG8_SNORM: number;
  62214. readonly RGB8_SNORM: number;
  62215. readonly RGBA8_SNORM: number;
  62216. readonly R8I: number;
  62217. readonly RG8I: number;
  62218. readonly RGB8I: number;
  62219. readonly RGBA8I: number;
  62220. readonly R8UI: number;
  62221. readonly RG8UI: number;
  62222. readonly RGB8UI: number;
  62223. readonly RGBA8UI: number;
  62224. readonly R16I: number;
  62225. readonly RG16I: number;
  62226. readonly RGB16I: number;
  62227. readonly RGBA16I: number;
  62228. readonly R16UI: number;
  62229. readonly RG16UI: number;
  62230. readonly RGB16UI: number;
  62231. readonly RGBA16UI: number;
  62232. readonly R32I: number;
  62233. readonly RG32I: number;
  62234. readonly RGB32I: number;
  62235. readonly RGBA32I: number;
  62236. readonly R32UI: number;
  62237. readonly RG32UI: number;
  62238. readonly RGB32UI: number;
  62239. readonly RGBA32UI: number;
  62240. readonly RGB10_A2UI: number;
  62241. readonly R11F_G11F_B10F: number;
  62242. readonly RGB9_E5: number;
  62243. readonly RGB10_A2: number;
  62244. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  62245. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  62246. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  62247. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  62248. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  62249. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  62250. 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;
  62251. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  62252. readonly TRANSFORM_FEEDBACK: number;
  62253. readonly INTERLEAVED_ATTRIBS: number;
  62254. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  62255. createTransformFeedback(): WebGLTransformFeedback;
  62256. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  62257. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  62258. beginTransformFeedback(primitiveMode: number): void;
  62259. endTransformFeedback(): void;
  62260. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  62261. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62262. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62263. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62264. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  62265. }
  62266. interface ImageBitmap {
  62267. readonly width: number;
  62268. readonly height: number;
  62269. close(): void;
  62270. }
  62271. interface WebGLQuery extends WebGLObject {
  62272. }
  62273. declare var WebGLQuery: {
  62274. prototype: WebGLQuery;
  62275. new(): WebGLQuery;
  62276. };
  62277. interface WebGLSampler extends WebGLObject {
  62278. }
  62279. declare var WebGLSampler: {
  62280. prototype: WebGLSampler;
  62281. new(): WebGLSampler;
  62282. };
  62283. interface WebGLSync extends WebGLObject {
  62284. }
  62285. declare var WebGLSync: {
  62286. prototype: WebGLSync;
  62287. new(): WebGLSync;
  62288. };
  62289. interface WebGLTransformFeedback extends WebGLObject {
  62290. }
  62291. declare var WebGLTransformFeedback: {
  62292. prototype: WebGLTransformFeedback;
  62293. new(): WebGLTransformFeedback;
  62294. };
  62295. interface WebGLVertexArrayObject extends WebGLObject {
  62296. }
  62297. declare var WebGLVertexArrayObject: {
  62298. prototype: WebGLVertexArrayObject;
  62299. new(): WebGLVertexArrayObject;
  62300. };
  62301. // Type definitions for WebVR API
  62302. // Project: https://w3c.github.io/webvr/
  62303. // Definitions by: six a <https://github.com/lostfictions>
  62304. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62305. interface VRDisplay extends EventTarget {
  62306. /**
  62307. * Dictionary of capabilities describing the VRDisplay.
  62308. */
  62309. readonly capabilities: VRDisplayCapabilities;
  62310. /**
  62311. * z-depth defining the far plane of the eye view frustum
  62312. * enables mapping of values in the render target depth
  62313. * attachment to scene coordinates. Initially set to 10000.0.
  62314. */
  62315. depthFar: number;
  62316. /**
  62317. * z-depth defining the near plane of the eye view frustum
  62318. * enables mapping of values in the render target depth
  62319. * attachment to scene coordinates. Initially set to 0.01.
  62320. */
  62321. depthNear: number;
  62322. /**
  62323. * An identifier for this distinct VRDisplay. Used as an
  62324. * association point in the Gamepad API.
  62325. */
  62326. readonly displayId: number;
  62327. /**
  62328. * A display name, a user-readable name identifying it.
  62329. */
  62330. readonly displayName: string;
  62331. readonly isConnected: boolean;
  62332. readonly isPresenting: boolean;
  62333. /**
  62334. * If this VRDisplay supports room-scale experiences, the optional
  62335. * stage attribute contains details on the room-scale parameters.
  62336. */
  62337. readonly stageParameters: VRStageParameters | null;
  62338. /**
  62339. * Passing the value returned by `requestAnimationFrame` to
  62340. * `cancelAnimationFrame` will unregister the callback.
  62341. * @param handle Define the hanle of the request to cancel
  62342. */
  62343. cancelAnimationFrame(handle: number): void;
  62344. /**
  62345. * Stops presenting to the VRDisplay.
  62346. * @returns a promise to know when it stopped
  62347. */
  62348. exitPresent(): Promise<void>;
  62349. /**
  62350. * Return the current VREyeParameters for the given eye.
  62351. * @param whichEye Define the eye we want the parameter for
  62352. * @returns the eye parameters
  62353. */
  62354. getEyeParameters(whichEye: string): VREyeParameters;
  62355. /**
  62356. * Populates the passed VRFrameData with the information required to render
  62357. * the current frame.
  62358. * @param frameData Define the data structure to populate
  62359. * @returns true if ok otherwise false
  62360. */
  62361. getFrameData(frameData: VRFrameData): boolean;
  62362. /**
  62363. * Get the layers currently being presented.
  62364. * @returns the list of VR layers
  62365. */
  62366. getLayers(): VRLayer[];
  62367. /**
  62368. * Return a VRPose containing the future predicted pose of the VRDisplay
  62369. * when the current frame will be presented. The value returned will not
  62370. * change until JavaScript has returned control to the browser.
  62371. *
  62372. * The VRPose will contain the position, orientation, velocity,
  62373. * and acceleration of each of these properties.
  62374. * @returns the pose object
  62375. */
  62376. getPose(): VRPose;
  62377. /**
  62378. * Return the current instantaneous pose of the VRDisplay, with no
  62379. * prediction applied.
  62380. * @returns the current instantaneous pose
  62381. */
  62382. getImmediatePose(): VRPose;
  62383. /**
  62384. * The callback passed to `requestAnimationFrame` will be called
  62385. * any time a new frame should be rendered. When the VRDisplay is
  62386. * presenting the callback will be called at the native refresh
  62387. * rate of the HMD. When not presenting this function acts
  62388. * identically to how window.requestAnimationFrame acts. Content should
  62389. * make no assumptions of frame rate or vsync behavior as the HMD runs
  62390. * asynchronously from other displays and at differing refresh rates.
  62391. * @param callback Define the eaction to run next frame
  62392. * @returns the request handle it
  62393. */
  62394. requestAnimationFrame(callback: FrameRequestCallback): number;
  62395. /**
  62396. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  62397. * Repeat calls while already presenting will update the VRLayers being displayed.
  62398. * @param layers Define the list of layer to present
  62399. * @returns a promise to know when the request has been fulfilled
  62400. */
  62401. requestPresent(layers: VRLayer[]): Promise<void>;
  62402. /**
  62403. * Reset the pose for this display, treating its current position and
  62404. * orientation as the "origin/zero" values. VRPose.position,
  62405. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  62406. * updated when calling resetPose(). This should be called in only
  62407. * sitting-space experiences.
  62408. */
  62409. resetPose(): void;
  62410. /**
  62411. * The VRLayer provided to the VRDisplay will be captured and presented
  62412. * in the HMD. Calling this function has the same effect on the source
  62413. * canvas as any other operation that uses its source image, and canvases
  62414. * created without preserveDrawingBuffer set to true will be cleared.
  62415. * @param pose Define the pose to submit
  62416. */
  62417. submitFrame(pose?: VRPose): void;
  62418. }
  62419. declare var VRDisplay: {
  62420. prototype: VRDisplay;
  62421. new(): VRDisplay;
  62422. };
  62423. interface VRLayer {
  62424. leftBounds?: number[] | Float32Array | null;
  62425. rightBounds?: number[] | Float32Array | null;
  62426. source?: HTMLCanvasElement | null;
  62427. }
  62428. interface VRDisplayCapabilities {
  62429. readonly canPresent: boolean;
  62430. readonly hasExternalDisplay: boolean;
  62431. readonly hasOrientation: boolean;
  62432. readonly hasPosition: boolean;
  62433. readonly maxLayers: number;
  62434. }
  62435. interface VREyeParameters {
  62436. /** @deprecated */
  62437. readonly fieldOfView: VRFieldOfView;
  62438. readonly offset: Float32Array;
  62439. readonly renderHeight: number;
  62440. readonly renderWidth: number;
  62441. }
  62442. interface VRFieldOfView {
  62443. readonly downDegrees: number;
  62444. readonly leftDegrees: number;
  62445. readonly rightDegrees: number;
  62446. readonly upDegrees: number;
  62447. }
  62448. interface VRFrameData {
  62449. readonly leftProjectionMatrix: Float32Array;
  62450. readonly leftViewMatrix: Float32Array;
  62451. readonly pose: VRPose;
  62452. readonly rightProjectionMatrix: Float32Array;
  62453. readonly rightViewMatrix: Float32Array;
  62454. readonly timestamp: number;
  62455. }
  62456. interface VRPose {
  62457. readonly angularAcceleration: Float32Array | null;
  62458. readonly angularVelocity: Float32Array | null;
  62459. readonly linearAcceleration: Float32Array | null;
  62460. readonly linearVelocity: Float32Array | null;
  62461. readonly orientation: Float32Array | null;
  62462. readonly position: Float32Array | null;
  62463. readonly timestamp: number;
  62464. }
  62465. interface VRStageParameters {
  62466. sittingToStandingTransform?: Float32Array;
  62467. sizeX?: number;
  62468. sizeY?: number;
  62469. }
  62470. interface Navigator {
  62471. getVRDisplays(): Promise<VRDisplay[]>;
  62472. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  62473. }
  62474. interface Window {
  62475. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  62476. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  62477. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  62478. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62479. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62480. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  62481. }
  62482. interface Gamepad {
  62483. readonly displayId: number;
  62484. }
  62485. type XRSessionMode =
  62486. | "inline"
  62487. | "immersive-vr"
  62488. | "immersive-ar";
  62489. type XRReferenceSpaceType =
  62490. | "viewer"
  62491. | "local"
  62492. | "local-floor"
  62493. | "bounded-floor"
  62494. | "unbounded";
  62495. type XREnvironmentBlendMode =
  62496. | "opaque"
  62497. | "additive"
  62498. | "alpha-blend";
  62499. type XRVisibilityState =
  62500. | "visible"
  62501. | "visible-blurred"
  62502. | "hidden";
  62503. type XRHandedness =
  62504. | "none"
  62505. | "left"
  62506. | "right";
  62507. type XRTargetRayMode =
  62508. | "gaze"
  62509. | "tracked-pointer"
  62510. | "screen";
  62511. type XREye =
  62512. | "none"
  62513. | "left"
  62514. | "right";
  62515. interface XRSpace extends EventTarget {
  62516. }
  62517. interface XRRenderState {
  62518. depthNear?: number;
  62519. depthFar?: number;
  62520. inlineVerticalFieldOfView?: number;
  62521. baseLayer?: XRWebGLLayer;
  62522. }
  62523. interface XRInputSource {
  62524. handedness: XRHandedness;
  62525. targetRayMode: XRTargetRayMode;
  62526. targetRaySpace: XRSpace;
  62527. gripSpace: XRSpace | undefined;
  62528. gamepad: Gamepad | undefined;
  62529. profiles: Array<string>;
  62530. }
  62531. interface XRSession {
  62532. addEventListener: Function;
  62533. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  62534. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  62535. requestAnimationFrame: Function;
  62536. end(): Promise<void>;
  62537. renderState: XRRenderState;
  62538. inputSources: Array<XRInputSource>;
  62539. }
  62540. interface XRReferenceSpace extends XRSpace {
  62541. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  62542. onreset: any;
  62543. }
  62544. interface XRFrame {
  62545. session: XRSession;
  62546. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  62547. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  62548. }
  62549. interface XRViewerPose extends XRPose {
  62550. views: Array<XRView>;
  62551. }
  62552. interface XRPose {
  62553. transform: XRRigidTransform;
  62554. emulatedPosition: boolean;
  62555. }
  62556. declare var XRWebGLLayer: {
  62557. prototype: XRWebGLLayer;
  62558. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  62559. };
  62560. interface XRWebGLLayer {
  62561. framebuffer: WebGLFramebuffer;
  62562. framebufferWidth: number;
  62563. framebufferHeight: number;
  62564. getViewport: Function;
  62565. }
  62566. interface XRRigidTransform {
  62567. position: DOMPointReadOnly;
  62568. orientation: DOMPointReadOnly;
  62569. matrix: Float32Array;
  62570. inverse: XRRigidTransform;
  62571. }
  62572. interface XRView {
  62573. eye: XREye;
  62574. projectionMatrix: Float32Array;
  62575. transform: XRRigidTransform;
  62576. }
  62577. interface XRInputSourceChangeEvent {
  62578. session: XRSession;
  62579. removed: Array<XRInputSource>;
  62580. added: Array<XRInputSource>;
  62581. }
  62582. declare module BABYLON.GUI {
  62583. /**
  62584. * Class used to specific a value and its associated unit
  62585. */
  62586. export class ValueAndUnit {
  62587. /** defines the unit to store */
  62588. unit: number;
  62589. /** defines a boolean indicating if the value can be negative */
  62590. negativeValueAllowed: boolean;
  62591. private _value;
  62592. private _originalUnit;
  62593. /**
  62594. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  62595. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62596. */
  62597. ignoreAdaptiveScaling: boolean;
  62598. /**
  62599. * Creates a new ValueAndUnit
  62600. * @param value defines the value to store
  62601. * @param unit defines the unit to store
  62602. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  62603. */
  62604. constructor(value: number,
  62605. /** defines the unit to store */
  62606. unit?: number,
  62607. /** defines a boolean indicating if the value can be negative */
  62608. negativeValueAllowed?: boolean);
  62609. /** Gets a boolean indicating if the value is a percentage */
  62610. readonly isPercentage: boolean;
  62611. /** Gets a boolean indicating if the value is store as pixel */
  62612. readonly isPixel: boolean;
  62613. /** Gets direct internal value */
  62614. readonly internalValue: number;
  62615. /**
  62616. * Gets value as pixel
  62617. * @param host defines the root host
  62618. * @param refValue defines the reference value for percentages
  62619. * @returns the value as pixel
  62620. */
  62621. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  62622. /**
  62623. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  62624. * @param value defines the value to store
  62625. * @param unit defines the unit to store
  62626. * @returns the current ValueAndUnit
  62627. */
  62628. updateInPlace(value: number, unit?: number): ValueAndUnit;
  62629. /**
  62630. * Gets the value accordingly to its unit
  62631. * @param host defines the root host
  62632. * @returns the value
  62633. */
  62634. getValue(host: AdvancedDynamicTexture): number;
  62635. /**
  62636. * Gets a string representation of the value
  62637. * @param host defines the root host
  62638. * @param decimals defines an optional number of decimals to display
  62639. * @returns a string
  62640. */
  62641. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  62642. /**
  62643. * Store a value parsed from a string
  62644. * @param source defines the source string
  62645. * @returns true if the value was successfully parsed
  62646. */
  62647. fromString(source: string | number): boolean;
  62648. private static _Regex;
  62649. private static _UNITMODE_PERCENTAGE;
  62650. private static _UNITMODE_PIXEL;
  62651. /** UNITMODE_PERCENTAGE */
  62652. static readonly UNITMODE_PERCENTAGE: number;
  62653. /** UNITMODE_PIXEL */
  62654. static readonly UNITMODE_PIXEL: number;
  62655. }
  62656. }
  62657. declare module BABYLON.GUI {
  62658. /**
  62659. * Define a style used by control to automatically setup properties based on a template.
  62660. * Only support font related properties so far
  62661. */
  62662. export class Style implements BABYLON.IDisposable {
  62663. private _fontFamily;
  62664. private _fontStyle;
  62665. private _fontWeight;
  62666. /** @hidden */
  62667. _host: AdvancedDynamicTexture;
  62668. /** @hidden */
  62669. _fontSize: ValueAndUnit;
  62670. /**
  62671. * BABYLON.Observable raised when the style values are changed
  62672. */
  62673. onChangedObservable: BABYLON.Observable<Style>;
  62674. /**
  62675. * Creates a new style object
  62676. * @param host defines the AdvancedDynamicTexture which hosts this style
  62677. */
  62678. constructor(host: AdvancedDynamicTexture);
  62679. /**
  62680. * Gets or sets the font size
  62681. */
  62682. fontSize: string | number;
  62683. /**
  62684. * Gets or sets the font family
  62685. */
  62686. fontFamily: string;
  62687. /**
  62688. * Gets or sets the font style
  62689. */
  62690. fontStyle: string;
  62691. /** Gets or sets font weight */
  62692. fontWeight: string;
  62693. /** Dispose all associated resources */
  62694. dispose(): void;
  62695. }
  62696. }
  62697. declare module BABYLON.GUI {
  62698. /**
  62699. * Class used to transport BABYLON.Vector2 information for pointer events
  62700. */
  62701. export class Vector2WithInfo extends BABYLON.Vector2 {
  62702. /** defines the current mouse button index */
  62703. buttonIndex: number;
  62704. /**
  62705. * Creates a new Vector2WithInfo
  62706. * @param source defines the vector2 data to transport
  62707. * @param buttonIndex defines the current mouse button index
  62708. */
  62709. constructor(source: BABYLON.Vector2,
  62710. /** defines the current mouse button index */
  62711. buttonIndex?: number);
  62712. }
  62713. /** Class used to provide 2D matrix features */
  62714. export class Matrix2D {
  62715. /** Gets the internal array of 6 floats used to store matrix data */
  62716. m: Float32Array;
  62717. /**
  62718. * Creates a new matrix
  62719. * @param m00 defines value for (0, 0)
  62720. * @param m01 defines value for (0, 1)
  62721. * @param m10 defines value for (1, 0)
  62722. * @param m11 defines value for (1, 1)
  62723. * @param m20 defines value for (2, 0)
  62724. * @param m21 defines value for (2, 1)
  62725. */
  62726. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  62727. /**
  62728. * Fills the matrix from direct values
  62729. * @param m00 defines value for (0, 0)
  62730. * @param m01 defines value for (0, 1)
  62731. * @param m10 defines value for (1, 0)
  62732. * @param m11 defines value for (1, 1)
  62733. * @param m20 defines value for (2, 0)
  62734. * @param m21 defines value for (2, 1)
  62735. * @returns the current modified matrix
  62736. */
  62737. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  62738. /**
  62739. * Gets matrix determinant
  62740. * @returns the determinant
  62741. */
  62742. determinant(): number;
  62743. /**
  62744. * Inverses the matrix and stores it in a target matrix
  62745. * @param result defines the target matrix
  62746. * @returns the current matrix
  62747. */
  62748. invertToRef(result: Matrix2D): Matrix2D;
  62749. /**
  62750. * Multiplies the current matrix with another one
  62751. * @param other defines the second operand
  62752. * @param result defines the target matrix
  62753. * @returns the current matrix
  62754. */
  62755. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  62756. /**
  62757. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  62758. * @param x defines the x coordinate to transform
  62759. * @param y defines the x coordinate to transform
  62760. * @param result defines the target vector2
  62761. * @returns the current matrix
  62762. */
  62763. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  62764. /**
  62765. * Creates an identity matrix
  62766. * @returns a new matrix
  62767. */
  62768. static Identity(): Matrix2D;
  62769. /**
  62770. * Creates a translation matrix and stores it in a target matrix
  62771. * @param x defines the x coordinate of the translation
  62772. * @param y defines the y coordinate of the translation
  62773. * @param result defines the target matrix
  62774. */
  62775. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  62776. /**
  62777. * Creates a scaling matrix and stores it in a target matrix
  62778. * @param x defines the x coordinate of the scaling
  62779. * @param y defines the y coordinate of the scaling
  62780. * @param result defines the target matrix
  62781. */
  62782. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  62783. /**
  62784. * Creates a rotation matrix and stores it in a target matrix
  62785. * @param angle defines the rotation angle
  62786. * @param result defines the target matrix
  62787. */
  62788. static RotationToRef(angle: number, result: Matrix2D): void;
  62789. private static _TempPreTranslationMatrix;
  62790. private static _TempPostTranslationMatrix;
  62791. private static _TempRotationMatrix;
  62792. private static _TempScalingMatrix;
  62793. private static _TempCompose0;
  62794. private static _TempCompose1;
  62795. private static _TempCompose2;
  62796. /**
  62797. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  62798. * @param tx defines the x coordinate of the translation
  62799. * @param ty defines the y coordinate of the translation
  62800. * @param angle defines the rotation angle
  62801. * @param scaleX defines the x coordinate of the scaling
  62802. * @param scaleY defines the y coordinate of the scaling
  62803. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  62804. * @param result defines the target matrix
  62805. */
  62806. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  62807. }
  62808. }
  62809. declare module BABYLON.GUI {
  62810. /**
  62811. * Class used to store 2D control sizes
  62812. */
  62813. export class Measure {
  62814. /** defines left coordinate */
  62815. left: number;
  62816. /** defines top coordinate */
  62817. top: number;
  62818. /** defines width dimension */
  62819. width: number;
  62820. /** defines height dimension */
  62821. height: number;
  62822. /**
  62823. * Creates a new measure
  62824. * @param left defines left coordinate
  62825. * @param top defines top coordinate
  62826. * @param width defines width dimension
  62827. * @param height defines height dimension
  62828. */
  62829. constructor(
  62830. /** defines left coordinate */
  62831. left: number,
  62832. /** defines top coordinate */
  62833. top: number,
  62834. /** defines width dimension */
  62835. width: number,
  62836. /** defines height dimension */
  62837. height: number);
  62838. /**
  62839. * Copy from another measure
  62840. * @param other defines the other measure to copy from
  62841. */
  62842. copyFrom(other: Measure): void;
  62843. /**
  62844. * Copy from a group of 4 floats
  62845. * @param left defines left coordinate
  62846. * @param top defines top coordinate
  62847. * @param width defines width dimension
  62848. * @param height defines height dimension
  62849. */
  62850. copyFromFloats(left: number, top: number, width: number, height: number): void;
  62851. /**
  62852. * Computes the axis aligned bounding box measure for two given measures
  62853. * @param a Input measure
  62854. * @param b Input measure
  62855. * @param result the resulting bounding measure
  62856. */
  62857. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  62858. /**
  62859. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  62860. * @param transform the matrix to transform the measure before computing the AABB
  62861. * @param result the resulting AABB
  62862. */
  62863. transformToRef(transform: Matrix2D, result: Measure): void;
  62864. /**
  62865. * Check equality between this measure and another one
  62866. * @param other defines the other measures
  62867. * @returns true if both measures are equals
  62868. */
  62869. isEqualsTo(other: Measure): boolean;
  62870. /**
  62871. * Creates an empty measure
  62872. * @returns a new measure
  62873. */
  62874. static Empty(): Measure;
  62875. }
  62876. }
  62877. declare module BABYLON.GUI {
  62878. /**
  62879. * Interface used to define a control that can receive focus
  62880. */
  62881. export interface IFocusableControl {
  62882. /**
  62883. * Function called when the control receives the focus
  62884. */
  62885. onFocus(): void;
  62886. /**
  62887. * Function called when the control loses the focus
  62888. */
  62889. onBlur(): void;
  62890. /**
  62891. * Function called to let the control handle keyboard events
  62892. * @param evt defines the current keyboard event
  62893. */
  62894. processKeyboard(evt: KeyboardEvent): void;
  62895. /**
  62896. * Function called to get the list of controls that should not steal the focus from this control
  62897. * @returns an array of controls
  62898. */
  62899. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  62900. }
  62901. /**
  62902. * Class used to create texture to support 2D GUI elements
  62903. * @see http://doc.babylonjs.com/how_to/gui
  62904. */
  62905. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  62906. private _isDirty;
  62907. private _renderObserver;
  62908. private _resizeObserver;
  62909. private _preKeyboardObserver;
  62910. private _pointerMoveObserver;
  62911. private _pointerObserver;
  62912. private _canvasPointerOutObserver;
  62913. private _background;
  62914. /** @hidden */
  62915. _rootContainer: Container;
  62916. /** @hidden */
  62917. _lastPickedControl: Control;
  62918. /** @hidden */
  62919. _lastControlOver: {
  62920. [pointerId: number]: Control;
  62921. };
  62922. /** @hidden */
  62923. _lastControlDown: {
  62924. [pointerId: number]: Control;
  62925. };
  62926. /** @hidden */
  62927. _capturingControl: {
  62928. [pointerId: number]: Control;
  62929. };
  62930. /** @hidden */
  62931. _shouldBlockPointer: boolean;
  62932. /** @hidden */
  62933. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  62934. /** @hidden */
  62935. _linkedControls: Control[];
  62936. private _isFullscreen;
  62937. private _fullscreenViewport;
  62938. private _idealWidth;
  62939. private _idealHeight;
  62940. private _useSmallestIdeal;
  62941. private _renderAtIdealSize;
  62942. private _focusedControl;
  62943. private _blockNextFocusCheck;
  62944. private _renderScale;
  62945. private _rootCanvas;
  62946. private _cursorChanged;
  62947. /**
  62948. * Define type to string to ensure compatibility across browsers
  62949. * Safari doesn't support DataTransfer constructor
  62950. */
  62951. private _clipboardData;
  62952. /**
  62953. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  62954. */
  62955. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  62956. /**
  62957. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  62958. */
  62959. onControlPickedObservable: BABYLON.Observable<Control>;
  62960. /**
  62961. * BABYLON.Observable event triggered before layout is evaluated
  62962. */
  62963. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62964. /**
  62965. * BABYLON.Observable event triggered after the layout was evaluated
  62966. */
  62967. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62968. /**
  62969. * BABYLON.Observable event triggered before the texture is rendered
  62970. */
  62971. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62972. /**
  62973. * BABYLON.Observable event triggered after the texture was rendered
  62974. */
  62975. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62976. /**
  62977. * Gets or sets a boolean defining if alpha is stored as premultiplied
  62978. */
  62979. premulAlpha: boolean;
  62980. /**
  62981. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  62982. * Useful when you want more antialiasing
  62983. */
  62984. renderScale: number;
  62985. /** Gets or sets the background color */
  62986. background: string;
  62987. /**
  62988. * Gets or sets the ideal width used to design controls.
  62989. * The GUI will then rescale everything accordingly
  62990. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62991. */
  62992. idealWidth: number;
  62993. /**
  62994. * Gets or sets the ideal height used to design controls.
  62995. * The GUI will then rescale everything accordingly
  62996. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62997. */
  62998. idealHeight: number;
  62999. /**
  63000. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  63001. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63002. */
  63003. useSmallestIdeal: boolean;
  63004. /**
  63005. * Gets or sets a boolean indicating if adaptive scaling must be used
  63006. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63007. */
  63008. renderAtIdealSize: boolean;
  63009. /**
  63010. * Gets the underlying layer used to render the texture when in fullscreen mode
  63011. */
  63012. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  63013. /**
  63014. * Gets the root container control
  63015. */
  63016. readonly rootContainer: Container;
  63017. /**
  63018. * Returns an array containing the root container.
  63019. * This is mostly used to let the Inspector introspects the ADT
  63020. * @returns an array containing the rootContainer
  63021. */
  63022. getChildren(): Array<Container>;
  63023. /**
  63024. * Will return all controls that are inside this texture
  63025. * @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
  63026. * @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
  63027. * @return all child controls
  63028. */
  63029. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  63030. /**
  63031. * Gets or sets the current focused control
  63032. */
  63033. focusedControl: BABYLON.Nullable<IFocusableControl>;
  63034. /**
  63035. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  63036. */
  63037. isForeground: boolean;
  63038. /**
  63039. * Gets or set information about clipboardData
  63040. */
  63041. clipboardData: string;
  63042. /**
  63043. * Creates a new AdvancedDynamicTexture
  63044. * @param name defines the name of the texture
  63045. * @param width defines the width of the texture
  63046. * @param height defines the height of the texture
  63047. * @param scene defines the hosting scene
  63048. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  63049. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  63050. */
  63051. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  63052. /**
  63053. * Get the current class name of the texture useful for serialization or dynamic coding.
  63054. * @returns "AdvancedDynamicTexture"
  63055. */
  63056. getClassName(): string;
  63057. /**
  63058. * Function used to execute a function on all controls
  63059. * @param func defines the function to execute
  63060. * @param container defines the container where controls belong. If null the root container will be used
  63061. */
  63062. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  63063. private _useInvalidateRectOptimization;
  63064. /**
  63065. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  63066. */
  63067. useInvalidateRectOptimization: boolean;
  63068. private _invalidatedRectangle;
  63069. /**
  63070. * Invalidates a rectangle area on the gui texture
  63071. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  63072. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  63073. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  63074. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  63075. */
  63076. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  63077. /**
  63078. * Marks the texture as dirty forcing a complete update
  63079. */
  63080. markAsDirty(): void;
  63081. /**
  63082. * Helper function used to create a new style
  63083. * @returns a new style
  63084. * @see http://doc.babylonjs.com/how_to/gui#styles
  63085. */
  63086. createStyle(): Style;
  63087. /**
  63088. * Adds a new control to the root container
  63089. * @param control defines the control to add
  63090. * @returns the current texture
  63091. */
  63092. addControl(control: Control): AdvancedDynamicTexture;
  63093. /**
  63094. * Removes a control from the root container
  63095. * @param control defines the control to remove
  63096. * @returns the current texture
  63097. */
  63098. removeControl(control: Control): AdvancedDynamicTexture;
  63099. /**
  63100. * Release all resources
  63101. */
  63102. dispose(): void;
  63103. private _onResize;
  63104. /** @hidden */
  63105. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  63106. /**
  63107. * Get screen coordinates for a vector3
  63108. * @param position defines the position to project
  63109. * @param worldMatrix defines the world matrix to use
  63110. * @returns the projected position
  63111. */
  63112. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  63113. private _checkUpdate;
  63114. private _clearMeasure;
  63115. private _render;
  63116. /** @hidden */
  63117. _changeCursor(cursor: string): void;
  63118. /** @hidden */
  63119. _registerLastControlDown(control: Control, pointerId: number): void;
  63120. private _doPicking;
  63121. /** @hidden */
  63122. _cleanControlAfterRemovalFromList(list: {
  63123. [pointerId: number]: Control;
  63124. }, control: Control): void;
  63125. /** @hidden */
  63126. _cleanControlAfterRemoval(control: Control): void;
  63127. /** Attach to all scene events required to support pointer events */
  63128. attach(): void;
  63129. /** @hidden */
  63130. private onClipboardCopy;
  63131. /** @hidden */
  63132. private onClipboardCut;
  63133. /** @hidden */
  63134. private onClipboardPaste;
  63135. /**
  63136. * Register the clipboard Events onto the canvas
  63137. */
  63138. registerClipboardEvents(): void;
  63139. /**
  63140. * Unregister the clipboard Events from the canvas
  63141. */
  63142. unRegisterClipboardEvents(): void;
  63143. /**
  63144. * Connect the texture to a hosting mesh to enable interactions
  63145. * @param mesh defines the mesh to attach to
  63146. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  63147. */
  63148. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  63149. /**
  63150. * Move the focus to a specific control
  63151. * @param control defines the control which will receive the focus
  63152. */
  63153. moveFocusToControl(control: IFocusableControl): void;
  63154. private _manageFocus;
  63155. private _attachToOnPointerOut;
  63156. /**
  63157. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  63158. * @param mesh defines the mesh which will receive the texture
  63159. * @param width defines the texture width (1024 by default)
  63160. * @param height defines the texture height (1024 by default)
  63161. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  63162. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  63163. * @returns a new AdvancedDynamicTexture
  63164. */
  63165. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  63166. /**
  63167. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  63168. * In this mode the texture will rely on a layer for its rendering.
  63169. * This allows it to be treated like any other layer.
  63170. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  63171. * LayerMask is set through advancedTexture.layer.layerMask
  63172. * @param name defines name for the texture
  63173. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  63174. * @param scene defines the hsoting scene
  63175. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  63176. * @returns a new AdvancedDynamicTexture
  63177. */
  63178. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  63179. }
  63180. }
  63181. declare module BABYLON.GUI {
  63182. /**
  63183. * Root class used for all 2D controls
  63184. * @see http://doc.babylonjs.com/how_to/gui#controls
  63185. */
  63186. export class Control {
  63187. /** defines the name of the control */
  63188. name?: string | undefined;
  63189. /**
  63190. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  63191. */
  63192. static AllowAlphaInheritance: boolean;
  63193. private _alpha;
  63194. private _alphaSet;
  63195. private _zIndex;
  63196. /** @hidden */
  63197. _host: AdvancedDynamicTexture;
  63198. /** Gets or sets the control parent */
  63199. parent: BABYLON.Nullable<Container>;
  63200. /** @hidden */
  63201. _currentMeasure: Measure;
  63202. private _fontFamily;
  63203. private _fontStyle;
  63204. private _fontWeight;
  63205. private _fontSize;
  63206. private _font;
  63207. /** @hidden */
  63208. _width: ValueAndUnit;
  63209. /** @hidden */
  63210. _height: ValueAndUnit;
  63211. /** @hidden */
  63212. protected _fontOffset: {
  63213. ascent: number;
  63214. height: number;
  63215. descent: number;
  63216. };
  63217. private _color;
  63218. private _style;
  63219. private _styleObserver;
  63220. /** @hidden */
  63221. protected _horizontalAlignment: number;
  63222. /** @hidden */
  63223. protected _verticalAlignment: number;
  63224. /** @hidden */
  63225. protected _isDirty: boolean;
  63226. /** @hidden */
  63227. protected _wasDirty: boolean;
  63228. /** @hidden */
  63229. _tempParentMeasure: Measure;
  63230. /** @hidden */
  63231. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  63232. /** @hidden */
  63233. protected _cachedParentMeasure: Measure;
  63234. private _paddingLeft;
  63235. private _paddingRight;
  63236. private _paddingTop;
  63237. private _paddingBottom;
  63238. /** @hidden */
  63239. _left: ValueAndUnit;
  63240. /** @hidden */
  63241. _top: ValueAndUnit;
  63242. private _scaleX;
  63243. private _scaleY;
  63244. private _rotation;
  63245. private _transformCenterX;
  63246. private _transformCenterY;
  63247. /** @hidden */
  63248. _transformMatrix: Matrix2D;
  63249. /** @hidden */
  63250. protected _invertTransformMatrix: Matrix2D;
  63251. /** @hidden */
  63252. protected _transformedPosition: BABYLON.Vector2;
  63253. private _isMatrixDirty;
  63254. private _cachedOffsetX;
  63255. private _cachedOffsetY;
  63256. private _isVisible;
  63257. private _isHighlighted;
  63258. /** @hidden */
  63259. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  63260. private _fontSet;
  63261. private _dummyVector2;
  63262. private _downCount;
  63263. private _enterCount;
  63264. private _doNotRender;
  63265. private _downPointerIds;
  63266. protected _isEnabled: boolean;
  63267. protected _disabledColor: string;
  63268. /** @hidden */
  63269. protected _rebuildLayout: boolean;
  63270. /** @hidden */
  63271. _isClipped: boolean;
  63272. /** @hidden */
  63273. _tag: any;
  63274. /**
  63275. * 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
  63276. */
  63277. uniqueId: number;
  63278. /**
  63279. * Gets or sets an object used to store user defined information for the node
  63280. */
  63281. metadata: any;
  63282. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  63283. isHitTestVisible: boolean;
  63284. /** Gets or sets a boolean indicating if the control can block pointer events */
  63285. isPointerBlocker: boolean;
  63286. /** Gets or sets a boolean indicating if the control can be focusable */
  63287. isFocusInvisible: boolean;
  63288. /**
  63289. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  63290. * 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
  63291. */
  63292. clipChildren: boolean;
  63293. /**
  63294. * Gets or sets a boolean indicating that control content must be clipped
  63295. * 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
  63296. */
  63297. clipContent: boolean;
  63298. /**
  63299. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  63300. */
  63301. useBitmapCache: boolean;
  63302. private _cacheData;
  63303. private _shadowOffsetX;
  63304. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  63305. shadowOffsetX: number;
  63306. private _shadowOffsetY;
  63307. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  63308. shadowOffsetY: number;
  63309. private _shadowBlur;
  63310. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  63311. shadowBlur: number;
  63312. private _shadowColor;
  63313. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  63314. shadowColor: string;
  63315. /** Gets or sets the cursor to use when the control is hovered */
  63316. hoverCursor: string;
  63317. /** @hidden */
  63318. protected _linkOffsetX: ValueAndUnit;
  63319. /** @hidden */
  63320. protected _linkOffsetY: ValueAndUnit;
  63321. /** Gets the control type name */
  63322. readonly typeName: string;
  63323. /**
  63324. * Get the current class name of the control.
  63325. * @returns current class name
  63326. */
  63327. getClassName(): string;
  63328. /**
  63329. * An event triggered when the pointer move over the control.
  63330. */
  63331. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  63332. /**
  63333. * An event triggered when the pointer move out of the control.
  63334. */
  63335. onPointerOutObservable: BABYLON.Observable<Control>;
  63336. /**
  63337. * An event triggered when the pointer taps the control
  63338. */
  63339. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  63340. /**
  63341. * An event triggered when pointer up
  63342. */
  63343. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  63344. /**
  63345. * An event triggered when a control is clicked on
  63346. */
  63347. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  63348. /**
  63349. * An event triggered when pointer enters the control
  63350. */
  63351. onPointerEnterObservable: BABYLON.Observable<Control>;
  63352. /**
  63353. * An event triggered when the control is marked as dirty
  63354. */
  63355. onDirtyObservable: BABYLON.Observable<Control>;
  63356. /**
  63357. * An event triggered before drawing the control
  63358. */
  63359. onBeforeDrawObservable: BABYLON.Observable<Control>;
  63360. /**
  63361. * An event triggered after the control was drawn
  63362. */
  63363. onAfterDrawObservable: BABYLON.Observable<Control>;
  63364. /**
  63365. * Get the hosting AdvancedDynamicTexture
  63366. */
  63367. readonly host: AdvancedDynamicTexture;
  63368. /** Gets or set information about font offsets (used to render and align text) */
  63369. fontOffset: {
  63370. ascent: number;
  63371. height: number;
  63372. descent: number;
  63373. };
  63374. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  63375. alpha: number;
  63376. /**
  63377. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  63378. */
  63379. isHighlighted: boolean;
  63380. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  63381. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63382. */
  63383. scaleX: number;
  63384. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  63385. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63386. */
  63387. scaleY: number;
  63388. /** Gets or sets the rotation angle (0 by default)
  63389. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63390. */
  63391. rotation: number;
  63392. /** Gets or sets the transformation center on Y axis (0 by default)
  63393. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63394. */
  63395. transformCenterY: number;
  63396. /** Gets or sets the transformation center on X axis (0 by default)
  63397. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63398. */
  63399. transformCenterX: number;
  63400. /**
  63401. * Gets or sets the horizontal alignment
  63402. * @see http://doc.babylonjs.com/how_to/gui#alignments
  63403. */
  63404. horizontalAlignment: number;
  63405. /**
  63406. * Gets or sets the vertical alignment
  63407. * @see http://doc.babylonjs.com/how_to/gui#alignments
  63408. */
  63409. verticalAlignment: number;
  63410. /**
  63411. * Gets or sets control width
  63412. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63413. */
  63414. width: string | number;
  63415. /**
  63416. * Gets or sets the control width in pixel
  63417. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63418. */
  63419. widthInPixels: number;
  63420. /**
  63421. * Gets or sets control height
  63422. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63423. */
  63424. height: string | number;
  63425. /**
  63426. * Gets or sets control height in pixel
  63427. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63428. */
  63429. heightInPixels: number;
  63430. /** Gets or set font family */
  63431. fontFamily: string;
  63432. /** Gets or sets font style */
  63433. fontStyle: string;
  63434. /** Gets or sets font weight */
  63435. fontWeight: string;
  63436. /**
  63437. * Gets or sets style
  63438. * @see http://doc.babylonjs.com/how_to/gui#styles
  63439. */
  63440. style: BABYLON.Nullable<Style>;
  63441. /** @hidden */
  63442. readonly _isFontSizeInPercentage: boolean;
  63443. /** Gets or sets font size in pixels */
  63444. fontSizeInPixels: number;
  63445. /** Gets or sets font size */
  63446. fontSize: string | number;
  63447. /** Gets or sets foreground color */
  63448. color: string;
  63449. /** Gets or sets z index which is used to reorder controls on the z axis */
  63450. zIndex: number;
  63451. /** Gets or sets a boolean indicating if the control can be rendered */
  63452. notRenderable: boolean;
  63453. /** Gets or sets a boolean indicating if the control is visible */
  63454. isVisible: boolean;
  63455. /** Gets a boolean indicating that the control needs to update its rendering */
  63456. readonly isDirty: boolean;
  63457. /**
  63458. * Gets the current linked mesh (or null if none)
  63459. */
  63460. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  63461. /**
  63462. * Gets or sets a value indicating the padding to use on the left of the control
  63463. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63464. */
  63465. paddingLeft: string | number;
  63466. /**
  63467. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  63468. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63469. */
  63470. paddingLeftInPixels: number;
  63471. /**
  63472. * Gets or sets a value indicating the padding to use on the right of the control
  63473. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63474. */
  63475. paddingRight: string | number;
  63476. /**
  63477. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  63478. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63479. */
  63480. paddingRightInPixels: number;
  63481. /**
  63482. * Gets or sets a value indicating the padding to use on the top of the control
  63483. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63484. */
  63485. paddingTop: string | number;
  63486. /**
  63487. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  63488. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63489. */
  63490. paddingTopInPixels: number;
  63491. /**
  63492. * Gets or sets a value indicating the padding to use on the bottom of the control
  63493. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63494. */
  63495. paddingBottom: string | number;
  63496. /**
  63497. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  63498. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63499. */
  63500. paddingBottomInPixels: number;
  63501. /**
  63502. * Gets or sets a value indicating the left coordinate of the control
  63503. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63504. */
  63505. left: string | number;
  63506. /**
  63507. * Gets or sets a value indicating the left coordinate in pixels of the control
  63508. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63509. */
  63510. leftInPixels: number;
  63511. /**
  63512. * Gets or sets a value indicating the top coordinate of the control
  63513. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63514. */
  63515. top: string | number;
  63516. /**
  63517. * Gets or sets a value indicating the top coordinate in pixels of the control
  63518. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63519. */
  63520. topInPixels: number;
  63521. /**
  63522. * Gets or sets a value indicating the offset on X axis to the linked mesh
  63523. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63524. */
  63525. linkOffsetX: string | number;
  63526. /**
  63527. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  63528. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63529. */
  63530. linkOffsetXInPixels: number;
  63531. /**
  63532. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  63533. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63534. */
  63535. linkOffsetY: string | number;
  63536. /**
  63537. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  63538. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63539. */
  63540. linkOffsetYInPixels: number;
  63541. /** Gets the center coordinate on X axis */
  63542. readonly centerX: number;
  63543. /** Gets the center coordinate on Y axis */
  63544. readonly centerY: number;
  63545. /** Gets or sets if control is Enabled*/
  63546. isEnabled: boolean;
  63547. /** Gets or sets background color of control if it's disabled*/
  63548. disabledColor: string;
  63549. /**
  63550. * Creates a new control
  63551. * @param name defines the name of the control
  63552. */
  63553. constructor(
  63554. /** defines the name of the control */
  63555. name?: string | undefined);
  63556. /** @hidden */
  63557. protected _getTypeName(): string;
  63558. /**
  63559. * Gets the first ascendant in the hierarchy of the given type
  63560. * @param className defines the required type
  63561. * @returns the ascendant or null if not found
  63562. */
  63563. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  63564. /** @hidden */
  63565. _resetFontCache(): void;
  63566. /**
  63567. * Determines if a container is an ascendant of the current control
  63568. * @param container defines the container to look for
  63569. * @returns true if the container is one of the ascendant of the control
  63570. */
  63571. isAscendant(container: Control): boolean;
  63572. /**
  63573. * Gets coordinates in local control space
  63574. * @param globalCoordinates defines the coordinates to transform
  63575. * @returns the new coordinates in local space
  63576. */
  63577. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  63578. /**
  63579. * Gets coordinates in local control space
  63580. * @param globalCoordinates defines the coordinates to transform
  63581. * @param result defines the target vector2 where to store the result
  63582. * @returns the current control
  63583. */
  63584. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  63585. /**
  63586. * Gets coordinates in parent local control space
  63587. * @param globalCoordinates defines the coordinates to transform
  63588. * @returns the new coordinates in parent local space
  63589. */
  63590. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  63591. /**
  63592. * Move the current control to a vector3 position projected onto the screen.
  63593. * @param position defines the target position
  63594. * @param scene defines the hosting scene
  63595. */
  63596. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  63597. /** @hidden */
  63598. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  63599. /**
  63600. * Will return all controls that have this control as ascendant
  63601. * @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
  63602. * @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
  63603. * @return all child controls
  63604. */
  63605. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  63606. /**
  63607. * Link current control with a target mesh
  63608. * @param mesh defines the mesh to link with
  63609. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63610. */
  63611. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  63612. /** @hidden */
  63613. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  63614. /** @hidden */
  63615. _offsetLeft(offset: number): void;
  63616. /** @hidden */
  63617. _offsetTop(offset: number): void;
  63618. /** @hidden */
  63619. _markMatrixAsDirty(): void;
  63620. /** @hidden */
  63621. _flagDescendantsAsMatrixDirty(): void;
  63622. /** @hidden */
  63623. _intersectsRect(rect: Measure): boolean;
  63624. /** @hidden */
  63625. protected invalidateRect(): void;
  63626. /** @hidden */
  63627. _markAsDirty(force?: boolean): void;
  63628. /** @hidden */
  63629. _markAllAsDirty(): void;
  63630. /** @hidden */
  63631. _link(host: AdvancedDynamicTexture): void;
  63632. /** @hidden */
  63633. protected _transform(context?: CanvasRenderingContext2D): void;
  63634. /** @hidden */
  63635. _renderHighlight(context: CanvasRenderingContext2D): void;
  63636. /** @hidden */
  63637. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  63638. /** @hidden */
  63639. protected _applyStates(context: CanvasRenderingContext2D): void;
  63640. /** @hidden */
  63641. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  63642. /** @hidden */
  63643. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63644. protected _evaluateClippingState(parentMeasure: Measure): void;
  63645. /** @hidden */
  63646. _measure(): void;
  63647. /** @hidden */
  63648. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63649. /** @hidden */
  63650. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63651. /** @hidden */
  63652. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63653. /** @hidden */
  63654. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  63655. private static _ClipMeasure;
  63656. private _tmpMeasureA;
  63657. private _clip;
  63658. /** @hidden */
  63659. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  63660. /** @hidden */
  63661. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  63662. /**
  63663. * Tests if a given coordinates belong to the current control
  63664. * @param x defines x coordinate to test
  63665. * @param y defines y coordinate to test
  63666. * @returns true if the coordinates are inside the control
  63667. */
  63668. contains(x: number, y: number): boolean;
  63669. /** @hidden */
  63670. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  63671. /** @hidden */
  63672. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  63673. /** @hidden */
  63674. _onPointerEnter(target: Control): boolean;
  63675. /** @hidden */
  63676. _onPointerOut(target: Control, force?: boolean): void;
  63677. /** @hidden */
  63678. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63679. /** @hidden */
  63680. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63681. /** @hidden */
  63682. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  63683. /** @hidden */
  63684. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  63685. private _prepareFont;
  63686. /** Releases associated resources */
  63687. dispose(): void;
  63688. private static _HORIZONTAL_ALIGNMENT_LEFT;
  63689. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  63690. private static _HORIZONTAL_ALIGNMENT_CENTER;
  63691. private static _VERTICAL_ALIGNMENT_TOP;
  63692. private static _VERTICAL_ALIGNMENT_BOTTOM;
  63693. private static _VERTICAL_ALIGNMENT_CENTER;
  63694. /** HORIZONTAL_ALIGNMENT_LEFT */
  63695. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  63696. /** HORIZONTAL_ALIGNMENT_RIGHT */
  63697. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  63698. /** HORIZONTAL_ALIGNMENT_CENTER */
  63699. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  63700. /** VERTICAL_ALIGNMENT_TOP */
  63701. static readonly VERTICAL_ALIGNMENT_TOP: number;
  63702. /** VERTICAL_ALIGNMENT_BOTTOM */
  63703. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  63704. /** VERTICAL_ALIGNMENT_CENTER */
  63705. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  63706. private static _FontHeightSizes;
  63707. /** @hidden */
  63708. static _GetFontOffset(font: string): {
  63709. ascent: number;
  63710. height: number;
  63711. descent: number;
  63712. };
  63713. /**
  63714. * Creates a stack panel that can be used to render headers
  63715. * @param control defines the control to associate with the header
  63716. * @param text defines the text of the header
  63717. * @param size defines the size of the header
  63718. * @param options defines options used to configure the header
  63719. * @returns a new StackPanel
  63720. * @ignore
  63721. * @hidden
  63722. */
  63723. static AddHeader: (control: Control, text: string, size: string | number, options: {
  63724. isHorizontal: boolean;
  63725. controlFirst: boolean;
  63726. }) => any;
  63727. /** @hidden */
  63728. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  63729. }
  63730. }
  63731. declare module BABYLON.GUI {
  63732. /**
  63733. * Root class for 2D containers
  63734. * @see http://doc.babylonjs.com/how_to/gui#containers
  63735. */
  63736. export class Container extends Control {
  63737. name?: string | undefined;
  63738. /** @hidden */
  63739. protected _children: Control[];
  63740. /** @hidden */
  63741. protected _measureForChildren: Measure;
  63742. /** @hidden */
  63743. protected _background: string;
  63744. /** @hidden */
  63745. protected _adaptWidthToChildren: boolean;
  63746. /** @hidden */
  63747. protected _adaptHeightToChildren: boolean;
  63748. /**
  63749. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  63750. */
  63751. logLayoutCycleErrors: boolean;
  63752. /**
  63753. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  63754. */
  63755. maxLayoutCycle: number;
  63756. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  63757. adaptHeightToChildren: boolean;
  63758. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  63759. adaptWidthToChildren: boolean;
  63760. /** Gets or sets background color */
  63761. background: string;
  63762. /** Gets the list of children */
  63763. readonly children: Control[];
  63764. /**
  63765. * Creates a new Container
  63766. * @param name defines the name of the container
  63767. */
  63768. constructor(name?: string | undefined);
  63769. protected _getTypeName(): string;
  63770. _flagDescendantsAsMatrixDirty(): void;
  63771. /**
  63772. * Gets a child using its name
  63773. * @param name defines the child name to look for
  63774. * @returns the child control if found
  63775. */
  63776. getChildByName(name: string): BABYLON.Nullable<Control>;
  63777. /**
  63778. * Gets a child using its type and its name
  63779. * @param name defines the child name to look for
  63780. * @param type defines the child type to look for
  63781. * @returns the child control if found
  63782. */
  63783. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  63784. /**
  63785. * Search for a specific control in children
  63786. * @param control defines the control to look for
  63787. * @returns true if the control is in child list
  63788. */
  63789. containsControl(control: Control): boolean;
  63790. /**
  63791. * Adds a new control to the current container
  63792. * @param control defines the control to add
  63793. * @returns the current container
  63794. */
  63795. addControl(control: BABYLON.Nullable<Control>): Container;
  63796. /**
  63797. * Removes all controls from the current container
  63798. * @returns the current container
  63799. */
  63800. clearControls(): Container;
  63801. /**
  63802. * Removes a control from the current container
  63803. * @param control defines the control to remove
  63804. * @returns the current container
  63805. */
  63806. removeControl(control: Control): Container;
  63807. /** @hidden */
  63808. _reOrderControl(control: Control): void;
  63809. /** @hidden */
  63810. _offsetLeft(offset: number): void;
  63811. /** @hidden */
  63812. _offsetTop(offset: number): void;
  63813. /** @hidden */
  63814. _markAllAsDirty(): void;
  63815. /** @hidden */
  63816. protected _localDraw(context: CanvasRenderingContext2D): void;
  63817. /** @hidden */
  63818. _link(host: AdvancedDynamicTexture): void;
  63819. /** @hidden */
  63820. protected _beforeLayout(): void;
  63821. /** @hidden */
  63822. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63823. /** @hidden */
  63824. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  63825. protected _postMeasure(): void;
  63826. /** @hidden */
  63827. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  63828. /** @hidden */
  63829. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  63830. /** @hidden */
  63831. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  63832. /** @hidden */
  63833. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63834. /** Releases associated resources */
  63835. dispose(): void;
  63836. }
  63837. }
  63838. declare module BABYLON.GUI {
  63839. /** Class used to create rectangle container */
  63840. export class Rectangle extends Container {
  63841. name?: string | undefined;
  63842. private _thickness;
  63843. private _cornerRadius;
  63844. /** Gets or sets border thickness */
  63845. thickness: number;
  63846. /** Gets or sets the corner radius angle */
  63847. cornerRadius: number;
  63848. /**
  63849. * Creates a new Rectangle
  63850. * @param name defines the control name
  63851. */
  63852. constructor(name?: string | undefined);
  63853. protected _getTypeName(): string;
  63854. protected _localDraw(context: CanvasRenderingContext2D): void;
  63855. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63856. private _drawRoundedRect;
  63857. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  63858. }
  63859. }
  63860. declare module BABYLON.GUI {
  63861. /**
  63862. * Enum that determines the text-wrapping mode to use.
  63863. */
  63864. export enum TextWrapping {
  63865. /**
  63866. * Clip the text when it's larger than Control.width; this is the default mode.
  63867. */
  63868. Clip = 0,
  63869. /**
  63870. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  63871. */
  63872. WordWrap = 1,
  63873. /**
  63874. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  63875. */
  63876. Ellipsis = 2
  63877. }
  63878. /**
  63879. * Class used to create text block control
  63880. */
  63881. export class TextBlock extends Control {
  63882. /**
  63883. * Defines the name of the control
  63884. */
  63885. name?: string | undefined;
  63886. private _text;
  63887. private _textWrapping;
  63888. private _textHorizontalAlignment;
  63889. private _textVerticalAlignment;
  63890. private _lines;
  63891. private _resizeToFit;
  63892. private _lineSpacing;
  63893. private _outlineWidth;
  63894. private _outlineColor;
  63895. /**
  63896. * An event triggered after the text is changed
  63897. */
  63898. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  63899. /**
  63900. * An event triggered after the text was broken up into lines
  63901. */
  63902. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  63903. /**
  63904. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  63905. */
  63906. readonly lines: any[];
  63907. /**
  63908. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  63909. */
  63910. /**
  63911. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  63912. */
  63913. resizeToFit: boolean;
  63914. /**
  63915. * Gets or sets a boolean indicating if text must be wrapped
  63916. */
  63917. /**
  63918. * Gets or sets a boolean indicating if text must be wrapped
  63919. */
  63920. textWrapping: TextWrapping | boolean;
  63921. /**
  63922. * Gets or sets text to display
  63923. */
  63924. /**
  63925. * Gets or sets text to display
  63926. */
  63927. text: string;
  63928. /**
  63929. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  63930. */
  63931. /**
  63932. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  63933. */
  63934. textHorizontalAlignment: number;
  63935. /**
  63936. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  63937. */
  63938. /**
  63939. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  63940. */
  63941. textVerticalAlignment: number;
  63942. /**
  63943. * Gets or sets line spacing value
  63944. */
  63945. /**
  63946. * Gets or sets line spacing value
  63947. */
  63948. lineSpacing: string | number;
  63949. /**
  63950. * Gets or sets outlineWidth of the text to display
  63951. */
  63952. /**
  63953. * Gets or sets outlineWidth of the text to display
  63954. */
  63955. outlineWidth: number;
  63956. /**
  63957. * Gets or sets outlineColor of the text to display
  63958. */
  63959. /**
  63960. * Gets or sets outlineColor of the text to display
  63961. */
  63962. outlineColor: string;
  63963. /**
  63964. * Creates a new TextBlock object
  63965. * @param name defines the name of the control
  63966. * @param text defines the text to display (emptry string by default)
  63967. */
  63968. constructor(
  63969. /**
  63970. * Defines the name of the control
  63971. */
  63972. name?: string | undefined, text?: string);
  63973. protected _getTypeName(): string;
  63974. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63975. private _drawText;
  63976. /** @hidden */
  63977. _draw(context: CanvasRenderingContext2D): void;
  63978. protected _applyStates(context: CanvasRenderingContext2D): void;
  63979. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  63980. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  63981. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  63982. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  63983. protected _renderLines(context: CanvasRenderingContext2D): void;
  63984. /**
  63985. * Given a width constraint applied on the text block, find the expected height
  63986. * @returns expected height
  63987. */
  63988. computeExpectedHeight(): number;
  63989. dispose(): void;
  63990. }
  63991. }
  63992. declare module BABYLON.GUI {
  63993. /**
  63994. * Class used to create 2D images
  63995. */
  63996. export class Image extends Control {
  63997. name?: string | undefined;
  63998. private static _WorkingCanvas;
  63999. private _domImage;
  64000. private _imageWidth;
  64001. private _imageHeight;
  64002. private _loaded;
  64003. private _stretch;
  64004. private _source;
  64005. private _autoScale;
  64006. private _sourceLeft;
  64007. private _sourceTop;
  64008. private _sourceWidth;
  64009. private _sourceHeight;
  64010. private _cellWidth;
  64011. private _cellHeight;
  64012. private _cellId;
  64013. private _populateNinePatchSlicesFromImage;
  64014. private _sliceLeft;
  64015. private _sliceRight;
  64016. private _sliceTop;
  64017. private _sliceBottom;
  64018. private _detectPointerOnOpaqueOnly;
  64019. /**
  64020. * BABYLON.Observable notified when the content is loaded
  64021. */
  64022. onImageLoadedObservable: BABYLON.Observable<Image>;
  64023. /**
  64024. * Gets a boolean indicating that the content is loaded
  64025. */
  64026. readonly isLoaded: boolean;
  64027. /**
  64028. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  64029. */
  64030. populateNinePatchSlicesFromImage: boolean;
  64031. /**
  64032. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  64033. * Beware using this as this will comsume more memory as the image has to be stored twice
  64034. */
  64035. detectPointerOnOpaqueOnly: boolean;
  64036. /**
  64037. * Gets or sets the left value for slicing (9-patch)
  64038. */
  64039. sliceLeft: number;
  64040. /**
  64041. * Gets or sets the right value for slicing (9-patch)
  64042. */
  64043. sliceRight: number;
  64044. /**
  64045. * Gets or sets the top value for slicing (9-patch)
  64046. */
  64047. sliceTop: number;
  64048. /**
  64049. * Gets or sets the bottom value for slicing (9-patch)
  64050. */
  64051. sliceBottom: number;
  64052. /**
  64053. * Gets or sets the left coordinate in the source image
  64054. */
  64055. sourceLeft: number;
  64056. /**
  64057. * Gets or sets the top coordinate in the source image
  64058. */
  64059. sourceTop: number;
  64060. /**
  64061. * Gets or sets the width to capture in the source image
  64062. */
  64063. sourceWidth: number;
  64064. /**
  64065. * Gets or sets the height to capture in the source image
  64066. */
  64067. sourceHeight: number;
  64068. /**
  64069. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  64070. * @see http://doc.babylonjs.com/how_to/gui#image
  64071. */
  64072. autoScale: boolean;
  64073. /** Gets or sets the streching mode used by the image */
  64074. stretch: number;
  64075. /**
  64076. * Gets or sets the internal DOM image used to render the control
  64077. */
  64078. domImage: HTMLImageElement;
  64079. private _onImageLoaded;
  64080. private _extractNinePatchSliceDataFromImage;
  64081. /**
  64082. * Gets or sets image source url
  64083. */
  64084. source: BABYLON.Nullable<string>;
  64085. /**
  64086. * Gets or sets the cell width to use when animation sheet is enabled
  64087. * @see http://doc.babylonjs.com/how_to/gui#image
  64088. */
  64089. cellWidth: number;
  64090. /**
  64091. * Gets or sets the cell height to use when animation sheet is enabled
  64092. * @see http://doc.babylonjs.com/how_to/gui#image
  64093. */
  64094. cellHeight: number;
  64095. /**
  64096. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  64097. * @see http://doc.babylonjs.com/how_to/gui#image
  64098. */
  64099. cellId: number;
  64100. /**
  64101. * Creates a new Image
  64102. * @param name defines the control name
  64103. * @param url defines the image url
  64104. */
  64105. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  64106. /**
  64107. * Tests if a given coordinates belong to the current control
  64108. * @param x defines x coordinate to test
  64109. * @param y defines y coordinate to test
  64110. * @returns true if the coordinates are inside the control
  64111. */
  64112. contains(x: number, y: number): boolean;
  64113. protected _getTypeName(): string;
  64114. /** Force the control to synchronize with its content */
  64115. synchronizeSizeWithContent(): void;
  64116. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64117. private _prepareWorkingCanvasForOpaqueDetection;
  64118. private _drawImage;
  64119. _draw(context: CanvasRenderingContext2D): void;
  64120. private _renderCornerPatch;
  64121. private _renderNinePatch;
  64122. dispose(): void;
  64123. /** STRETCH_NONE */
  64124. static readonly STRETCH_NONE: number;
  64125. /** STRETCH_FILL */
  64126. static readonly STRETCH_FILL: number;
  64127. /** STRETCH_UNIFORM */
  64128. static readonly STRETCH_UNIFORM: number;
  64129. /** STRETCH_EXTEND */
  64130. static readonly STRETCH_EXTEND: number;
  64131. /** NINE_PATCH */
  64132. static readonly STRETCH_NINE_PATCH: number;
  64133. }
  64134. }
  64135. declare module BABYLON.GUI {
  64136. /**
  64137. * Class used to create 2D buttons
  64138. */
  64139. export class Button extends Rectangle {
  64140. name?: string | undefined;
  64141. /**
  64142. * Function called to generate a pointer enter animation
  64143. */
  64144. pointerEnterAnimation: () => void;
  64145. /**
  64146. * Function called to generate a pointer out animation
  64147. */
  64148. pointerOutAnimation: () => void;
  64149. /**
  64150. * Function called to generate a pointer down animation
  64151. */
  64152. pointerDownAnimation: () => void;
  64153. /**
  64154. * Function called to generate a pointer up animation
  64155. */
  64156. pointerUpAnimation: () => void;
  64157. /**
  64158. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  64159. */
  64160. delegatePickingToChildren: boolean;
  64161. private _image;
  64162. /**
  64163. * Returns the image part of the button (if any)
  64164. */
  64165. readonly image: BABYLON.Nullable<Image>;
  64166. private _textBlock;
  64167. /**
  64168. * Returns the image part of the button (if any)
  64169. */
  64170. readonly textBlock: BABYLON.Nullable<TextBlock>;
  64171. /**
  64172. * Creates a new Button
  64173. * @param name defines the name of the button
  64174. */
  64175. constructor(name?: string | undefined);
  64176. protected _getTypeName(): string;
  64177. /** @hidden */
  64178. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  64179. /** @hidden */
  64180. _onPointerEnter(target: Control): boolean;
  64181. /** @hidden */
  64182. _onPointerOut(target: Control, force?: boolean): void;
  64183. /** @hidden */
  64184. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64185. /** @hidden */
  64186. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64187. /**
  64188. * Creates a new button made with an image and a text
  64189. * @param name defines the name of the button
  64190. * @param text defines the text of the button
  64191. * @param imageUrl defines the url of the image
  64192. * @returns a new Button
  64193. */
  64194. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  64195. /**
  64196. * Creates a new button made with an image
  64197. * @param name defines the name of the button
  64198. * @param imageUrl defines the url of the image
  64199. * @returns a new Button
  64200. */
  64201. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  64202. /**
  64203. * Creates a new button made with a text
  64204. * @param name defines the name of the button
  64205. * @param text defines the text of the button
  64206. * @returns a new Button
  64207. */
  64208. static CreateSimpleButton(name: string, text: string): Button;
  64209. /**
  64210. * Creates a new button made with an image and a centered text
  64211. * @param name defines the name of the button
  64212. * @param text defines the text of the button
  64213. * @param imageUrl defines the url of the image
  64214. * @returns a new Button
  64215. */
  64216. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  64217. }
  64218. }
  64219. declare module BABYLON.GUI {
  64220. /**
  64221. * Class used to create a 2D stack panel container
  64222. */
  64223. export class StackPanel extends Container {
  64224. name?: string | undefined;
  64225. private _isVertical;
  64226. private _manualWidth;
  64227. private _manualHeight;
  64228. private _doNotTrackManualChanges;
  64229. /**
  64230. * Gets or sets a boolean indicating that layou warnings should be ignored
  64231. */
  64232. ignoreLayoutWarnings: boolean;
  64233. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  64234. isVertical: boolean;
  64235. /**
  64236. * Gets or sets panel width.
  64237. * This value should not be set when in horizontal mode as it will be computed automatically
  64238. */
  64239. width: string | number;
  64240. /**
  64241. * Gets or sets panel height.
  64242. * This value should not be set when in vertical mode as it will be computed automatically
  64243. */
  64244. height: string | number;
  64245. /**
  64246. * Creates a new StackPanel
  64247. * @param name defines control name
  64248. */
  64249. constructor(name?: string | undefined);
  64250. protected _getTypeName(): string;
  64251. /** @hidden */
  64252. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64253. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64254. protected _postMeasure(): void;
  64255. }
  64256. }
  64257. declare module BABYLON.GUI {
  64258. /**
  64259. * Class used to represent a 2D checkbox
  64260. */
  64261. export class Checkbox extends Control {
  64262. name?: string | undefined;
  64263. private _isChecked;
  64264. private _background;
  64265. private _checkSizeRatio;
  64266. private _thickness;
  64267. /** Gets or sets border thickness */
  64268. thickness: number;
  64269. /**
  64270. * BABYLON.Observable raised when isChecked property changes
  64271. */
  64272. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  64273. /** Gets or sets a value indicating the ratio between overall size and check size */
  64274. checkSizeRatio: number;
  64275. /** Gets or sets background color */
  64276. background: string;
  64277. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  64278. isChecked: boolean;
  64279. /**
  64280. * Creates a new CheckBox
  64281. * @param name defines the control name
  64282. */
  64283. constructor(name?: string | undefined);
  64284. protected _getTypeName(): string;
  64285. /** @hidden */
  64286. _draw(context: CanvasRenderingContext2D): void;
  64287. /** @hidden */
  64288. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64289. /**
  64290. * Utility function to easily create a checkbox with a header
  64291. * @param title defines the label to use for the header
  64292. * @param onValueChanged defines the callback to call when value changes
  64293. * @returns a StackPanel containing the checkbox and a textBlock
  64294. */
  64295. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  64296. }
  64297. }
  64298. declare module BABYLON.GUI {
  64299. /**
  64300. * Class used to store key control properties
  64301. */
  64302. export class KeyPropertySet {
  64303. /** Width */
  64304. width?: string;
  64305. /** Height */
  64306. height?: string;
  64307. /** Left padding */
  64308. paddingLeft?: string;
  64309. /** Right padding */
  64310. paddingRight?: string;
  64311. /** Top padding */
  64312. paddingTop?: string;
  64313. /** Bottom padding */
  64314. paddingBottom?: string;
  64315. /** Foreground color */
  64316. color?: string;
  64317. /** Background color */
  64318. background?: string;
  64319. }
  64320. /**
  64321. * Class used to create virtual keyboard
  64322. */
  64323. export class VirtualKeyboard extends StackPanel {
  64324. /** BABYLON.Observable raised when a key is pressed */
  64325. onKeyPressObservable: BABYLON.Observable<string>;
  64326. /** Gets or sets default key button width */
  64327. defaultButtonWidth: string;
  64328. /** Gets or sets default key button height */
  64329. defaultButtonHeight: string;
  64330. /** Gets or sets default key button left padding */
  64331. defaultButtonPaddingLeft: string;
  64332. /** Gets or sets default key button right padding */
  64333. defaultButtonPaddingRight: string;
  64334. /** Gets or sets default key button top padding */
  64335. defaultButtonPaddingTop: string;
  64336. /** Gets or sets default key button bottom padding */
  64337. defaultButtonPaddingBottom: string;
  64338. /** Gets or sets default key button foreground color */
  64339. defaultButtonColor: string;
  64340. /** Gets or sets default key button background color */
  64341. defaultButtonBackground: string;
  64342. /** Gets or sets shift button foreground color */
  64343. shiftButtonColor: string;
  64344. /** Gets or sets shift button thickness*/
  64345. selectedShiftThickness: number;
  64346. /** Gets shift key state */
  64347. shiftState: number;
  64348. protected _getTypeName(): string;
  64349. private _createKey;
  64350. /**
  64351. * Adds a new row of keys
  64352. * @param keys defines the list of keys to add
  64353. * @param propertySets defines the associated property sets
  64354. */
  64355. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  64356. /**
  64357. * Set the shift key to a specific state
  64358. * @param shiftState defines the new shift state
  64359. */
  64360. applyShiftState(shiftState: number): void;
  64361. private _currentlyConnectedInputText;
  64362. private _connectedInputTexts;
  64363. private _onKeyPressObserver;
  64364. /** Gets the input text control currently attached to the keyboard */
  64365. readonly connectedInputText: BABYLON.Nullable<InputText>;
  64366. /**
  64367. * Connects the keyboard with an input text control
  64368. *
  64369. * @param input defines the target control
  64370. */
  64371. connect(input: InputText): void;
  64372. /**
  64373. * Disconnects the keyboard from connected InputText controls
  64374. *
  64375. * @param input optionally defines a target control, otherwise all are disconnected
  64376. */
  64377. disconnect(input?: InputText): void;
  64378. private _removeConnectedInputObservables;
  64379. /**
  64380. * Release all resources
  64381. */
  64382. dispose(): void;
  64383. /**
  64384. * Creates a new keyboard using a default layout
  64385. *
  64386. * @param name defines control name
  64387. * @returns a new VirtualKeyboard
  64388. */
  64389. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  64390. }
  64391. }
  64392. declare module BABYLON.GUI {
  64393. /**
  64394. * Class used to create input text control
  64395. */
  64396. export class InputText extends Control implements IFocusableControl {
  64397. name?: string | undefined;
  64398. private _text;
  64399. private _placeholderText;
  64400. private _background;
  64401. private _focusedBackground;
  64402. private _focusedColor;
  64403. private _placeholderColor;
  64404. private _thickness;
  64405. private _margin;
  64406. private _autoStretchWidth;
  64407. private _maxWidth;
  64408. private _isFocused;
  64409. private _blinkTimeout;
  64410. private _blinkIsEven;
  64411. private _cursorOffset;
  64412. private _scrollLeft;
  64413. private _textWidth;
  64414. private _clickedCoordinate;
  64415. private _deadKey;
  64416. private _addKey;
  64417. private _currentKey;
  64418. private _isTextHighlightOn;
  64419. private _textHighlightColor;
  64420. private _highligherOpacity;
  64421. private _highlightedText;
  64422. private _startHighlightIndex;
  64423. private _endHighlightIndex;
  64424. private _cursorIndex;
  64425. private _onFocusSelectAll;
  64426. private _isPointerDown;
  64427. private _onClipboardObserver;
  64428. private _onPointerDblTapObserver;
  64429. /** @hidden */
  64430. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  64431. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  64432. promptMessage: string;
  64433. /** Force disable prompt on mobile device */
  64434. disableMobilePrompt: boolean;
  64435. /** BABYLON.Observable raised when the text changes */
  64436. onTextChangedObservable: BABYLON.Observable<InputText>;
  64437. /** BABYLON.Observable raised just before an entered character is to be added */
  64438. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  64439. /** BABYLON.Observable raised when the control gets the focus */
  64440. onFocusObservable: BABYLON.Observable<InputText>;
  64441. /** BABYLON.Observable raised when the control loses the focus */
  64442. onBlurObservable: BABYLON.Observable<InputText>;
  64443. /**Observable raised when the text is highlighted */
  64444. onTextHighlightObservable: BABYLON.Observable<InputText>;
  64445. /**Observable raised when copy event is triggered */
  64446. onTextCopyObservable: BABYLON.Observable<InputText>;
  64447. /** BABYLON.Observable raised when cut event is triggered */
  64448. onTextCutObservable: BABYLON.Observable<InputText>;
  64449. /** BABYLON.Observable raised when paste event is triggered */
  64450. onTextPasteObservable: BABYLON.Observable<InputText>;
  64451. /** BABYLON.Observable raised when a key event was processed */
  64452. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  64453. /** Gets or sets the maximum width allowed by the control */
  64454. maxWidth: string | number;
  64455. /** Gets the maximum width allowed by the control in pixels */
  64456. readonly maxWidthInPixels: number;
  64457. /** Gets or sets the text highlighter transparency; default: 0.4 */
  64458. highligherOpacity: number;
  64459. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  64460. onFocusSelectAll: boolean;
  64461. /** Gets or sets the text hightlight color */
  64462. textHighlightColor: string;
  64463. /** Gets or sets control margin */
  64464. margin: string;
  64465. /** Gets control margin in pixels */
  64466. readonly marginInPixels: number;
  64467. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  64468. autoStretchWidth: boolean;
  64469. /** Gets or sets border thickness */
  64470. thickness: number;
  64471. /** Gets or sets the background color when focused */
  64472. focusedBackground: string;
  64473. /** Gets or sets the background color when focused */
  64474. focusedColor: string;
  64475. /** Gets or sets the background color */
  64476. background: string;
  64477. /** Gets or sets the placeholder color */
  64478. placeholderColor: string;
  64479. /** Gets or sets the text displayed when the control is empty */
  64480. placeholderText: string;
  64481. /** Gets or sets the dead key flag */
  64482. deadKey: boolean;
  64483. /** Gets or sets the highlight text */
  64484. highlightedText: string;
  64485. /** Gets or sets if the current key should be added */
  64486. addKey: boolean;
  64487. /** Gets or sets the value of the current key being entered */
  64488. currentKey: string;
  64489. /** Gets or sets the text displayed in the control */
  64490. text: string;
  64491. /** Gets or sets control width */
  64492. width: string | number;
  64493. /**
  64494. * Creates a new InputText
  64495. * @param name defines the control name
  64496. * @param text defines the text of the control
  64497. */
  64498. constructor(name?: string | undefined, text?: string);
  64499. /** @hidden */
  64500. onBlur(): void;
  64501. /** @hidden */
  64502. onFocus(): void;
  64503. protected _getTypeName(): string;
  64504. /**
  64505. * Function called to get the list of controls that should not steal the focus from this control
  64506. * @returns an array of controls
  64507. */
  64508. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  64509. /** @hidden */
  64510. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  64511. /** @hidden */
  64512. private _updateValueFromCursorIndex;
  64513. /** @hidden */
  64514. private _processDblClick;
  64515. /** @hidden */
  64516. private _selectAllText;
  64517. /**
  64518. * Handles the keyboard event
  64519. * @param evt Defines the KeyboardEvent
  64520. */
  64521. processKeyboard(evt: KeyboardEvent): void;
  64522. /** @hidden */
  64523. private _onCopyText;
  64524. /** @hidden */
  64525. private _onCutText;
  64526. /** @hidden */
  64527. private _onPasteText;
  64528. _draw(context: CanvasRenderingContext2D): void;
  64529. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64530. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  64531. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64532. protected _beforeRenderText(text: string): string;
  64533. dispose(): void;
  64534. }
  64535. }
  64536. declare module BABYLON.GUI {
  64537. /**
  64538. * Class used to create a 2D grid container
  64539. */
  64540. export class Grid extends Container {
  64541. name?: string | undefined;
  64542. private _rowDefinitions;
  64543. private _columnDefinitions;
  64544. private _cells;
  64545. private _childControls;
  64546. /**
  64547. * Gets the number of columns
  64548. */
  64549. readonly columnCount: number;
  64550. /**
  64551. * Gets the number of rows
  64552. */
  64553. readonly rowCount: number;
  64554. /** Gets the list of children */
  64555. readonly children: Control[];
  64556. /** Gets the list of cells (e.g. the containers) */
  64557. readonly cells: {
  64558. [key: string]: Container;
  64559. };
  64560. /**
  64561. * Gets the definition of a specific row
  64562. * @param index defines the index of the row
  64563. * @returns the row definition
  64564. */
  64565. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  64566. /**
  64567. * Gets the definition of a specific column
  64568. * @param index defines the index of the column
  64569. * @returns the column definition
  64570. */
  64571. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  64572. /**
  64573. * Adds a new row to the grid
  64574. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  64575. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  64576. * @returns the current grid
  64577. */
  64578. addRowDefinition(height: number, isPixel?: boolean): Grid;
  64579. /**
  64580. * Adds a new column to the grid
  64581. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  64582. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  64583. * @returns the current grid
  64584. */
  64585. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  64586. /**
  64587. * Update a row definition
  64588. * @param index defines the index of the row to update
  64589. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  64590. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  64591. * @returns the current grid
  64592. */
  64593. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  64594. /**
  64595. * Update a column definition
  64596. * @param index defines the index of the column to update
  64597. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  64598. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  64599. * @returns the current grid
  64600. */
  64601. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  64602. /**
  64603. * Gets the list of children stored in a specific cell
  64604. * @param row defines the row to check
  64605. * @param column defines the column to check
  64606. * @returns the list of controls
  64607. */
  64608. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  64609. /**
  64610. * Gets a string representing the child cell info (row x column)
  64611. * @param child defines the control to get info from
  64612. * @returns a string containing the child cell info (row x column)
  64613. */
  64614. getChildCellInfo(child: Control): string;
  64615. private _removeCell;
  64616. private _offsetCell;
  64617. /**
  64618. * Remove a column definition at specified index
  64619. * @param index defines the index of the column to remove
  64620. * @returns the current grid
  64621. */
  64622. removeColumnDefinition(index: number): Grid;
  64623. /**
  64624. * Remove a row definition at specified index
  64625. * @param index defines the index of the row to remove
  64626. * @returns the current grid
  64627. */
  64628. removeRowDefinition(index: number): Grid;
  64629. /**
  64630. * Adds a new control to the current grid
  64631. * @param control defines the control to add
  64632. * @param row defines the row where to add the control (0 by default)
  64633. * @param column defines the column where to add the control (0 by default)
  64634. * @returns the current grid
  64635. */
  64636. addControl(control: Control, row?: number, column?: number): Grid;
  64637. /**
  64638. * Removes a control from the current container
  64639. * @param control defines the control to remove
  64640. * @returns the current container
  64641. */
  64642. removeControl(control: Control): Container;
  64643. /**
  64644. * Creates a new Grid
  64645. * @param name defines control name
  64646. */
  64647. constructor(name?: string | undefined);
  64648. protected _getTypeName(): string;
  64649. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  64650. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64651. _flagDescendantsAsMatrixDirty(): void;
  64652. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  64653. /** Releases associated resources */
  64654. dispose(): void;
  64655. }
  64656. }
  64657. declare module BABYLON.GUI {
  64658. /** Class used to create color pickers */
  64659. export class ColorPicker extends Control {
  64660. name?: string | undefined;
  64661. private static _Epsilon;
  64662. private _colorWheelCanvas;
  64663. private _value;
  64664. private _tmpColor;
  64665. private _pointerStartedOnSquare;
  64666. private _pointerStartedOnWheel;
  64667. private _squareLeft;
  64668. private _squareTop;
  64669. private _squareSize;
  64670. private _h;
  64671. private _s;
  64672. private _v;
  64673. private _lastPointerDownID;
  64674. /**
  64675. * BABYLON.Observable raised when the value changes
  64676. */
  64677. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  64678. /** Gets or sets the color of the color picker */
  64679. value: BABYLON.Color3;
  64680. /**
  64681. * Gets or sets control width
  64682. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64683. */
  64684. width: string | number;
  64685. /**
  64686. * Gets or sets control height
  64687. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64688. */
  64689. /** Gets or sets control height */
  64690. height: string | number;
  64691. /** Gets or sets control size */
  64692. size: string | number;
  64693. /**
  64694. * Creates a new ColorPicker
  64695. * @param name defines the control name
  64696. */
  64697. constructor(name?: string | undefined);
  64698. protected _getTypeName(): string;
  64699. /** @hidden */
  64700. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64701. private _updateSquareProps;
  64702. private _drawGradientSquare;
  64703. private _drawCircle;
  64704. private _createColorWheelCanvas;
  64705. /** @hidden */
  64706. _draw(context: CanvasRenderingContext2D): void;
  64707. private _pointerIsDown;
  64708. private _updateValueFromPointer;
  64709. private _isPointOnSquare;
  64710. private _isPointOnWheel;
  64711. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64712. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  64713. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64714. /**
  64715. * This function expands the color picker by creating a color picker dialog with manual
  64716. * color value input and the ability to save colors into an array to be used later in
  64717. * subsequent launches of the dialogue.
  64718. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  64719. * @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.
  64720. * @returns picked color as a hex string and the saved colors array as hex strings.
  64721. */
  64722. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  64723. pickerWidth?: string;
  64724. pickerHeight?: string;
  64725. headerHeight?: string;
  64726. lastColor?: string;
  64727. swatchLimit?: number;
  64728. numSwatchesPerLine?: number;
  64729. savedColors?: Array<string>;
  64730. }): Promise<{
  64731. savedColors?: string[];
  64732. pickedColor: string;
  64733. }>;
  64734. }
  64735. }
  64736. declare module BABYLON.GUI {
  64737. /** Class used to create 2D ellipse containers */
  64738. export class Ellipse extends Container {
  64739. name?: string | undefined;
  64740. private _thickness;
  64741. /** Gets or sets border thickness */
  64742. thickness: number;
  64743. /**
  64744. * Creates a new Ellipse
  64745. * @param name defines the control name
  64746. */
  64747. constructor(name?: string | undefined);
  64748. protected _getTypeName(): string;
  64749. protected _localDraw(context: CanvasRenderingContext2D): void;
  64750. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64751. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  64752. }
  64753. }
  64754. declare module BABYLON.GUI {
  64755. /**
  64756. * Class used to create a password control
  64757. */
  64758. export class InputPassword extends InputText {
  64759. protected _beforeRenderText(text: string): string;
  64760. }
  64761. }
  64762. declare module BABYLON.GUI {
  64763. /** Class used to render 2D lines */
  64764. export class Line extends Control {
  64765. name?: string | undefined;
  64766. private _lineWidth;
  64767. private _x1;
  64768. private _y1;
  64769. private _x2;
  64770. private _y2;
  64771. private _dash;
  64772. private _connectedControl;
  64773. private _connectedControlDirtyObserver;
  64774. /** Gets or sets the dash pattern */
  64775. dash: Array<number>;
  64776. /** Gets or sets the control connected with the line end */
  64777. connectedControl: Control;
  64778. /** Gets or sets start coordinates on X axis */
  64779. x1: string | number;
  64780. /** Gets or sets start coordinates on Y axis */
  64781. y1: string | number;
  64782. /** Gets or sets end coordinates on X axis */
  64783. x2: string | number;
  64784. /** Gets or sets end coordinates on Y axis */
  64785. y2: string | number;
  64786. /** Gets or sets line width */
  64787. lineWidth: number;
  64788. /** Gets or sets horizontal alignment */
  64789. horizontalAlignment: number;
  64790. /** Gets or sets vertical alignment */
  64791. verticalAlignment: number;
  64792. private readonly _effectiveX2;
  64793. private readonly _effectiveY2;
  64794. /**
  64795. * Creates a new Line
  64796. * @param name defines the control name
  64797. */
  64798. constructor(name?: string | undefined);
  64799. protected _getTypeName(): string;
  64800. _draw(context: CanvasRenderingContext2D): void;
  64801. _measure(): void;
  64802. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64803. /**
  64804. * Move one end of the line given 3D cartesian coordinates.
  64805. * @param position Targeted world position
  64806. * @param scene BABYLON.Scene
  64807. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  64808. */
  64809. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  64810. /**
  64811. * Move one end of the line to a position in screen absolute space.
  64812. * @param projectedPosition Position in screen absolute space (X, Y)
  64813. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  64814. */
  64815. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  64816. }
  64817. }
  64818. declare module BABYLON.GUI {
  64819. /**
  64820. * Class used to store a point for a MultiLine object.
  64821. * The point can be pure 2D coordinates, a mesh or a control
  64822. */
  64823. export class MultiLinePoint {
  64824. private _multiLine;
  64825. private _x;
  64826. private _y;
  64827. private _control;
  64828. private _mesh;
  64829. private _controlObserver;
  64830. private _meshObserver;
  64831. /** @hidden */
  64832. _point: BABYLON.Vector2;
  64833. /**
  64834. * Creates a new MultiLinePoint
  64835. * @param multiLine defines the source MultiLine object
  64836. */
  64837. constructor(multiLine: MultiLine);
  64838. /** Gets or sets x coordinate */
  64839. x: string | number;
  64840. /** Gets or sets y coordinate */
  64841. y: string | number;
  64842. /** Gets or sets the control associated with this point */
  64843. control: BABYLON.Nullable<Control>;
  64844. /** Gets or sets the mesh associated with this point */
  64845. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  64846. /** Resets links */
  64847. resetLinks(): void;
  64848. /**
  64849. * Gets a translation vector
  64850. * @returns the translation vector
  64851. */
  64852. translate(): BABYLON.Vector2;
  64853. private _translatePoint;
  64854. /** Release associated resources */
  64855. dispose(): void;
  64856. }
  64857. }
  64858. declare module BABYLON.GUI {
  64859. /**
  64860. * Class used to create multi line control
  64861. */
  64862. export class MultiLine extends Control {
  64863. name?: string | undefined;
  64864. private _lineWidth;
  64865. private _dash;
  64866. private _points;
  64867. private _minX;
  64868. private _minY;
  64869. private _maxX;
  64870. private _maxY;
  64871. /**
  64872. * Creates a new MultiLine
  64873. * @param name defines the control name
  64874. */
  64875. constructor(name?: string | undefined);
  64876. /** Gets or sets dash pattern */
  64877. dash: Array<number>;
  64878. /**
  64879. * Gets point stored at specified index
  64880. * @param index defines the index to look for
  64881. * @returns the requested point if found
  64882. */
  64883. getAt(index: number): MultiLinePoint;
  64884. /** Function called when a point is updated */
  64885. onPointUpdate: () => void;
  64886. /**
  64887. * Adds new points to the point collection
  64888. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  64889. * @returns the list of created MultiLinePoint
  64890. */
  64891. add(...items: (AbstractMesh | Control | {
  64892. x: string | number;
  64893. y: string | number;
  64894. })[]): MultiLinePoint[];
  64895. /**
  64896. * Adds a new point to the point collection
  64897. * @param item defines the item (mesh, control or 2d coordiantes) to add
  64898. * @returns the created MultiLinePoint
  64899. */
  64900. push(item?: (AbstractMesh | Control | {
  64901. x: string | number;
  64902. y: string | number;
  64903. })): MultiLinePoint;
  64904. /**
  64905. * Remove a specific value or point from the active point collection
  64906. * @param value defines the value or point to remove
  64907. */
  64908. remove(value: number | MultiLinePoint): void;
  64909. /**
  64910. * Resets this object to initial state (no point)
  64911. */
  64912. reset(): void;
  64913. /**
  64914. * Resets all links
  64915. */
  64916. resetLinks(): void;
  64917. /** Gets or sets line width */
  64918. lineWidth: number;
  64919. horizontalAlignment: number;
  64920. verticalAlignment: number;
  64921. protected _getTypeName(): string;
  64922. _draw(context: CanvasRenderingContext2D): void;
  64923. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64924. _measure(): void;
  64925. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64926. dispose(): void;
  64927. }
  64928. }
  64929. declare module BABYLON.GUI {
  64930. /**
  64931. * Class used to create radio button controls
  64932. */
  64933. export class RadioButton extends Control {
  64934. name?: string | undefined;
  64935. private _isChecked;
  64936. private _background;
  64937. private _checkSizeRatio;
  64938. private _thickness;
  64939. /** Gets or sets border thickness */
  64940. thickness: number;
  64941. /** Gets or sets group name */
  64942. group: string;
  64943. /** BABYLON.Observable raised when isChecked is changed */
  64944. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  64945. /** Gets or sets a value indicating the ratio between overall size and check size */
  64946. checkSizeRatio: number;
  64947. /** Gets or sets background color */
  64948. background: string;
  64949. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  64950. isChecked: boolean;
  64951. /**
  64952. * Creates a new RadioButton
  64953. * @param name defines the control name
  64954. */
  64955. constructor(name?: string | undefined);
  64956. protected _getTypeName(): string;
  64957. _draw(context: CanvasRenderingContext2D): void;
  64958. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64959. /**
  64960. * Utility function to easily create a radio button with a header
  64961. * @param title defines the label to use for the header
  64962. * @param group defines the group to use for the radio button
  64963. * @param isChecked defines the initial state of the radio button
  64964. * @param onValueChanged defines the callback to call when value changes
  64965. * @returns a StackPanel containing the radio button and a textBlock
  64966. */
  64967. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  64968. }
  64969. }
  64970. declare module BABYLON.GUI {
  64971. /**
  64972. * Class used to create slider controls
  64973. */
  64974. export class BaseSlider extends Control {
  64975. name?: string | undefined;
  64976. protected _thumbWidth: ValueAndUnit;
  64977. private _minimum;
  64978. private _maximum;
  64979. private _value;
  64980. private _isVertical;
  64981. protected _barOffset: ValueAndUnit;
  64982. private _isThumbClamped;
  64983. protected _displayThumb: boolean;
  64984. private _step;
  64985. private _lastPointerDownID;
  64986. protected _effectiveBarOffset: number;
  64987. protected _renderLeft: number;
  64988. protected _renderTop: number;
  64989. protected _renderWidth: number;
  64990. protected _renderHeight: number;
  64991. protected _backgroundBoxLength: number;
  64992. protected _backgroundBoxThickness: number;
  64993. protected _effectiveThumbThickness: number;
  64994. /** BABYLON.Observable raised when the sldier value changes */
  64995. onValueChangedObservable: BABYLON.Observable<number>;
  64996. /** Gets or sets a boolean indicating if the thumb must be rendered */
  64997. displayThumb: boolean;
  64998. /** Gets or sets a step to apply to values (0 by default) */
  64999. step: number;
  65000. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  65001. barOffset: string | number;
  65002. /** Gets main bar offset in pixels*/
  65003. readonly barOffsetInPixels: number;
  65004. /** Gets or sets thumb width */
  65005. thumbWidth: string | number;
  65006. /** Gets thumb width in pixels */
  65007. readonly thumbWidthInPixels: number;
  65008. /** Gets or sets minimum value */
  65009. minimum: number;
  65010. /** Gets or sets maximum value */
  65011. maximum: number;
  65012. /** Gets or sets current value */
  65013. value: number;
  65014. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  65015. isVertical: boolean;
  65016. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  65017. isThumbClamped: boolean;
  65018. /**
  65019. * Creates a new BaseSlider
  65020. * @param name defines the control name
  65021. */
  65022. constructor(name?: string | undefined);
  65023. protected _getTypeName(): string;
  65024. protected _getThumbPosition(): number;
  65025. protected _getThumbThickness(type: string): number;
  65026. protected _prepareRenderingData(type: string): void;
  65027. private _pointerIsDown;
  65028. /** @hidden */
  65029. protected _updateValueFromPointer(x: number, y: number): void;
  65030. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65031. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  65032. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65033. }
  65034. }
  65035. declare module BABYLON.GUI {
  65036. /**
  65037. * Class used to create slider controls
  65038. */
  65039. export class Slider extends BaseSlider {
  65040. name?: string | undefined;
  65041. private _background;
  65042. private _borderColor;
  65043. private _isThumbCircle;
  65044. protected _displayValueBar: boolean;
  65045. /** Gets or sets a boolean indicating if the value bar must be rendered */
  65046. displayValueBar: boolean;
  65047. /** Gets or sets border color */
  65048. borderColor: string;
  65049. /** Gets or sets background color */
  65050. background: string;
  65051. /** Gets or sets a boolean indicating if the thumb should be round or square */
  65052. isThumbCircle: boolean;
  65053. /**
  65054. * Creates a new Slider
  65055. * @param name defines the control name
  65056. */
  65057. constructor(name?: string | undefined);
  65058. protected _getTypeName(): string;
  65059. _draw(context: CanvasRenderingContext2D): void;
  65060. }
  65061. }
  65062. declare module BABYLON.GUI {
  65063. /** Class used to create a RadioGroup
  65064. * which contains groups of radio buttons
  65065. */
  65066. export class SelectorGroup {
  65067. /** name of SelectorGroup */
  65068. name: string;
  65069. private _groupPanel;
  65070. private _selectors;
  65071. private _groupHeader;
  65072. /**
  65073. * Creates a new SelectorGroup
  65074. * @param name of group, used as a group heading
  65075. */
  65076. constructor(
  65077. /** name of SelectorGroup */
  65078. name: string);
  65079. /** Gets the groupPanel of the SelectorGroup */
  65080. readonly groupPanel: StackPanel;
  65081. /** Gets the selectors array */
  65082. readonly selectors: StackPanel[];
  65083. /** Gets and sets the group header */
  65084. header: string;
  65085. /** @hidden */
  65086. private _addGroupHeader;
  65087. /** @hidden*/
  65088. _getSelector(selectorNb: number): StackPanel | undefined;
  65089. /** Removes the selector at the given position
  65090. * @param selectorNb the position of the selector within the group
  65091. */
  65092. removeSelector(selectorNb: number): void;
  65093. }
  65094. /** Class used to create a CheckboxGroup
  65095. * which contains groups of checkbox buttons
  65096. */
  65097. export class CheckboxGroup extends SelectorGroup {
  65098. /** Adds a checkbox as a control
  65099. * @param text is the label for the selector
  65100. * @param func is the function called when the Selector is checked
  65101. * @param checked is true when Selector is checked
  65102. */
  65103. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  65104. /** @hidden */
  65105. _setSelectorLabel(selectorNb: number, label: string): void;
  65106. /** @hidden */
  65107. _setSelectorLabelColor(selectorNb: number, color: string): void;
  65108. /** @hidden */
  65109. _setSelectorButtonColor(selectorNb: number, color: string): void;
  65110. /** @hidden */
  65111. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  65112. }
  65113. /** Class used to create a RadioGroup
  65114. * which contains groups of radio buttons
  65115. */
  65116. export class RadioGroup extends SelectorGroup {
  65117. private _selectNb;
  65118. /** Adds a radio button as a control
  65119. * @param label is the label for the selector
  65120. * @param func is the function called when the Selector is checked
  65121. * @param checked is true when Selector is checked
  65122. */
  65123. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  65124. /** @hidden */
  65125. _setSelectorLabel(selectorNb: number, label: string): void;
  65126. /** @hidden */
  65127. _setSelectorLabelColor(selectorNb: number, color: string): void;
  65128. /** @hidden */
  65129. _setSelectorButtonColor(selectorNb: number, color: string): void;
  65130. /** @hidden */
  65131. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  65132. }
  65133. /** Class used to create a SliderGroup
  65134. * which contains groups of slider buttons
  65135. */
  65136. export class SliderGroup extends SelectorGroup {
  65137. /**
  65138. * Adds a slider to the SelectorGroup
  65139. * @param label is the label for the SliderBar
  65140. * @param func is the function called when the Slider moves
  65141. * @param unit is a string describing the units used, eg degrees or metres
  65142. * @param min is the minimum value for the Slider
  65143. * @param max is the maximum value for the Slider
  65144. * @param value is the start value for the Slider between min and max
  65145. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  65146. */
  65147. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  65148. /** @hidden */
  65149. _setSelectorLabel(selectorNb: number, label: string): void;
  65150. /** @hidden */
  65151. _setSelectorLabelColor(selectorNb: number, color: string): void;
  65152. /** @hidden */
  65153. _setSelectorButtonColor(selectorNb: number, color: string): void;
  65154. /** @hidden */
  65155. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  65156. }
  65157. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  65158. * @see http://doc.babylonjs.com/how_to/selector
  65159. */
  65160. export class SelectionPanel extends Rectangle {
  65161. /** name of SelectionPanel */
  65162. name: string;
  65163. /** an array of SelectionGroups */
  65164. groups: SelectorGroup[];
  65165. private _panel;
  65166. private _buttonColor;
  65167. private _buttonBackground;
  65168. private _headerColor;
  65169. private _barColor;
  65170. private _barHeight;
  65171. private _spacerHeight;
  65172. private _labelColor;
  65173. private _groups;
  65174. private _bars;
  65175. /**
  65176. * Creates a new SelectionPanel
  65177. * @param name of SelectionPanel
  65178. * @param groups is an array of SelectionGroups
  65179. */
  65180. constructor(
  65181. /** name of SelectionPanel */
  65182. name: string,
  65183. /** an array of SelectionGroups */
  65184. groups?: SelectorGroup[]);
  65185. protected _getTypeName(): string;
  65186. /** Gets or sets the headerColor */
  65187. headerColor: string;
  65188. private _setHeaderColor;
  65189. /** Gets or sets the button color */
  65190. buttonColor: string;
  65191. private _setbuttonColor;
  65192. /** Gets or sets the label color */
  65193. labelColor: string;
  65194. private _setLabelColor;
  65195. /** Gets or sets the button background */
  65196. buttonBackground: string;
  65197. private _setButtonBackground;
  65198. /** Gets or sets the color of separator bar */
  65199. barColor: string;
  65200. private _setBarColor;
  65201. /** Gets or sets the height of separator bar */
  65202. barHeight: string;
  65203. private _setBarHeight;
  65204. /** Gets or sets the height of spacers*/
  65205. spacerHeight: string;
  65206. private _setSpacerHeight;
  65207. /** Adds a bar between groups */
  65208. private _addSpacer;
  65209. /** Add a group to the selection panel
  65210. * @param group is the selector group to add
  65211. */
  65212. addGroup(group: SelectorGroup): void;
  65213. /** Remove the group from the given position
  65214. * @param groupNb is the position of the group in the list
  65215. */
  65216. removeGroup(groupNb: number): void;
  65217. /** Change a group header label
  65218. * @param label is the new group header label
  65219. * @param groupNb is the number of the group to relabel
  65220. * */
  65221. setHeaderName(label: string, groupNb: number): void;
  65222. /** Change selector label to the one given
  65223. * @param label is the new selector label
  65224. * @param groupNb is the number of the groupcontaining the selector
  65225. * @param selectorNb is the number of the selector within a group to relabel
  65226. * */
  65227. relabel(label: string, groupNb: number, selectorNb: number): void;
  65228. /** For a given group position remove the selector at the given position
  65229. * @param groupNb is the number of the group to remove the selector from
  65230. * @param selectorNb is the number of the selector within the group
  65231. */
  65232. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  65233. /** For a given group position of correct type add a checkbox button
  65234. * @param groupNb is the number of the group to remove the selector from
  65235. * @param label is the label for the selector
  65236. * @param func is the function called when the Selector is checked
  65237. * @param checked is true when Selector is checked
  65238. */
  65239. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  65240. /** For a given group position of correct type add a radio button
  65241. * @param groupNb is the number of the group to remove the selector from
  65242. * @param label is the label for the selector
  65243. * @param func is the function called when the Selector is checked
  65244. * @param checked is true when Selector is checked
  65245. */
  65246. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  65247. /**
  65248. * For a given slider group add a slider
  65249. * @param groupNb is the number of the group to add the slider to
  65250. * @param label is the label for the Slider
  65251. * @param func is the function called when the Slider moves
  65252. * @param unit is a string describing the units used, eg degrees or metres
  65253. * @param min is the minimum value for the Slider
  65254. * @param max is the maximum value for the Slider
  65255. * @param value is the start value for the Slider between min and max
  65256. * @param onVal is the function used to format the value displayed, eg radians to degrees
  65257. */
  65258. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  65259. }
  65260. }
  65261. declare module BABYLON.GUI {
  65262. /**
  65263. * Class used to hold a the container for ScrollViewer
  65264. * @hidden
  65265. */
  65266. export class _ScrollViewerWindow extends Container {
  65267. parentClientWidth: number;
  65268. parentClientHeight: number;
  65269. /**
  65270. * Creates a new ScrollViewerWindow
  65271. * @param name of ScrollViewerWindow
  65272. */
  65273. constructor(name?: string);
  65274. protected _getTypeName(): string;
  65275. /** @hidden */
  65276. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65277. protected _postMeasure(): void;
  65278. }
  65279. }
  65280. declare module BABYLON.GUI {
  65281. /**
  65282. * Class used to create slider controls
  65283. */
  65284. export class ScrollBar extends BaseSlider {
  65285. name?: string | undefined;
  65286. private _background;
  65287. private _borderColor;
  65288. private _thumbMeasure;
  65289. /** Gets or sets border color */
  65290. borderColor: string;
  65291. /** Gets or sets background color */
  65292. background: string;
  65293. /**
  65294. * Creates a new Slider
  65295. * @param name defines the control name
  65296. */
  65297. constructor(name?: string | undefined);
  65298. protected _getTypeName(): string;
  65299. protected _getThumbThickness(): number;
  65300. _draw(context: CanvasRenderingContext2D): void;
  65301. private _first;
  65302. private _originX;
  65303. private _originY;
  65304. /** @hidden */
  65305. protected _updateValueFromPointer(x: number, y: number): void;
  65306. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65307. }
  65308. }
  65309. declare module BABYLON.GUI {
  65310. /**
  65311. * Class used to hold a viewer window and sliders in a grid
  65312. */
  65313. export class ScrollViewer extends Rectangle {
  65314. private _grid;
  65315. private _horizontalBarSpace;
  65316. private _verticalBarSpace;
  65317. private _dragSpace;
  65318. private _horizontalBar;
  65319. private _verticalBar;
  65320. private _barColor;
  65321. private _barBackground;
  65322. private _barSize;
  65323. private _endLeft;
  65324. private _endTop;
  65325. private _window;
  65326. private _pointerIsOver;
  65327. private _wheelPrecision;
  65328. private _onPointerObserver;
  65329. private _clientWidth;
  65330. private _clientHeight;
  65331. /**
  65332. * Gets the horizontal scrollbar
  65333. */
  65334. readonly horizontalBar: ScrollBar;
  65335. /**
  65336. * Gets the vertical scrollbar
  65337. */
  65338. readonly verticalBar: ScrollBar;
  65339. /**
  65340. * Adds a new control to the current container
  65341. * @param control defines the control to add
  65342. * @returns the current container
  65343. */
  65344. addControl(control: BABYLON.Nullable<Control>): Container;
  65345. /**
  65346. * Removes a control from the current container
  65347. * @param control defines the control to remove
  65348. * @returns the current container
  65349. */
  65350. removeControl(control: Control): Container;
  65351. /** Gets the list of children */
  65352. readonly children: Control[];
  65353. _flagDescendantsAsMatrixDirty(): void;
  65354. /**
  65355. * Creates a new ScrollViewer
  65356. * @param name of ScrollViewer
  65357. */
  65358. constructor(name?: string);
  65359. /** Reset the scroll viewer window to initial size */
  65360. resetWindow(): void;
  65361. protected _getTypeName(): string;
  65362. private _buildClientSizes;
  65363. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65364. protected _postMeasure(): void;
  65365. /**
  65366. * Gets or sets the mouse wheel precision
  65367. * from 0 to 1 with a default value of 0.05
  65368. * */
  65369. wheelPrecision: number;
  65370. /** Gets or sets the bar color */
  65371. barColor: string;
  65372. /** Gets or sets the size of the bar */
  65373. barSize: number;
  65374. /** Gets or sets the bar background */
  65375. barBackground: string;
  65376. /** @hidden */
  65377. private _updateScroller;
  65378. _link(host: AdvancedDynamicTexture): void;
  65379. /** @hidden */
  65380. private _attachWheel;
  65381. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  65382. /** Releases associated resources */
  65383. dispose(): void;
  65384. }
  65385. }
  65386. declare module BABYLON.GUI {
  65387. /** Class used to render a grid */
  65388. export class DisplayGrid extends Control {
  65389. name?: string | undefined;
  65390. private _cellWidth;
  65391. private _cellHeight;
  65392. private _minorLineTickness;
  65393. private _minorLineColor;
  65394. private _majorLineTickness;
  65395. private _majorLineColor;
  65396. private _majorLineFrequency;
  65397. private _background;
  65398. private _displayMajorLines;
  65399. private _displayMinorLines;
  65400. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  65401. displayMinorLines: boolean;
  65402. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  65403. displayMajorLines: boolean;
  65404. /** Gets or sets background color (Black by default) */
  65405. background: string;
  65406. /** Gets or sets the width of each cell (20 by default) */
  65407. cellWidth: number;
  65408. /** Gets or sets the height of each cell (20 by default) */
  65409. cellHeight: number;
  65410. /** Gets or sets the tickness of minor lines (1 by default) */
  65411. minorLineTickness: number;
  65412. /** Gets or sets the color of minor lines (DarkGray by default) */
  65413. minorLineColor: string;
  65414. /** Gets or sets the tickness of major lines (2 by default) */
  65415. majorLineTickness: number;
  65416. /** Gets or sets the color of major lines (White by default) */
  65417. majorLineColor: string;
  65418. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  65419. majorLineFrequency: number;
  65420. /**
  65421. * Creates a new GridDisplayRectangle
  65422. * @param name defines the control name
  65423. */
  65424. constructor(name?: string | undefined);
  65425. _draw(context: CanvasRenderingContext2D): void;
  65426. protected _getTypeName(): string;
  65427. }
  65428. }
  65429. declare module BABYLON.GUI {
  65430. /**
  65431. * Class used to create slider controls based on images
  65432. */
  65433. export class ImageBasedSlider extends BaseSlider {
  65434. name?: string | undefined;
  65435. private _backgroundImage;
  65436. private _thumbImage;
  65437. private _valueBarImage;
  65438. private _tempMeasure;
  65439. displayThumb: boolean;
  65440. /**
  65441. * Gets or sets the image used to render the background
  65442. */
  65443. backgroundImage: Image;
  65444. /**
  65445. * Gets or sets the image used to render the value bar
  65446. */
  65447. valueBarImage: Image;
  65448. /**
  65449. * Gets or sets the image used to render the thumb
  65450. */
  65451. thumbImage: Image;
  65452. /**
  65453. * Creates a new ImageBasedSlider
  65454. * @param name defines the control name
  65455. */
  65456. constructor(name?: string | undefined);
  65457. protected _getTypeName(): string;
  65458. _draw(context: CanvasRenderingContext2D): void;
  65459. }
  65460. }
  65461. declare module BABYLON.GUI {
  65462. /**
  65463. * Forcing an export so that this code will execute
  65464. * @hidden
  65465. */
  65466. const name = "Statics";
  65467. }
  65468. declare module BABYLON.GUI {
  65469. /**
  65470. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  65471. */
  65472. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  65473. /**
  65474. * Define the instrumented AdvancedDynamicTexture.
  65475. */
  65476. texture: AdvancedDynamicTexture;
  65477. private _captureRenderTime;
  65478. private _renderTime;
  65479. private _captureLayoutTime;
  65480. private _layoutTime;
  65481. private _onBeginRenderObserver;
  65482. private _onEndRenderObserver;
  65483. private _onBeginLayoutObserver;
  65484. private _onEndLayoutObserver;
  65485. /**
  65486. * Gets the perf counter used to capture render time
  65487. */
  65488. readonly renderTimeCounter: BABYLON.PerfCounter;
  65489. /**
  65490. * Gets the perf counter used to capture layout time
  65491. */
  65492. readonly layoutTimeCounter: BABYLON.PerfCounter;
  65493. /**
  65494. * Enable or disable the render time capture
  65495. */
  65496. captureRenderTime: boolean;
  65497. /**
  65498. * Enable or disable the layout time capture
  65499. */
  65500. captureLayoutTime: boolean;
  65501. /**
  65502. * Instantiates a new advanced dynamic texture instrumentation.
  65503. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  65504. * @param texture Defines the AdvancedDynamicTexture to instrument
  65505. */
  65506. constructor(
  65507. /**
  65508. * Define the instrumented AdvancedDynamicTexture.
  65509. */
  65510. texture: AdvancedDynamicTexture);
  65511. /**
  65512. * Dispose and release associated resources.
  65513. */
  65514. dispose(): void;
  65515. }
  65516. }
  65517. declare module BABYLON.GUI {
  65518. /**
  65519. * Class used to create containers for controls
  65520. */
  65521. export class Container3D extends Control3D {
  65522. private _blockLayout;
  65523. /**
  65524. * Gets the list of child controls
  65525. */
  65526. protected _children: Control3D[];
  65527. /**
  65528. * Gets the list of child controls
  65529. */
  65530. readonly children: Array<Control3D>;
  65531. /**
  65532. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  65533. * This is helpful to optimize layout operation when adding multiple children in a row
  65534. */
  65535. blockLayout: boolean;
  65536. /**
  65537. * Creates a new container
  65538. * @param name defines the container name
  65539. */
  65540. constructor(name?: string);
  65541. /**
  65542. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  65543. * @returns the current container
  65544. */
  65545. updateLayout(): Container3D;
  65546. /**
  65547. * Gets a boolean indicating if the given control is in the children of this control
  65548. * @param control defines the control to check
  65549. * @returns true if the control is in the child list
  65550. */
  65551. containsControl(control: Control3D): boolean;
  65552. /**
  65553. * Adds a control to the children of this control
  65554. * @param control defines the control to add
  65555. * @returns the current container
  65556. */
  65557. addControl(control: Control3D): Container3D;
  65558. /**
  65559. * This function will be called everytime a new control is added
  65560. */
  65561. protected _arrangeChildren(): void;
  65562. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  65563. /**
  65564. * Removes a control from the children of this control
  65565. * @param control defines the control to remove
  65566. * @returns the current container
  65567. */
  65568. removeControl(control: Control3D): Container3D;
  65569. protected _getTypeName(): string;
  65570. /**
  65571. * Releases all associated resources
  65572. */
  65573. dispose(): void;
  65574. /** Control rotation will remain unchanged */
  65575. static readonly UNSET_ORIENTATION: number;
  65576. /** Control will rotate to make it look at sphere central axis */
  65577. static readonly FACEORIGIN_ORIENTATION: number;
  65578. /** Control will rotate to make it look back at sphere central axis */
  65579. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  65580. /** Control will rotate to look at z axis (0, 0, 1) */
  65581. static readonly FACEFORWARD_ORIENTATION: number;
  65582. /** Control will rotate to look at negative z axis (0, 0, -1) */
  65583. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  65584. }
  65585. }
  65586. declare module BABYLON.GUI {
  65587. /**
  65588. * Class used to manage 3D user interface
  65589. * @see http://doc.babylonjs.com/how_to/gui3d
  65590. */
  65591. export class GUI3DManager implements BABYLON.IDisposable {
  65592. private _scene;
  65593. private _sceneDisposeObserver;
  65594. private _utilityLayer;
  65595. private _rootContainer;
  65596. private _pointerObserver;
  65597. private _pointerOutObserver;
  65598. /** @hidden */
  65599. _lastPickedControl: Control3D;
  65600. /** @hidden */
  65601. _lastControlOver: {
  65602. [pointerId: number]: Control3D;
  65603. };
  65604. /** @hidden */
  65605. _lastControlDown: {
  65606. [pointerId: number]: Control3D;
  65607. };
  65608. /**
  65609. * BABYLON.Observable raised when the point picked by the pointer events changed
  65610. */
  65611. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  65612. /** @hidden */
  65613. _sharedMaterials: {
  65614. [key: string]: BABYLON.Material;
  65615. };
  65616. /** Gets the hosting scene */
  65617. readonly scene: BABYLON.Scene;
  65618. /** Gets associated utility layer */
  65619. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  65620. /**
  65621. * Creates a new GUI3DManager
  65622. * @param scene
  65623. */
  65624. constructor(scene?: BABYLON.Scene);
  65625. private _handlePointerOut;
  65626. private _doPicking;
  65627. /**
  65628. * Gets the root container
  65629. */
  65630. readonly rootContainer: Container3D;
  65631. /**
  65632. * Gets a boolean indicating if the given control is in the root child list
  65633. * @param control defines the control to check
  65634. * @returns true if the control is in the root child list
  65635. */
  65636. containsControl(control: Control3D): boolean;
  65637. /**
  65638. * Adds a control to the root child list
  65639. * @param control defines the control to add
  65640. * @returns the current manager
  65641. */
  65642. addControl(control: Control3D): GUI3DManager;
  65643. /**
  65644. * Removes a control from the root child list
  65645. * @param control defines the control to remove
  65646. * @returns the current container
  65647. */
  65648. removeControl(control: Control3D): GUI3DManager;
  65649. /**
  65650. * Releases all associated resources
  65651. */
  65652. dispose(): void;
  65653. }
  65654. }
  65655. declare module BABYLON.GUI {
  65656. /**
  65657. * Class used to transport BABYLON.Vector3 information for pointer events
  65658. */
  65659. export class Vector3WithInfo extends BABYLON.Vector3 {
  65660. /** defines the current mouse button index */
  65661. buttonIndex: number;
  65662. /**
  65663. * Creates a new Vector3WithInfo
  65664. * @param source defines the vector3 data to transport
  65665. * @param buttonIndex defines the current mouse button index
  65666. */
  65667. constructor(source: BABYLON.Vector3,
  65668. /** defines the current mouse button index */
  65669. buttonIndex?: number);
  65670. }
  65671. }
  65672. declare module BABYLON.GUI {
  65673. /**
  65674. * Class used as base class for controls
  65675. */
  65676. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  65677. /** Defines the control name */
  65678. name?: string | undefined;
  65679. /** @hidden */
  65680. _host: GUI3DManager;
  65681. private _node;
  65682. private _downCount;
  65683. private _enterCount;
  65684. private _downPointerIds;
  65685. private _isVisible;
  65686. /** Gets or sets the control position in world space */
  65687. position: BABYLON.Vector3;
  65688. /** Gets or sets the control scaling in world space */
  65689. scaling: BABYLON.Vector3;
  65690. /** Callback used to start pointer enter animation */
  65691. pointerEnterAnimation: () => void;
  65692. /** Callback used to start pointer out animation */
  65693. pointerOutAnimation: () => void;
  65694. /** Callback used to start pointer down animation */
  65695. pointerDownAnimation: () => void;
  65696. /** Callback used to start pointer up animation */
  65697. pointerUpAnimation: () => void;
  65698. /**
  65699. * An event triggered when the pointer move over the control
  65700. */
  65701. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  65702. /**
  65703. * An event triggered when the pointer move out of the control
  65704. */
  65705. onPointerOutObservable: BABYLON.Observable<Control3D>;
  65706. /**
  65707. * An event triggered when the pointer taps the control
  65708. */
  65709. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  65710. /**
  65711. * An event triggered when pointer is up
  65712. */
  65713. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  65714. /**
  65715. * An event triggered when a control is clicked on (with a mouse)
  65716. */
  65717. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  65718. /**
  65719. * An event triggered when pointer enters the control
  65720. */
  65721. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  65722. /**
  65723. * Gets or sets the parent container
  65724. */
  65725. parent: BABYLON.Nullable<Container3D>;
  65726. private _behaviors;
  65727. /**
  65728. * Gets the list of attached behaviors
  65729. * @see http://doc.babylonjs.com/features/behaviour
  65730. */
  65731. readonly behaviors: BABYLON.Behavior<Control3D>[];
  65732. /**
  65733. * Attach a behavior to the control
  65734. * @see http://doc.babylonjs.com/features/behaviour
  65735. * @param behavior defines the behavior to attach
  65736. * @returns the current control
  65737. */
  65738. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  65739. /**
  65740. * Remove an attached behavior
  65741. * @see http://doc.babylonjs.com/features/behaviour
  65742. * @param behavior defines the behavior to attach
  65743. * @returns the current control
  65744. */
  65745. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  65746. /**
  65747. * Gets an attached behavior by name
  65748. * @param name defines the name of the behavior to look for
  65749. * @see http://doc.babylonjs.com/features/behaviour
  65750. * @returns null if behavior was not found else the requested behavior
  65751. */
  65752. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  65753. /** Gets or sets a boolean indicating if the control is visible */
  65754. isVisible: boolean;
  65755. /**
  65756. * Creates a new control
  65757. * @param name defines the control name
  65758. */
  65759. constructor(
  65760. /** Defines the control name */
  65761. name?: string | undefined);
  65762. /**
  65763. * Gets a string representing the class name
  65764. */
  65765. readonly typeName: string;
  65766. /**
  65767. * Get the current class name of the control.
  65768. * @returns current class name
  65769. */
  65770. getClassName(): string;
  65771. protected _getTypeName(): string;
  65772. /**
  65773. * Gets the transform node used by this control
  65774. */
  65775. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  65776. /**
  65777. * Gets the mesh used to render this control
  65778. */
  65779. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  65780. /**
  65781. * Link the control as child of the given node
  65782. * @param node defines the node to link to. Use null to unlink the control
  65783. * @returns the current control
  65784. */
  65785. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  65786. /** @hidden **/
  65787. _prepareNode(scene: BABYLON.Scene): void;
  65788. /**
  65789. * Node creation.
  65790. * Can be overriden by children
  65791. * @param scene defines the scene where the node must be attached
  65792. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  65793. */
  65794. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  65795. /**
  65796. * Affect a material to the given mesh
  65797. * @param mesh defines the mesh which will represent the control
  65798. */
  65799. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  65800. /** @hidden */
  65801. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  65802. /** @hidden */
  65803. _onPointerEnter(target: Control3D): boolean;
  65804. /** @hidden */
  65805. _onPointerOut(target: Control3D): void;
  65806. /** @hidden */
  65807. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  65808. /** @hidden */
  65809. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65810. /** @hidden */
  65811. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  65812. /** @hidden */
  65813. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  65814. /** @hidden */
  65815. _disposeNode(): void;
  65816. /**
  65817. * Releases all associated resources
  65818. */
  65819. dispose(): void;
  65820. }
  65821. }
  65822. declare module BABYLON.GUI {
  65823. /**
  65824. * Class used as a root to all buttons
  65825. */
  65826. export class AbstractButton3D extends Control3D {
  65827. /**
  65828. * Creates a new button
  65829. * @param name defines the control name
  65830. */
  65831. constructor(name?: string);
  65832. protected _getTypeName(): string;
  65833. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  65834. }
  65835. }
  65836. declare module BABYLON.GUI {
  65837. /**
  65838. * Class used to create a button in 3D
  65839. */
  65840. export class Button3D extends AbstractButton3D {
  65841. /** @hidden */
  65842. protected _currentMaterial: BABYLON.Material;
  65843. private _facadeTexture;
  65844. private _content;
  65845. private _contentResolution;
  65846. private _contentScaleRatio;
  65847. /**
  65848. * Gets or sets the texture resolution used to render content (512 by default)
  65849. */
  65850. contentResolution: BABYLON.int;
  65851. /**
  65852. * Gets or sets the texture scale ratio used to render content (2 by default)
  65853. */
  65854. contentScaleRatio: number;
  65855. protected _disposeFacadeTexture(): void;
  65856. protected _resetContent(): void;
  65857. /**
  65858. * Creates a new button
  65859. * @param name defines the control name
  65860. */
  65861. constructor(name?: string);
  65862. /**
  65863. * Gets or sets the GUI 2D content used to display the button's facade
  65864. */
  65865. content: Control;
  65866. /**
  65867. * Apply the facade texture (created from the content property).
  65868. * This function can be overloaded by child classes
  65869. * @param facadeTexture defines the AdvancedDynamicTexture to use
  65870. */
  65871. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  65872. protected _getTypeName(): string;
  65873. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  65874. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  65875. /**
  65876. * Releases all associated resources
  65877. */
  65878. dispose(): void;
  65879. }
  65880. }
  65881. declare module BABYLON.GUI {
  65882. /**
  65883. * Abstract class used to create a container panel deployed on the surface of a volume
  65884. */
  65885. export abstract class VolumeBasedPanel extends Container3D {
  65886. private _columns;
  65887. private _rows;
  65888. private _rowThenColum;
  65889. private _orientation;
  65890. protected _cellWidth: number;
  65891. protected _cellHeight: number;
  65892. /**
  65893. * Gets or sets the distance between elements
  65894. */
  65895. margin: number;
  65896. /**
  65897. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  65898. * | Value | Type | Description |
  65899. * | ----- | ----------------------------------- | ----------- |
  65900. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  65901. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  65902. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  65903. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  65904. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  65905. */
  65906. orientation: number;
  65907. /**
  65908. * Gets or sets the number of columns requested (10 by default).
  65909. * The panel will automatically compute the number of rows based on number of child controls.
  65910. */
  65911. columns: BABYLON.int;
  65912. /**
  65913. * Gets or sets a the number of rows requested.
  65914. * The panel will automatically compute the number of columns based on number of child controls.
  65915. */
  65916. rows: BABYLON.int;
  65917. /**
  65918. * Creates new VolumeBasedPanel
  65919. */
  65920. constructor();
  65921. protected _arrangeChildren(): void;
  65922. /** Child classes must implement this function to provide correct control positioning */
  65923. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65924. /** Child classes can implement this function to provide additional processing */
  65925. protected _finalProcessing(): void;
  65926. }
  65927. }
  65928. declare module BABYLON.GUI {
  65929. /**
  65930. * Class used to create a container panel deployed on the surface of a cylinder
  65931. */
  65932. export class CylinderPanel extends VolumeBasedPanel {
  65933. private _radius;
  65934. /**
  65935. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  65936. */
  65937. radius: BABYLON.float;
  65938. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65939. private _cylindricalMapping;
  65940. }
  65941. }
  65942. declare module BABYLON.GUI {
  65943. /** @hidden */
  65944. export var fluentVertexShader: {
  65945. name: string;
  65946. shader: string;
  65947. };
  65948. }
  65949. declare module BABYLON.GUI {
  65950. /** @hidden */
  65951. export var fluentPixelShader: {
  65952. name: string;
  65953. shader: string;
  65954. };
  65955. }
  65956. declare module BABYLON.GUI {
  65957. /** @hidden */
  65958. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  65959. INNERGLOW: boolean;
  65960. BORDER: boolean;
  65961. HOVERLIGHT: boolean;
  65962. TEXTURE: boolean;
  65963. constructor();
  65964. }
  65965. /**
  65966. * Class used to render controls with fluent desgin
  65967. */
  65968. export class FluentMaterial extends BABYLON.PushMaterial {
  65969. /**
  65970. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  65971. */
  65972. innerGlowColorIntensity: number;
  65973. /**
  65974. * Gets or sets the inner glow color (white by default)
  65975. */
  65976. innerGlowColor: BABYLON.Color3;
  65977. /**
  65978. * Gets or sets alpha value (default is 1.0)
  65979. */
  65980. alpha: number;
  65981. /**
  65982. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  65983. */
  65984. albedoColor: BABYLON.Color3;
  65985. /**
  65986. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  65987. */
  65988. renderBorders: boolean;
  65989. /**
  65990. * Gets or sets border width (default is 0.5)
  65991. */
  65992. borderWidth: number;
  65993. /**
  65994. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  65995. */
  65996. edgeSmoothingValue: number;
  65997. /**
  65998. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  65999. */
  66000. borderMinValue: number;
  66001. /**
  66002. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  66003. */
  66004. renderHoverLight: boolean;
  66005. /**
  66006. * Gets or sets the radius used to render the hover light (default is 1.0)
  66007. */
  66008. hoverRadius: number;
  66009. /**
  66010. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  66011. */
  66012. hoverColor: BABYLON.Color4;
  66013. /**
  66014. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  66015. */
  66016. hoverPosition: BABYLON.Vector3;
  66017. private _albedoTexture;
  66018. /** Gets or sets the texture to use for albedo color */
  66019. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  66020. /**
  66021. * Creates a new Fluent material
  66022. * @param name defines the name of the material
  66023. * @param scene defines the hosting scene
  66024. */
  66025. constructor(name: string, scene: BABYLON.Scene);
  66026. needAlphaBlending(): boolean;
  66027. needAlphaTesting(): boolean;
  66028. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66029. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66030. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66031. getActiveTextures(): BABYLON.BaseTexture[];
  66032. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66033. dispose(forceDisposeEffect?: boolean): void;
  66034. clone(name: string): FluentMaterial;
  66035. serialize(): any;
  66036. getClassName(): string;
  66037. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  66038. }
  66039. }
  66040. declare module BABYLON.GUI {
  66041. /**
  66042. * Class used to create a holographic button in 3D
  66043. */
  66044. export class HolographicButton extends Button3D {
  66045. private _backPlate;
  66046. private _textPlate;
  66047. private _frontPlate;
  66048. private _text;
  66049. private _imageUrl;
  66050. private _shareMaterials;
  66051. private _frontMaterial;
  66052. private _backMaterial;
  66053. private _plateMaterial;
  66054. private _pickedPointObserver;
  66055. private _tooltipFade;
  66056. private _tooltipTextBlock;
  66057. private _tooltipTexture;
  66058. private _tooltipMesh;
  66059. private _tooltipHoverObserver;
  66060. private _tooltipOutObserver;
  66061. private _disposeTooltip;
  66062. /**
  66063. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  66064. */
  66065. tooltipText: BABYLON.Nullable<string>;
  66066. /**
  66067. * Gets or sets text for the button
  66068. */
  66069. text: string;
  66070. /**
  66071. * Gets or sets the image url for the button
  66072. */
  66073. imageUrl: string;
  66074. /**
  66075. * Gets the back material used by this button
  66076. */
  66077. readonly backMaterial: FluentMaterial;
  66078. /**
  66079. * Gets the front material used by this button
  66080. */
  66081. readonly frontMaterial: FluentMaterial;
  66082. /**
  66083. * Gets the plate material used by this button
  66084. */
  66085. readonly plateMaterial: BABYLON.StandardMaterial;
  66086. /**
  66087. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  66088. */
  66089. readonly shareMaterials: boolean;
  66090. /**
  66091. * Creates a new button
  66092. * @param name defines the control name
  66093. */
  66094. constructor(name?: string, shareMaterials?: boolean);
  66095. protected _getTypeName(): string;
  66096. private _rebuildContent;
  66097. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66098. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  66099. private _createBackMaterial;
  66100. private _createFrontMaterial;
  66101. private _createPlateMaterial;
  66102. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  66103. /**
  66104. * Releases all associated resources
  66105. */
  66106. dispose(): void;
  66107. }
  66108. }
  66109. declare module BABYLON.GUI {
  66110. /**
  66111. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  66112. */
  66113. export class MeshButton3D extends Button3D {
  66114. /** @hidden */
  66115. protected _currentMesh: BABYLON.Mesh;
  66116. /**
  66117. * Creates a new 3D button based on a mesh
  66118. * @param mesh mesh to become a 3D button
  66119. * @param name defines the control name
  66120. */
  66121. constructor(mesh: BABYLON.Mesh, name?: string);
  66122. protected _getTypeName(): string;
  66123. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66124. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  66125. }
  66126. }
  66127. declare module BABYLON.GUI {
  66128. /**
  66129. * Class used to create a container panel deployed on the surface of a plane
  66130. */
  66131. export class PlanePanel extends VolumeBasedPanel {
  66132. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66133. }
  66134. }
  66135. declare module BABYLON.GUI {
  66136. /**
  66137. * Class used to create a container panel where items get randomized planar mapping
  66138. */
  66139. export class ScatterPanel extends VolumeBasedPanel {
  66140. private _iteration;
  66141. /**
  66142. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  66143. */
  66144. iteration: BABYLON.float;
  66145. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66146. private _scatterMapping;
  66147. protected _finalProcessing(): void;
  66148. }
  66149. }
  66150. declare module BABYLON.GUI {
  66151. /**
  66152. * Class used to create a container panel deployed on the surface of a sphere
  66153. */
  66154. export class SpherePanel extends VolumeBasedPanel {
  66155. private _radius;
  66156. /**
  66157. * Gets or sets the radius of the sphere where to project controls (5 by default)
  66158. */
  66159. radius: BABYLON.float;
  66160. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66161. private _sphericalMapping;
  66162. }
  66163. }
  66164. declare module BABYLON.GUI {
  66165. /**
  66166. * Class used to create a stack panel in 3D on XY plane
  66167. */
  66168. export class StackPanel3D extends Container3D {
  66169. private _isVertical;
  66170. /**
  66171. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  66172. */
  66173. isVertical: boolean;
  66174. /**
  66175. * Gets or sets the distance between elements
  66176. */
  66177. margin: number;
  66178. /**
  66179. * Creates new StackPanel
  66180. * @param isVertical
  66181. */
  66182. constructor(isVertical?: boolean);
  66183. protected _arrangeChildren(): void;
  66184. }
  66185. }
  66186. declare module BABYLON {
  66187. /**
  66188. * Mode that determines the coordinate system to use.
  66189. */
  66190. export enum GLTFLoaderCoordinateSystemMode {
  66191. /**
  66192. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  66193. */
  66194. AUTO = 0,
  66195. /**
  66196. * Sets the useRightHandedSystem flag on the scene.
  66197. */
  66198. FORCE_RIGHT_HANDED = 1
  66199. }
  66200. /**
  66201. * Mode that determines what animations will start.
  66202. */
  66203. export enum GLTFLoaderAnimationStartMode {
  66204. /**
  66205. * No animation will start.
  66206. */
  66207. NONE = 0,
  66208. /**
  66209. * The first animation will start.
  66210. */
  66211. FIRST = 1,
  66212. /**
  66213. * All animations will start.
  66214. */
  66215. ALL = 2
  66216. }
  66217. /**
  66218. * Interface that contains the data for the glTF asset.
  66219. */
  66220. export interface IGLTFLoaderData {
  66221. /**
  66222. * Object that represents the glTF JSON.
  66223. */
  66224. json: Object;
  66225. /**
  66226. * The BIN chunk of a binary glTF.
  66227. */
  66228. bin: Nullable<ArrayBufferView>;
  66229. }
  66230. /**
  66231. * Interface for extending the loader.
  66232. */
  66233. export interface IGLTFLoaderExtension {
  66234. /**
  66235. * The name of this extension.
  66236. */
  66237. readonly name: string;
  66238. /**
  66239. * Defines whether this extension is enabled.
  66240. */
  66241. enabled: boolean;
  66242. }
  66243. /**
  66244. * Loader state.
  66245. */
  66246. export enum GLTFLoaderState {
  66247. /**
  66248. * The asset is loading.
  66249. */
  66250. LOADING = 0,
  66251. /**
  66252. * The asset is ready for rendering.
  66253. */
  66254. READY = 1,
  66255. /**
  66256. * The asset is completely loaded.
  66257. */
  66258. COMPLETE = 2
  66259. }
  66260. /** @hidden */
  66261. export interface IGLTFLoader extends IDisposable {
  66262. readonly state: Nullable<GLTFLoaderState>;
  66263. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  66264. meshes: AbstractMesh[];
  66265. particleSystems: IParticleSystem[];
  66266. skeletons: Skeleton[];
  66267. animationGroups: AnimationGroup[];
  66268. }>;
  66269. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  66270. }
  66271. /**
  66272. * File loader for loading glTF files into a scene.
  66273. */
  66274. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  66275. /** @hidden */
  66276. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  66277. /** @hidden */
  66278. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  66279. /**
  66280. * Raised when the asset has been parsed
  66281. */
  66282. onParsedObservable: Observable<IGLTFLoaderData>;
  66283. private _onParsedObserver;
  66284. /**
  66285. * Raised when the asset has been parsed
  66286. */
  66287. onParsed: (loaderData: IGLTFLoaderData) => void;
  66288. /**
  66289. * 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.
  66290. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  66291. * Defaults to true.
  66292. * @hidden
  66293. */
  66294. static IncrementalLoading: boolean;
  66295. /**
  66296. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  66297. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  66298. * @hidden
  66299. */
  66300. static HomogeneousCoordinates: boolean;
  66301. /**
  66302. * The coordinate system mode. Defaults to AUTO.
  66303. */
  66304. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  66305. /**
  66306. * The animation start mode. Defaults to FIRST.
  66307. */
  66308. animationStartMode: GLTFLoaderAnimationStartMode;
  66309. /**
  66310. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  66311. */
  66312. compileMaterials: boolean;
  66313. /**
  66314. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  66315. */
  66316. useClipPlane: boolean;
  66317. /**
  66318. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  66319. */
  66320. compileShadowGenerators: boolean;
  66321. /**
  66322. * Defines if the Alpha blended materials are only applied as coverage.
  66323. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  66324. * If true, no extra effects are applied to transparent pixels.
  66325. */
  66326. transparencyAsCoverage: boolean;
  66327. /**
  66328. * Function called before loading a url referenced by the asset.
  66329. */
  66330. preprocessUrlAsync: (url: string) => Promise<string>;
  66331. /**
  66332. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  66333. */
  66334. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  66335. private _onMeshLoadedObserver;
  66336. /**
  66337. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  66338. */
  66339. onMeshLoaded: (mesh: AbstractMesh) => void;
  66340. /**
  66341. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  66342. */
  66343. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  66344. private _onTextureLoadedObserver;
  66345. /**
  66346. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  66347. */
  66348. onTextureLoaded: (texture: BaseTexture) => void;
  66349. /**
  66350. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  66351. */
  66352. readonly onMaterialLoadedObservable: Observable<Material>;
  66353. private _onMaterialLoadedObserver;
  66354. /**
  66355. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  66356. */
  66357. onMaterialLoaded: (material: Material) => void;
  66358. /**
  66359. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  66360. */
  66361. readonly onCameraLoadedObservable: Observable<Camera>;
  66362. private _onCameraLoadedObserver;
  66363. /**
  66364. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  66365. */
  66366. onCameraLoaded: (camera: Camera) => void;
  66367. /**
  66368. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  66369. * For assets with LODs, raised when all of the LODs are complete.
  66370. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  66371. */
  66372. readonly onCompleteObservable: Observable<void>;
  66373. private _onCompleteObserver;
  66374. /**
  66375. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  66376. * For assets with LODs, raised when all of the LODs are complete.
  66377. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  66378. */
  66379. onComplete: () => void;
  66380. /**
  66381. * Observable raised when an error occurs.
  66382. */
  66383. readonly onErrorObservable: Observable<any>;
  66384. private _onErrorObserver;
  66385. /**
  66386. * Callback raised when an error occurs.
  66387. */
  66388. onError: (reason: any) => void;
  66389. /**
  66390. * Observable raised after the loader is disposed.
  66391. */
  66392. readonly onDisposeObservable: Observable<void>;
  66393. private _onDisposeObserver;
  66394. /**
  66395. * Callback raised after the loader is disposed.
  66396. */
  66397. onDispose: () => void;
  66398. /**
  66399. * Observable raised after a loader extension is created.
  66400. * Set additional options for a loader extension in this event.
  66401. */
  66402. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  66403. private _onExtensionLoadedObserver;
  66404. /**
  66405. * Callback raised after a loader extension is created.
  66406. */
  66407. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  66408. /**
  66409. * Defines if the loader logging is enabled.
  66410. */
  66411. loggingEnabled: boolean;
  66412. /**
  66413. * Defines if the loader should capture performance counters.
  66414. */
  66415. capturePerformanceCounters: boolean;
  66416. /**
  66417. * Defines if the loader should validate the asset.
  66418. */
  66419. validate: boolean;
  66420. /**
  66421. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  66422. */
  66423. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  66424. private _onValidatedObserver;
  66425. /**
  66426. * Callback raised after a loader extension is created.
  66427. */
  66428. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  66429. private _loader;
  66430. /**
  66431. * Name of the loader ("gltf")
  66432. */
  66433. name: string;
  66434. /**
  66435. * Supported file extensions of the loader (.gltf, .glb)
  66436. */
  66437. extensions: ISceneLoaderPluginExtensions;
  66438. /**
  66439. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  66440. */
  66441. dispose(): void;
  66442. /** @hidden */
  66443. _clear(): void;
  66444. /**
  66445. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  66446. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  66447. * @param scene the scene the meshes should be added to
  66448. * @param data the glTF data to load
  66449. * @param rootUrl root url to load from
  66450. * @param onProgress event that fires when loading progress has occured
  66451. * @param fileName Defines the name of the file to load
  66452. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  66453. */
  66454. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  66455. meshes: AbstractMesh[];
  66456. particleSystems: IParticleSystem[];
  66457. skeletons: Skeleton[];
  66458. animationGroups: AnimationGroup[];
  66459. }>;
  66460. /**
  66461. * Imports all objects from the loaded glTF data and adds them to the scene
  66462. * @param scene the scene the objects should be added to
  66463. * @param data the glTF data to load
  66464. * @param rootUrl root url to load from
  66465. * @param onProgress event that fires when loading progress has occured
  66466. * @param fileName Defines the name of the file to load
  66467. * @returns a promise which completes when objects have been loaded to the scene
  66468. */
  66469. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  66470. /**
  66471. * Load into an asset container.
  66472. * @param scene The scene to load into
  66473. * @param data The data to import
  66474. * @param rootUrl The root url for scene and resources
  66475. * @param onProgress The callback when the load progresses
  66476. * @param fileName Defines the name of the file to load
  66477. * @returns The loaded asset container
  66478. */
  66479. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  66480. /**
  66481. * If the data string can be loaded directly.
  66482. * @param data string contianing the file data
  66483. * @returns if the data can be loaded directly
  66484. */
  66485. canDirectLoad(data: string): boolean;
  66486. /**
  66487. * Rewrites a url by combining a root url and response url.
  66488. */
  66489. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  66490. /**
  66491. * Instantiates a glTF file loader plugin.
  66492. * @returns the created plugin
  66493. */
  66494. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  66495. /**
  66496. * The loader state or null if the loader is not active.
  66497. */
  66498. readonly loaderState: Nullable<GLTFLoaderState>;
  66499. /**
  66500. * Returns a promise that resolves when the asset is completely loaded.
  66501. * @returns a promise that resolves when the asset is completely loaded.
  66502. */
  66503. whenCompleteAsync(): Promise<void>;
  66504. private _parseAsync;
  66505. private _validateAsync;
  66506. private _getLoader;
  66507. private _unpackBinary;
  66508. private _unpackBinaryV1;
  66509. private _unpackBinaryV2;
  66510. private static _parseVersion;
  66511. private static _compareVersion;
  66512. private static _decodeBufferToText;
  66513. private static readonly _logSpaces;
  66514. private _logIndentLevel;
  66515. private _loggingEnabled;
  66516. /** @hidden */
  66517. _log: (message: string) => void;
  66518. /** @hidden */
  66519. _logOpen(message: string): void;
  66520. /** @hidden */
  66521. _logClose(): void;
  66522. private _logEnabled;
  66523. private _logDisabled;
  66524. private _capturePerformanceCounters;
  66525. /** @hidden */
  66526. _startPerformanceCounter: (counterName: string) => void;
  66527. /** @hidden */
  66528. _endPerformanceCounter: (counterName: string) => void;
  66529. private _startPerformanceCounterEnabled;
  66530. private _startPerformanceCounterDisabled;
  66531. private _endPerformanceCounterEnabled;
  66532. private _endPerformanceCounterDisabled;
  66533. }
  66534. }
  66535. declare module BABYLON.GLTF1 {
  66536. /**
  66537. * Enums
  66538. * @hidden
  66539. */
  66540. export enum EComponentType {
  66541. BYTE = 5120,
  66542. UNSIGNED_BYTE = 5121,
  66543. SHORT = 5122,
  66544. UNSIGNED_SHORT = 5123,
  66545. FLOAT = 5126
  66546. }
  66547. /** @hidden */
  66548. export enum EShaderType {
  66549. FRAGMENT = 35632,
  66550. VERTEX = 35633
  66551. }
  66552. /** @hidden */
  66553. export enum EParameterType {
  66554. BYTE = 5120,
  66555. UNSIGNED_BYTE = 5121,
  66556. SHORT = 5122,
  66557. UNSIGNED_SHORT = 5123,
  66558. INT = 5124,
  66559. UNSIGNED_INT = 5125,
  66560. FLOAT = 5126,
  66561. FLOAT_VEC2 = 35664,
  66562. FLOAT_VEC3 = 35665,
  66563. FLOAT_VEC4 = 35666,
  66564. INT_VEC2 = 35667,
  66565. INT_VEC3 = 35668,
  66566. INT_VEC4 = 35669,
  66567. BOOL = 35670,
  66568. BOOL_VEC2 = 35671,
  66569. BOOL_VEC3 = 35672,
  66570. BOOL_VEC4 = 35673,
  66571. FLOAT_MAT2 = 35674,
  66572. FLOAT_MAT3 = 35675,
  66573. FLOAT_MAT4 = 35676,
  66574. SAMPLER_2D = 35678
  66575. }
  66576. /** @hidden */
  66577. export enum ETextureWrapMode {
  66578. CLAMP_TO_EDGE = 33071,
  66579. MIRRORED_REPEAT = 33648,
  66580. REPEAT = 10497
  66581. }
  66582. /** @hidden */
  66583. export enum ETextureFilterType {
  66584. NEAREST = 9728,
  66585. LINEAR = 9728,
  66586. NEAREST_MIPMAP_NEAREST = 9984,
  66587. LINEAR_MIPMAP_NEAREST = 9985,
  66588. NEAREST_MIPMAP_LINEAR = 9986,
  66589. LINEAR_MIPMAP_LINEAR = 9987
  66590. }
  66591. /** @hidden */
  66592. export enum ETextureFormat {
  66593. ALPHA = 6406,
  66594. RGB = 6407,
  66595. RGBA = 6408,
  66596. LUMINANCE = 6409,
  66597. LUMINANCE_ALPHA = 6410
  66598. }
  66599. /** @hidden */
  66600. export enum ECullingType {
  66601. FRONT = 1028,
  66602. BACK = 1029,
  66603. FRONT_AND_BACK = 1032
  66604. }
  66605. /** @hidden */
  66606. export enum EBlendingFunction {
  66607. ZERO = 0,
  66608. ONE = 1,
  66609. SRC_COLOR = 768,
  66610. ONE_MINUS_SRC_COLOR = 769,
  66611. DST_COLOR = 774,
  66612. ONE_MINUS_DST_COLOR = 775,
  66613. SRC_ALPHA = 770,
  66614. ONE_MINUS_SRC_ALPHA = 771,
  66615. DST_ALPHA = 772,
  66616. ONE_MINUS_DST_ALPHA = 773,
  66617. CONSTANT_COLOR = 32769,
  66618. ONE_MINUS_CONSTANT_COLOR = 32770,
  66619. CONSTANT_ALPHA = 32771,
  66620. ONE_MINUS_CONSTANT_ALPHA = 32772,
  66621. SRC_ALPHA_SATURATE = 776
  66622. }
  66623. /** @hidden */
  66624. export interface IGLTFProperty {
  66625. extensions?: {
  66626. [key: string]: any;
  66627. };
  66628. extras?: Object;
  66629. }
  66630. /** @hidden */
  66631. export interface IGLTFChildRootProperty extends IGLTFProperty {
  66632. name?: string;
  66633. }
  66634. /** @hidden */
  66635. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  66636. bufferView: string;
  66637. byteOffset: number;
  66638. byteStride: number;
  66639. count: number;
  66640. type: string;
  66641. componentType: EComponentType;
  66642. max?: number[];
  66643. min?: number[];
  66644. name?: string;
  66645. }
  66646. /** @hidden */
  66647. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  66648. buffer: string;
  66649. byteOffset: number;
  66650. byteLength: number;
  66651. byteStride: number;
  66652. target?: number;
  66653. }
  66654. /** @hidden */
  66655. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  66656. uri: string;
  66657. byteLength?: number;
  66658. type?: string;
  66659. }
  66660. /** @hidden */
  66661. export interface IGLTFShader extends IGLTFChildRootProperty {
  66662. uri: string;
  66663. type: EShaderType;
  66664. }
  66665. /** @hidden */
  66666. export interface IGLTFProgram extends IGLTFChildRootProperty {
  66667. attributes: string[];
  66668. fragmentShader: string;
  66669. vertexShader: string;
  66670. }
  66671. /** @hidden */
  66672. export interface IGLTFTechniqueParameter {
  66673. type: number;
  66674. count?: number;
  66675. semantic?: string;
  66676. node?: string;
  66677. value?: number | boolean | string | Array<any>;
  66678. source?: string;
  66679. babylonValue?: any;
  66680. }
  66681. /** @hidden */
  66682. export interface IGLTFTechniqueCommonProfile {
  66683. lightingModel: string;
  66684. texcoordBindings: Object;
  66685. parameters?: Array<any>;
  66686. }
  66687. /** @hidden */
  66688. export interface IGLTFTechniqueStatesFunctions {
  66689. blendColor?: number[];
  66690. blendEquationSeparate?: number[];
  66691. blendFuncSeparate?: number[];
  66692. colorMask: boolean[];
  66693. cullFace: number[];
  66694. }
  66695. /** @hidden */
  66696. export interface IGLTFTechniqueStates {
  66697. enable: number[];
  66698. functions: IGLTFTechniqueStatesFunctions;
  66699. }
  66700. /** @hidden */
  66701. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  66702. parameters: {
  66703. [key: string]: IGLTFTechniqueParameter;
  66704. };
  66705. program: string;
  66706. attributes: {
  66707. [key: string]: string;
  66708. };
  66709. uniforms: {
  66710. [key: string]: string;
  66711. };
  66712. states: IGLTFTechniqueStates;
  66713. }
  66714. /** @hidden */
  66715. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  66716. technique?: string;
  66717. values: string[];
  66718. }
  66719. /** @hidden */
  66720. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  66721. attributes: {
  66722. [key: string]: string;
  66723. };
  66724. indices: string;
  66725. material: string;
  66726. mode?: number;
  66727. }
  66728. /** @hidden */
  66729. export interface IGLTFMesh extends IGLTFChildRootProperty {
  66730. primitives: IGLTFMeshPrimitive[];
  66731. }
  66732. /** @hidden */
  66733. export interface IGLTFImage extends IGLTFChildRootProperty {
  66734. uri: string;
  66735. }
  66736. /** @hidden */
  66737. export interface IGLTFSampler extends IGLTFChildRootProperty {
  66738. magFilter?: number;
  66739. minFilter?: number;
  66740. wrapS?: number;
  66741. wrapT?: number;
  66742. }
  66743. /** @hidden */
  66744. export interface IGLTFTexture extends IGLTFChildRootProperty {
  66745. sampler: string;
  66746. source: string;
  66747. format?: ETextureFormat;
  66748. internalFormat?: ETextureFormat;
  66749. target?: number;
  66750. type?: number;
  66751. babylonTexture?: Texture;
  66752. }
  66753. /** @hidden */
  66754. export interface IGLTFAmbienLight {
  66755. color?: number[];
  66756. }
  66757. /** @hidden */
  66758. export interface IGLTFDirectionalLight {
  66759. color?: number[];
  66760. }
  66761. /** @hidden */
  66762. export interface IGLTFPointLight {
  66763. color?: number[];
  66764. constantAttenuation?: number;
  66765. linearAttenuation?: number;
  66766. quadraticAttenuation?: number;
  66767. }
  66768. /** @hidden */
  66769. export interface IGLTFSpotLight {
  66770. color?: number[];
  66771. constantAttenuation?: number;
  66772. fallOfAngle?: number;
  66773. fallOffExponent?: number;
  66774. linearAttenuation?: number;
  66775. quadraticAttenuation?: number;
  66776. }
  66777. /** @hidden */
  66778. export interface IGLTFLight extends IGLTFChildRootProperty {
  66779. type: string;
  66780. }
  66781. /** @hidden */
  66782. export interface IGLTFCameraOrthographic {
  66783. xmag: number;
  66784. ymag: number;
  66785. zfar: number;
  66786. znear: number;
  66787. }
  66788. /** @hidden */
  66789. export interface IGLTFCameraPerspective {
  66790. aspectRatio: number;
  66791. yfov: number;
  66792. zfar: number;
  66793. znear: number;
  66794. }
  66795. /** @hidden */
  66796. export interface IGLTFCamera extends IGLTFChildRootProperty {
  66797. type: string;
  66798. }
  66799. /** @hidden */
  66800. export interface IGLTFAnimationChannelTarget {
  66801. id: string;
  66802. path: string;
  66803. }
  66804. /** @hidden */
  66805. export interface IGLTFAnimationChannel {
  66806. sampler: string;
  66807. target: IGLTFAnimationChannelTarget;
  66808. }
  66809. /** @hidden */
  66810. export interface IGLTFAnimationSampler {
  66811. input: string;
  66812. output: string;
  66813. interpolation?: string;
  66814. }
  66815. /** @hidden */
  66816. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  66817. channels?: IGLTFAnimationChannel[];
  66818. parameters?: {
  66819. [key: string]: string;
  66820. };
  66821. samplers?: {
  66822. [key: string]: IGLTFAnimationSampler;
  66823. };
  66824. }
  66825. /** @hidden */
  66826. export interface IGLTFNodeInstanceSkin {
  66827. skeletons: string[];
  66828. skin: string;
  66829. meshes: string[];
  66830. }
  66831. /** @hidden */
  66832. export interface IGLTFSkins extends IGLTFChildRootProperty {
  66833. bindShapeMatrix: number[];
  66834. inverseBindMatrices: string;
  66835. jointNames: string[];
  66836. babylonSkeleton?: Skeleton;
  66837. }
  66838. /** @hidden */
  66839. export interface IGLTFNode extends IGLTFChildRootProperty {
  66840. camera?: string;
  66841. children: string[];
  66842. skin?: string;
  66843. jointName?: string;
  66844. light?: string;
  66845. matrix: number[];
  66846. mesh?: string;
  66847. meshes?: string[];
  66848. rotation?: number[];
  66849. scale?: number[];
  66850. translation?: number[];
  66851. babylonNode?: Node;
  66852. }
  66853. /** @hidden */
  66854. export interface IGLTFScene extends IGLTFChildRootProperty {
  66855. nodes: string[];
  66856. }
  66857. /** @hidden */
  66858. export interface IGLTFRuntime {
  66859. extensions: {
  66860. [key: string]: any;
  66861. };
  66862. accessors: {
  66863. [key: string]: IGLTFAccessor;
  66864. };
  66865. buffers: {
  66866. [key: string]: IGLTFBuffer;
  66867. };
  66868. bufferViews: {
  66869. [key: string]: IGLTFBufferView;
  66870. };
  66871. meshes: {
  66872. [key: string]: IGLTFMesh;
  66873. };
  66874. lights: {
  66875. [key: string]: IGLTFLight;
  66876. };
  66877. cameras: {
  66878. [key: string]: IGLTFCamera;
  66879. };
  66880. nodes: {
  66881. [key: string]: IGLTFNode;
  66882. };
  66883. images: {
  66884. [key: string]: IGLTFImage;
  66885. };
  66886. textures: {
  66887. [key: string]: IGLTFTexture;
  66888. };
  66889. shaders: {
  66890. [key: string]: IGLTFShader;
  66891. };
  66892. programs: {
  66893. [key: string]: IGLTFProgram;
  66894. };
  66895. samplers: {
  66896. [key: string]: IGLTFSampler;
  66897. };
  66898. techniques: {
  66899. [key: string]: IGLTFTechnique;
  66900. };
  66901. materials: {
  66902. [key: string]: IGLTFMaterial;
  66903. };
  66904. animations: {
  66905. [key: string]: IGLTFAnimation;
  66906. };
  66907. skins: {
  66908. [key: string]: IGLTFSkins;
  66909. };
  66910. currentScene?: Object;
  66911. scenes: {
  66912. [key: string]: IGLTFScene;
  66913. };
  66914. extensionsUsed: string[];
  66915. extensionsRequired?: string[];
  66916. buffersCount: number;
  66917. shaderscount: number;
  66918. scene: Scene;
  66919. rootUrl: string;
  66920. loadedBufferCount: number;
  66921. loadedBufferViews: {
  66922. [name: string]: ArrayBufferView;
  66923. };
  66924. loadedShaderCount: number;
  66925. importOnlyMeshes: boolean;
  66926. importMeshesNames?: string[];
  66927. dummyNodes: Node[];
  66928. }
  66929. /** @hidden */
  66930. export interface INodeToRoot {
  66931. bone: Bone;
  66932. node: IGLTFNode;
  66933. id: string;
  66934. }
  66935. /** @hidden */
  66936. export interface IJointNode {
  66937. node: IGLTFNode;
  66938. id: string;
  66939. }
  66940. }
  66941. declare module BABYLON.GLTF1 {
  66942. /**
  66943. * Utils functions for GLTF
  66944. * @hidden
  66945. */
  66946. export class GLTFUtils {
  66947. /**
  66948. * Sets the given "parameter" matrix
  66949. * @param scene: the Scene object
  66950. * @param source: the source node where to pick the matrix
  66951. * @param parameter: the GLTF technique parameter
  66952. * @param uniformName: the name of the shader's uniform
  66953. * @param shaderMaterial: the shader material
  66954. */
  66955. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  66956. /**
  66957. * Sets the given "parameter" matrix
  66958. * @param shaderMaterial: the shader material
  66959. * @param uniform: the name of the shader's uniform
  66960. * @param value: the value of the uniform
  66961. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  66962. */
  66963. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  66964. /**
  66965. * Returns the wrap mode of the texture
  66966. * @param mode: the mode value
  66967. */
  66968. static GetWrapMode(mode: number): number;
  66969. /**
  66970. * Returns the byte stride giving an accessor
  66971. * @param accessor: the GLTF accessor objet
  66972. */
  66973. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  66974. /**
  66975. * Returns the texture filter mode giving a mode value
  66976. * @param mode: the filter mode value
  66977. */
  66978. static GetTextureFilterMode(mode: number): ETextureFilterType;
  66979. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  66980. /**
  66981. * Returns a buffer from its accessor
  66982. * @param gltfRuntime: the GLTF runtime
  66983. * @param accessor: the GLTF accessor
  66984. */
  66985. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  66986. /**
  66987. * Decodes a buffer view into a string
  66988. * @param view: the buffer view
  66989. */
  66990. static DecodeBufferToText(view: ArrayBufferView): string;
  66991. /**
  66992. * Returns the default material of gltf. Related to
  66993. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  66994. * @param scene: the Babylon.js scene
  66995. */
  66996. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  66997. private static _DefaultMaterial;
  66998. }
  66999. }
  67000. declare module BABYLON.GLTF1 {
  67001. /**
  67002. * Implementation of the base glTF spec
  67003. * @hidden
  67004. */
  67005. export class GLTFLoaderBase {
  67006. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  67007. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  67008. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  67009. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  67010. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  67011. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  67012. }
  67013. /**
  67014. * glTF V1 Loader
  67015. * @hidden
  67016. */
  67017. export class GLTFLoader implements IGLTFLoader {
  67018. static Extensions: {
  67019. [name: string]: GLTFLoaderExtension;
  67020. };
  67021. static RegisterExtension(extension: GLTFLoaderExtension): void;
  67022. state: Nullable<GLTFLoaderState>;
  67023. dispose(): void;
  67024. private _importMeshAsync;
  67025. /**
  67026. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  67027. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  67028. * @param scene the scene the meshes should be added to
  67029. * @param data gltf data containing information of the meshes in a loaded file
  67030. * @param rootUrl root url to load from
  67031. * @param onProgress event that fires when loading progress has occured
  67032. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  67033. */
  67034. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  67035. meshes: AbstractMesh[];
  67036. particleSystems: IParticleSystem[];
  67037. skeletons: Skeleton[];
  67038. animationGroups: AnimationGroup[];
  67039. }>;
  67040. private _loadAsync;
  67041. /**
  67042. * Imports all objects from a loaded gltf file and adds them to the scene
  67043. * @param scene the scene the objects should be added to
  67044. * @param data gltf data containing information of the meshes in a loaded file
  67045. * @param rootUrl root url to load from
  67046. * @param onProgress event that fires when loading progress has occured
  67047. * @returns a promise which completes when objects have been loaded to the scene
  67048. */
  67049. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  67050. private _loadShadersAsync;
  67051. private _loadBuffersAsync;
  67052. private _createNodes;
  67053. }
  67054. /** @hidden */
  67055. export abstract class GLTFLoaderExtension {
  67056. private _name;
  67057. constructor(name: string);
  67058. readonly name: string;
  67059. /**
  67060. * Defines an override for loading the runtime
  67061. * Return true to stop further extensions from loading the runtime
  67062. */
  67063. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  67064. /**
  67065. * Defines an onverride for creating gltf runtime
  67066. * Return true to stop further extensions from creating the runtime
  67067. */
  67068. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  67069. /**
  67070. * Defines an override for loading buffers
  67071. * Return true to stop further extensions from loading this buffer
  67072. */
  67073. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  67074. /**
  67075. * Defines an override for loading texture buffers
  67076. * Return true to stop further extensions from loading this texture data
  67077. */
  67078. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  67079. /**
  67080. * Defines an override for creating textures
  67081. * Return true to stop further extensions from loading this texture
  67082. */
  67083. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  67084. /**
  67085. * Defines an override for loading shader strings
  67086. * Return true to stop further extensions from loading this shader data
  67087. */
  67088. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  67089. /**
  67090. * Defines an override for loading materials
  67091. * Return true to stop further extensions from loading this material
  67092. */
  67093. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  67094. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  67095. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  67096. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  67097. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  67098. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  67099. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  67100. private static LoadTextureBufferAsync;
  67101. private static CreateTextureAsync;
  67102. private static ApplyExtensions;
  67103. }
  67104. }
  67105. declare module BABYLON.GLTF1 {
  67106. /** @hidden */
  67107. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  67108. private _bin;
  67109. constructor();
  67110. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  67111. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  67112. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  67113. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  67114. }
  67115. }
  67116. declare module BABYLON.GLTF1 {
  67117. /** @hidden */
  67118. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  67119. constructor();
  67120. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  67121. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  67122. private _loadTexture;
  67123. }
  67124. }
  67125. declare module BABYLON.GLTF2.Loader {
  67126. /**
  67127. * Loader interface with an index field.
  67128. */
  67129. export interface IArrayItem {
  67130. /**
  67131. * The index of this item in the array.
  67132. */
  67133. index: number;
  67134. }
  67135. /**
  67136. * Loader interface with additional members.
  67137. */
  67138. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  67139. /** @hidden */
  67140. _data?: Promise<ArrayBufferView>;
  67141. /** @hidden */
  67142. _babylonVertexBuffer?: Promise<VertexBuffer>;
  67143. }
  67144. /**
  67145. * Loader interface with additional members.
  67146. */
  67147. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  67148. }
  67149. /** @hidden */
  67150. export interface _IAnimationSamplerData {
  67151. input: Float32Array;
  67152. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  67153. output: Float32Array;
  67154. }
  67155. /**
  67156. * Loader interface with additional members.
  67157. */
  67158. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  67159. /** @hidden */
  67160. _data?: Promise<_IAnimationSamplerData>;
  67161. }
  67162. /**
  67163. * Loader interface with additional members.
  67164. */
  67165. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  67166. channels: IAnimationChannel[];
  67167. samplers: IAnimationSampler[];
  67168. /** @hidden */
  67169. _babylonAnimationGroup?: AnimationGroup;
  67170. }
  67171. /**
  67172. * Loader interface with additional members.
  67173. */
  67174. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  67175. /** @hidden */
  67176. _data?: Promise<ArrayBufferView>;
  67177. }
  67178. /**
  67179. * Loader interface with additional members.
  67180. */
  67181. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  67182. /** @hidden */
  67183. _data?: Promise<ArrayBufferView>;
  67184. /** @hidden */
  67185. _babylonBuffer?: Promise<Buffer>;
  67186. }
  67187. /**
  67188. * Loader interface with additional members.
  67189. */
  67190. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  67191. }
  67192. /**
  67193. * Loader interface with additional members.
  67194. */
  67195. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  67196. /** @hidden */
  67197. _data?: Promise<ArrayBufferView>;
  67198. }
  67199. /**
  67200. * Loader interface with additional members.
  67201. */
  67202. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  67203. }
  67204. /**
  67205. * Loader interface with additional members.
  67206. */
  67207. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  67208. }
  67209. /**
  67210. * Loader interface with additional members.
  67211. */
  67212. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  67213. baseColorTexture?: ITextureInfo;
  67214. metallicRoughnessTexture?: ITextureInfo;
  67215. }
  67216. /**
  67217. * Loader interface with additional members.
  67218. */
  67219. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  67220. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  67221. normalTexture?: IMaterialNormalTextureInfo;
  67222. occlusionTexture?: IMaterialOcclusionTextureInfo;
  67223. emissiveTexture?: ITextureInfo;
  67224. /** @hidden */
  67225. _data?: {
  67226. [babylonDrawMode: number]: {
  67227. babylonMaterial: Material;
  67228. babylonMeshes: AbstractMesh[];
  67229. promise: Promise<void>;
  67230. };
  67231. };
  67232. }
  67233. /**
  67234. * Loader interface with additional members.
  67235. */
  67236. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  67237. primitives: IMeshPrimitive[];
  67238. }
  67239. /**
  67240. * Loader interface with additional members.
  67241. */
  67242. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  67243. /** @hidden */
  67244. _instanceData?: {
  67245. babylonSourceMesh: Mesh;
  67246. promise: Promise<any>;
  67247. };
  67248. }
  67249. /**
  67250. * Loader interface with additional members.
  67251. */
  67252. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  67253. /**
  67254. * The parent glTF node.
  67255. */
  67256. parent?: INode;
  67257. /** @hidden */
  67258. _babylonTransformNode?: TransformNode;
  67259. /** @hidden */
  67260. _primitiveBabylonMeshes?: AbstractMesh[];
  67261. /** @hidden */
  67262. _babylonBones?: Bone[];
  67263. /** @hidden */
  67264. _numMorphTargets?: number;
  67265. }
  67266. /** @hidden */
  67267. export interface _ISamplerData {
  67268. noMipMaps: boolean;
  67269. samplingMode: number;
  67270. wrapU: number;
  67271. wrapV: number;
  67272. }
  67273. /**
  67274. * Loader interface with additional members.
  67275. */
  67276. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  67277. /** @hidden */
  67278. _data?: _ISamplerData;
  67279. }
  67280. /**
  67281. * Loader interface with additional members.
  67282. */
  67283. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  67284. }
  67285. /**
  67286. * Loader interface with additional members.
  67287. */
  67288. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  67289. /** @hidden */
  67290. _data?: {
  67291. babylonSkeleton: Skeleton;
  67292. promise: Promise<void>;
  67293. };
  67294. }
  67295. /**
  67296. * Loader interface with additional members.
  67297. */
  67298. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  67299. }
  67300. /**
  67301. * Loader interface with additional members.
  67302. */
  67303. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  67304. }
  67305. /**
  67306. * Loader interface with additional members.
  67307. */
  67308. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  67309. accessors?: IAccessor[];
  67310. animations?: IAnimation[];
  67311. buffers?: IBuffer[];
  67312. bufferViews?: IBufferView[];
  67313. cameras?: ICamera[];
  67314. images?: IImage[];
  67315. materials?: IMaterial[];
  67316. meshes?: IMesh[];
  67317. nodes?: INode[];
  67318. samplers?: ISampler[];
  67319. scenes?: IScene[];
  67320. skins?: ISkin[];
  67321. textures?: ITexture[];
  67322. }
  67323. }
  67324. declare module BABYLON.GLTF2 {
  67325. /**
  67326. * Interface for a glTF loader extension.
  67327. */
  67328. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  67329. /**
  67330. * Called after the loader state changes to LOADING.
  67331. */
  67332. onLoading?(): void;
  67333. /**
  67334. * Called after the loader state changes to READY.
  67335. */
  67336. onReady?(): void;
  67337. /**
  67338. * Define this method to modify the default behavior when loading scenes.
  67339. * @param context The context when loading the asset
  67340. * @param scene The glTF scene property
  67341. * @returns A promise that resolves when the load is complete or null if not handled
  67342. */
  67343. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  67344. /**
  67345. * Define this method to modify the default behavior when loading nodes.
  67346. * @param context The context when loading the asset
  67347. * @param node The glTF node property
  67348. * @param assign A function called synchronously after parsing the glTF properties
  67349. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  67350. */
  67351. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67352. /**
  67353. * Define this method to modify the default behavior when loading cameras.
  67354. * @param context The context when loading the asset
  67355. * @param camera The glTF camera property
  67356. * @param assign A function called synchronously after parsing the glTF properties
  67357. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  67358. */
  67359. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  67360. /**
  67361. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  67362. * @param context The context when loading the asset
  67363. * @param primitive The glTF mesh primitive property
  67364. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  67365. */
  67366. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  67367. /**
  67368. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  67369. * @param context The context when loading the asset
  67370. * @param name The mesh name when loading the asset
  67371. * @param node The glTF node when loading the asset
  67372. * @param mesh The glTF mesh when loading the asset
  67373. * @param primitive The glTF mesh primitive property
  67374. * @param assign A function called synchronously after parsing the glTF properties
  67375. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  67376. */
  67377. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  67378. /**
  67379. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  67380. * @param context The context when loading the asset
  67381. * @param material The glTF material property
  67382. * @param assign A function called synchronously after parsing the glTF properties
  67383. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  67384. */
  67385. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  67386. /**
  67387. * Define this method to modify the default behavior when creating materials.
  67388. * @param context The context when loading the asset
  67389. * @param material The glTF material property
  67390. * @param babylonDrawMode The draw mode for the Babylon material
  67391. * @returns The Babylon material or null if not handled
  67392. */
  67393. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  67394. /**
  67395. * Define this method to modify the default behavior when loading material properties.
  67396. * @param context The context when loading the asset
  67397. * @param material The glTF material property
  67398. * @param babylonMaterial The Babylon material
  67399. * @returns A promise that resolves when the load is complete or null if not handled
  67400. */
  67401. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67402. /**
  67403. * Define this method to modify the default behavior when loading texture infos.
  67404. * @param context The context when loading the asset
  67405. * @param textureInfo The glTF texture info property
  67406. * @param assign A function called synchronously after parsing the glTF properties
  67407. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  67408. */
  67409. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  67410. /**
  67411. * Define this method to modify the default behavior when loading animations.
  67412. * @param context The context when loading the asset
  67413. * @param animation The glTF animation property
  67414. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  67415. */
  67416. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  67417. /**
  67418. * @hidden Define this method to modify the default behavior when loading skins.
  67419. * @param context The context when loading the asset
  67420. * @param node The glTF node property
  67421. * @param skin The glTF skin property
  67422. * @returns A promise that resolves when the load is complete or null if not handled
  67423. */
  67424. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  67425. /**
  67426. * @hidden Define this method to modify the default behavior when loading uris.
  67427. * @param context The context when loading the asset
  67428. * @param property The glTF property associated with the uri
  67429. * @param uri The uri to load
  67430. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  67431. */
  67432. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  67433. }
  67434. }
  67435. declare module BABYLON.GLTF2 {
  67436. /**
  67437. * Helper class for working with arrays when loading the glTF asset
  67438. */
  67439. export class ArrayItem {
  67440. /**
  67441. * Gets an item from the given array.
  67442. * @param context The context when loading the asset
  67443. * @param array The array to get the item from
  67444. * @param index The index to the array
  67445. * @returns The array item
  67446. */
  67447. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  67448. /**
  67449. * Assign an `index` field to each item of the given array.
  67450. * @param array The array of items
  67451. */
  67452. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  67453. }
  67454. /**
  67455. * The glTF 2.0 loader
  67456. */
  67457. export class GLTFLoader implements IGLTFLoader {
  67458. /** @hidden */
  67459. _completePromises: Promise<any>[];
  67460. private _disposed;
  67461. private _parent;
  67462. private _state;
  67463. private _extensions;
  67464. private _rootUrl;
  67465. private _fileName;
  67466. private _uniqueRootUrl;
  67467. private _gltf;
  67468. private _babylonScene;
  67469. private _rootBabylonMesh;
  67470. private _defaultBabylonMaterialData;
  67471. private _progressCallback?;
  67472. private _requests;
  67473. private static readonly _DefaultSampler;
  67474. private static _ExtensionNames;
  67475. private static _ExtensionFactories;
  67476. /**
  67477. * Registers a loader extension.
  67478. * @param name The name of the loader extension.
  67479. * @param factory The factory function that creates the loader extension.
  67480. */
  67481. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  67482. /**
  67483. * Unregisters a loader extension.
  67484. * @param name The name of the loader extenion.
  67485. * @returns A boolean indicating whether the extension has been unregistered
  67486. */
  67487. static UnregisterExtension(name: string): boolean;
  67488. /**
  67489. * Gets the loader state.
  67490. */
  67491. readonly state: Nullable<GLTFLoaderState>;
  67492. /**
  67493. * The glTF object parsed from the JSON.
  67494. */
  67495. readonly gltf: IGLTF;
  67496. /**
  67497. * The Babylon scene when loading the asset.
  67498. */
  67499. readonly babylonScene: Scene;
  67500. /**
  67501. * The root Babylon mesh when loading the asset.
  67502. */
  67503. readonly rootBabylonMesh: Mesh;
  67504. /** @hidden */
  67505. constructor(parent: GLTFFileLoader);
  67506. /** @hidden */
  67507. dispose(): void;
  67508. /** @hidden */
  67509. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  67510. meshes: AbstractMesh[];
  67511. particleSystems: IParticleSystem[];
  67512. skeletons: Skeleton[];
  67513. animationGroups: AnimationGroup[];
  67514. }>;
  67515. /** @hidden */
  67516. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  67517. private _loadAsync;
  67518. private _loadData;
  67519. private _setupData;
  67520. private _loadExtensions;
  67521. private _checkExtensions;
  67522. private _setState;
  67523. private _createRootNode;
  67524. /**
  67525. * Loads a glTF scene.
  67526. * @param context The context when loading the asset
  67527. * @param scene The glTF scene property
  67528. * @returns A promise that resolves when the load is complete
  67529. */
  67530. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  67531. private _forEachPrimitive;
  67532. private _getMeshes;
  67533. private _getSkeletons;
  67534. private _getAnimationGroups;
  67535. private _startAnimations;
  67536. /**
  67537. * Loads a glTF node.
  67538. * @param context The context when loading the asset
  67539. * @param node The glTF node property
  67540. * @param assign A function called synchronously after parsing the glTF properties
  67541. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  67542. */
  67543. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  67544. private _loadMeshAsync;
  67545. /**
  67546. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  67547. * @param context The context when loading the asset
  67548. * @param name The mesh name when loading the asset
  67549. * @param node The glTF node when loading the asset
  67550. * @param mesh The glTF mesh when loading the asset
  67551. * @param primitive The glTF mesh primitive property
  67552. * @param assign A function called synchronously after parsing the glTF properties
  67553. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  67554. */
  67555. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  67556. private _loadVertexDataAsync;
  67557. private _createMorphTargets;
  67558. private _loadMorphTargetsAsync;
  67559. private _loadMorphTargetVertexDataAsync;
  67560. private static _LoadTransform;
  67561. private _loadSkinAsync;
  67562. private _loadBones;
  67563. private _loadBone;
  67564. private _loadSkinInverseBindMatricesDataAsync;
  67565. private _updateBoneMatrices;
  67566. private _getNodeMatrix;
  67567. /**
  67568. * Loads a glTF camera.
  67569. * @param context The context when loading the asset
  67570. * @param camera The glTF camera property
  67571. * @param assign A function called synchronously after parsing the glTF properties
  67572. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  67573. */
  67574. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  67575. private _loadAnimationsAsync;
  67576. /**
  67577. * Loads a glTF animation.
  67578. * @param context The context when loading the asset
  67579. * @param animation The glTF animation property
  67580. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  67581. */
  67582. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  67583. /**
  67584. * @hidden Loads a glTF animation channel.
  67585. * @param context The context when loading the asset
  67586. * @param animationContext The context of the animation when loading the asset
  67587. * @param animation The glTF animation property
  67588. * @param channel The glTF animation channel property
  67589. * @param babylonAnimationGroup The babylon animation group property
  67590. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  67591. * @returns A void promise when the channel load is complete
  67592. */
  67593. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  67594. private _loadAnimationSamplerAsync;
  67595. private _loadBufferAsync;
  67596. /**
  67597. * Loads a glTF buffer view.
  67598. * @param context The context when loading the asset
  67599. * @param bufferView The glTF buffer view property
  67600. * @returns A promise that resolves with the loaded data when the load is complete
  67601. */
  67602. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  67603. private _loadAccessorAsync;
  67604. private _loadFloatAccessorAsync;
  67605. private _loadIndicesAccessorAsync;
  67606. private _loadVertexBufferViewAsync;
  67607. private _loadVertexAccessorAsync;
  67608. private _loadMaterialMetallicRoughnessPropertiesAsync;
  67609. /** @hidden */
  67610. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  67611. private _createDefaultMaterial;
  67612. /**
  67613. * Creates a Babylon material from a glTF material.
  67614. * @param context The context when loading the asset
  67615. * @param material The glTF material property
  67616. * @param babylonDrawMode The draw mode for the Babylon material
  67617. * @returns The Babylon material
  67618. */
  67619. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  67620. /**
  67621. * Loads properties from a glTF material into a Babylon material.
  67622. * @param context The context when loading the asset
  67623. * @param material The glTF material property
  67624. * @param babylonMaterial The Babylon material
  67625. * @returns A promise that resolves when the load is complete
  67626. */
  67627. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  67628. /**
  67629. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  67630. * @param context The context when loading the asset
  67631. * @param material The glTF material property
  67632. * @param babylonMaterial The Babylon material
  67633. * @returns A promise that resolves when the load is complete
  67634. */
  67635. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  67636. /**
  67637. * Loads the alpha properties from a glTF material into a Babylon material.
  67638. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  67639. * @param context The context when loading the asset
  67640. * @param material The glTF material property
  67641. * @param babylonMaterial The Babylon material
  67642. */
  67643. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  67644. /**
  67645. * Loads a glTF texture info.
  67646. * @param context The context when loading the asset
  67647. * @param textureInfo The glTF texture info property
  67648. * @param assign A function called synchronously after parsing the glTF properties
  67649. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  67650. */
  67651. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  67652. private _loadTextureAsync;
  67653. private _loadSampler;
  67654. /**
  67655. * Loads a glTF image.
  67656. * @param context The context when loading the asset
  67657. * @param image The glTF image property
  67658. * @returns A promise that resolves with the loaded data when the load is complete
  67659. */
  67660. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  67661. /**
  67662. * Loads a glTF uri.
  67663. * @param context The context when loading the asset
  67664. * @param property The glTF property associated with the uri
  67665. * @param uri The base64 or relative uri
  67666. * @returns A promise that resolves with the loaded data when the load is complete
  67667. */
  67668. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  67669. private _onProgress;
  67670. /**
  67671. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  67672. * @param babylonObject the Babylon object with metadata
  67673. * @param pointer the JSON pointer
  67674. */
  67675. static AddPointerMetadata(babylonObject: {
  67676. metadata: any;
  67677. }, pointer: string): void;
  67678. private static _GetTextureWrapMode;
  67679. private static _GetTextureSamplingMode;
  67680. private static _GetTypedArrayConstructor;
  67681. private static _GetTypedArray;
  67682. private static _GetNumComponents;
  67683. private static _ValidateUri;
  67684. private static _GetDrawMode;
  67685. private _compileMaterialsAsync;
  67686. private _compileShadowGeneratorsAsync;
  67687. private _forEachExtensions;
  67688. private _applyExtensions;
  67689. private _extensionsOnLoading;
  67690. private _extensionsOnReady;
  67691. private _extensionsLoadSceneAsync;
  67692. private _extensionsLoadNodeAsync;
  67693. private _extensionsLoadCameraAsync;
  67694. private _extensionsLoadVertexDataAsync;
  67695. private _extensionsLoadMeshPrimitiveAsync;
  67696. private _extensionsLoadMaterialAsync;
  67697. private _extensionsCreateMaterial;
  67698. private _extensionsLoadMaterialPropertiesAsync;
  67699. private _extensionsLoadTextureInfoAsync;
  67700. private _extensionsLoadAnimationAsync;
  67701. private _extensionsLoadSkinAsync;
  67702. private _extensionsLoadUriAsync;
  67703. /**
  67704. * Helper method called by a loader extension to load an glTF extension.
  67705. * @param context The context when loading the asset
  67706. * @param property The glTF property to load the extension from
  67707. * @param extensionName The name of the extension to load
  67708. * @param actionAsync The action to run
  67709. * @returns The promise returned by actionAsync or null if the extension does not exist
  67710. */
  67711. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  67712. /**
  67713. * Helper method called by a loader extension to load a glTF extra.
  67714. * @param context The context when loading the asset
  67715. * @param property The glTF property to load the extra from
  67716. * @param extensionName The name of the extension to load
  67717. * @param actionAsync The action to run
  67718. * @returns The promise returned by actionAsync or null if the extra does not exist
  67719. */
  67720. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  67721. /**
  67722. * Increments the indentation level and logs a message.
  67723. * @param message The message to log
  67724. */
  67725. logOpen(message: string): void;
  67726. /**
  67727. * Decrements the indentation level.
  67728. */
  67729. logClose(): void;
  67730. /**
  67731. * Logs a message
  67732. * @param message The message to log
  67733. */
  67734. log(message: string): void;
  67735. /**
  67736. * Starts a performance counter.
  67737. * @param counterName The name of the performance counter
  67738. */
  67739. startPerformanceCounter(counterName: string): void;
  67740. /**
  67741. * Ends a performance counter.
  67742. * @param counterName The name of the performance counter
  67743. */
  67744. endPerformanceCounter(counterName: string): void;
  67745. }
  67746. }
  67747. declare module BABYLON.GLTF2.Loader.Extensions {
  67748. /**
  67749. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  67750. */
  67751. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  67752. /** The name of this extension. */
  67753. readonly name: string;
  67754. /** Defines whether this extension is enabled. */
  67755. enabled: boolean;
  67756. private _loader;
  67757. private _lights?;
  67758. /** @hidden */
  67759. constructor(loader: GLTFLoader);
  67760. /** @hidden */
  67761. dispose(): void;
  67762. /** @hidden */
  67763. onLoading(): void;
  67764. /** @hidden */
  67765. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  67766. private _loadLightAsync;
  67767. }
  67768. }
  67769. declare module BABYLON.GLTF2.Loader.Extensions {
  67770. /**
  67771. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  67772. */
  67773. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  67774. /** The name of this extension. */
  67775. readonly name: string;
  67776. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  67777. dracoCompression?: DracoCompression;
  67778. /** Defines whether this extension is enabled. */
  67779. enabled: boolean;
  67780. private _loader;
  67781. /** @hidden */
  67782. constructor(loader: GLTFLoader);
  67783. /** @hidden */
  67784. dispose(): void;
  67785. /** @hidden */
  67786. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  67787. }
  67788. }
  67789. declare module BABYLON.GLTF2.Loader.Extensions {
  67790. /**
  67791. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  67792. */
  67793. export class KHR_lights implements IGLTFLoaderExtension {
  67794. /** The name of this extension. */
  67795. readonly name: string;
  67796. /** Defines whether this extension is enabled. */
  67797. enabled: boolean;
  67798. private _loader;
  67799. private _lights?;
  67800. /** @hidden */
  67801. constructor(loader: GLTFLoader);
  67802. /** @hidden */
  67803. dispose(): void;
  67804. /** @hidden */
  67805. onLoading(): void;
  67806. /** @hidden */
  67807. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67808. }
  67809. }
  67810. declare module BABYLON.GLTF2.Loader.Extensions {
  67811. /**
  67812. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  67813. */
  67814. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  67815. /** The name of this extension. */
  67816. readonly name: string;
  67817. /** Defines whether this extension is enabled. */
  67818. enabled: boolean;
  67819. private _loader;
  67820. /** @hidden */
  67821. constructor(loader: GLTFLoader);
  67822. /** @hidden */
  67823. dispose(): void;
  67824. /** @hidden */
  67825. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67826. private _loadSpecularGlossinessPropertiesAsync;
  67827. }
  67828. }
  67829. declare module BABYLON.GLTF2.Loader.Extensions {
  67830. /**
  67831. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  67832. */
  67833. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  67834. /** The name of this extension. */
  67835. readonly name: string;
  67836. /** Defines whether this extension is enabled. */
  67837. enabled: boolean;
  67838. private _loader;
  67839. /** @hidden */
  67840. constructor(loader: GLTFLoader);
  67841. /** @hidden */
  67842. dispose(): void;
  67843. /** @hidden */
  67844. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67845. private _loadUnlitPropertiesAsync;
  67846. }
  67847. }
  67848. declare module BABYLON.GLTF2.Loader.Extensions {
  67849. /**
  67850. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  67851. */
  67852. export class KHR_texture_transform implements IGLTFLoaderExtension {
  67853. /** The name of this extension. */
  67854. readonly name: string;
  67855. /** Defines whether this extension is enabled. */
  67856. enabled: boolean;
  67857. private _loader;
  67858. /** @hidden */
  67859. constructor(loader: GLTFLoader);
  67860. /** @hidden */
  67861. dispose(): void;
  67862. /** @hidden */
  67863. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  67864. }
  67865. }
  67866. declare module BABYLON.GLTF2.Loader.Extensions {
  67867. /**
  67868. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  67869. */
  67870. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  67871. /** The name of this extension. */
  67872. readonly name: string;
  67873. /** Defines whether this extension is enabled. */
  67874. enabled: boolean;
  67875. private _loader;
  67876. private _clips;
  67877. private _emitters;
  67878. /** @hidden */
  67879. constructor(loader: GLTFLoader);
  67880. /** @hidden */
  67881. dispose(): void;
  67882. /** @hidden */
  67883. onLoading(): void;
  67884. /** @hidden */
  67885. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  67886. /** @hidden */
  67887. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67888. /** @hidden */
  67889. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  67890. private _loadClipAsync;
  67891. private _loadEmitterAsync;
  67892. private _getEventAction;
  67893. private _loadAnimationEventAsync;
  67894. }
  67895. }
  67896. declare module BABYLON.GLTF2.Loader.Extensions {
  67897. /**
  67898. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  67899. */
  67900. export class MSFT_lod implements IGLTFLoaderExtension {
  67901. /** The name of this extension. */
  67902. readonly name: string;
  67903. /** Defines whether this extension is enabled. */
  67904. enabled: boolean;
  67905. /**
  67906. * Maximum number of LODs to load, starting from the lowest LOD.
  67907. */
  67908. maxLODsToLoad: number;
  67909. /**
  67910. * Observable raised when all node LODs of one level are loaded.
  67911. * The event data is the index of the loaded LOD starting from zero.
  67912. * Dispose the loader to cancel the loading of the next level of LODs.
  67913. */
  67914. onNodeLODsLoadedObservable: Observable<number>;
  67915. /**
  67916. * Observable raised when all material LODs of one level are loaded.
  67917. * The event data is the index of the loaded LOD starting from zero.
  67918. * Dispose the loader to cancel the loading of the next level of LODs.
  67919. */
  67920. onMaterialLODsLoadedObservable: Observable<number>;
  67921. private _loader;
  67922. private _nodeIndexLOD;
  67923. private _nodeSignalLODs;
  67924. private _nodePromiseLODs;
  67925. private _materialIndexLOD;
  67926. private _materialSignalLODs;
  67927. private _materialPromiseLODs;
  67928. /** @hidden */
  67929. constructor(loader: GLTFLoader);
  67930. /** @hidden */
  67931. dispose(): void;
  67932. /** @hidden */
  67933. onReady(): void;
  67934. /** @hidden */
  67935. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67936. /** @hidden */
  67937. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  67938. /** @hidden */
  67939. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  67940. /**
  67941. * Gets an array of LOD properties from lowest to highest.
  67942. */
  67943. private _getLODs;
  67944. private _disposeUnusedMaterials;
  67945. }
  67946. }
  67947. declare module BABYLON.GLTF2.Loader.Extensions {
  67948. /** @hidden */
  67949. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  67950. readonly name: string;
  67951. enabled: boolean;
  67952. private _loader;
  67953. constructor(loader: GLTFLoader);
  67954. dispose(): void;
  67955. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67956. }
  67957. }
  67958. declare module BABYLON.GLTF2.Loader.Extensions {
  67959. /** @hidden */
  67960. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  67961. readonly name: string;
  67962. enabled: boolean;
  67963. private _loader;
  67964. constructor(loader: GLTFLoader);
  67965. dispose(): void;
  67966. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67967. }
  67968. }
  67969. declare module BABYLON.GLTF2.Loader.Extensions {
  67970. /**
  67971. * Store glTF extras (if present) in BJS objects' metadata
  67972. */
  67973. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  67974. /** The name of this extension. */
  67975. readonly name: string;
  67976. /** Defines whether this extension is enabled. */
  67977. enabled: boolean;
  67978. private _loader;
  67979. private _assignExtras;
  67980. /** @hidden */
  67981. constructor(loader: GLTFLoader);
  67982. /** @hidden */
  67983. dispose(): void;
  67984. /** @hidden */
  67985. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67986. /** @hidden */
  67987. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  67988. /** @hidden */
  67989. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  67990. }
  67991. }
  67992. declare module BABYLON {
  67993. /**
  67994. * Class reading and parsing the MTL file bundled with the obj file.
  67995. */
  67996. export class MTLFileLoader {
  67997. /**
  67998. * All material loaded from the mtl will be set here
  67999. */
  68000. materials: StandardMaterial[];
  68001. /**
  68002. * This function will read the mtl file and create each material described inside
  68003. * This function could be improve by adding :
  68004. * -some component missing (Ni, Tf...)
  68005. * -including the specific options available
  68006. *
  68007. * @param scene defines the scene the material will be created in
  68008. * @param data defines the mtl data to parse
  68009. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  68010. */
  68011. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  68012. /**
  68013. * Gets the texture for the material.
  68014. *
  68015. * If the material is imported from input file,
  68016. * We sanitize the url to ensure it takes the textre from aside the material.
  68017. *
  68018. * @param rootUrl The root url to load from
  68019. * @param value The value stored in the mtl
  68020. * @return The Texture
  68021. */
  68022. private static _getTexture;
  68023. }
  68024. /**
  68025. * Options for loading OBJ/MTL files
  68026. */
  68027. type MeshLoadOptions = {
  68028. /**
  68029. * Defines if UVs are optimized by default during load.
  68030. */
  68031. OptimizeWithUV: boolean;
  68032. /**
  68033. * Defines custom scaling of UV coordinates of loaded meshes.
  68034. */
  68035. UVScaling: Vector2;
  68036. /**
  68037. * Invert model on y-axis (does a model scaling inversion)
  68038. */
  68039. InvertY: boolean;
  68040. /**
  68041. * Invert Y-Axis of referenced textures on load
  68042. */
  68043. InvertTextureY: boolean;
  68044. /**
  68045. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  68046. */
  68047. ImportVertexColors: boolean;
  68048. /**
  68049. * Compute the normals for the model, even if normals are present in the file.
  68050. */
  68051. ComputeNormals: boolean;
  68052. /**
  68053. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  68054. */
  68055. SkipMaterials: boolean;
  68056. /**
  68057. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  68058. */
  68059. MaterialLoadingFailsSilently: boolean;
  68060. };
  68061. /**
  68062. * OBJ file type loader.
  68063. * This is a babylon scene loader plugin.
  68064. */
  68065. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  68066. /**
  68067. * Defines if UVs are optimized by default during load.
  68068. */
  68069. static OPTIMIZE_WITH_UV: boolean;
  68070. /**
  68071. * Invert model on y-axis (does a model scaling inversion)
  68072. */
  68073. static INVERT_Y: boolean;
  68074. /**
  68075. * Invert Y-Axis of referenced textures on load
  68076. */
  68077. static INVERT_TEXTURE_Y: boolean;
  68078. /**
  68079. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  68080. */
  68081. static IMPORT_VERTEX_COLORS: boolean;
  68082. /**
  68083. * Compute the normals for the model, even if normals are present in the file.
  68084. */
  68085. static COMPUTE_NORMALS: boolean;
  68086. /**
  68087. * Defines custom scaling of UV coordinates of loaded meshes.
  68088. */
  68089. static UV_SCALING: Vector2;
  68090. /**
  68091. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  68092. */
  68093. static SKIP_MATERIALS: boolean;
  68094. /**
  68095. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  68096. *
  68097. * Defaults to true for backwards compatibility.
  68098. */
  68099. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  68100. /**
  68101. * Defines the name of the plugin.
  68102. */
  68103. name: string;
  68104. /**
  68105. * Defines the extension the plugin is able to load.
  68106. */
  68107. extensions: string;
  68108. /** @hidden */
  68109. obj: RegExp;
  68110. /** @hidden */
  68111. group: RegExp;
  68112. /** @hidden */
  68113. mtllib: RegExp;
  68114. /** @hidden */
  68115. usemtl: RegExp;
  68116. /** @hidden */
  68117. smooth: RegExp;
  68118. /** @hidden */
  68119. vertexPattern: RegExp;
  68120. /** @hidden */
  68121. normalPattern: RegExp;
  68122. /** @hidden */
  68123. uvPattern: RegExp;
  68124. /** @hidden */
  68125. facePattern1: RegExp;
  68126. /** @hidden */
  68127. facePattern2: RegExp;
  68128. /** @hidden */
  68129. facePattern3: RegExp;
  68130. /** @hidden */
  68131. facePattern4: RegExp;
  68132. /** @hidden */
  68133. facePattern5: RegExp;
  68134. private _meshLoadOptions;
  68135. /**
  68136. * Creates loader for .OBJ files
  68137. *
  68138. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  68139. */
  68140. constructor(meshLoadOptions?: MeshLoadOptions);
  68141. private static readonly currentMeshLoadOptions;
  68142. /**
  68143. * Calls synchronously the MTL file attached to this obj.
  68144. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  68145. * Without this function materials are not displayed in the first frame (but displayed after).
  68146. * In consequence it is impossible to get material information in your HTML file
  68147. *
  68148. * @param url The URL of the MTL file
  68149. * @param rootUrl
  68150. * @param onSuccess Callback function to be called when the MTL file is loaded
  68151. * @private
  68152. */
  68153. private _loadMTL;
  68154. /**
  68155. * Instantiates a OBJ file loader plugin.
  68156. * @returns the created plugin
  68157. */
  68158. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  68159. /**
  68160. * If the data string can be loaded directly.
  68161. *
  68162. * @param data string containing the file data
  68163. * @returns if the data can be loaded directly
  68164. */
  68165. canDirectLoad(data: string): boolean;
  68166. /**
  68167. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  68168. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  68169. * @param scene the scene the meshes should be added to
  68170. * @param data the OBJ data to load
  68171. * @param rootUrl root url to load from
  68172. * @param onProgress event that fires when loading progress has occured
  68173. * @param fileName Defines the name of the file to load
  68174. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  68175. */
  68176. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  68177. meshes: AbstractMesh[];
  68178. particleSystems: IParticleSystem[];
  68179. skeletons: Skeleton[];
  68180. animationGroups: AnimationGroup[];
  68181. }>;
  68182. /**
  68183. * Imports all objects from the loaded OBJ data and adds them to the scene
  68184. * @param scene the scene the objects should be added to
  68185. * @param data the OBJ data to load
  68186. * @param rootUrl root url to load from
  68187. * @param onProgress event that fires when loading progress has occured
  68188. * @param fileName Defines the name of the file to load
  68189. * @returns a promise which completes when objects have been loaded to the scene
  68190. */
  68191. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  68192. /**
  68193. * Load into an asset container.
  68194. * @param scene The scene to load into
  68195. * @param data The data to import
  68196. * @param rootUrl The root url for scene and resources
  68197. * @param onProgress The callback when the load progresses
  68198. * @param fileName Defines the name of the file to load
  68199. * @returns The loaded asset container
  68200. */
  68201. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  68202. /**
  68203. * Read the OBJ file and create an Array of meshes.
  68204. * Each mesh contains all information given by the OBJ and the MTL file.
  68205. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  68206. *
  68207. * @param meshesNames
  68208. * @param scene Scene The scene where are displayed the data
  68209. * @param data String The content of the obj file
  68210. * @param rootUrl String The path to the folder
  68211. * @returns Array<AbstractMesh>
  68212. * @private
  68213. */
  68214. private _parseSolid;
  68215. }
  68216. }
  68217. declare module BABYLON {
  68218. /**
  68219. * STL file type loader.
  68220. * This is a babylon scene loader plugin.
  68221. */
  68222. export class STLFileLoader implements ISceneLoaderPlugin {
  68223. /** @hidden */
  68224. solidPattern: RegExp;
  68225. /** @hidden */
  68226. facetsPattern: RegExp;
  68227. /** @hidden */
  68228. normalPattern: RegExp;
  68229. /** @hidden */
  68230. vertexPattern: RegExp;
  68231. /**
  68232. * Defines the name of the plugin.
  68233. */
  68234. name: string;
  68235. /**
  68236. * Defines the extensions the stl loader is able to load.
  68237. * force data to come in as an ArrayBuffer
  68238. * we'll convert to string if it looks like it's an ASCII .stl
  68239. */
  68240. extensions: ISceneLoaderPluginExtensions;
  68241. /**
  68242. * Import meshes into a scene.
  68243. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  68244. * @param scene The scene to import into
  68245. * @param data The data to import
  68246. * @param rootUrl The root url for scene and resources
  68247. * @param meshes The meshes array to import into
  68248. * @param particleSystems The particle systems array to import into
  68249. * @param skeletons The skeletons array to import into
  68250. * @param onError The callback when import fails
  68251. * @returns True if successful or false otherwise
  68252. */
  68253. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  68254. /**
  68255. * Load into a scene.
  68256. * @param scene The scene to load into
  68257. * @param data The data to import
  68258. * @param rootUrl The root url for scene and resources
  68259. * @param onError The callback when import fails
  68260. * @returns true if successful or false otherwise
  68261. */
  68262. load(scene: Scene, data: any, rootUrl: string): boolean;
  68263. /**
  68264. * Load into an asset container.
  68265. * @param scene The scene to load into
  68266. * @param data The data to import
  68267. * @param rootUrl The root url for scene and resources
  68268. * @param onError The callback when import fails
  68269. * @returns The loaded asset container
  68270. */
  68271. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  68272. private _isBinary;
  68273. private _parseBinary;
  68274. private _parseASCII;
  68275. }
  68276. }
  68277. declare module BABYLON {
  68278. /**
  68279. * Class for generating OBJ data from a Babylon scene.
  68280. */
  68281. export class OBJExport {
  68282. /**
  68283. * Exports the geometry of a Mesh array in .OBJ file format (text)
  68284. * @param mesh defines the list of meshes to serialize
  68285. * @param materials defines if materials should be exported
  68286. * @param matlibname defines the name of the associated mtl file
  68287. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  68288. * @returns the OBJ content
  68289. */
  68290. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  68291. /**
  68292. * Exports the material(s) of a mesh in .MTL file format (text)
  68293. * @param mesh defines the mesh to extract the material from
  68294. * @returns the mtl content
  68295. */
  68296. static MTL(mesh: Mesh): string;
  68297. }
  68298. }
  68299. declare module BABYLON {
  68300. /** @hidden */
  68301. export var __IGLTFExporterExtension: number;
  68302. /**
  68303. * Interface for extending the exporter
  68304. * @hidden
  68305. */
  68306. export interface IGLTFExporterExtension {
  68307. /**
  68308. * The name of this extension
  68309. */
  68310. readonly name: string;
  68311. /**
  68312. * Defines whether this extension is enabled
  68313. */
  68314. enabled: boolean;
  68315. /**
  68316. * Defines whether this extension is required
  68317. */
  68318. required: boolean;
  68319. }
  68320. }
  68321. declare module BABYLON.GLTF2.Exporter {
  68322. /** @hidden */
  68323. export var __IGLTFExporterExtensionV2: number;
  68324. /**
  68325. * Interface for a glTF exporter extension
  68326. * @hidden
  68327. */
  68328. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  68329. /**
  68330. * Define this method to modify the default behavior before exporting a texture
  68331. * @param context The context when loading the asset
  68332. * @param babylonTexture The glTF texture info property
  68333. * @param mimeType The mime-type of the generated image
  68334. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  68335. */
  68336. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  68337. /**
  68338. * Define this method to modify the default behavior when exporting texture info
  68339. * @param context The context when loading the asset
  68340. * @param meshPrimitive glTF mesh primitive
  68341. * @param babylonSubMesh Babylon submesh
  68342. * @param binaryWriter glTF serializer binary writer instance
  68343. * @returns nullable IMeshPrimitive promise
  68344. */
  68345. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  68346. /**
  68347. * Define this method to modify the default behavior when exporting a node
  68348. * @param context The context when exporting the node
  68349. * @param node glTF node
  68350. * @param babylonNode BabylonJS node
  68351. * @returns nullable INode promise
  68352. */
  68353. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  68354. /**
  68355. * Called after the exporter state changes to EXPORTING
  68356. */
  68357. onExporting?(): void;
  68358. }
  68359. }
  68360. declare module BABYLON.GLTF2.Exporter {
  68361. /**
  68362. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  68363. * @hidden
  68364. */
  68365. export class _GLTFMaterialExporter {
  68366. /**
  68367. * Represents the dielectric specular values for R, G and B
  68368. */
  68369. private static readonly _DielectricSpecular;
  68370. /**
  68371. * Allows the maximum specular power to be defined for material calculations
  68372. */
  68373. private static readonly _MaxSpecularPower;
  68374. /**
  68375. * Mapping to store textures
  68376. */
  68377. private _textureMap;
  68378. /**
  68379. * Numeric tolerance value
  68380. */
  68381. private static readonly _Epsilon;
  68382. /**
  68383. * Reference to the glTF Exporter
  68384. */
  68385. private _exporter;
  68386. constructor(exporter: _Exporter);
  68387. /**
  68388. * Specifies if two colors are approximately equal in value
  68389. * @param color1 first color to compare to
  68390. * @param color2 second color to compare to
  68391. * @param epsilon threshold value
  68392. */
  68393. private static FuzzyEquals;
  68394. /**
  68395. * Gets the materials from a Babylon scene and converts them to glTF materials
  68396. * @param scene babylonjs scene
  68397. * @param mimeType texture mime type
  68398. * @param images array of images
  68399. * @param textures array of textures
  68400. * @param materials array of materials
  68401. * @param imageData mapping of texture names to base64 textures
  68402. * @param hasTextureCoords specifies if texture coordinates are present on the material
  68403. */
  68404. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68405. /**
  68406. * Makes a copy of the glTF material without the texture parameters
  68407. * @param originalMaterial original glTF material
  68408. * @returns glTF material without texture parameters
  68409. */
  68410. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  68411. /**
  68412. * Specifies if the material has any texture parameters present
  68413. * @param material glTF Material
  68414. * @returns boolean specifying if texture parameters are present
  68415. */
  68416. _hasTexturesPresent(material: IMaterial): boolean;
  68417. /**
  68418. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  68419. * @param babylonStandardMaterial
  68420. * @returns glTF Metallic Roughness Material representation
  68421. */
  68422. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  68423. /**
  68424. * Computes the metallic factor
  68425. * @param diffuse diffused value
  68426. * @param specular specular value
  68427. * @param oneMinusSpecularStrength one minus the specular strength
  68428. * @returns metallic value
  68429. */
  68430. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  68431. /**
  68432. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  68433. * @param glTFMaterial glTF material
  68434. * @param babylonMaterial Babylon material
  68435. */
  68436. private static _SetAlphaMode;
  68437. /**
  68438. * Converts a Babylon Standard Material to a glTF Material
  68439. * @param babylonStandardMaterial BJS Standard Material
  68440. * @param mimeType mime type to use for the textures
  68441. * @param images array of glTF image interfaces
  68442. * @param textures array of glTF texture interfaces
  68443. * @param materials array of glTF material interfaces
  68444. * @param imageData map of image file name to data
  68445. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68446. */
  68447. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68448. /**
  68449. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  68450. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  68451. * @param mimeType mime type to use for the textures
  68452. * @param images array of glTF image interfaces
  68453. * @param textures array of glTF texture interfaces
  68454. * @param materials array of glTF material interfaces
  68455. * @param imageData map of image file name to data
  68456. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68457. */
  68458. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68459. /**
  68460. * Converts an image typed array buffer to a base64 image
  68461. * @param buffer typed array buffer
  68462. * @param width width of the image
  68463. * @param height height of the image
  68464. * @param mimeType mimetype of the image
  68465. * @returns base64 image string
  68466. */
  68467. private _createBase64FromCanvasAsync;
  68468. /**
  68469. * Generates a white texture based on the specified width and height
  68470. * @param width width of the texture in pixels
  68471. * @param height height of the texture in pixels
  68472. * @param scene babylonjs scene
  68473. * @returns white texture
  68474. */
  68475. private _createWhiteTexture;
  68476. /**
  68477. * 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
  68478. * @param texture1 first texture to resize
  68479. * @param texture2 second texture to resize
  68480. * @param scene babylonjs scene
  68481. * @returns resized textures or null
  68482. */
  68483. private _resizeTexturesToSameDimensions;
  68484. /**
  68485. * Converts an array of pixels to a Float32Array
  68486. * Throws an error if the pixel format is not supported
  68487. * @param pixels - array buffer containing pixel values
  68488. * @returns Float32 of pixels
  68489. */
  68490. private _convertPixelArrayToFloat32;
  68491. /**
  68492. * Convert Specular Glossiness Textures to Metallic Roughness
  68493. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  68494. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  68495. * @param diffuseTexture texture used to store diffuse information
  68496. * @param specularGlossinessTexture texture used to store specular and glossiness information
  68497. * @param factors specular glossiness material factors
  68498. * @param mimeType the mime type to use for the texture
  68499. * @returns pbr metallic roughness interface or null
  68500. */
  68501. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  68502. /**
  68503. * Converts specular glossiness material properties to metallic roughness
  68504. * @param specularGlossiness interface with specular glossiness material properties
  68505. * @returns interface with metallic roughness material properties
  68506. */
  68507. private _convertSpecularGlossinessToMetallicRoughness;
  68508. /**
  68509. * Calculates the surface reflectance, independent of lighting conditions
  68510. * @param color Color source to calculate brightness from
  68511. * @returns number representing the perceived brightness, or zero if color is undefined
  68512. */
  68513. private _getPerceivedBrightness;
  68514. /**
  68515. * Returns the maximum color component value
  68516. * @param color
  68517. * @returns maximum color component value, or zero if color is null or undefined
  68518. */
  68519. private _getMaxComponent;
  68520. /**
  68521. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  68522. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  68523. * @param mimeType mime type to use for the textures
  68524. * @param images array of glTF image interfaces
  68525. * @param textures array of glTF texture interfaces
  68526. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  68527. * @param imageData map of image file name to data
  68528. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68529. * @returns glTF PBR Metallic Roughness factors
  68530. */
  68531. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  68532. private _getGLTFTextureSampler;
  68533. private _getGLTFTextureWrapMode;
  68534. private _getGLTFTextureWrapModesSampler;
  68535. /**
  68536. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  68537. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  68538. * @param mimeType mime type to use for the textures
  68539. * @param images array of glTF image interfaces
  68540. * @param textures array of glTF texture interfaces
  68541. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  68542. * @param imageData map of image file name to data
  68543. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68544. * @returns glTF PBR Metallic Roughness factors
  68545. */
  68546. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  68547. /**
  68548. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  68549. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  68550. * @param mimeType mime type to use for the textures
  68551. * @param images array of glTF image interfaces
  68552. * @param textures array of glTF texture interfaces
  68553. * @param materials array of glTF material interfaces
  68554. * @param imageData map of image file name to data
  68555. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68556. */
  68557. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68558. private setMetallicRoughnessPbrMaterial;
  68559. private getPixelsFromTexture;
  68560. /**
  68561. * Extracts a texture from a Babylon texture into file data and glTF data
  68562. * @param babylonTexture Babylon texture to extract
  68563. * @param mimeType Mime Type of the babylonTexture
  68564. * @return glTF texture info, or null if the texture format is not supported
  68565. */
  68566. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  68567. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  68568. /**
  68569. * Builds a texture from base64 string
  68570. * @param base64Texture base64 texture string
  68571. * @param baseTextureName Name to use for the texture
  68572. * @param mimeType image mime type for the texture
  68573. * @param images array of images
  68574. * @param textures array of textures
  68575. * @param imageData map of image data
  68576. * @returns glTF texture info, or null if the texture format is not supported
  68577. */
  68578. private _getTextureInfoFromBase64;
  68579. }
  68580. }
  68581. declare module BABYLON {
  68582. /**
  68583. * Class for holding and downloading glTF file data
  68584. */
  68585. export class GLTFData {
  68586. /**
  68587. * Object which contains the file name as the key and its data as the value
  68588. */
  68589. glTFFiles: {
  68590. [fileName: string]: string | Blob;
  68591. };
  68592. /**
  68593. * Initializes the glTF file object
  68594. */
  68595. constructor();
  68596. /**
  68597. * Downloads the glTF data as files based on their names and data
  68598. */
  68599. downloadFiles(): void;
  68600. }
  68601. }
  68602. declare module BABYLON {
  68603. /**
  68604. * Holds a collection of exporter options and parameters
  68605. */
  68606. export interface IExportOptions {
  68607. /**
  68608. * Function which indicates whether a babylon node should be exported or not
  68609. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  68610. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  68611. */
  68612. shouldExportNode?(node: Node): boolean;
  68613. /**
  68614. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  68615. * @param metadata source metadata to read from
  68616. * @returns the data to store to glTF node extras
  68617. */
  68618. metadataSelector?(metadata: any): any;
  68619. /**
  68620. * The sample rate to bake animation curves
  68621. */
  68622. animationSampleRate?: number;
  68623. /**
  68624. * Begin serialization without waiting for the scene to be ready
  68625. */
  68626. exportWithoutWaitingForScene?: boolean;
  68627. }
  68628. /**
  68629. * Class for generating glTF data from a Babylon scene.
  68630. */
  68631. export class GLTF2Export {
  68632. /**
  68633. * Exports the geometry of the scene to .gltf file format asynchronously
  68634. * @param scene Babylon scene with scene hierarchy information
  68635. * @param filePrefix File prefix to use when generating the glTF file
  68636. * @param options Exporter options
  68637. * @returns Returns an object with a .gltf file and associates texture names
  68638. * as keys and their data and paths as values
  68639. */
  68640. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  68641. private static _PreExportAsync;
  68642. private static _PostExportAsync;
  68643. /**
  68644. * Exports the geometry of the scene to .glb file format asychronously
  68645. * @param scene Babylon scene with scene hierarchy information
  68646. * @param filePrefix File prefix to use when generating glb file
  68647. * @param options Exporter options
  68648. * @returns Returns an object with a .glb filename as key and data as value
  68649. */
  68650. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  68651. }
  68652. }
  68653. declare module BABYLON.GLTF2.Exporter {
  68654. /**
  68655. * @hidden
  68656. */
  68657. export class _GLTFUtilities {
  68658. /**
  68659. * Creates a buffer view based on the supplied arguments
  68660. * @param bufferIndex index value of the specified buffer
  68661. * @param byteOffset byte offset value
  68662. * @param byteLength byte length of the bufferView
  68663. * @param byteStride byte distance between conequential elements
  68664. * @param name name of the buffer view
  68665. * @returns bufferView for glTF
  68666. */
  68667. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  68668. /**
  68669. * Creates an accessor based on the supplied arguments
  68670. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  68671. * @param name The name of the accessor
  68672. * @param type The type of the accessor
  68673. * @param componentType The datatype of components in the attribute
  68674. * @param count The number of attributes referenced by this accessor
  68675. * @param byteOffset The offset relative to the start of the bufferView in bytes
  68676. * @param min Minimum value of each component in this attribute
  68677. * @param max Maximum value of each component in this attribute
  68678. * @returns accessor for glTF
  68679. */
  68680. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  68681. /**
  68682. * Calculates the minimum and maximum values of an array of position floats
  68683. * @param positions Positions array of a mesh
  68684. * @param vertexStart Starting vertex offset to calculate min and max values
  68685. * @param vertexCount Number of vertices to check for min and max values
  68686. * @returns min number array and max number array
  68687. */
  68688. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  68689. min: number[];
  68690. max: number[];
  68691. };
  68692. /**
  68693. * Converts a new right-handed Vector3
  68694. * @param vector vector3 array
  68695. * @returns right-handed Vector3
  68696. */
  68697. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  68698. /**
  68699. * Converts a Vector3 to right-handed
  68700. * @param vector Vector3 to convert to right-handed
  68701. */
  68702. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  68703. /**
  68704. * Converts a three element number array to right-handed
  68705. * @param vector number array to convert to right-handed
  68706. */
  68707. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  68708. /**
  68709. * Converts a new right-handed Vector3
  68710. * @param vector vector3 array
  68711. * @returns right-handed Vector3
  68712. */
  68713. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  68714. /**
  68715. * Converts a Vector3 to right-handed
  68716. * @param vector Vector3 to convert to right-handed
  68717. */
  68718. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  68719. /**
  68720. * Converts a three element number array to right-handed
  68721. * @param vector number array to convert to right-handed
  68722. */
  68723. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  68724. /**
  68725. * Converts a Vector4 to right-handed
  68726. * @param vector Vector4 to convert to right-handed
  68727. */
  68728. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  68729. /**
  68730. * Converts a Vector4 to right-handed
  68731. * @param vector Vector4 to convert to right-handed
  68732. */
  68733. static _GetRightHandedArray4FromRef(vector: number[]): void;
  68734. /**
  68735. * Converts a Quaternion to right-handed
  68736. * @param quaternion Source quaternion to convert to right-handed
  68737. */
  68738. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  68739. /**
  68740. * Converts a Quaternion to right-handed
  68741. * @param quaternion Source quaternion to convert to right-handed
  68742. */
  68743. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  68744. static _NormalizeTangentFromRef(tangent: Vector4): void;
  68745. }
  68746. }
  68747. declare module BABYLON.GLTF2.Exporter {
  68748. /**
  68749. * Converts Babylon Scene into glTF 2.0.
  68750. * @hidden
  68751. */
  68752. export class _Exporter {
  68753. /**
  68754. * Stores the glTF to export
  68755. */
  68756. _glTF: IGLTF;
  68757. /**
  68758. * Stores all generated buffer views, which represents views into the main glTF buffer data
  68759. */
  68760. _bufferViews: IBufferView[];
  68761. /**
  68762. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  68763. */
  68764. _accessors: IAccessor[];
  68765. /**
  68766. * Stores all the generated nodes, which contains transform and/or mesh information per node
  68767. */
  68768. private _nodes;
  68769. /**
  68770. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  68771. */
  68772. private _scenes;
  68773. /**
  68774. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  68775. */
  68776. private _meshes;
  68777. /**
  68778. * Stores all the generated material information, which represents the appearance of each primitive
  68779. */
  68780. _materials: IMaterial[];
  68781. _materialMap: {
  68782. [materialID: number]: number;
  68783. };
  68784. /**
  68785. * Stores all the generated texture information, which is referenced by glTF materials
  68786. */
  68787. _textures: ITexture[];
  68788. /**
  68789. * Stores all the generated image information, which is referenced by glTF textures
  68790. */
  68791. _images: IImage[];
  68792. /**
  68793. * Stores all the texture samplers
  68794. */
  68795. _samplers: ISampler[];
  68796. /**
  68797. * Stores all the generated animation samplers, which is referenced by glTF animations
  68798. */
  68799. /**
  68800. * Stores the animations for glTF models
  68801. */
  68802. private _animations;
  68803. /**
  68804. * Stores the total amount of bytes stored in the glTF buffer
  68805. */
  68806. private _totalByteLength;
  68807. /**
  68808. * Stores a reference to the Babylon scene containing the source geometry and material information
  68809. */
  68810. _babylonScene: Scene;
  68811. /**
  68812. * Stores a map of the image data, where the key is the file name and the value
  68813. * is the image data
  68814. */
  68815. _imageData: {
  68816. [fileName: string]: {
  68817. data: Uint8Array;
  68818. mimeType: ImageMimeType;
  68819. };
  68820. };
  68821. /**
  68822. * Stores a map of the unique id of a node to its index in the node array
  68823. */
  68824. private _nodeMap;
  68825. /**
  68826. * Specifies if the Babylon scene should be converted to right-handed on export
  68827. */
  68828. _convertToRightHandedSystem: boolean;
  68829. /**
  68830. * Baked animation sample rate
  68831. */
  68832. private _animationSampleRate;
  68833. private _options;
  68834. private _localEngine;
  68835. _glTFMaterialExporter: _GLTFMaterialExporter;
  68836. private _extensions;
  68837. private static _ExtensionNames;
  68838. private static _ExtensionFactories;
  68839. private _applyExtensions;
  68840. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  68841. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  68842. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  68843. private _forEachExtensions;
  68844. private _extensionsOnExporting;
  68845. /**
  68846. * Load glTF serializer extensions
  68847. */
  68848. private _loadExtensions;
  68849. /**
  68850. * Creates a glTF Exporter instance, which can accept optional exporter options
  68851. * @param babylonScene Babylon scene object
  68852. * @param options Options to modify the behavior of the exporter
  68853. */
  68854. constructor(babylonScene: Scene, options?: IExportOptions);
  68855. /**
  68856. * Registers a glTF exporter extension
  68857. * @param name Name of the extension to export
  68858. * @param factory The factory function that creates the exporter extension
  68859. */
  68860. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  68861. /**
  68862. * Un-registers an exporter extension
  68863. * @param name The name fo the exporter extension
  68864. * @returns A boolean indicating whether the extension has been un-registered
  68865. */
  68866. static UnregisterExtension(name: string): boolean;
  68867. /**
  68868. * Lazy load a local engine with premultiplied alpha set to false
  68869. */
  68870. _getLocalEngine(): Engine;
  68871. private reorderIndicesBasedOnPrimitiveMode;
  68872. /**
  68873. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  68874. * clock-wise during export to glTF
  68875. * @param submesh BabylonJS submesh
  68876. * @param primitiveMode Primitive mode of the mesh
  68877. * @param sideOrientation the winding order of the submesh
  68878. * @param vertexBufferKind The type of vertex attribute
  68879. * @param meshAttributeArray The vertex attribute data
  68880. * @param byteOffset The offset to the binary data
  68881. * @param binaryWriter The binary data for the glTF file
  68882. */
  68883. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  68884. /**
  68885. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  68886. * clock-wise during export to glTF
  68887. * @param submesh BabylonJS submesh
  68888. * @param primitiveMode Primitive mode of the mesh
  68889. * @param sideOrientation the winding order of the submesh
  68890. * @param vertexBufferKind The type of vertex attribute
  68891. * @param meshAttributeArray The vertex attribute data
  68892. * @param byteOffset The offset to the binary data
  68893. * @param binaryWriter The binary data for the glTF file
  68894. */
  68895. private reorderTriangleFillMode;
  68896. /**
  68897. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  68898. * clock-wise during export to glTF
  68899. * @param submesh BabylonJS submesh
  68900. * @param primitiveMode Primitive mode of the mesh
  68901. * @param sideOrientation the winding order of the submesh
  68902. * @param vertexBufferKind The type of vertex attribute
  68903. * @param meshAttributeArray The vertex attribute data
  68904. * @param byteOffset The offset to the binary data
  68905. * @param binaryWriter The binary data for the glTF file
  68906. */
  68907. private reorderTriangleStripDrawMode;
  68908. /**
  68909. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  68910. * clock-wise during export to glTF
  68911. * @param submesh BabylonJS submesh
  68912. * @param primitiveMode Primitive mode of the mesh
  68913. * @param sideOrientation the winding order of the submesh
  68914. * @param vertexBufferKind The type of vertex attribute
  68915. * @param meshAttributeArray The vertex attribute data
  68916. * @param byteOffset The offset to the binary data
  68917. * @param binaryWriter The binary data for the glTF file
  68918. */
  68919. private reorderTriangleFanMode;
  68920. /**
  68921. * Writes the vertex attribute data to binary
  68922. * @param vertices The vertices to write to the binary writer
  68923. * @param byteOffset The offset into the binary writer to overwrite binary data
  68924. * @param vertexAttributeKind The vertex attribute type
  68925. * @param meshAttributeArray The vertex attribute data
  68926. * @param binaryWriter The writer containing the binary data
  68927. */
  68928. private writeVertexAttributeData;
  68929. /**
  68930. * Writes mesh attribute data to a data buffer
  68931. * Returns the bytelength of the data
  68932. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  68933. * @param meshAttributeArray Array containing the attribute data
  68934. * @param binaryWriter The buffer to write the binary data to
  68935. * @param indices Used to specify the order of the vertex data
  68936. */
  68937. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  68938. /**
  68939. * Generates glTF json data
  68940. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  68941. * @param glTFPrefix Text to use when prefixing a glTF file
  68942. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  68943. * @returns json data as string
  68944. */
  68945. private generateJSON;
  68946. /**
  68947. * Generates data for .gltf and .bin files based on the glTF prefix string
  68948. * @param glTFPrefix Text to use when prefixing a glTF file
  68949. * @returns GLTFData with glTF file data
  68950. */
  68951. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  68952. /**
  68953. * Creates a binary buffer for glTF
  68954. * @returns array buffer for binary data
  68955. */
  68956. private _generateBinaryAsync;
  68957. /**
  68958. * Pads the number to a multiple of 4
  68959. * @param num number to pad
  68960. * @returns padded number
  68961. */
  68962. private _getPadding;
  68963. /**
  68964. * Generates a glb file from the json and binary data
  68965. * Returns an object with the glb file name as the key and data as the value
  68966. * @param glTFPrefix
  68967. * @returns object with glb filename as key and data as value
  68968. */
  68969. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  68970. /**
  68971. * Sets the TRS for each node
  68972. * @param node glTF Node for storing the transformation data
  68973. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  68974. */
  68975. private setNodeTransformation;
  68976. private getVertexBufferFromMesh;
  68977. /**
  68978. * Creates a bufferview based on the vertices type for the Babylon mesh
  68979. * @param kind Indicates the type of vertices data
  68980. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  68981. * @param binaryWriter The buffer to write the bufferview data to
  68982. */
  68983. private createBufferViewKind;
  68984. /**
  68985. * The primitive mode of the Babylon mesh
  68986. * @param babylonMesh The BabylonJS mesh
  68987. */
  68988. private getMeshPrimitiveMode;
  68989. /**
  68990. * Sets the primitive mode of the glTF mesh primitive
  68991. * @param meshPrimitive glTF mesh primitive
  68992. * @param primitiveMode The primitive mode
  68993. */
  68994. private setPrimitiveMode;
  68995. /**
  68996. * Sets the vertex attribute accessor based of the glTF mesh primitive
  68997. * @param meshPrimitive glTF mesh primitive
  68998. * @param attributeKind vertex attribute
  68999. * @returns boolean specifying if uv coordinates are present
  69000. */
  69001. private setAttributeKind;
  69002. /**
  69003. * Sets data for the primitive attributes of each submesh
  69004. * @param mesh glTF Mesh object to store the primitive attribute information
  69005. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  69006. * @param binaryWriter Buffer to write the attribute data to
  69007. */
  69008. private setPrimitiveAttributesAsync;
  69009. /**
  69010. * Creates a glTF scene based on the array of meshes
  69011. * Returns the the total byte offset
  69012. * @param babylonScene Babylon scene to get the mesh data from
  69013. * @param binaryWriter Buffer to write binary data to
  69014. */
  69015. private createSceneAsync;
  69016. /**
  69017. * Creates a mapping of Node unique id to node index and handles animations
  69018. * @param babylonScene Babylon Scene
  69019. * @param nodes Babylon transform nodes
  69020. * @param binaryWriter Buffer to write binary data to
  69021. * @returns Node mapping of unique id to index
  69022. */
  69023. private createNodeMapAndAnimationsAsync;
  69024. /**
  69025. * Creates a glTF node from a Babylon mesh
  69026. * @param babylonMesh Source Babylon mesh
  69027. * @param binaryWriter Buffer for storing geometry data
  69028. * @returns glTF node
  69029. */
  69030. private createNodeAsync;
  69031. }
  69032. /**
  69033. * @hidden
  69034. *
  69035. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  69036. */
  69037. export class _BinaryWriter {
  69038. /**
  69039. * Array buffer which stores all binary data
  69040. */
  69041. private _arrayBuffer;
  69042. /**
  69043. * View of the array buffer
  69044. */
  69045. private _dataView;
  69046. /**
  69047. * byte offset of data in array buffer
  69048. */
  69049. private _byteOffset;
  69050. /**
  69051. * Initialize binary writer with an initial byte length
  69052. * @param byteLength Initial byte length of the array buffer
  69053. */
  69054. constructor(byteLength: number);
  69055. /**
  69056. * Resize the array buffer to the specified byte length
  69057. * @param byteLength
  69058. */
  69059. private resizeBuffer;
  69060. /**
  69061. * Get an array buffer with the length of the byte offset
  69062. * @returns ArrayBuffer resized to the byte offset
  69063. */
  69064. getArrayBuffer(): ArrayBuffer;
  69065. /**
  69066. * Get the byte offset of the array buffer
  69067. * @returns byte offset
  69068. */
  69069. getByteOffset(): number;
  69070. /**
  69071. * Stores an UInt8 in the array buffer
  69072. * @param entry
  69073. * @param byteOffset If defined, specifies where to set the value as an offset.
  69074. */
  69075. setUInt8(entry: number, byteOffset?: number): void;
  69076. /**
  69077. * Gets an UInt32 in the array buffer
  69078. * @param entry
  69079. * @param byteOffset If defined, specifies where to set the value as an offset.
  69080. */
  69081. getUInt32(byteOffset: number): number;
  69082. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  69083. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  69084. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  69085. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  69086. /**
  69087. * Stores a Float32 in the array buffer
  69088. * @param entry
  69089. */
  69090. setFloat32(entry: number, byteOffset?: number): void;
  69091. /**
  69092. * Stores an UInt32 in the array buffer
  69093. * @param entry
  69094. * @param byteOffset If defined, specifies where to set the value as an offset.
  69095. */
  69096. setUInt32(entry: number, byteOffset?: number): void;
  69097. }
  69098. }
  69099. declare module BABYLON.GLTF2.Exporter {
  69100. /**
  69101. * @hidden
  69102. * Interface to store animation data.
  69103. */
  69104. export interface _IAnimationData {
  69105. /**
  69106. * Keyframe data.
  69107. */
  69108. inputs: number[];
  69109. /**
  69110. * Value data.
  69111. */
  69112. outputs: number[][];
  69113. /**
  69114. * Animation interpolation data.
  69115. */
  69116. samplerInterpolation: AnimationSamplerInterpolation;
  69117. /**
  69118. * Minimum keyframe value.
  69119. */
  69120. inputsMin: number;
  69121. /**
  69122. * Maximum keyframe value.
  69123. */
  69124. inputsMax: number;
  69125. }
  69126. /**
  69127. * @hidden
  69128. */
  69129. export interface _IAnimationInfo {
  69130. /**
  69131. * The target channel for the animation
  69132. */
  69133. animationChannelTargetPath: AnimationChannelTargetPath;
  69134. /**
  69135. * The glTF accessor type for the data.
  69136. */
  69137. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  69138. /**
  69139. * Specifies if quaternions should be used.
  69140. */
  69141. useQuaternion: boolean;
  69142. }
  69143. /**
  69144. * @hidden
  69145. * Utility class for generating glTF animation data from BabylonJS.
  69146. */
  69147. export class _GLTFAnimation {
  69148. /**
  69149. * @ignore
  69150. *
  69151. * Creates glTF channel animation from BabylonJS animation.
  69152. * @param babylonTransformNode - BabylonJS mesh.
  69153. * @param animation - animation.
  69154. * @param animationChannelTargetPath - The target animation channel.
  69155. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  69156. * @param useQuaternion - Specifies if quaternions are used.
  69157. * @returns nullable IAnimationData
  69158. */
  69159. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  69160. private static _DeduceAnimationInfo;
  69161. /**
  69162. * @ignore
  69163. * Create node animations from the transform node animations
  69164. * @param babylonNode
  69165. * @param runtimeGLTFAnimation
  69166. * @param idleGLTFAnimations
  69167. * @param nodeMap
  69168. * @param nodes
  69169. * @param binaryWriter
  69170. * @param bufferViews
  69171. * @param accessors
  69172. * @param convertToRightHandedSystem
  69173. */
  69174. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  69175. [key: number]: number;
  69176. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  69177. /**
  69178. * @ignore
  69179. * Create node animations from the animation groups
  69180. * @param babylonScene
  69181. * @param glTFAnimations
  69182. * @param nodeMap
  69183. * @param nodes
  69184. * @param binaryWriter
  69185. * @param bufferViews
  69186. * @param accessors
  69187. * @param convertToRightHandedSystem
  69188. */
  69189. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  69190. [key: number]: number;
  69191. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  69192. private static AddAnimation;
  69193. /**
  69194. * Create a baked animation
  69195. * @param babylonTransformNode BabylonJS mesh
  69196. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  69197. * @param animationChannelTargetPath animation target channel
  69198. * @param minFrame minimum animation frame
  69199. * @param maxFrame maximum animation frame
  69200. * @param fps frames per second of the animation
  69201. * @param inputs input key frames of the animation
  69202. * @param outputs output key frame data of the animation
  69203. * @param convertToRightHandedSystem converts the values to right-handed
  69204. * @param useQuaternion specifies if quaternions should be used
  69205. */
  69206. private static _CreateBakedAnimation;
  69207. private static _ConvertFactorToVector3OrQuaternion;
  69208. private static _SetInterpolatedValue;
  69209. /**
  69210. * Creates linear animation from the animation key frames
  69211. * @param babylonTransformNode BabylonJS mesh
  69212. * @param animation BabylonJS animation
  69213. * @param animationChannelTargetPath The target animation channel
  69214. * @param frameDelta The difference between the last and first frame of the animation
  69215. * @param inputs Array to store the key frame times
  69216. * @param outputs Array to store the key frame data
  69217. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  69218. * @param useQuaternion Specifies if quaternions are used in the animation
  69219. */
  69220. private static _CreateLinearOrStepAnimation;
  69221. /**
  69222. * Creates cubic spline animation from the animation key frames
  69223. * @param babylonTransformNode BabylonJS mesh
  69224. * @param animation BabylonJS animation
  69225. * @param animationChannelTargetPath The target animation channel
  69226. * @param frameDelta The difference between the last and first frame of the animation
  69227. * @param inputs Array to store the key frame times
  69228. * @param outputs Array to store the key frame data
  69229. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  69230. * @param useQuaternion Specifies if quaternions are used in the animation
  69231. */
  69232. private static _CreateCubicSplineAnimation;
  69233. private static _GetBasePositionRotationOrScale;
  69234. /**
  69235. * Adds a key frame value
  69236. * @param keyFrame
  69237. * @param animation
  69238. * @param outputs
  69239. * @param animationChannelTargetPath
  69240. * @param basePositionRotationOrScale
  69241. * @param convertToRightHandedSystem
  69242. * @param useQuaternion
  69243. */
  69244. private static _AddKeyframeValue;
  69245. /**
  69246. * Determine the interpolation based on the key frames
  69247. * @param keyFrames
  69248. * @param animationChannelTargetPath
  69249. * @param useQuaternion
  69250. */
  69251. private static _DeduceInterpolation;
  69252. /**
  69253. * Adds an input tangent or output tangent to the output data
  69254. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  69255. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  69256. * @param outputs The animation data by keyframe
  69257. * @param animationChannelTargetPath The target animation channel
  69258. * @param interpolation The interpolation type
  69259. * @param keyFrame The key frame with the animation data
  69260. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  69261. * @param useQuaternion Specifies if quaternions are used
  69262. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  69263. */
  69264. private static AddSplineTangent;
  69265. /**
  69266. * Get the minimum and maximum key frames' frame values
  69267. * @param keyFrames animation key frames
  69268. * @returns the minimum and maximum key frame value
  69269. */
  69270. private static calculateMinMaxKeyFrames;
  69271. }
  69272. }
  69273. declare module BABYLON.GLTF2.Exporter {
  69274. /** @hidden */
  69275. export var textureTransformPixelShader: {
  69276. name: string;
  69277. shader: string;
  69278. };
  69279. }
  69280. declare module BABYLON.GLTF2.Exporter.Extensions {
  69281. /**
  69282. * @hidden
  69283. */
  69284. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  69285. /** Name of this extension */
  69286. readonly name: string;
  69287. /** Defines whether this extension is enabled */
  69288. enabled: boolean;
  69289. /** Defines whether this extension is required */
  69290. required: boolean;
  69291. /** Reference to the glTF exporter */
  69292. private _exporter;
  69293. constructor(exporter: _Exporter);
  69294. dispose(): void;
  69295. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  69296. /**
  69297. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  69298. * @param babylonTexture
  69299. * @param offset
  69300. * @param rotation
  69301. * @param scale
  69302. * @param scene
  69303. */
  69304. private _textureTransformTextureAsync;
  69305. }
  69306. }
  69307. declare module BABYLON.GLTF2.Exporter.Extensions {
  69308. /**
  69309. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  69310. */
  69311. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  69312. /** The name of this extension. */
  69313. readonly name: string;
  69314. /** Defines whether this extension is enabled. */
  69315. enabled: boolean;
  69316. /** Defines whether this extension is required */
  69317. required: boolean;
  69318. /** Reference to the glTF exporter */
  69319. private _exporter;
  69320. private _lights;
  69321. /** @hidden */
  69322. constructor(exporter: _Exporter);
  69323. /** @hidden */
  69324. dispose(): void;
  69325. /** @hidden */
  69326. onExporting(): void;
  69327. /**
  69328. * Define this method to modify the default behavior when exporting a node
  69329. * @param context The context when exporting the node
  69330. * @param node glTF node
  69331. * @param babylonNode BabylonJS node
  69332. * @returns nullable INode promise
  69333. */
  69334. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  69335. }
  69336. }
  69337. declare module BABYLON {
  69338. /**
  69339. * Class for generating STL data from a Babylon scene.
  69340. */
  69341. export class STLExport {
  69342. /**
  69343. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  69344. * @param meshes list defines the mesh to serialize
  69345. * @param download triggers the automatic download of the file.
  69346. * @param fileName changes the downloads fileName.
  69347. * @param binary changes the STL to a binary type.
  69348. * @param isLittleEndian toggle for binary type exporter.
  69349. * @returns the STL as UTF8 string
  69350. */
  69351. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  69352. }
  69353. }
  69354. /**
  69355. * @ignoreChildren
  69356. * @ignore
  69357. */
  69358. declare module "babylonjs-gltf2interface" {
  69359. export = BABYLON.GLTF2;
  69360. }
  69361. /**
  69362. * Module for glTF 2.0 Interface
  69363. * @ignoreChildren
  69364. * @ignore
  69365. */
  69366. declare module BABYLON.GLTF2 {
  69367. /**
  69368. * The datatype of the components in the attribute
  69369. */
  69370. const enum AccessorComponentType {
  69371. /**
  69372. * Byte
  69373. */
  69374. BYTE = 5120,
  69375. /**
  69376. * Unsigned Byte
  69377. */
  69378. UNSIGNED_BYTE = 5121,
  69379. /**
  69380. * Short
  69381. */
  69382. SHORT = 5122,
  69383. /**
  69384. * Unsigned Short
  69385. */
  69386. UNSIGNED_SHORT = 5123,
  69387. /**
  69388. * Unsigned Int
  69389. */
  69390. UNSIGNED_INT = 5125,
  69391. /**
  69392. * Float
  69393. */
  69394. FLOAT = 5126,
  69395. }
  69396. /**
  69397. * Specifies if the attirbute is a scalar, vector, or matrix
  69398. */
  69399. const enum AccessorType {
  69400. /**
  69401. * Scalar
  69402. */
  69403. SCALAR = "SCALAR",
  69404. /**
  69405. * Vector2
  69406. */
  69407. VEC2 = "VEC2",
  69408. /**
  69409. * Vector3
  69410. */
  69411. VEC3 = "VEC3",
  69412. /**
  69413. * Vector4
  69414. */
  69415. VEC4 = "VEC4",
  69416. /**
  69417. * Matrix2x2
  69418. */
  69419. MAT2 = "MAT2",
  69420. /**
  69421. * Matrix3x3
  69422. */
  69423. MAT3 = "MAT3",
  69424. /**
  69425. * Matrix4x4
  69426. */
  69427. MAT4 = "MAT4",
  69428. }
  69429. /**
  69430. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  69431. */
  69432. const enum AnimationChannelTargetPath {
  69433. /**
  69434. * Translation
  69435. */
  69436. TRANSLATION = "translation",
  69437. /**
  69438. * Rotation
  69439. */
  69440. ROTATION = "rotation",
  69441. /**
  69442. * Scale
  69443. */
  69444. SCALE = "scale",
  69445. /**
  69446. * Weights
  69447. */
  69448. WEIGHTS = "weights",
  69449. }
  69450. /**
  69451. * Interpolation algorithm
  69452. */
  69453. const enum AnimationSamplerInterpolation {
  69454. /**
  69455. * The animated values are linearly interpolated between keyframes
  69456. */
  69457. LINEAR = "LINEAR",
  69458. /**
  69459. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  69460. */
  69461. STEP = "STEP",
  69462. /**
  69463. * The animation's interpolation is computed using a cubic spline with specified tangents
  69464. */
  69465. CUBICSPLINE = "CUBICSPLINE",
  69466. }
  69467. /**
  69468. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  69469. */
  69470. const enum CameraType {
  69471. /**
  69472. * A perspective camera containing properties to create a perspective projection matrix
  69473. */
  69474. PERSPECTIVE = "perspective",
  69475. /**
  69476. * An orthographic camera containing properties to create an orthographic projection matrix
  69477. */
  69478. ORTHOGRAPHIC = "orthographic",
  69479. }
  69480. /**
  69481. * The mime-type of the image
  69482. */
  69483. const enum ImageMimeType {
  69484. /**
  69485. * JPEG Mime-type
  69486. */
  69487. JPEG = "image/jpeg",
  69488. /**
  69489. * PNG Mime-type
  69490. */
  69491. PNG = "image/png",
  69492. }
  69493. /**
  69494. * The alpha rendering mode of the material
  69495. */
  69496. const enum MaterialAlphaMode {
  69497. /**
  69498. * The alpha value is ignored and the rendered output is fully opaque
  69499. */
  69500. OPAQUE = "OPAQUE",
  69501. /**
  69502. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  69503. */
  69504. MASK = "MASK",
  69505. /**
  69506. * 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)
  69507. */
  69508. BLEND = "BLEND",
  69509. }
  69510. /**
  69511. * The type of the primitives to render
  69512. */
  69513. const enum MeshPrimitiveMode {
  69514. /**
  69515. * Points
  69516. */
  69517. POINTS = 0,
  69518. /**
  69519. * Lines
  69520. */
  69521. LINES = 1,
  69522. /**
  69523. * Line Loop
  69524. */
  69525. LINE_LOOP = 2,
  69526. /**
  69527. * Line Strip
  69528. */
  69529. LINE_STRIP = 3,
  69530. /**
  69531. * Triangles
  69532. */
  69533. TRIANGLES = 4,
  69534. /**
  69535. * Triangle Strip
  69536. */
  69537. TRIANGLE_STRIP = 5,
  69538. /**
  69539. * Triangle Fan
  69540. */
  69541. TRIANGLE_FAN = 6,
  69542. }
  69543. /**
  69544. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  69545. */
  69546. const enum TextureMagFilter {
  69547. /**
  69548. * Nearest
  69549. */
  69550. NEAREST = 9728,
  69551. /**
  69552. * Linear
  69553. */
  69554. LINEAR = 9729,
  69555. }
  69556. /**
  69557. * Minification filter. All valid values correspond to WebGL enums
  69558. */
  69559. const enum TextureMinFilter {
  69560. /**
  69561. * Nearest
  69562. */
  69563. NEAREST = 9728,
  69564. /**
  69565. * Linear
  69566. */
  69567. LINEAR = 9729,
  69568. /**
  69569. * Nearest Mip-Map Nearest
  69570. */
  69571. NEAREST_MIPMAP_NEAREST = 9984,
  69572. /**
  69573. * Linear Mipmap Nearest
  69574. */
  69575. LINEAR_MIPMAP_NEAREST = 9985,
  69576. /**
  69577. * Nearest Mipmap Linear
  69578. */
  69579. NEAREST_MIPMAP_LINEAR = 9986,
  69580. /**
  69581. * Linear Mipmap Linear
  69582. */
  69583. LINEAR_MIPMAP_LINEAR = 9987,
  69584. }
  69585. /**
  69586. * S (U) wrapping mode. All valid values correspond to WebGL enums
  69587. */
  69588. const enum TextureWrapMode {
  69589. /**
  69590. * Clamp to Edge
  69591. */
  69592. CLAMP_TO_EDGE = 33071,
  69593. /**
  69594. * Mirrored Repeat
  69595. */
  69596. MIRRORED_REPEAT = 33648,
  69597. /**
  69598. * Repeat
  69599. */
  69600. REPEAT = 10497,
  69601. }
  69602. /**
  69603. * glTF Property
  69604. */
  69605. interface IProperty {
  69606. /**
  69607. * Dictionary object with extension-specific objects
  69608. */
  69609. extensions?: {
  69610. [key: string]: any;
  69611. };
  69612. /**
  69613. * Application-Specific data
  69614. */
  69615. extras?: any;
  69616. }
  69617. /**
  69618. * glTF Child of Root Property
  69619. */
  69620. interface IChildRootProperty extends IProperty {
  69621. /**
  69622. * The user-defined name of this object
  69623. */
  69624. name?: string;
  69625. }
  69626. /**
  69627. * Indices of those attributes that deviate from their initialization value
  69628. */
  69629. interface IAccessorSparseIndices extends IProperty {
  69630. /**
  69631. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  69632. */
  69633. bufferView: number;
  69634. /**
  69635. * The offset relative to the start of the bufferView in bytes. Must be aligned
  69636. */
  69637. byteOffset?: number;
  69638. /**
  69639. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  69640. */
  69641. componentType: AccessorComponentType;
  69642. }
  69643. /**
  69644. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  69645. */
  69646. interface IAccessorSparseValues extends IProperty {
  69647. /**
  69648. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  69649. */
  69650. bufferView: number;
  69651. /**
  69652. * The offset relative to the start of the bufferView in bytes. Must be aligned
  69653. */
  69654. byteOffset?: number;
  69655. }
  69656. /**
  69657. * Sparse storage of attributes that deviate from their initialization value
  69658. */
  69659. interface IAccessorSparse extends IProperty {
  69660. /**
  69661. * The number of attributes encoded in this sparse accessor
  69662. */
  69663. count: number;
  69664. /**
  69665. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  69666. */
  69667. indices: IAccessorSparseIndices;
  69668. /**
  69669. * 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
  69670. */
  69671. values: IAccessorSparseValues;
  69672. }
  69673. /**
  69674. * 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
  69675. */
  69676. interface IAccessor extends IChildRootProperty {
  69677. /**
  69678. * The index of the bufferview
  69679. */
  69680. bufferView?: number;
  69681. /**
  69682. * The offset relative to the start of the bufferView in bytes
  69683. */
  69684. byteOffset?: number;
  69685. /**
  69686. * The datatype of components in the attribute
  69687. */
  69688. componentType: AccessorComponentType;
  69689. /**
  69690. * Specifies whether integer data values should be normalized
  69691. */
  69692. normalized?: boolean;
  69693. /**
  69694. * The number of attributes referenced by this accessor
  69695. */
  69696. count: number;
  69697. /**
  69698. * Specifies if the attribute is a scalar, vector, or matrix
  69699. */
  69700. type: AccessorType;
  69701. /**
  69702. * Maximum value of each component in this attribute
  69703. */
  69704. max?: number[];
  69705. /**
  69706. * Minimum value of each component in this attribute
  69707. */
  69708. min?: number[];
  69709. /**
  69710. * Sparse storage of attributes that deviate from their initialization value
  69711. */
  69712. sparse?: IAccessorSparse;
  69713. }
  69714. /**
  69715. * Targets an animation's sampler at a node's property
  69716. */
  69717. interface IAnimationChannel extends IProperty {
  69718. /**
  69719. * The index of a sampler in this animation used to compute the value for the target
  69720. */
  69721. sampler: number;
  69722. /**
  69723. * The index of the node and TRS property to target
  69724. */
  69725. target: IAnimationChannelTarget;
  69726. }
  69727. /**
  69728. * The index of the node and TRS property that an animation channel targets
  69729. */
  69730. interface IAnimationChannelTarget extends IProperty {
  69731. /**
  69732. * The index of the node to target
  69733. */
  69734. node: number;
  69735. /**
  69736. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  69737. */
  69738. path: AnimationChannelTargetPath;
  69739. }
  69740. /**
  69741. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  69742. */
  69743. interface IAnimationSampler extends IProperty {
  69744. /**
  69745. * The index of an accessor containing keyframe input values, e.g., time
  69746. */
  69747. input: number;
  69748. /**
  69749. * Interpolation algorithm
  69750. */
  69751. interpolation?: AnimationSamplerInterpolation;
  69752. /**
  69753. * The index of an accessor, containing keyframe output values
  69754. */
  69755. output: number;
  69756. }
  69757. /**
  69758. * A keyframe animation
  69759. */
  69760. interface IAnimation extends IChildRootProperty {
  69761. /**
  69762. * An array of channels, each of which targets an animation's sampler at a node's property
  69763. */
  69764. channels: IAnimationChannel[];
  69765. /**
  69766. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  69767. */
  69768. samplers: IAnimationSampler[];
  69769. }
  69770. /**
  69771. * Metadata about the glTF asset
  69772. */
  69773. interface IAsset extends IChildRootProperty {
  69774. /**
  69775. * A copyright message suitable for display to credit the content creator
  69776. */
  69777. copyright?: string;
  69778. /**
  69779. * Tool that generated this glTF model. Useful for debugging
  69780. */
  69781. generator?: string;
  69782. /**
  69783. * The glTF version that this asset targets
  69784. */
  69785. version: string;
  69786. /**
  69787. * The minimum glTF version that this asset targets
  69788. */
  69789. minVersion?: string;
  69790. }
  69791. /**
  69792. * A buffer points to binary geometry, animation, or skins
  69793. */
  69794. interface IBuffer extends IChildRootProperty {
  69795. /**
  69796. * 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
  69797. */
  69798. uri?: string;
  69799. /**
  69800. * The length of the buffer in bytes
  69801. */
  69802. byteLength: number;
  69803. }
  69804. /**
  69805. * A view into a buffer generally representing a subset of the buffer
  69806. */
  69807. interface IBufferView extends IChildRootProperty {
  69808. /**
  69809. * The index of the buffer
  69810. */
  69811. buffer: number;
  69812. /**
  69813. * The offset into the buffer in bytes
  69814. */
  69815. byteOffset?: number;
  69816. /**
  69817. * The lenth of the bufferView in bytes
  69818. */
  69819. byteLength: number;
  69820. /**
  69821. * The stride, in bytes
  69822. */
  69823. byteStride?: number;
  69824. }
  69825. /**
  69826. * An orthographic camera containing properties to create an orthographic projection matrix
  69827. */
  69828. interface ICameraOrthographic extends IProperty {
  69829. /**
  69830. * The floating-point horizontal magnification of the view. Must not be zero
  69831. */
  69832. xmag: number;
  69833. /**
  69834. * The floating-point vertical magnification of the view. Must not be zero
  69835. */
  69836. ymag: number;
  69837. /**
  69838. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  69839. */
  69840. zfar: number;
  69841. /**
  69842. * The floating-point distance to the near clipping plane
  69843. */
  69844. znear: number;
  69845. }
  69846. /**
  69847. * A perspective camera containing properties to create a perspective projection matrix
  69848. */
  69849. interface ICameraPerspective extends IProperty {
  69850. /**
  69851. * The floating-point aspect ratio of the field of view
  69852. */
  69853. aspectRatio?: number;
  69854. /**
  69855. * The floating-point vertical field of view in radians
  69856. */
  69857. yfov: number;
  69858. /**
  69859. * The floating-point distance to the far clipping plane
  69860. */
  69861. zfar?: number;
  69862. /**
  69863. * The floating-point distance to the near clipping plane
  69864. */
  69865. znear: number;
  69866. }
  69867. /**
  69868. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  69869. */
  69870. interface ICamera extends IChildRootProperty {
  69871. /**
  69872. * An orthographic camera containing properties to create an orthographic projection matrix
  69873. */
  69874. orthographic?: ICameraOrthographic;
  69875. /**
  69876. * A perspective camera containing properties to create a perspective projection matrix
  69877. */
  69878. perspective?: ICameraPerspective;
  69879. /**
  69880. * Specifies if the camera uses a perspective or orthographic projection
  69881. */
  69882. type: CameraType;
  69883. }
  69884. /**
  69885. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  69886. */
  69887. interface IImage extends IChildRootProperty {
  69888. /**
  69889. * 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
  69890. */
  69891. uri?: string;
  69892. /**
  69893. * The image's MIME type
  69894. */
  69895. mimeType?: ImageMimeType;
  69896. /**
  69897. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  69898. */
  69899. bufferView?: number;
  69900. }
  69901. /**
  69902. * Material Normal Texture Info
  69903. */
  69904. interface IMaterialNormalTextureInfo extends ITextureInfo {
  69905. /**
  69906. * The scalar multiplier applied to each normal vector of the normal texture
  69907. */
  69908. scale?: number;
  69909. }
  69910. /**
  69911. * Material Occlusion Texture Info
  69912. */
  69913. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  69914. /**
  69915. * A scalar multiplier controlling the amount of occlusion applied
  69916. */
  69917. strength?: number;
  69918. }
  69919. /**
  69920. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  69921. */
  69922. interface IMaterialPbrMetallicRoughness {
  69923. /**
  69924. * The material's base color factor
  69925. */
  69926. baseColorFactor?: number[];
  69927. /**
  69928. * The base color texture
  69929. */
  69930. baseColorTexture?: ITextureInfo;
  69931. /**
  69932. * The metalness of the material
  69933. */
  69934. metallicFactor?: number;
  69935. /**
  69936. * The roughness of the material
  69937. */
  69938. roughnessFactor?: number;
  69939. /**
  69940. * The metallic-roughness texture
  69941. */
  69942. metallicRoughnessTexture?: ITextureInfo;
  69943. }
  69944. /**
  69945. * The material appearance of a primitive
  69946. */
  69947. interface IMaterial extends IChildRootProperty {
  69948. /**
  69949. * 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
  69950. */
  69951. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  69952. /**
  69953. * The normal map texture
  69954. */
  69955. normalTexture?: IMaterialNormalTextureInfo;
  69956. /**
  69957. * The occlusion map texture
  69958. */
  69959. occlusionTexture?: IMaterialOcclusionTextureInfo;
  69960. /**
  69961. * The emissive map texture
  69962. */
  69963. emissiveTexture?: ITextureInfo;
  69964. /**
  69965. * 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
  69966. */
  69967. emissiveFactor?: number[];
  69968. /**
  69969. * The alpha rendering mode of the material
  69970. */
  69971. alphaMode?: MaterialAlphaMode;
  69972. /**
  69973. * The alpha cutoff value of the material
  69974. */
  69975. alphaCutoff?: number;
  69976. /**
  69977. * Specifies whether the material is double sided
  69978. */
  69979. doubleSided?: boolean;
  69980. }
  69981. /**
  69982. * Geometry to be rendered with the given material
  69983. */
  69984. interface IMeshPrimitive extends IProperty {
  69985. /**
  69986. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  69987. */
  69988. attributes: {
  69989. [name: string]: number;
  69990. };
  69991. /**
  69992. * The index of the accessor that contains the indices
  69993. */
  69994. indices?: number;
  69995. /**
  69996. * The index of the material to apply to this primitive when rendering
  69997. */
  69998. material?: number;
  69999. /**
  70000. * The type of primitives to render. All valid values correspond to WebGL enums
  70001. */
  70002. mode?: MeshPrimitiveMode;
  70003. /**
  70004. * 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
  70005. */
  70006. targets?: {
  70007. [name: string]: number;
  70008. }[];
  70009. }
  70010. /**
  70011. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  70012. */
  70013. interface IMesh extends IChildRootProperty {
  70014. /**
  70015. * An array of primitives, each defining geometry to be rendered with a material
  70016. */
  70017. primitives: IMeshPrimitive[];
  70018. /**
  70019. * Array of weights to be applied to the Morph Targets
  70020. */
  70021. weights?: number[];
  70022. }
  70023. /**
  70024. * A node in the node hierarchy
  70025. */
  70026. interface INode extends IChildRootProperty {
  70027. /**
  70028. * The index of the camera referenced by this node
  70029. */
  70030. camera?: number;
  70031. /**
  70032. * The indices of this node's children
  70033. */
  70034. children?: number[];
  70035. /**
  70036. * The index of the skin referenced by this node
  70037. */
  70038. skin?: number;
  70039. /**
  70040. * A floating-point 4x4 transformation matrix stored in column-major order
  70041. */
  70042. matrix?: number[];
  70043. /**
  70044. * The index of the mesh in this node
  70045. */
  70046. mesh?: number;
  70047. /**
  70048. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  70049. */
  70050. rotation?: number[];
  70051. /**
  70052. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  70053. */
  70054. scale?: number[];
  70055. /**
  70056. * The node's translation along the x, y, and z axes
  70057. */
  70058. translation?: number[];
  70059. /**
  70060. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  70061. */
  70062. weights?: number[];
  70063. }
  70064. /**
  70065. * Texture sampler properties for filtering and wrapping modes
  70066. */
  70067. interface ISampler extends IChildRootProperty {
  70068. /**
  70069. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  70070. */
  70071. magFilter?: TextureMagFilter;
  70072. /**
  70073. * Minification filter. All valid values correspond to WebGL enums
  70074. */
  70075. minFilter?: TextureMinFilter;
  70076. /**
  70077. * S (U) wrapping mode. All valid values correspond to WebGL enums
  70078. */
  70079. wrapS?: TextureWrapMode;
  70080. /**
  70081. * T (V) wrapping mode. All valid values correspond to WebGL enums
  70082. */
  70083. wrapT?: TextureWrapMode;
  70084. }
  70085. /**
  70086. * The root nodes of a scene
  70087. */
  70088. interface IScene extends IChildRootProperty {
  70089. /**
  70090. * The indices of each root node
  70091. */
  70092. nodes: number[];
  70093. }
  70094. /**
  70095. * Joints and matrices defining a skin
  70096. */
  70097. interface ISkin extends IChildRootProperty {
  70098. /**
  70099. * 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
  70100. */
  70101. inverseBindMatrices?: number;
  70102. /**
  70103. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  70104. */
  70105. skeleton?: number;
  70106. /**
  70107. * 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)
  70108. */
  70109. joints: number[];
  70110. }
  70111. /**
  70112. * A texture and its sampler
  70113. */
  70114. interface ITexture extends IChildRootProperty {
  70115. /**
  70116. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  70117. */
  70118. sampler?: number;
  70119. /**
  70120. * The index of the image used by this texture
  70121. */
  70122. source: number;
  70123. }
  70124. /**
  70125. * Reference to a texture
  70126. */
  70127. interface ITextureInfo extends IProperty {
  70128. /**
  70129. * The index of the texture
  70130. */
  70131. index: number;
  70132. /**
  70133. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  70134. */
  70135. texCoord?: number;
  70136. }
  70137. /**
  70138. * The root object for a glTF asset
  70139. */
  70140. interface IGLTF extends IProperty {
  70141. /**
  70142. * An array of accessors. An accessor is a typed view into a bufferView
  70143. */
  70144. accessors?: IAccessor[];
  70145. /**
  70146. * An array of keyframe animations
  70147. */
  70148. animations?: IAnimation[];
  70149. /**
  70150. * Metadata about the glTF asset
  70151. */
  70152. asset: IAsset;
  70153. /**
  70154. * An array of buffers. A buffer points to binary geometry, animation, or skins
  70155. */
  70156. buffers?: IBuffer[];
  70157. /**
  70158. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  70159. */
  70160. bufferViews?: IBufferView[];
  70161. /**
  70162. * An array of cameras
  70163. */
  70164. cameras?: ICamera[];
  70165. /**
  70166. * Names of glTF extensions used somewhere in this asset
  70167. */
  70168. extensionsUsed?: string[];
  70169. /**
  70170. * Names of glTF extensions required to properly load this asset
  70171. */
  70172. extensionsRequired?: string[];
  70173. /**
  70174. * An array of images. An image defines data used to create a texture
  70175. */
  70176. images?: IImage[];
  70177. /**
  70178. * An array of materials. A material defines the appearance of a primitive
  70179. */
  70180. materials?: IMaterial[];
  70181. /**
  70182. * An array of meshes. A mesh is a set of primitives to be rendered
  70183. */
  70184. meshes?: IMesh[];
  70185. /**
  70186. * An array of nodes
  70187. */
  70188. nodes?: INode[];
  70189. /**
  70190. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  70191. */
  70192. samplers?: ISampler[];
  70193. /**
  70194. * The index of the default scene
  70195. */
  70196. scene?: number;
  70197. /**
  70198. * An array of scenes
  70199. */
  70200. scenes?: IScene[];
  70201. /**
  70202. * An array of skins. A skin is defined by joints and matrices
  70203. */
  70204. skins?: ISkin[];
  70205. /**
  70206. * An array of textures
  70207. */
  70208. textures?: ITexture[];
  70209. }
  70210. /**
  70211. * The glTF validation results
  70212. */
  70213. interface IGLTFValidationResults {
  70214. info: {
  70215. generator: string;
  70216. hasAnimations: boolean;
  70217. hasDefaultScene: boolean;
  70218. hasMaterials: boolean;
  70219. hasMorphTargets: boolean;
  70220. hasSkins: boolean;
  70221. hasTextures: boolean;
  70222. maxAttributesUsed: number;
  70223. primitivesCount: number
  70224. };
  70225. issues: {
  70226. messages: Array<string>;
  70227. numErrors: number;
  70228. numHints: number;
  70229. numInfos: number;
  70230. numWarnings: number;
  70231. truncated: boolean
  70232. };
  70233. mimeType: string;
  70234. uri: string;
  70235. validatedAt: string;
  70236. validatorVersion: string;
  70237. }
  70238. /**
  70239. * The glTF validation options
  70240. */
  70241. interface IGLTFValidationOptions {
  70242. uri?: string;
  70243. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  70244. validateAccessorData?: boolean;
  70245. maxIssues?: number;
  70246. ignoredIssues?: Array<string>;
  70247. severityOverrides?: Object;
  70248. }
  70249. /**
  70250. * The glTF validator object
  70251. */
  70252. interface IGLTFValidator {
  70253. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  70254. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  70255. }
  70256. }
  70257. declare module BABYLON {
  70258. /** @hidden */
  70259. export var cellPixelShader: {
  70260. name: string;
  70261. shader: string;
  70262. };
  70263. }
  70264. declare module BABYLON {
  70265. /** @hidden */
  70266. export var cellVertexShader: {
  70267. name: string;
  70268. shader: string;
  70269. };
  70270. }
  70271. declare module BABYLON {
  70272. export class CellMaterial extends BABYLON.PushMaterial {
  70273. private _diffuseTexture;
  70274. diffuseTexture: BABYLON.BaseTexture;
  70275. diffuseColor: BABYLON.Color3;
  70276. _computeHighLevel: boolean;
  70277. computeHighLevel: boolean;
  70278. private _disableLighting;
  70279. disableLighting: boolean;
  70280. private _maxSimultaneousLights;
  70281. maxSimultaneousLights: number;
  70282. private _renderId;
  70283. constructor(name: string, scene: BABYLON.Scene);
  70284. needAlphaBlending(): boolean;
  70285. needAlphaTesting(): boolean;
  70286. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70287. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70288. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70289. getAnimatables(): BABYLON.IAnimatable[];
  70290. getActiveTextures(): BABYLON.BaseTexture[];
  70291. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70292. dispose(forceDisposeEffect?: boolean): void;
  70293. getClassName(): string;
  70294. clone(name: string): CellMaterial;
  70295. serialize(): any;
  70296. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  70297. }
  70298. }
  70299. declare module BABYLON {
  70300. export class CustomShaderStructure {
  70301. FragmentStore: string;
  70302. VertexStore: string;
  70303. constructor();
  70304. }
  70305. export class ShaderSpecialParts {
  70306. constructor();
  70307. Fragment_Begin: string;
  70308. Fragment_Definitions: string;
  70309. Fragment_MainBegin: string;
  70310. Fragment_Custom_Diffuse: string;
  70311. Fragment_Before_Lights: string;
  70312. Fragment_Before_Fog: string;
  70313. Fragment_Custom_Alpha: string;
  70314. Fragment_Before_FragColor: string;
  70315. Vertex_Begin: string;
  70316. Vertex_Definitions: string;
  70317. Vertex_MainBegin: string;
  70318. Vertex_Before_PositionUpdated: string;
  70319. Vertex_Before_NormalUpdated: string;
  70320. Vertex_MainEnd: string;
  70321. }
  70322. export class CustomMaterial extends BABYLON.StandardMaterial {
  70323. static ShaderIndexer: number;
  70324. CustomParts: ShaderSpecialParts;
  70325. _isCreatedShader: boolean;
  70326. _createdShaderName: string;
  70327. _customUniform: string[];
  70328. _newUniforms: string[];
  70329. _newUniformInstances: any[];
  70330. _newSamplerInstances: BABYLON.Texture[];
  70331. FragmentShader: string;
  70332. VertexShader: string;
  70333. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  70334. ReviewUniform(name: string, arr: string[]): string[];
  70335. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  70336. constructor(name: string, scene: BABYLON.Scene);
  70337. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  70338. Fragment_Begin(shaderPart: string): CustomMaterial;
  70339. Fragment_Definitions(shaderPart: string): CustomMaterial;
  70340. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  70341. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  70342. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  70343. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  70344. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  70345. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  70346. Vertex_Begin(shaderPart: string): CustomMaterial;
  70347. Vertex_Definitions(shaderPart: string): CustomMaterial;
  70348. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  70349. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  70350. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  70351. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  70352. }
  70353. }
  70354. declare module BABYLON {
  70355. export class ShaderAlebdoParts {
  70356. constructor();
  70357. Fragment_Begin: string;
  70358. Fragment_Definitions: string;
  70359. Fragment_MainBegin: string;
  70360. Fragment_Custom_Albedo: string;
  70361. Fragment_Before_Lights: string;
  70362. Fragment_Custom_MetallicRoughness: string;
  70363. Fragment_Custom_MicroSurface: string;
  70364. Fragment_Before_Fog: string;
  70365. Fragment_Custom_Alpha: string;
  70366. Fragment_Before_FragColor: string;
  70367. Vertex_Begin: string;
  70368. Vertex_Definitions: string;
  70369. Vertex_MainBegin: string;
  70370. Vertex_Before_PositionUpdated: string;
  70371. Vertex_Before_NormalUpdated: string;
  70372. Vertex_MainEnd: string;
  70373. }
  70374. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  70375. static ShaderIndexer: number;
  70376. CustomParts: ShaderAlebdoParts;
  70377. _isCreatedShader: boolean;
  70378. _createdShaderName: string;
  70379. _customUniform: string[];
  70380. _newUniforms: string[];
  70381. _newUniformInstances: any[];
  70382. _newSamplerInstances: BABYLON.Texture[];
  70383. FragmentShader: string;
  70384. VertexShader: string;
  70385. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  70386. ReviewUniform(name: string, arr: string[]): string[];
  70387. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  70388. constructor(name: string, scene: BABYLON.Scene);
  70389. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  70390. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  70391. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  70392. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  70393. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  70394. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  70395. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  70396. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  70397. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  70398. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  70399. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  70400. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  70401. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  70402. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  70403. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  70404. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  70405. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  70406. }
  70407. }
  70408. declare module BABYLON {
  70409. /** @hidden */
  70410. export var firePixelShader: {
  70411. name: string;
  70412. shader: string;
  70413. };
  70414. }
  70415. declare module BABYLON {
  70416. /** @hidden */
  70417. export var fireVertexShader: {
  70418. name: string;
  70419. shader: string;
  70420. };
  70421. }
  70422. declare module BABYLON {
  70423. export class FireMaterial extends BABYLON.PushMaterial {
  70424. private _diffuseTexture;
  70425. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  70426. private _distortionTexture;
  70427. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  70428. private _opacityTexture;
  70429. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  70430. diffuseColor: BABYLON.Color3;
  70431. speed: number;
  70432. private _scaledDiffuse;
  70433. private _renderId;
  70434. private _lastTime;
  70435. constructor(name: string, scene: BABYLON.Scene);
  70436. needAlphaBlending(): boolean;
  70437. needAlphaTesting(): boolean;
  70438. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70439. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70440. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70441. getAnimatables(): BABYLON.IAnimatable[];
  70442. getActiveTextures(): BABYLON.BaseTexture[];
  70443. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70444. getClassName(): string;
  70445. dispose(forceDisposeEffect?: boolean): void;
  70446. clone(name: string): FireMaterial;
  70447. serialize(): any;
  70448. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  70449. }
  70450. }
  70451. declare module BABYLON {
  70452. /** @hidden */
  70453. export var furPixelShader: {
  70454. name: string;
  70455. shader: string;
  70456. };
  70457. }
  70458. declare module BABYLON {
  70459. /** @hidden */
  70460. export var furVertexShader: {
  70461. name: string;
  70462. shader: string;
  70463. };
  70464. }
  70465. declare module BABYLON {
  70466. export class FurMaterial extends BABYLON.PushMaterial {
  70467. private _diffuseTexture;
  70468. diffuseTexture: BABYLON.BaseTexture;
  70469. private _heightTexture;
  70470. heightTexture: BABYLON.BaseTexture;
  70471. diffuseColor: BABYLON.Color3;
  70472. furLength: number;
  70473. furAngle: number;
  70474. furColor: BABYLON.Color3;
  70475. furOffset: number;
  70476. furSpacing: number;
  70477. furGravity: BABYLON.Vector3;
  70478. furSpeed: number;
  70479. furDensity: number;
  70480. furOcclusion: number;
  70481. furTexture: BABYLON.DynamicTexture;
  70482. private _disableLighting;
  70483. disableLighting: boolean;
  70484. private _maxSimultaneousLights;
  70485. maxSimultaneousLights: number;
  70486. highLevelFur: boolean;
  70487. _meshes: BABYLON.AbstractMesh[];
  70488. private _renderId;
  70489. private _furTime;
  70490. constructor(name: string, scene: BABYLON.Scene);
  70491. furTime: number;
  70492. needAlphaBlending(): boolean;
  70493. needAlphaTesting(): boolean;
  70494. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70495. updateFur(): void;
  70496. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70497. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70498. getAnimatables(): BABYLON.IAnimatable[];
  70499. getActiveTextures(): BABYLON.BaseTexture[];
  70500. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70501. dispose(forceDisposeEffect?: boolean): void;
  70502. clone(name: string): FurMaterial;
  70503. serialize(): any;
  70504. getClassName(): string;
  70505. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  70506. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  70507. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  70508. }
  70509. }
  70510. declare module BABYLON {
  70511. /** @hidden */
  70512. export var gradientPixelShader: {
  70513. name: string;
  70514. shader: string;
  70515. };
  70516. }
  70517. declare module BABYLON {
  70518. /** @hidden */
  70519. export var gradientVertexShader: {
  70520. name: string;
  70521. shader: string;
  70522. };
  70523. }
  70524. declare module BABYLON {
  70525. export class GradientMaterial extends BABYLON.PushMaterial {
  70526. private _maxSimultaneousLights;
  70527. maxSimultaneousLights: number;
  70528. topColor: BABYLON.Color3;
  70529. topColorAlpha: number;
  70530. bottomColor: BABYLON.Color3;
  70531. bottomColorAlpha: number;
  70532. offset: number;
  70533. scale: number;
  70534. smoothness: number;
  70535. private _disableLighting;
  70536. disableLighting: boolean;
  70537. private _renderId;
  70538. constructor(name: string, scene: BABYLON.Scene);
  70539. needAlphaBlending(): boolean;
  70540. needAlphaTesting(): boolean;
  70541. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70542. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70543. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70544. getAnimatables(): BABYLON.IAnimatable[];
  70545. dispose(forceDisposeEffect?: boolean): void;
  70546. clone(name: string): GradientMaterial;
  70547. serialize(): any;
  70548. getClassName(): string;
  70549. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  70550. }
  70551. }
  70552. declare module BABYLON {
  70553. /** @hidden */
  70554. export var gridPixelShader: {
  70555. name: string;
  70556. shader: string;
  70557. };
  70558. }
  70559. declare module BABYLON {
  70560. /** @hidden */
  70561. export var gridVertexShader: {
  70562. name: string;
  70563. shader: string;
  70564. };
  70565. }
  70566. declare module BABYLON {
  70567. /**
  70568. * The grid materials allows you to wrap any shape with a grid.
  70569. * Colors are customizable.
  70570. */
  70571. export class GridMaterial extends BABYLON.PushMaterial {
  70572. /**
  70573. * Main color of the grid (e.g. between lines)
  70574. */
  70575. mainColor: BABYLON.Color3;
  70576. /**
  70577. * Color of the grid lines.
  70578. */
  70579. lineColor: BABYLON.Color3;
  70580. /**
  70581. * The scale of the grid compared to unit.
  70582. */
  70583. gridRatio: number;
  70584. /**
  70585. * Allows setting an offset for the grid lines.
  70586. */
  70587. gridOffset: BABYLON.Vector3;
  70588. /**
  70589. * The frequency of thicker lines.
  70590. */
  70591. majorUnitFrequency: number;
  70592. /**
  70593. * The visibility of minor units in the grid.
  70594. */
  70595. minorUnitVisibility: number;
  70596. /**
  70597. * The grid opacity outside of the lines.
  70598. */
  70599. opacity: number;
  70600. /**
  70601. * Determine RBG output is premultiplied by alpha value.
  70602. */
  70603. preMultiplyAlpha: boolean;
  70604. private _opacityTexture;
  70605. opacityTexture: BABYLON.BaseTexture;
  70606. private _gridControl;
  70607. private _renderId;
  70608. /**
  70609. * constructor
  70610. * @param name The name given to the material in order to identify it afterwards.
  70611. * @param scene The scene the material is used in.
  70612. */
  70613. constructor(name: string, scene: BABYLON.Scene);
  70614. /**
  70615. * Returns wehter or not the grid requires alpha blending.
  70616. */
  70617. needAlphaBlending(): boolean;
  70618. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  70619. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70620. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70621. /**
  70622. * Dispose the material and its associated resources.
  70623. * @param forceDisposeEffect will also dispose the used effect when true
  70624. */
  70625. dispose(forceDisposeEffect?: boolean): void;
  70626. clone(name: string): GridMaterial;
  70627. serialize(): any;
  70628. getClassName(): string;
  70629. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  70630. }
  70631. }
  70632. declare module BABYLON {
  70633. /** @hidden */
  70634. export var lavaPixelShader: {
  70635. name: string;
  70636. shader: string;
  70637. };
  70638. }
  70639. declare module BABYLON {
  70640. /** @hidden */
  70641. export var lavaVertexShader: {
  70642. name: string;
  70643. shader: string;
  70644. };
  70645. }
  70646. declare module BABYLON {
  70647. export class LavaMaterial extends BABYLON.PushMaterial {
  70648. private _diffuseTexture;
  70649. diffuseTexture: BABYLON.BaseTexture;
  70650. noiseTexture: BABYLON.BaseTexture;
  70651. fogColor: BABYLON.Color3;
  70652. speed: number;
  70653. movingSpeed: number;
  70654. lowFrequencySpeed: number;
  70655. fogDensity: number;
  70656. private _lastTime;
  70657. diffuseColor: BABYLON.Color3;
  70658. private _disableLighting;
  70659. disableLighting: boolean;
  70660. private _unlit;
  70661. unlit: boolean;
  70662. private _maxSimultaneousLights;
  70663. maxSimultaneousLights: number;
  70664. private _scaledDiffuse;
  70665. private _renderId;
  70666. constructor(name: string, scene: BABYLON.Scene);
  70667. needAlphaBlending(): boolean;
  70668. needAlphaTesting(): boolean;
  70669. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70670. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70671. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70672. getAnimatables(): BABYLON.IAnimatable[];
  70673. getActiveTextures(): BABYLON.BaseTexture[];
  70674. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70675. dispose(forceDisposeEffect?: boolean): void;
  70676. clone(name: string): LavaMaterial;
  70677. serialize(): any;
  70678. getClassName(): string;
  70679. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  70680. }
  70681. }
  70682. declare module BABYLON {
  70683. /** @hidden */
  70684. export var mixPixelShader: {
  70685. name: string;
  70686. shader: string;
  70687. };
  70688. }
  70689. declare module BABYLON {
  70690. /** @hidden */
  70691. export var mixVertexShader: {
  70692. name: string;
  70693. shader: string;
  70694. };
  70695. }
  70696. declare module BABYLON {
  70697. export class MixMaterial extends BABYLON.PushMaterial {
  70698. /**
  70699. * Mix textures
  70700. */
  70701. private _mixTexture1;
  70702. mixTexture1: BABYLON.BaseTexture;
  70703. private _mixTexture2;
  70704. mixTexture2: BABYLON.BaseTexture;
  70705. /**
  70706. * Diffuse textures
  70707. */
  70708. private _diffuseTexture1;
  70709. diffuseTexture1: BABYLON.Texture;
  70710. private _diffuseTexture2;
  70711. diffuseTexture2: BABYLON.Texture;
  70712. private _diffuseTexture3;
  70713. diffuseTexture3: BABYLON.Texture;
  70714. private _diffuseTexture4;
  70715. diffuseTexture4: BABYLON.Texture;
  70716. private _diffuseTexture5;
  70717. diffuseTexture5: BABYLON.Texture;
  70718. private _diffuseTexture6;
  70719. diffuseTexture6: BABYLON.Texture;
  70720. private _diffuseTexture7;
  70721. diffuseTexture7: BABYLON.Texture;
  70722. private _diffuseTexture8;
  70723. diffuseTexture8: BABYLON.Texture;
  70724. /**
  70725. * Uniforms
  70726. */
  70727. diffuseColor: BABYLON.Color3;
  70728. specularColor: BABYLON.Color3;
  70729. specularPower: number;
  70730. private _disableLighting;
  70731. disableLighting: boolean;
  70732. private _maxSimultaneousLights;
  70733. maxSimultaneousLights: number;
  70734. private _renderId;
  70735. constructor(name: string, scene: BABYLON.Scene);
  70736. needAlphaBlending(): boolean;
  70737. needAlphaTesting(): boolean;
  70738. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70739. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70740. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70741. getAnimatables(): BABYLON.IAnimatable[];
  70742. getActiveTextures(): BABYLON.BaseTexture[];
  70743. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70744. dispose(forceDisposeEffect?: boolean): void;
  70745. clone(name: string): MixMaterial;
  70746. serialize(): any;
  70747. getClassName(): string;
  70748. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  70749. }
  70750. }
  70751. declare module BABYLON {
  70752. /** @hidden */
  70753. export var normalPixelShader: {
  70754. name: string;
  70755. shader: string;
  70756. };
  70757. }
  70758. declare module BABYLON {
  70759. /** @hidden */
  70760. export var normalVertexShader: {
  70761. name: string;
  70762. shader: string;
  70763. };
  70764. }
  70765. declare module BABYLON {
  70766. export class NormalMaterial extends BABYLON.PushMaterial {
  70767. private _diffuseTexture;
  70768. diffuseTexture: BABYLON.BaseTexture;
  70769. diffuseColor: BABYLON.Color3;
  70770. private _disableLighting;
  70771. disableLighting: boolean;
  70772. private _maxSimultaneousLights;
  70773. maxSimultaneousLights: number;
  70774. private _renderId;
  70775. constructor(name: string, scene: BABYLON.Scene);
  70776. needAlphaBlending(): boolean;
  70777. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  70778. needAlphaTesting(): boolean;
  70779. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70780. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70781. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70782. getAnimatables(): BABYLON.IAnimatable[];
  70783. getActiveTextures(): BABYLON.BaseTexture[];
  70784. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70785. dispose(forceDisposeEffect?: boolean): void;
  70786. clone(name: string): NormalMaterial;
  70787. serialize(): any;
  70788. getClassName(): string;
  70789. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  70790. }
  70791. }
  70792. declare module BABYLON {
  70793. /** @hidden */
  70794. export var shadowOnlyPixelShader: {
  70795. name: string;
  70796. shader: string;
  70797. };
  70798. }
  70799. declare module BABYLON {
  70800. /** @hidden */
  70801. export var shadowOnlyVertexShader: {
  70802. name: string;
  70803. shader: string;
  70804. };
  70805. }
  70806. declare module BABYLON {
  70807. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  70808. private _renderId;
  70809. private _activeLight;
  70810. constructor(name: string, scene: BABYLON.Scene);
  70811. shadowColor: BABYLON.Color3;
  70812. needAlphaBlending(): boolean;
  70813. needAlphaTesting(): boolean;
  70814. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70815. activeLight: BABYLON.IShadowLight;
  70816. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70817. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70818. clone(name: string): ShadowOnlyMaterial;
  70819. serialize(): any;
  70820. getClassName(): string;
  70821. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  70822. }
  70823. }
  70824. declare module BABYLON {
  70825. /** @hidden */
  70826. export var simplePixelShader: {
  70827. name: string;
  70828. shader: string;
  70829. };
  70830. }
  70831. declare module BABYLON {
  70832. /** @hidden */
  70833. export var simpleVertexShader: {
  70834. name: string;
  70835. shader: string;
  70836. };
  70837. }
  70838. declare module BABYLON {
  70839. export class SimpleMaterial extends BABYLON.PushMaterial {
  70840. private _diffuseTexture;
  70841. diffuseTexture: BABYLON.BaseTexture;
  70842. diffuseColor: BABYLON.Color3;
  70843. private _disableLighting;
  70844. disableLighting: boolean;
  70845. private _maxSimultaneousLights;
  70846. maxSimultaneousLights: number;
  70847. private _renderId;
  70848. constructor(name: string, scene: BABYLON.Scene);
  70849. needAlphaBlending(): boolean;
  70850. needAlphaTesting(): boolean;
  70851. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70852. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70853. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70854. getAnimatables(): BABYLON.IAnimatable[];
  70855. getActiveTextures(): BABYLON.BaseTexture[];
  70856. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70857. dispose(forceDisposeEffect?: boolean): void;
  70858. clone(name: string): SimpleMaterial;
  70859. serialize(): any;
  70860. getClassName(): string;
  70861. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  70862. }
  70863. }
  70864. declare module BABYLON {
  70865. /** @hidden */
  70866. export var skyPixelShader: {
  70867. name: string;
  70868. shader: string;
  70869. };
  70870. }
  70871. declare module BABYLON {
  70872. /** @hidden */
  70873. export var skyVertexShader: {
  70874. name: string;
  70875. shader: string;
  70876. };
  70877. }
  70878. declare module BABYLON {
  70879. /**
  70880. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  70881. * @see https://doc.babylonjs.com/extensions/sky
  70882. */
  70883. export class SkyMaterial extends BABYLON.PushMaterial {
  70884. /**
  70885. * Defines the overall luminance of sky in interval ]0, 1[.
  70886. */
  70887. luminance: number;
  70888. /**
  70889. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  70890. */
  70891. turbidity: number;
  70892. /**
  70893. * Defines the sky appearance (light intensity).
  70894. */
  70895. rayleigh: number;
  70896. /**
  70897. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  70898. */
  70899. mieCoefficient: number;
  70900. /**
  70901. * Defines the amount of haze particles following the Mie scattering theory.
  70902. */
  70903. mieDirectionalG: number;
  70904. /**
  70905. * Defines the distance of the sun according to the active scene camera.
  70906. */
  70907. distance: number;
  70908. /**
  70909. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  70910. * "inclined".
  70911. */
  70912. inclination: number;
  70913. /**
  70914. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  70915. * an object direction and a reference direction.
  70916. */
  70917. azimuth: number;
  70918. /**
  70919. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  70920. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  70921. */
  70922. sunPosition: BABYLON.Vector3;
  70923. /**
  70924. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  70925. * .sunPosition property.
  70926. */
  70927. useSunPosition: boolean;
  70928. /**
  70929. * Defines an offset vector used to get a horizon offset.
  70930. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  70931. */
  70932. cameraOffset: BABYLON.Vector3;
  70933. private _cameraPosition;
  70934. private _renderId;
  70935. /**
  70936. * Instantiates a new sky material.
  70937. * This material allows to create dynamic and texture free
  70938. * effects for skyboxes by taking care of the atmosphere state.
  70939. * @see https://doc.babylonjs.com/extensions/sky
  70940. * @param name Define the name of the material in the scene
  70941. * @param scene Define the scene the material belong to
  70942. */
  70943. constructor(name: string, scene: BABYLON.Scene);
  70944. /**
  70945. * Specifies if the material will require alpha blending
  70946. * @returns a boolean specifying if alpha blending is needed
  70947. */
  70948. needAlphaBlending(): boolean;
  70949. /**
  70950. * Specifies if this material should be rendered in alpha test mode
  70951. * @returns false as the sky material doesn't need alpha testing.
  70952. */
  70953. needAlphaTesting(): boolean;
  70954. /**
  70955. * Get the texture used for alpha test purpose.
  70956. * @returns null as the sky material has no texture.
  70957. */
  70958. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70959. /**
  70960. * Get if the submesh is ready to be used and all its information available.
  70961. * Child classes can use it to update shaders
  70962. * @param mesh defines the mesh to check
  70963. * @param subMesh defines which submesh to check
  70964. * @param useInstances specifies that instances should be used
  70965. * @returns a boolean indicating that the submesh is ready or not
  70966. */
  70967. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70968. /**
  70969. * Binds the submesh to this material by preparing the effect and shader to draw
  70970. * @param world defines the world transformation matrix
  70971. * @param mesh defines the mesh containing the submesh
  70972. * @param subMesh defines the submesh to bind the material to
  70973. */
  70974. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70975. /**
  70976. * Get the list of animatables in the material.
  70977. * @returns the list of animatables object used in the material
  70978. */
  70979. getAnimatables(): BABYLON.IAnimatable[];
  70980. /**
  70981. * Disposes the material
  70982. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  70983. */
  70984. dispose(forceDisposeEffect?: boolean): void;
  70985. /**
  70986. * Makes a duplicate of the material, and gives it a new name
  70987. * @param name defines the new name for the duplicated material
  70988. * @returns the cloned material
  70989. */
  70990. clone(name: string): SkyMaterial;
  70991. /**
  70992. * Serializes this material in a JSON representation
  70993. * @returns the serialized material object
  70994. */
  70995. serialize(): any;
  70996. /**
  70997. * Gets the current class name of the material e.g. "SkyMaterial"
  70998. * Mainly use in serialization.
  70999. * @returns the class name
  71000. */
  71001. getClassName(): string;
  71002. /**
  71003. * Creates a sky material from parsed material data
  71004. * @param source defines the JSON representation of the material
  71005. * @param scene defines the hosting scene
  71006. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71007. * @returns a new sky material
  71008. */
  71009. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  71010. }
  71011. }
  71012. declare module BABYLON {
  71013. /** @hidden */
  71014. export var terrainPixelShader: {
  71015. name: string;
  71016. shader: string;
  71017. };
  71018. }
  71019. declare module BABYLON {
  71020. /** @hidden */
  71021. export var terrainVertexShader: {
  71022. name: string;
  71023. shader: string;
  71024. };
  71025. }
  71026. declare module BABYLON {
  71027. export class TerrainMaterial extends BABYLON.PushMaterial {
  71028. private _mixTexture;
  71029. mixTexture: BABYLON.BaseTexture;
  71030. private _diffuseTexture1;
  71031. diffuseTexture1: BABYLON.Texture;
  71032. private _diffuseTexture2;
  71033. diffuseTexture2: BABYLON.Texture;
  71034. private _diffuseTexture3;
  71035. diffuseTexture3: BABYLON.Texture;
  71036. private _bumpTexture1;
  71037. bumpTexture1: BABYLON.Texture;
  71038. private _bumpTexture2;
  71039. bumpTexture2: BABYLON.Texture;
  71040. private _bumpTexture3;
  71041. bumpTexture3: BABYLON.Texture;
  71042. diffuseColor: BABYLON.Color3;
  71043. specularColor: BABYLON.Color3;
  71044. specularPower: number;
  71045. private _disableLighting;
  71046. disableLighting: boolean;
  71047. private _maxSimultaneousLights;
  71048. maxSimultaneousLights: number;
  71049. private _renderId;
  71050. constructor(name: string, scene: BABYLON.Scene);
  71051. needAlphaBlending(): boolean;
  71052. needAlphaTesting(): boolean;
  71053. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71054. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71055. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71056. getAnimatables(): BABYLON.IAnimatable[];
  71057. getActiveTextures(): BABYLON.BaseTexture[];
  71058. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71059. dispose(forceDisposeEffect?: boolean): void;
  71060. clone(name: string): TerrainMaterial;
  71061. serialize(): any;
  71062. getClassName(): string;
  71063. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  71064. }
  71065. }
  71066. declare module BABYLON {
  71067. /** @hidden */
  71068. export var triplanarPixelShader: {
  71069. name: string;
  71070. shader: string;
  71071. };
  71072. }
  71073. declare module BABYLON {
  71074. /** @hidden */
  71075. export var triplanarVertexShader: {
  71076. name: string;
  71077. shader: string;
  71078. };
  71079. }
  71080. declare module BABYLON {
  71081. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  71082. mixTexture: BABYLON.BaseTexture;
  71083. private _diffuseTextureX;
  71084. diffuseTextureX: BABYLON.BaseTexture;
  71085. private _diffuseTextureY;
  71086. diffuseTextureY: BABYLON.BaseTexture;
  71087. private _diffuseTextureZ;
  71088. diffuseTextureZ: BABYLON.BaseTexture;
  71089. private _normalTextureX;
  71090. normalTextureX: BABYLON.BaseTexture;
  71091. private _normalTextureY;
  71092. normalTextureY: BABYLON.BaseTexture;
  71093. private _normalTextureZ;
  71094. normalTextureZ: BABYLON.BaseTexture;
  71095. tileSize: number;
  71096. diffuseColor: BABYLON.Color3;
  71097. specularColor: BABYLON.Color3;
  71098. specularPower: number;
  71099. private _disableLighting;
  71100. disableLighting: boolean;
  71101. private _maxSimultaneousLights;
  71102. maxSimultaneousLights: number;
  71103. private _renderId;
  71104. constructor(name: string, scene: BABYLON.Scene);
  71105. needAlphaBlending(): boolean;
  71106. needAlphaTesting(): boolean;
  71107. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71108. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71109. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71110. getAnimatables(): BABYLON.IAnimatable[];
  71111. getActiveTextures(): BABYLON.BaseTexture[];
  71112. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71113. dispose(forceDisposeEffect?: boolean): void;
  71114. clone(name: string): TriPlanarMaterial;
  71115. serialize(): any;
  71116. getClassName(): string;
  71117. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  71118. }
  71119. }
  71120. declare module BABYLON {
  71121. /** @hidden */
  71122. export var waterPixelShader: {
  71123. name: string;
  71124. shader: string;
  71125. };
  71126. }
  71127. declare module BABYLON {
  71128. /** @hidden */
  71129. export var waterVertexShader: {
  71130. name: string;
  71131. shader: string;
  71132. };
  71133. }
  71134. declare module BABYLON {
  71135. export class WaterMaterial extends BABYLON.PushMaterial {
  71136. renderTargetSize: BABYLON.Vector2;
  71137. private _bumpTexture;
  71138. bumpTexture: BABYLON.BaseTexture;
  71139. diffuseColor: BABYLON.Color3;
  71140. specularColor: BABYLON.Color3;
  71141. specularPower: number;
  71142. private _disableLighting;
  71143. disableLighting: boolean;
  71144. private _maxSimultaneousLights;
  71145. maxSimultaneousLights: number;
  71146. /**
  71147. * @param {number}: Represents the wind force
  71148. */
  71149. windForce: number;
  71150. /**
  71151. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  71152. */
  71153. windDirection: BABYLON.Vector2;
  71154. /**
  71155. * @param {number}: Wave height, represents the height of the waves
  71156. */
  71157. waveHeight: number;
  71158. /**
  71159. * @param {number}: Bump height, represents the bump height related to the bump map
  71160. */
  71161. bumpHeight: number;
  71162. /**
  71163. * @param {boolean}: Add a smaller moving bump to less steady waves.
  71164. */
  71165. private _bumpSuperimpose;
  71166. bumpSuperimpose: boolean;
  71167. /**
  71168. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  71169. */
  71170. private _fresnelSeparate;
  71171. fresnelSeparate: boolean;
  71172. /**
  71173. * @param {boolean}: bump Waves modify the reflection.
  71174. */
  71175. private _bumpAffectsReflection;
  71176. bumpAffectsReflection: boolean;
  71177. /**
  71178. * @param {number}: The water color blended with the refraction (near)
  71179. */
  71180. waterColor: BABYLON.Color3;
  71181. /**
  71182. * @param {number}: The blend factor related to the water color
  71183. */
  71184. colorBlendFactor: number;
  71185. /**
  71186. * @param {number}: The water color blended with the reflection (far)
  71187. */
  71188. waterColor2: BABYLON.Color3;
  71189. /**
  71190. * @param {number}: The blend factor related to the water color (reflection, far)
  71191. */
  71192. colorBlendFactor2: number;
  71193. /**
  71194. * @param {number}: Represents the maximum length of a wave
  71195. */
  71196. waveLength: number;
  71197. /**
  71198. * @param {number}: Defines the waves speed
  71199. */
  71200. waveSpeed: number;
  71201. /**
  71202. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  71203. * will avoid calculating useless pixels in the pixel shader of the water material.
  71204. */
  71205. disableClipPlane: boolean;
  71206. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  71207. private _mesh;
  71208. private _refractionRTT;
  71209. private _reflectionRTT;
  71210. private _reflectionTransform;
  71211. private _lastTime;
  71212. private _lastDeltaTime;
  71213. private _renderId;
  71214. private _useLogarithmicDepth;
  71215. private _waitingRenderList;
  71216. private _imageProcessingConfiguration;
  71217. private _imageProcessingObserver;
  71218. /**
  71219. * Gets a boolean indicating that current material needs to register RTT
  71220. */
  71221. readonly hasRenderTargetTextures: boolean;
  71222. /**
  71223. * Constructor
  71224. */
  71225. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  71226. useLogarithmicDepth: boolean;
  71227. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  71228. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  71229. addToRenderList(node: any): void;
  71230. enableRenderTargets(enable: boolean): void;
  71231. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  71232. readonly renderTargetsEnabled: boolean;
  71233. needAlphaBlending(): boolean;
  71234. needAlphaTesting(): boolean;
  71235. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71236. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71237. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71238. private _createRenderTargets;
  71239. getAnimatables(): BABYLON.IAnimatable[];
  71240. getActiveTextures(): BABYLON.BaseTexture[];
  71241. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71242. dispose(forceDisposeEffect?: boolean): void;
  71243. clone(name: string): WaterMaterial;
  71244. serialize(): any;
  71245. getClassName(): string;
  71246. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  71247. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  71248. }
  71249. }
  71250. declare module BABYLON {
  71251. /** @hidden */
  71252. export var asciiartPixelShader: {
  71253. name: string;
  71254. shader: string;
  71255. };
  71256. }
  71257. declare module BABYLON {
  71258. /**
  71259. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  71260. *
  71261. * It basically takes care rendering the font front the given font size to a texture.
  71262. * This is used later on in the postprocess.
  71263. */
  71264. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  71265. private _font;
  71266. private _text;
  71267. private _charSize;
  71268. /**
  71269. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  71270. */
  71271. readonly charSize: number;
  71272. /**
  71273. * Create a new instance of the Ascii Art FontTexture class
  71274. * @param name the name of the texture
  71275. * @param font the font to use, use the W3C CSS notation
  71276. * @param text the caracter set to use in the rendering.
  71277. * @param scene the scene that owns the texture
  71278. */
  71279. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  71280. /**
  71281. * Gets the max char width of a font.
  71282. * @param font the font to use, use the W3C CSS notation
  71283. * @return the max char width
  71284. */
  71285. private getFontWidth;
  71286. /**
  71287. * Gets the max char height of a font.
  71288. * @param font the font to use, use the W3C CSS notation
  71289. * @return the max char height
  71290. */
  71291. private getFontHeight;
  71292. /**
  71293. * Clones the current AsciiArtTexture.
  71294. * @return the clone of the texture.
  71295. */
  71296. clone(): AsciiArtFontTexture;
  71297. /**
  71298. * Parses a json object representing the texture and returns an instance of it.
  71299. * @param source the source JSON representation
  71300. * @param scene the scene to create the texture for
  71301. * @return the parsed texture
  71302. */
  71303. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  71304. }
  71305. /**
  71306. * Option available in the Ascii Art Post Process.
  71307. */
  71308. export interface IAsciiArtPostProcessOptions {
  71309. /**
  71310. * The font to use following the w3c font definition.
  71311. */
  71312. font?: string;
  71313. /**
  71314. * The character set to use in the postprocess.
  71315. */
  71316. characterSet?: string;
  71317. /**
  71318. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  71319. * This number is defined between 0 and 1;
  71320. */
  71321. mixToTile?: number;
  71322. /**
  71323. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  71324. * This number is defined between 0 and 1;
  71325. */
  71326. mixToNormal?: number;
  71327. }
  71328. /**
  71329. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  71330. *
  71331. * Simmply add it to your scene and let the nerd that lives in you have fun.
  71332. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  71333. */
  71334. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  71335. /**
  71336. * The font texture used to render the char in the post process.
  71337. */
  71338. private _asciiArtFontTexture;
  71339. /**
  71340. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  71341. * This number is defined between 0 and 1;
  71342. */
  71343. mixToTile: number;
  71344. /**
  71345. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  71346. * This number is defined between 0 and 1;
  71347. */
  71348. mixToNormal: number;
  71349. /**
  71350. * Instantiates a new Ascii Art Post Process.
  71351. * @param name the name to give to the postprocess
  71352. * @camera the camera to apply the post process to.
  71353. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  71354. */
  71355. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  71356. }
  71357. }
  71358. declare module BABYLON {
  71359. /** @hidden */
  71360. export var digitalrainPixelShader: {
  71361. name: string;
  71362. shader: string;
  71363. };
  71364. }
  71365. declare module BABYLON {
  71366. /**
  71367. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  71368. *
  71369. * It basically takes care rendering the font front the given font size to a texture.
  71370. * This is used later on in the postprocess.
  71371. */
  71372. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  71373. private _font;
  71374. private _text;
  71375. private _charSize;
  71376. /**
  71377. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  71378. */
  71379. readonly charSize: number;
  71380. /**
  71381. * Create a new instance of the Digital Rain FontTexture class
  71382. * @param name the name of the texture
  71383. * @param font the font to use, use the W3C CSS notation
  71384. * @param text the caracter set to use in the rendering.
  71385. * @param scene the scene that owns the texture
  71386. */
  71387. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  71388. /**
  71389. * Gets the max char width of a font.
  71390. * @param font the font to use, use the W3C CSS notation
  71391. * @return the max char width
  71392. */
  71393. private getFontWidth;
  71394. /**
  71395. * Gets the max char height of a font.
  71396. * @param font the font to use, use the W3C CSS notation
  71397. * @return the max char height
  71398. */
  71399. private getFontHeight;
  71400. /**
  71401. * Clones the current DigitalRainFontTexture.
  71402. * @return the clone of the texture.
  71403. */
  71404. clone(): DigitalRainFontTexture;
  71405. /**
  71406. * Parses a json object representing the texture and returns an instance of it.
  71407. * @param source the source JSON representation
  71408. * @param scene the scene to create the texture for
  71409. * @return the parsed texture
  71410. */
  71411. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  71412. }
  71413. /**
  71414. * Option available in the Digital Rain Post Process.
  71415. */
  71416. export interface IDigitalRainPostProcessOptions {
  71417. /**
  71418. * The font to use following the w3c font definition.
  71419. */
  71420. font?: string;
  71421. /**
  71422. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  71423. * This number is defined between 0 and 1;
  71424. */
  71425. mixToTile?: number;
  71426. /**
  71427. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  71428. * This number is defined between 0 and 1;
  71429. */
  71430. mixToNormal?: number;
  71431. }
  71432. /**
  71433. * DigitalRainPostProcess helps rendering everithing in digital rain.
  71434. *
  71435. * Simmply add it to your scene and let the nerd that lives in you have fun.
  71436. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  71437. */
  71438. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  71439. /**
  71440. * The font texture used to render the char in the post process.
  71441. */
  71442. private _digitalRainFontTexture;
  71443. /**
  71444. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  71445. * This number is defined between 0 and 1;
  71446. */
  71447. mixToTile: number;
  71448. /**
  71449. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  71450. * This number is defined between 0 and 1;
  71451. */
  71452. mixToNormal: number;
  71453. /**
  71454. * Instantiates a new Digital Rain Post Process.
  71455. * @param name the name to give to the postprocess
  71456. * @camera the camera to apply the post process to.
  71457. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  71458. */
  71459. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  71460. }
  71461. }
  71462. declare module BABYLON {
  71463. /** @hidden */
  71464. export var oceanPostProcessPixelShader: {
  71465. name: string;
  71466. shader: string;
  71467. };
  71468. }
  71469. declare module BABYLON {
  71470. /**
  71471. * Option available in the Ocean Post Process.
  71472. */
  71473. export interface IOceanPostProcessOptions {
  71474. /**
  71475. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  71476. */
  71477. reflectionSize?: number | {
  71478. width: number;
  71479. height: number;
  71480. } | {
  71481. ratio: number;
  71482. };
  71483. /**
  71484. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  71485. */
  71486. refractionSize?: number | {
  71487. width: number;
  71488. height: number;
  71489. } | {
  71490. ratio: number;
  71491. };
  71492. }
  71493. /**
  71494. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  71495. *
  71496. * Simmply add it to your scene and let the nerd that lives in you have fun.
  71497. * Example usage:
  71498. * var pp = new OceanPostProcess("myOcean", camera);
  71499. * pp.reflectionEnabled = true;
  71500. * pp.refractionEnabled = true;
  71501. */
  71502. export class OceanPostProcess extends BABYLON.PostProcess {
  71503. /**
  71504. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  71505. */
  71506. /**
  71507. * Sets weither or not the real-time reflection is enabled on the ocean.
  71508. * Is set to true, the reflection mirror texture will be used as reflection texture.
  71509. */
  71510. reflectionEnabled: boolean;
  71511. /**
  71512. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  71513. */
  71514. /**
  71515. * Sets weither or not the real-time refraction is enabled on the ocean.
  71516. * Is set to true, the refraction render target texture will be used as refraction texture.
  71517. */
  71518. refractionEnabled: boolean;
  71519. /**
  71520. * Gets wether or not the post-processes is supported by the running hardware.
  71521. * This requires draw buffer supports.
  71522. */
  71523. readonly isSupported: boolean;
  71524. /**
  71525. * This is the reflection mirror texture used to display reflections on the ocean.
  71526. * By default, render list is empty.
  71527. */
  71528. reflectionTexture: BABYLON.MirrorTexture;
  71529. /**
  71530. * This is the refraction render target texture used to display refraction on the ocean.
  71531. * By default, render list is empty.
  71532. */
  71533. refractionTexture: BABYLON.RenderTargetTexture;
  71534. private _time;
  71535. private _cameraRotation;
  71536. private _cameraViewMatrix;
  71537. private _reflectionEnabled;
  71538. private _refractionEnabled;
  71539. private _geometryRenderer;
  71540. /**
  71541. * Instantiates a new Ocean Post Process.
  71542. * @param name the name to give to the postprocess.
  71543. * @camera the camera to apply the post process to.
  71544. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  71545. */
  71546. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  71547. /**
  71548. * Returns the appropriate defines according to the current configuration.
  71549. */
  71550. private _getDefines;
  71551. /**
  71552. * Computes the current camera rotation as the shader requires a camera rotation.
  71553. */
  71554. private _computeCameraRotation;
  71555. }
  71556. }
  71557. declare module BABYLON {
  71558. /** @hidden */
  71559. export var brickProceduralTexturePixelShader: {
  71560. name: string;
  71561. shader: string;
  71562. };
  71563. }
  71564. declare module BABYLON {
  71565. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  71566. private _numberOfBricksHeight;
  71567. private _numberOfBricksWidth;
  71568. private _jointColor;
  71569. private _brickColor;
  71570. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71571. updateShaderUniforms(): void;
  71572. numberOfBricksHeight: number;
  71573. numberOfBricksWidth: number;
  71574. jointColor: BABYLON.Color3;
  71575. brickColor: BABYLON.Color3;
  71576. /**
  71577. * Serializes this brick procedural texture
  71578. * @returns a serialized brick procedural texture object
  71579. */
  71580. serialize(): any;
  71581. /**
  71582. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  71583. * @param parsedTexture defines parsed texture data
  71584. * @param scene defines the current scene
  71585. * @param rootUrl defines the root URL containing brick procedural texture information
  71586. * @returns a parsed Brick Procedural BABYLON.Texture
  71587. */
  71588. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  71589. }
  71590. }
  71591. declare module BABYLON {
  71592. /** @hidden */
  71593. export var cloudProceduralTexturePixelShader: {
  71594. name: string;
  71595. shader: string;
  71596. };
  71597. }
  71598. declare module BABYLON {
  71599. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  71600. private _skyColor;
  71601. private _cloudColor;
  71602. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71603. updateShaderUniforms(): void;
  71604. skyColor: BABYLON.Color4;
  71605. cloudColor: BABYLON.Color4;
  71606. /**
  71607. * Serializes this cloud procedural texture
  71608. * @returns a serialized cloud procedural texture object
  71609. */
  71610. serialize(): any;
  71611. /**
  71612. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  71613. * @param parsedTexture defines parsed texture data
  71614. * @param scene defines the current scene
  71615. * @param rootUrl defines the root URL containing cloud procedural texture information
  71616. * @returns a parsed Cloud Procedural BABYLON.Texture
  71617. */
  71618. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  71619. }
  71620. }
  71621. declare module BABYLON {
  71622. /** @hidden */
  71623. export var fireProceduralTexturePixelShader: {
  71624. name: string;
  71625. shader: string;
  71626. };
  71627. }
  71628. declare module BABYLON {
  71629. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  71630. private _time;
  71631. private _speed;
  71632. private _autoGenerateTime;
  71633. private _fireColors;
  71634. private _alphaThreshold;
  71635. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71636. updateShaderUniforms(): void;
  71637. render(useCameraPostProcess?: boolean): void;
  71638. static readonly PurpleFireColors: BABYLON.Color3[];
  71639. static readonly GreenFireColors: BABYLON.Color3[];
  71640. static readonly RedFireColors: BABYLON.Color3[];
  71641. static readonly BlueFireColors: BABYLON.Color3[];
  71642. autoGenerateTime: boolean;
  71643. fireColors: BABYLON.Color3[];
  71644. time: number;
  71645. speed: BABYLON.Vector2;
  71646. alphaThreshold: number;
  71647. /**
  71648. * Serializes this fire procedural texture
  71649. * @returns a serialized fire procedural texture object
  71650. */
  71651. serialize(): any;
  71652. /**
  71653. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  71654. * @param parsedTexture defines parsed texture data
  71655. * @param scene defines the current scene
  71656. * @param rootUrl defines the root URL containing fire procedural texture information
  71657. * @returns a parsed Fire Procedural BABYLON.Texture
  71658. */
  71659. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  71660. }
  71661. }
  71662. declare module BABYLON {
  71663. /** @hidden */
  71664. export var grassProceduralTexturePixelShader: {
  71665. name: string;
  71666. shader: string;
  71667. };
  71668. }
  71669. declare module BABYLON {
  71670. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  71671. private _grassColors;
  71672. private _groundColor;
  71673. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71674. updateShaderUniforms(): void;
  71675. grassColors: BABYLON.Color3[];
  71676. groundColor: BABYLON.Color3;
  71677. /**
  71678. * Serializes this grass procedural texture
  71679. * @returns a serialized grass procedural texture object
  71680. */
  71681. serialize(): any;
  71682. /**
  71683. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  71684. * @param parsedTexture defines parsed texture data
  71685. * @param scene defines the current scene
  71686. * @param rootUrl defines the root URL containing grass procedural texture information
  71687. * @returns a parsed Grass Procedural BABYLON.Texture
  71688. */
  71689. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  71690. }
  71691. }
  71692. declare module BABYLON {
  71693. /** @hidden */
  71694. export var marbleProceduralTexturePixelShader: {
  71695. name: string;
  71696. shader: string;
  71697. };
  71698. }
  71699. declare module BABYLON {
  71700. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  71701. private _numberOfTilesHeight;
  71702. private _numberOfTilesWidth;
  71703. private _amplitude;
  71704. private _jointColor;
  71705. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71706. updateShaderUniforms(): void;
  71707. numberOfTilesHeight: number;
  71708. amplitude: number;
  71709. numberOfTilesWidth: number;
  71710. jointColor: BABYLON.Color3;
  71711. /**
  71712. * Serializes this marble procedural texture
  71713. * @returns a serialized marble procedural texture object
  71714. */
  71715. serialize(): any;
  71716. /**
  71717. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  71718. * @param parsedTexture defines parsed texture data
  71719. * @param scene defines the current scene
  71720. * @param rootUrl defines the root URL containing marble procedural texture information
  71721. * @returns a parsed Marble Procedural BABYLON.Texture
  71722. */
  71723. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  71724. }
  71725. }
  71726. declare module BABYLON {
  71727. /** @hidden */
  71728. export var normalMapProceduralTexturePixelShader: {
  71729. name: string;
  71730. shader: string;
  71731. };
  71732. }
  71733. declare module BABYLON {
  71734. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  71735. private _baseTexture;
  71736. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71737. updateShaderUniforms(): void;
  71738. render(useCameraPostProcess?: boolean): void;
  71739. resize(size: any, generateMipMaps: any): void;
  71740. baseTexture: BABYLON.Texture;
  71741. /**
  71742. * Serializes this normal map procedural texture
  71743. * @returns a serialized normal map procedural texture object
  71744. */
  71745. serialize(): any;
  71746. /**
  71747. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  71748. * @param parsedTexture defines parsed texture data
  71749. * @param scene defines the current scene
  71750. * @param rootUrl defines the root URL containing normal map procedural texture information
  71751. * @returns a parsed Normal Map Procedural BABYLON.Texture
  71752. */
  71753. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  71754. }
  71755. }
  71756. declare module BABYLON {
  71757. /** @hidden */
  71758. export var perlinNoiseProceduralTexturePixelShader: {
  71759. name: string;
  71760. shader: string;
  71761. };
  71762. }
  71763. declare module BABYLON {
  71764. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  71765. time: number;
  71766. timeScale: number;
  71767. translationSpeed: number;
  71768. private _currentTranslation;
  71769. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71770. updateShaderUniforms(): void;
  71771. render(useCameraPostProcess?: boolean): void;
  71772. resize(size: any, generateMipMaps: any): void;
  71773. /**
  71774. * Serializes this perlin noise procedural texture
  71775. * @returns a serialized perlin noise procedural texture object
  71776. */
  71777. serialize(): any;
  71778. /**
  71779. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  71780. * @param parsedTexture defines parsed texture data
  71781. * @param scene defines the current scene
  71782. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  71783. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  71784. */
  71785. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  71786. }
  71787. }
  71788. declare module BABYLON {
  71789. /** @hidden */
  71790. export var roadProceduralTexturePixelShader: {
  71791. name: string;
  71792. shader: string;
  71793. };
  71794. }
  71795. declare module BABYLON {
  71796. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  71797. private _roadColor;
  71798. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71799. updateShaderUniforms(): void;
  71800. roadColor: BABYLON.Color3;
  71801. /**
  71802. * Serializes this road procedural texture
  71803. * @returns a serialized road procedural texture object
  71804. */
  71805. serialize(): any;
  71806. /**
  71807. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  71808. * @param parsedTexture defines parsed texture data
  71809. * @param scene defines the current scene
  71810. * @param rootUrl defines the root URL containing road procedural texture information
  71811. * @returns a parsed Road Procedural BABYLON.Texture
  71812. */
  71813. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  71814. }
  71815. }
  71816. declare module BABYLON {
  71817. /** @hidden */
  71818. export var starfieldProceduralTexturePixelShader: {
  71819. name: string;
  71820. shader: string;
  71821. };
  71822. }
  71823. declare module BABYLON {
  71824. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  71825. private _time;
  71826. private _alpha;
  71827. private _beta;
  71828. private _zoom;
  71829. private _formuparam;
  71830. private _stepsize;
  71831. private _tile;
  71832. private _brightness;
  71833. private _darkmatter;
  71834. private _distfading;
  71835. private _saturation;
  71836. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71837. updateShaderUniforms(): void;
  71838. time: number;
  71839. alpha: number;
  71840. beta: number;
  71841. formuparam: number;
  71842. stepsize: number;
  71843. zoom: number;
  71844. tile: number;
  71845. brightness: number;
  71846. darkmatter: number;
  71847. distfading: number;
  71848. saturation: number;
  71849. /**
  71850. * Serializes this starfield procedural texture
  71851. * @returns a serialized starfield procedural texture object
  71852. */
  71853. serialize(): any;
  71854. /**
  71855. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  71856. * @param parsedTexture defines parsed texture data
  71857. * @param scene defines the current scene
  71858. * @param rootUrl defines the root URL containing startfield procedural texture information
  71859. * @returns a parsed Starfield Procedural BABYLON.Texture
  71860. */
  71861. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  71862. }
  71863. }
  71864. declare module BABYLON {
  71865. /** @hidden */
  71866. export var woodProceduralTexturePixelShader: {
  71867. name: string;
  71868. shader: string;
  71869. };
  71870. }
  71871. declare module BABYLON {
  71872. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  71873. private _ampScale;
  71874. private _woodColor;
  71875. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71876. updateShaderUniforms(): void;
  71877. ampScale: number;
  71878. woodColor: BABYLON.Color3;
  71879. /**
  71880. * Serializes this wood procedural texture
  71881. * @returns a serialized wood procedural texture object
  71882. */
  71883. serialize(): any;
  71884. /**
  71885. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  71886. * @param parsedTexture defines parsed texture data
  71887. * @param scene defines the current scene
  71888. * @param rootUrl defines the root URL containing wood procedural texture information
  71889. * @returns a parsed Wood Procedural BABYLON.Texture
  71890. */
  71891. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  71892. }
  71893. }