documentation.d.ts 3.7 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010810118101281013810148101581016810178101881019810208102181022810238102481025810268102781028810298103081031810328103381034810358103681037810388103981040810418104281043810448104581046810478104881049810508105181052810538105481055810568105781058810598106081061810628106381064810658106681067810688106981070810718107281073810748107581076810778107881079810808108181082810838108481085810868108781088810898109081091810928109381094810958109681097810988109981100811018110281103811048110581106811078110881109811108111181112811138111481115811168111781118811198112081121811228112381124811258112681127811288112981130811318113281133811348113581136811378113881139811408114181142811438114481145811468114781148811498115081151811528115381154811558115681157811588115981160811618116281163811648116581166811678116881169811708117181172811738117481175811768117781178811798118081181811828118381184811858118681187811888118981190811918119281193811948119581196811978119881199812008120181202812038120481205812068120781208812098121081211812128121381214812158121681217812188121981220812218122281223812248122581226812278122881229812308123181232812338123481235812368123781238812398124081241812428124381244812458124681247812488124981250812518125281253812548125581256812578125881259812608126181262812638126481265812668126781268812698127081271812728127381274812758127681277812788127981280812818128281283812848128581286812878128881289812908129181292812938129481295812968129781298812998130081301813028130381304813058130681307813088130981310813118131281313813148131581316813178131881319813208132181322813238132481325813268132781328813298133081331813328133381334813358133681337813388133981340813418134281343813448134581346813478134881349813508135181352813538135481355813568135781358813598136081361813628136381364813658136681367813688136981370813718137281373813748137581376813778137881379813808138181382813838138481385813868138781388813898139081391813928139381394813958139681397813988139981400814018140281403814048140581406814078140881409814108141181412814138141481415814168141781418814198142081421814228142381424814258142681427814288142981430814318143281433814348143581436814378143881439814408144181442814438144481445814468144781448814498145081451814528145381454814558145681457814588145981460814618146281463814648146581466814678146881469814708147181472814738147481475814768147781478814798148081481814828148381484814858148681487814888148981490814918149281493814948149581496814978149881499815008150181502815038150481505815068150781508815098151081511815128151381514815158151681517815188151981520815218152281523815248152581526815278152881529815308153181532815338153481535815368153781538815398154081541815428154381544815458154681547815488154981550815518155281553815548155581556815578155881559815608156181562815638156481565815668156781568815698157081571815728157381574815758157681577815788157981580815818158281583815848158581586815878158881589815908159181592815938159481595815968159781598815998160081601816028160381604816058160681607816088160981610816118161281613816148161581616816178161881619816208162181622816238162481625816268162781628816298163081631816328163381634816358163681637816388163981640816418164281643816448164581646816478164881649816508165181652816538165481655816568165781658816598166081661816628166381664816658166681667816688166981670816718167281673816748167581676816778167881679816808168181682816838168481685816868168781688816898169081691816928169381694816958169681697816988169981700817018170281703817048170581706817078170881709817108171181712817138171481715817168171781718817198172081721817228172381724817258172681727817288172981730817318173281733817348173581736817378173881739817408174181742817438174481745817468174781748817498175081751817528175381754817558175681757817588175981760817618176281763817648176581766817678176881769817708177181772817738177481775817768177781778817798178081781817828178381784817858178681787817888178981790817918179281793817948179581796817978179881799818008180181802818038180481805818068180781808818098181081811818128181381814818158181681817818188181981820818218182281823818248182581826818278182881829818308183181832818338183481835818368183781838818398184081841818428184381844818458184681847818488184981850818518185281853818548185581856818578185881859818608186181862818638186481865818668186781868818698187081871818728187381874818758187681877818788187981880818818188281883818848188581886818878188881889818908189181892818938189481895818968189781898818998190081901819028190381904819058190681907819088190981910819118191281913819148191581916819178191881919819208192181922819238192481925819268192781928819298193081931819328193381934819358193681937819388193981940819418194281943819448194581946819478194881949819508195181952819538195481955819568195781958819598196081961819628196381964819658196681967819688196981970819718197281973819748197581976819778197881979819808198181982819838198481985819868198781988819898199081991819928199381994819958199681997819988199982000820018200282003820048200582006820078200882009820108201182012820138201482015820168201782018820198202082021820228202382024820258202682027820288202982030820318203282033820348203582036820378203882039820408204182042820438204482045820468204782048820498205082051820528205382054820558205682057820588205982060820618206282063820648206582066820678206882069820708207182072820738207482075820768207782078820798208082081820828208382084820858208682087820888208982090820918209282093820948209582096820978209882099821008210182102821038210482105821068210782108821098211082111821128211382114821158211682117821188211982120821218212282123821248212582126821278212882129821308213182132821338213482135821368213782138821398214082141821428214382144821458214682147821488214982150821518215282153821548215582156821578215882159821608216182162821638216482165821668216782168821698217082171821728217382174821758217682177821788217982180821818218282183821848218582186821878218882189821908219182192821938219482195821968219782198821998220082201822028220382204822058220682207822088220982210822118221282213822148221582216822178221882219822208222182222822238222482225822268222782228822298223082231822328223382234822358223682237822388223982240822418224282243822448224582246822478224882249822508225182252822538225482255822568225782258822598226082261822628226382264822658226682267822688226982270822718227282273822748227582276822778227882279822808228182282822838228482285822868228782288822898229082291822928229382294822958229682297822988229982300823018230282303823048230582306823078230882309823108231182312823138231482315823168231782318823198232082321823228232382324823258232682327823288232982330823318233282333823348233582336823378233882339823408234182342823438234482345823468234782348823498235082351823528235382354823558235682357823588235982360823618236282363823648236582366823678236882369823708237182372823738237482375823768237782378823798238082381823828238382384823858238682387823888238982390823918239282393823948239582396823978239882399824008240182402824038240482405824068240782408824098241082411824128241382414824158241682417824188241982420824218242282423824248242582426824278242882429824308243182432824338243482435824368243782438824398244082441824428244382444824458244682447824488244982450824518245282453824548245582456824578245882459824608246182462824638246482465824668246782468824698247082471824728247382474824758247682477824788247982480824818248282483824848248582486824878248882489824908249182492824938249482495824968249782498824998250082501825028250382504825058250682507825088250982510825118251282513825148251582516825178251882519825208252182522825238252482525825268252782528825298253082531825328253382534825358253682537825388253982540825418254282543825448254582546825478254882549825508255182552825538255482555825568255782558825598256082561825628256382564825658256682567825688256982570825718257282573825748257582576825778257882579825808258182582825838258482585825868258782588825898259082591825928259382594825958259682597825988259982600826018260282603826048260582606826078260882609826108261182612826138261482615826168261782618826198262082621826228262382624826258262682627826288262982630826318263282633826348263582636826378263882639826408264182642826438264482645826468264782648826498265082651826528265382654826558265682657826588265982660826618266282663826648266582666826678266882669826708267182672826738267482675826768267782678826798268082681826828268382684826858268682687826888268982690826918269282693826948269582696826978269882699827008270182702827038270482705827068270782708827098271082711827128271382714827158271682717827188271982720827218272282723827248272582726827278272882729827308273182732827338273482735827368273782738827398274082741827428274382744827458274682747827488274982750827518275282753827548275582756827578275882759827608276182762827638276482765827668276782768827698277082771827728277382774827758277682777827788277982780827818278282783827848278582786827878278882789827908279182792827938279482795827968279782798827998280082801828028280382804828058280682807828088280982810828118281282813828148281582816828178281882819828208282182822828238282482825828268282782828828298283082831828328283382834828358283682837828388283982840828418284282843828448284582846828478284882849828508285182852828538285482855828568285782858828598286082861828628286382864828658286682867828688286982870828718287282873828748287582876828778287882879828808288182882828838288482885828868288782888828898289082891828928289382894828958289682897828988289982900829018290282903829048290582906829078290882909829108291182912829138291482915829168291782918829198292082921829228292382924829258292682927829288292982930829318293282933829348293582936829378293882939829408294182942829438294482945829468294782948829498295082951829528295382954829558295682957829588295982960829618296282963829648296582966829678296882969829708297182972829738297482975829768297782978829798298082981829828298382984829858298682987829888298982990829918299282993829948299582996829978299882999830008300183002830038300483005830068300783008830098301083011830128301383014830158301683017830188301983020830218302283023830248302583026830278302883029830308303183032830338303483035830368303783038830398304083041830428304383044830458304683047830488304983050830518305283053830548305583056830578305883059830608306183062830638306483065830668306783068830698307083071830728307383074830758307683077830788307983080830818308283083830848308583086830878308883089830908309183092830938309483095830968309783098830998310083101831028310383104831058310683107831088310983110831118311283113831148311583116831178311883119831208312183122831238312483125831268312783128831298313083131831328313383134831358313683137831388313983140831418314283143831448314583146831478314883149831508315183152831538315483155831568315783158831598316083161831628316383164831658316683167831688316983170831718317283173831748317583176831778317883179831808318183182831838318483185831868318783188831898319083191831928319383194831958319683197831988319983200832018320283203832048320583206832078320883209832108321183212832138321483215832168321783218832198322083221832228322383224832258322683227832288322983230832318323283233832348323583236832378323883239832408324183242832438324483245832468324783248832498325083251832528325383254832558325683257832588325983260832618326283263832648326583266832678326883269832708327183272832738327483275832768327783278832798328083281832828328383284832858328683287832888328983290832918329283293832948329583296832978329883299833008330183302833038330483305833068330783308833098331083311833128331383314833158331683317833188331983320833218332283323833248332583326833278332883329833308333183332833338333483335833368333783338833398334083341833428334383344833458334683347833488334983350833518335283353833548335583356833578335883359833608336183362833638336483365833668336783368833698337083371833728337383374833758337683377833788337983380833818338283383833848338583386833878338883389833908339183392833938339483395833968339783398833998340083401834028340383404834058340683407834088340983410834118341283413834148341583416834178341883419834208342183422834238342483425834268342783428834298343083431834328343383434834358343683437834388343983440834418344283443834448344583446834478344883449834508345183452834538345483455834568345783458834598346083461834628346383464834658346683467834688346983470834718347283473834748347583476834778347883479834808348183482834838348483485834868348783488834898349083491834928349383494834958349683497834988349983500835018350283503835048350583506835078350883509835108351183512835138351483515835168351783518835198352083521835228352383524835258352683527835288352983530835318353283533835348353583536835378353883539835408354183542835438354483545835468354783548835498355083551835528355383554835558355683557835588355983560835618356283563835648356583566835678356883569835708357183572835738357483575835768357783578835798358083581835828358383584835858358683587835888358983590835918359283593835948359583596835978359883599836008360183602836038360483605836068360783608836098361083611836128361383614836158361683617836188361983620836218362283623836248362583626836278362883629836308363183632836338363483635836368363783638836398364083641836428364383644836458364683647836488364983650836518365283653836548365583656836578365883659836608366183662836638366483665836668366783668836698367083671836728367383674836758367683677836788367983680836818368283683836848368583686836878368883689836908369183692836938369483695836968369783698836998370083701837028370383704837058370683707837088370983710837118371283713837148371583716837178371883719837208372183722837238372483725837268372783728837298373083731837328373383734837358373683737837388373983740837418374283743837448374583746837478374883749837508375183752837538375483755837568375783758837598376083761837628376383764837658376683767837688376983770837718377283773837748377583776837778377883779837808378183782837838378483785837868378783788837898379083791837928379383794837958379683797837988379983800838018380283803838048380583806838078380883809838108381183812838138381483815838168381783818838198382083821838228382383824838258382683827838288382983830838318383283833838348383583836838378383883839838408384183842838438384483845838468384783848838498385083851838528385383854838558385683857838588385983860838618386283863838648386583866838678386883869838708387183872838738387483875838768387783878838798388083881838828388383884838858388683887838888388983890838918389283893838948389583896838978389883899839008390183902839038390483905839068390783908839098391083911839128391383914839158391683917839188391983920839218392283923839248392583926839278392883929839308393183932839338393483935839368393783938839398394083941839428394383944839458394683947839488394983950839518395283953839548395583956839578395883959839608396183962839638396483965839668396783968839698397083971839728397383974839758397683977839788397983980839818398283983839848398583986839878398883989839908399183992839938399483995839968399783998839998400084001840028400384004840058400684007840088400984010840118401284013840148401584016840178401884019840208402184022840238402484025840268402784028840298403084031840328403384034840358403684037840388403984040840418404284043840448404584046840478404884049840508405184052840538405484055840568405784058840598406084061840628406384064840658406684067840688406984070840718407284073840748407584076840778407884079840808408184082840838408484085840868408784088840898409084091840928409384094840958409684097840988409984100841018410284103841048410584106841078410884109841108411184112841138411484115841168411784118841198412084121841228412384124841258412684127841288412984130841318413284133841348413584136841378413884139841408414184142841438414484145841468414784148841498415084151841528415384154841558415684157841588415984160841618416284163841648416584166841678416884169841708417184172841738417484175841768417784178841798418084181841828418384184841858418684187841888418984190841918419284193841948419584196841978419884199842008420184202842038420484205842068420784208842098421084211842128421384214842158421684217842188421984220842218422284223842248422584226842278422884229842308423184232842338423484235842368423784238842398424084241842428424384244842458424684247842488424984250842518425284253842548425584256842578425884259842608426184262842638426484265842668426784268842698427084271842728427384274842758427684277842788427984280842818428284283842848428584286842878428884289842908429184292842938429484295842968429784298842998430084301843028430384304843058430684307843088430984310843118431284313843148431584316843178431884319843208432184322843238432484325843268432784328843298433084331843328433384334843358433684337843388433984340843418434284343843448434584346843478434884349843508435184352843538435484355843568435784358843598436084361843628436384364843658436684367843688436984370843718437284373843748437584376843778437884379843808438184382843838438484385843868438784388843898439084391843928439384394843958439684397843988439984400844018440284403844048440584406844078440884409844108441184412844138441484415844168441784418844198442084421844228442384424844258442684427844288442984430844318443284433844348443584436844378443884439844408444184442844438444484445844468444784448844498445084451844528445384454844558445684457844588445984460844618446284463844648446584466844678446884469844708447184472844738447484475844768447784478844798448084481844828448384484844858448684487844888448984490844918449284493844948449584496844978449884499845008450184502845038450484505845068450784508845098451084511845128451384514845158451684517845188451984520845218452284523845248452584526845278452884529845308453184532845338453484535845368453784538845398454084541845428454384544845458454684547845488454984550845518455284553845548455584556845578455884559845608456184562845638456484565845668456784568845698457084571845728457384574845758457684577845788457984580845818458284583845848458584586845878458884589845908459184592845938459484595845968459784598845998460084601846028460384604846058460684607846088460984610846118461284613846148461584616846178461884619846208462184622846238462484625846268462784628846298463084631846328463384634846358463684637846388463984640846418464284643846448464584646846478464884649846508465184652846538465484655846568465784658846598466084661846628466384664846658466684667846688466984670846718467284673846748467584676846778467884679846808468184682846838468484685846868468784688846898469084691846928469384694846958469684697846988469984700847018470284703847048470584706847078470884709847108471184712847138471484715847168471784718847198472084721847228472384724847258472684727847288472984730847318473284733847348473584736847378473884739847408474184742847438474484745847468474784748847498475084751847528475384754847558475684757847588475984760847618476284763847648476584766847678476884769847708477184772847738477484775847768477784778847798478084781847828478384784847858478684787847888478984790847918479284793847948479584796847978479884799848008480184802848038480484805848068480784808848098481084811848128481384814848158481684817848188481984820848218482284823848248482584826848278482884829848308483184832848338483484835848368483784838848398484084841848428484384844848458484684847848488484984850848518485284853848548485584856848578485884859848608486184862848638486484865848668486784868848698487084871848728487384874848758487684877848788487984880848818488284883848848488584886848878488884889848908489184892848938489484895848968489784898848998490084901849028490384904849058490684907849088490984910849118491284913849148491584916849178491884919849208492184922849238492484925849268492784928849298493084931849328493384934849358493684937849388493984940849418494284943849448494584946849478494884949849508495184952849538495484955849568495784958849598496084961849628496384964849658496684967849688496984970849718497284973849748497584976849778497884979849808498184982849838498484985849868498784988849898499084991849928499384994849958499684997849988499985000850018500285003850048500585006850078500885009850108501185012850138501485015850168501785018850198502085021850228502385024850258502685027850288502985030850318503285033850348503585036850378503885039850408504185042850438504485045850468504785048850498505085051850528505385054850558505685057850588505985060850618506285063850648506585066850678506885069850708507185072850738507485075850768507785078850798508085081850828508385084850858508685087850888508985090850918509285093850948509585096850978509885099851008510185102851038510485105851068510785108851098511085111851128511385114851158511685117851188511985120851218512285123851248512585126851278512885129851308513185132851338513485135851368513785138851398514085141851428514385144851458514685147851488514985150851518515285153851548515585156851578515885159851608516185162851638516485165851668516785168851698517085171851728517385174851758517685177851788517985180851818518285183851848518585186851878518885189851908519185192851938519485195851968519785198851998520085201852028520385204852058520685207852088520985210852118521285213852148521585216852178521885219852208522185222852238522485225852268522785228852298523085231852328523385234852358523685237852388523985240852418524285243852448524585246852478524885249852508525185252852538525485255852568525785258852598526085261852628526385264852658526685267852688526985270852718527285273852748527585276852778527885279852808528185282852838528485285852868528785288852898529085291852928529385294852958529685297852988529985300853018530285303853048530585306853078530885309853108531185312853138531485315853168531785318853198532085321853228532385324853258532685327853288532985330853318533285333853348533585336853378533885339853408534185342853438534485345853468534785348853498535085351853528535385354853558535685357853588535985360853618536285363853648536585366853678536885369853708537185372853738537485375853768537785378853798538085381853828538385384853858538685387853888538985390853918539285393853948539585396853978539885399854008540185402854038540485405854068540785408854098541085411854128541385414854158541685417854188541985420854218542285423854248542585426854278542885429854308543185432854338543485435854368543785438854398544085441854428544385444854458544685447854488544985450854518545285453854548545585456854578545885459854608546185462854638546485465854668546785468854698547085471854728547385474854758547685477854788547985480854818548285483854848548585486854878548885489854908549185492854938549485495854968549785498854998550085501855028550385504855058550685507855088550985510855118551285513855148551585516855178551885519855208552185522855238552485525855268552785528855298553085531855328553385534855358553685537855388553985540855418554285543855448554585546855478554885549855508555185552855538555485555855568555785558855598556085561855628556385564855658556685567855688556985570855718557285573855748557585576855778557885579855808558185582855838558485585855868558785588855898559085591855928559385594855958559685597855988559985600856018560285603856048560585606856078560885609856108561185612856138561485615856168561785618856198562085621856228562385624856258562685627856288562985630856318563285633856348563585636856378563885639856408564185642856438564485645856468564785648856498565085651856528565385654856558565685657856588565985660856618566285663856648566585666856678566885669856708567185672856738567485675856768567785678856798568085681856828568385684856858568685687856888568985690856918569285693856948569585696856978569885699857008570185702857038570485705857068570785708857098571085711857128571385714857158571685717857188571985720857218572285723857248572585726857278572885729857308573185732857338573485735857368573785738857398574085741857428574385744857458574685747857488574985750857518575285753857548575585756857578575885759857608576185762857638576485765857668576785768857698577085771857728577385774857758577685777857788577985780857818578285783857848578585786857878578885789857908579185792857938579485795857968579785798857998580085801858028580385804858058580685807858088580985810858118581285813858148581585816858178581885819858208582185822858238582485825858268582785828858298583085831858328583385834858358583685837858388583985840858418584285843858448584585846858478584885849858508585185852858538585485855858568585785858858598586085861858628586385864858658586685867858688586985870858718587285873858748587585876858778587885879858808588185882858838588485885858868588785888858898589085891858928589385894858958589685897858988589985900859018590285903859048590585906859078590885909859108591185912859138591485915859168591785918859198592085921859228592385924859258592685927859288592985930859318593285933859348593585936859378593885939859408594185942859438594485945859468594785948859498595085951859528595385954859558595685957859588595985960859618596285963859648596585966859678596885969859708597185972859738597485975859768597785978859798598085981859828598385984859858598685987859888598985990859918599285993859948599585996859978599885999860008600186002860038600486005860068600786008860098601086011860128601386014860158601686017860188601986020860218602286023860248602586026860278602886029860308603186032860338603486035860368603786038860398604086041860428604386044860458604686047860488604986050860518605286053860548605586056860578605886059860608606186062860638606486065860668606786068860698607086071860728607386074860758607686077860788607986080860818608286083860848608586086860878608886089860908609186092860938609486095860968609786098860998610086101861028610386104861058610686107861088610986110861118611286113861148611586116861178611886119861208612186122861238612486125861268612786128861298613086131861328613386134861358613686137861388613986140861418614286143861448614586146861478614886149861508615186152861538615486155861568615786158861598616086161861628616386164861658616686167861688616986170861718617286173861748617586176861778617886179861808618186182861838618486185861868618786188861898619086191861928619386194861958619686197861988619986200862018620286203862048620586206862078620886209862108621186212862138621486215862168621786218862198622086221862228622386224862258622686227862288622986230862318623286233862348623586236862378623886239862408624186242862438624486245862468624786248862498625086251862528625386254862558625686257862588625986260862618626286263862648626586266862678626886269862708627186272862738627486275862768627786278862798628086281862828628386284862858628686287862888628986290862918629286293862948629586296862978629886299863008630186302863038630486305863068630786308863098631086311863128631386314863158631686317863188631986320863218632286323863248632586326863278632886329863308633186332863338633486335863368633786338863398634086341863428634386344863458634686347863488634986350863518635286353863548635586356863578635886359863608636186362863638636486365863668636786368863698637086371863728637386374863758637686377863788637986380863818638286383863848638586386863878638886389863908639186392863938639486395863968639786398863998640086401864028640386404864058640686407864088640986410864118641286413864148641586416864178641886419864208642186422864238642486425864268642786428864298643086431864328643386434864358643686437864388643986440864418644286443864448644586446864478644886449864508645186452864538645486455864568645786458864598646086461864628646386464864658646686467864688646986470864718647286473864748647586476864778647886479864808648186482864838648486485864868648786488864898649086491864928649386494864958649686497864988649986500865018650286503865048650586506865078650886509865108651186512865138651486515865168651786518865198652086521865228652386524865258652686527865288652986530865318653286533865348653586536865378653886539865408654186542865438654486545865468654786548865498655086551865528655386554865558655686557865588655986560865618656286563865648656586566865678656886569865708657186572865738657486575865768657786578865798658086581865828658386584865858658686587865888658986590865918659286593865948659586596865978659886599866008660186602866038660486605866068660786608866098661086611866128661386614866158661686617866188661986620866218662286623866248662586626866278662886629866308663186632866338663486635866368663786638866398664086641866428664386644866458664686647866488664986650866518665286653866548665586656866578665886659866608666186662866638666486665866668666786668866698667086671866728667386674866758667686677866788667986680866818668286683866848668586686866878668886689866908669186692866938669486695866968669786698866998670086701867028670386704867058670686707867088670986710867118671286713867148671586716867178671886719867208672186722867238672486725867268672786728867298673086731867328673386734867358673686737867388673986740867418674286743867448674586746867478674886749867508675186752867538675486755867568675786758867598676086761867628676386764867658676686767867688676986770867718677286773867748677586776867778677886779867808678186782867838678486785867868678786788867898679086791867928679386794867958679686797867988679986800868018680286803868048680586806868078680886809868108681186812868138681486815868168681786818868198682086821868228682386824868258682686827868288682986830868318683286833868348683586836868378683886839868408684186842868438684486845868468684786848868498685086851868528685386854868558685686857868588685986860868618686286863868648686586866868678686886869868708687186872868738687486875868768687786878868798688086881868828688386884868858688686887868888688986890868918689286893868948689586896868978689886899869008690186902869038690486905869068690786908869098691086911869128691386914869158691686917869188691986920869218692286923869248692586926869278692886929869308693186932869338693486935869368693786938869398694086941869428694386944869458694686947869488694986950869518695286953869548695586956869578695886959869608696186962869638696486965869668696786968869698697086971869728697386974869758697686977869788697986980869818698286983869848698586986869878698886989869908699186992869938699486995869968699786998869998700087001870028700387004870058700687007870088700987010870118701287013870148701587016870178701887019870208702187022870238702487025870268702787028870298703087031870328703387034870358703687037870388703987040870418704287043870448704587046870478704887049870508705187052870538705487055870568705787058870598706087061870628706387064870658706687067870688706987070870718707287073870748707587076870778707887079870808708187082870838708487085870868708787088870898709087091870928709387094870958709687097870988709987100871018710287103871048710587106871078710887109871108711187112871138711487115871168711787118871198712087121871228712387124871258712687127871288712987130871318713287133871348713587136871378713887139871408714187142871438714487145871468714787148871498715087151871528715387154871558715687157871588715987160871618716287163871648716587166871678716887169871708717187172871738717487175871768717787178871798718087181871828718387184871858718687187871888718987190871918719287193871948719587196871978719887199872008720187202872038720487205872068720787208872098721087211872128721387214872158721687217872188721987220872218722287223872248722587226872278722887229872308723187232872338723487235872368723787238872398724087241872428724387244872458724687247872488724987250872518725287253872548725587256872578725887259872608726187262872638726487265872668726787268872698727087271872728727387274872758727687277872788727987280872818728287283872848728587286872878728887289872908729187292872938729487295872968729787298872998730087301873028730387304873058730687307873088730987310873118731287313873148731587316873178731887319873208732187322873238732487325873268732787328873298733087331873328733387334873358733687337873388733987340873418734287343873448734587346873478734887349873508735187352873538735487355873568735787358873598736087361873628736387364873658736687367873688736987370873718737287373873748737587376873778737887379873808738187382873838738487385873868738787388873898739087391873928739387394873958739687397873988739987400874018740287403874048740587406874078740887409874108741187412874138741487415874168741787418874198742087421874228742387424874258742687427874288742987430874318743287433874348743587436874378743887439874408744187442874438744487445874468744787448874498745087451874528745387454874558745687457874588745987460874618746287463874648746587466874678746887469874708747187472874738747487475874768747787478874798748087481874828748387484874858748687487874888748987490874918749287493874948749587496874978749887499875008750187502875038750487505875068750787508875098751087511875128751387514875158751687517875188751987520875218752287523875248752587526875278752887529875308753187532875338753487535875368753787538875398754087541875428754387544875458754687547875488754987550875518755287553875548755587556875578755887559875608756187562875638756487565875668756787568875698757087571875728757387574875758757687577875788757987580875818758287583875848758587586875878758887589875908759187592875938759487595875968759787598875998760087601876028760387604876058760687607876088760987610876118761287613876148761587616876178761887619876208762187622876238762487625876268762787628876298763087631876328763387634876358763687637876388763987640876418764287643876448764587646876478764887649876508765187652876538765487655876568765787658876598766087661876628766387664876658766687667876688766987670876718767287673876748767587676876778767887679876808768187682876838768487685876868768787688876898769087691876928769387694876958769687697876988769987700877018770287703877048770587706877078770887709877108771187712877138771487715877168771787718877198772087721877228772387724877258772687727877288772987730877318773287733877348773587736877378773887739877408774187742877438774487745877468774787748877498775087751877528775387754877558775687757877588775987760877618776287763877648776587766877678776887769877708777187772877738777487775877768777787778877798778087781877828778387784877858778687787877888778987790877918779287793877948779587796877978779887799878008780187802878038780487805878068780787808878098781087811878128781387814878158781687817878188781987820878218782287823878248782587826878278782887829878308783187832878338783487835878368783787838878398784087841878428784387844878458784687847878488784987850878518785287853878548785587856878578785887859878608786187862878638786487865878668786787868878698787087871878728787387874878758787687877878788787987880878818788287883878848788587886878878788887889878908789187892878938789487895878968789787898878998790087901879028790387904879058790687907879088790987910879118791287913879148791587916879178791887919879208792187922879238792487925879268792787928879298793087931879328793387934879358793687937879388793987940879418794287943879448794587946879478794887949879508795187952879538795487955879568795787958879598796087961879628796387964879658796687967879688796987970879718797287973879748797587976879778797887979879808798187982879838798487985879868798787988879898799087991879928799387994879958799687997879988799988000880018800288003880048800588006880078800888009880108801188012880138801488015880168801788018880198802088021880228802388024880258802688027880288802988030880318803288033880348803588036880378803888039880408804188042880438804488045880468804788048880498805088051880528805388054880558805688057880588805988060880618806288063880648806588066880678806888069880708807188072880738807488075880768807788078880798808088081880828808388084880858808688087880888808988090880918809288093880948809588096880978809888099881008810188102881038810488105881068810788108881098811088111881128811388114881158811688117881188811988120881218812288123881248812588126881278812888129881308813188132881338813488135881368813788138881398814088141881428814388144881458814688147881488814988150881518815288153881548815588156881578815888159881608816188162881638816488165881668816788168881698817088171881728817388174881758817688177881788817988180881818818288183881848818588186881878818888189881908819188192881938819488195881968819788198881998820088201882028820388204882058820688207882088820988210882118821288213882148821588216882178821888219882208822188222882238822488225882268822788228882298823088231882328823388234882358823688237882388823988240882418824288243882448824588246882478824888249882508825188252882538825488255882568825788258882598826088261882628826388264882658826688267882688826988270882718827288273882748827588276882778827888279882808828188282882838828488285882868828788288882898829088291882928829388294882958829688297882988829988300883018830288303883048830588306883078830888309883108831188312883138831488315883168831788318883198832088321883228832388324883258832688327883288832988330883318833288333883348833588336883378833888339883408834188342883438834488345883468834788348883498835088351883528835388354883558835688357883588835988360883618836288363883648836588366883678836888369883708837188372883738837488375883768837788378883798838088381883828838388384883858838688387883888838988390883918839288393883948839588396883978839888399884008840188402884038840488405884068840788408884098841088411884128841388414884158841688417884188841988420884218842288423884248842588426884278842888429884308843188432884338843488435884368843788438884398844088441884428844388444884458844688447884488844988450884518845288453884548845588456884578845888459884608846188462884638846488465884668846788468884698847088471884728847388474884758847688477884788847988480884818848288483884848848588486884878848888489884908849188492884938849488495884968849788498884998850088501885028850388504885058850688507885088850988510885118851288513885148851588516885178851888519885208852188522885238852488525885268852788528885298853088531885328853388534885358853688537885388853988540885418854288543885448854588546885478854888549885508855188552885538855488555885568855788558885598856088561885628856388564885658856688567885688856988570885718857288573885748857588576885778857888579885808858188582885838858488585885868858788588885898859088591885928859388594885958859688597885988859988600886018860288603886048860588606886078860888609886108861188612886138861488615886168861788618886198862088621886228862388624886258862688627886288862988630886318863288633886348863588636886378863888639886408864188642886438864488645886468864788648886498865088651886528865388654886558865688657886588865988660886618866288663886648866588666886678866888669886708867188672886738867488675886768867788678886798868088681886828868388684886858868688687886888868988690886918869288693886948869588696886978869888699887008870188702887038870488705887068870788708887098871088711887128871388714887158871688717887188871988720887218872288723887248872588726887278872888729887308873188732887338873488735887368873788738887398874088741887428874388744887458874688747887488874988750887518875288753887548875588756887578875888759887608876188762887638876488765887668876788768887698877088771887728877388774887758877688777887788877988780887818878288783887848878588786887878878888789887908879188792887938879488795887968879788798887998880088801888028880388804888058880688807888088880988810888118881288813888148881588816888178881888819888208882188822888238882488825888268882788828888298883088831888328883388834888358883688837888388883988840888418884288843888448884588846888478884888849888508885188852888538885488855
  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. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. /**
  94. * User defined information that will be sent to observers
  95. */
  96. userInfo?: any;
  97. }
  98. /**
  99. * Represent an Observer registered to a given Observable object.
  100. */
  101. export class Observer<T> {
  102. /**
  103. * Defines the callback to call when the observer is notified
  104. */
  105. callback: (eventData: T, eventState: EventState) => void;
  106. /**
  107. * Defines the mask of the observer (used to filter notifications)
  108. */
  109. mask: number;
  110. /**
  111. * Defines the current scope used to restore the JS context
  112. */
  113. scope: any;
  114. /** @hidden */
  115. _willBeUnregistered: boolean;
  116. /**
  117. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  118. */
  119. unregisterOnNextCall: boolean;
  120. /**
  121. * Creates a new observer
  122. * @param callback defines the callback to call when the observer is notified
  123. * @param mask defines the mask of the observer (used to filter notifications)
  124. * @param scope defines the current scope used to restore the JS context
  125. */
  126. constructor(
  127. /**
  128. * Defines the callback to call when the observer is notified
  129. */
  130. callback: (eventData: T, eventState: EventState) => void,
  131. /**
  132. * Defines the mask of the observer (used to filter notifications)
  133. */
  134. mask: number,
  135. /**
  136. * Defines the current scope used to restore the JS context
  137. */
  138. scope?: any);
  139. }
  140. /**
  141. * Represent a list of observers registered to multiple Observables object.
  142. */
  143. export class MultiObserver<T> {
  144. private _observers;
  145. private _observables;
  146. /**
  147. * Release associated resources
  148. */
  149. dispose(): void;
  150. /**
  151. * Raise a callback when one of the observable will notify
  152. * @param observables defines a list of observables to watch
  153. * @param callback defines the callback to call on notification
  154. * @param mask defines the mask used to filter notifications
  155. * @param scope defines the current scope used to restore the JS context
  156. * @returns the new MultiObserver
  157. */
  158. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  159. }
  160. /**
  161. * The Observable class is a simple implementation of the Observable pattern.
  162. *
  163. * 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.
  164. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  165. * 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).
  166. * 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.
  167. */
  168. export class Observable<T> {
  169. private _observers;
  170. private _eventState;
  171. private _onObserverAdded;
  172. /**
  173. * Gets the list of observers
  174. */
  175. get observers(): Array<Observer<T>>;
  176. /**
  177. * Creates a new observable
  178. * @param onObserverAdded defines a callback to call when a new observer is added
  179. */
  180. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  181. /**
  182. * Create a new Observer with the specified callback
  183. * @param callback the callback that will be executed for that Observer
  184. * @param mask the mask used to filter observers
  185. * @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.
  186. * @param scope optional scope for the callback to be called from
  187. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  188. * @returns the new observer created for the callback
  189. */
  190. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  191. /**
  192. * Create a new Observer with the specified callback and unregisters after the next notification
  193. * @param callback the callback that will be executed for that Observer
  194. * @returns the new observer created for the callback
  195. */
  196. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  197. /**
  198. * Remove an Observer from the Observable object
  199. * @param observer the instance of the Observer to remove
  200. * @returns false if it doesn't belong to this Observable
  201. */
  202. remove(observer: Nullable<Observer<T>>): boolean;
  203. /**
  204. * Remove a callback from the Observable object
  205. * @param callback the callback to remove
  206. * @param scope optional scope. If used only the callbacks with this scope will be removed
  207. * @returns false if it doesn't belong to this Observable
  208. */
  209. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  210. private _deferUnregister;
  211. private _remove;
  212. /**
  213. * Moves the observable to the top of the observer list making it get called first when notified
  214. * @param observer the observer to move
  215. */
  216. makeObserverTopPriority(observer: Observer<T>): void;
  217. /**
  218. * Moves the observable to the bottom of the observer list making it get called last when notified
  219. * @param observer the observer to move
  220. */
  221. makeObserverBottomPriority(observer: Observer<T>): void;
  222. /**
  223. * Notify all Observers by calling their respective callback with the given data
  224. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  225. * @param eventData defines the data to send to all observers
  226. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  227. * @param target defines the original target of the state
  228. * @param currentTarget defines the current target of the state
  229. * @param userInfo defines any user info to send to observers
  230. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  231. */
  232. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  233. /**
  234. * Calling this will execute each callback, expecting it to be a promise or return a value.
  235. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  236. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  237. * and it is crucial that all callbacks will be executed.
  238. * The order of the callbacks is kept, callbacks are not executed parallel.
  239. *
  240. * @param eventData The data to be sent to each callback
  241. * @param mask is used to filter observers defaults to -1
  242. * @param target defines the callback target (see EventState)
  243. * @param currentTarget defines he current object in the bubbling phase
  244. * @param userInfo defines any user info to send to observers
  245. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  246. */
  247. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  248. /**
  249. * Notify a specific observer
  250. * @param observer defines the observer to notify
  251. * @param eventData defines the data to be sent to each callback
  252. * @param mask is used to filter observers defaults to -1
  253. */
  254. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  255. /**
  256. * Gets a boolean indicating if the observable has at least one observer
  257. * @returns true is the Observable has at least one Observer registered
  258. */
  259. hasObservers(): boolean;
  260. /**
  261. * Clear the list of observers
  262. */
  263. clear(): void;
  264. /**
  265. * Clone the current observable
  266. * @returns a new observable
  267. */
  268. clone(): Observable<T>;
  269. /**
  270. * Does this observable handles observer registered with a given mask
  271. * @param mask defines the mask to be tested
  272. * @return whether or not one observer registered with the given mask is handeled
  273. **/
  274. hasSpecificMask(mask?: number): boolean;
  275. }
  276. }
  277. declare module BABYLON {
  278. /**
  279. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  280. * Babylon.js
  281. */
  282. export class DomManagement {
  283. /**
  284. * Checks if the window object exists
  285. * @returns true if the window object exists
  286. */
  287. static IsWindowObjectExist(): boolean;
  288. /**
  289. * Checks if the navigator object exists
  290. * @returns true if the navigator object exists
  291. */
  292. static IsNavigatorAvailable(): boolean;
  293. /**
  294. * Check if the document object exists
  295. * @returns true if the document object exists
  296. */
  297. static IsDocumentAvailable(): boolean;
  298. /**
  299. * Extracts text content from a DOM element hierarchy
  300. * @param element defines the root element
  301. * @returns a string
  302. */
  303. static GetDOMTextContent(element: HTMLElement): string;
  304. }
  305. }
  306. declare module BABYLON {
  307. /**
  308. * Logger used througouht the application to allow configuration of
  309. * the log level required for the messages.
  310. */
  311. export class Logger {
  312. /**
  313. * No log
  314. */
  315. static readonly NoneLogLevel: number;
  316. /**
  317. * Only message logs
  318. */
  319. static readonly MessageLogLevel: number;
  320. /**
  321. * Only warning logs
  322. */
  323. static readonly WarningLogLevel: number;
  324. /**
  325. * Only error logs
  326. */
  327. static readonly ErrorLogLevel: number;
  328. /**
  329. * All logs
  330. */
  331. static readonly AllLogLevel: number;
  332. private static _LogCache;
  333. /**
  334. * Gets a value indicating the number of loading errors
  335. * @ignorenaming
  336. */
  337. static errorsCount: number;
  338. /**
  339. * Callback called when a new log is added
  340. */
  341. static OnNewCacheEntry: (entry: string) => void;
  342. private static _AddLogEntry;
  343. private static _FormatMessage;
  344. private static _LogDisabled;
  345. private static _LogEnabled;
  346. private static _WarnDisabled;
  347. private static _WarnEnabled;
  348. private static _ErrorDisabled;
  349. private static _ErrorEnabled;
  350. /**
  351. * Log a message to the console
  352. */
  353. static Log: (message: string) => void;
  354. /**
  355. * Write a warning message to the console
  356. */
  357. static Warn: (message: string) => void;
  358. /**
  359. * Write an error message to the console
  360. */
  361. static Error: (message: string) => void;
  362. /**
  363. * Gets current log cache (list of logs)
  364. */
  365. static get LogCache(): string;
  366. /**
  367. * Clears the log cache
  368. */
  369. static ClearLogCache(): void;
  370. /**
  371. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  372. */
  373. static set LogLevels(level: number);
  374. }
  375. }
  376. declare module BABYLON {
  377. /** @hidden */
  378. export class _TypeStore {
  379. /** @hidden */
  380. static RegisteredTypes: {
  381. [key: string]: Object;
  382. };
  383. /** @hidden */
  384. static GetClass(fqdn: string): any;
  385. }
  386. }
  387. declare module BABYLON {
  388. /**
  389. * Helper to manipulate strings
  390. */
  391. export class StringTools {
  392. /**
  393. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  394. * @param str Source string
  395. * @param suffix Suffix to search for in the source string
  396. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  397. */
  398. static EndsWith(str: string, suffix: string): boolean;
  399. /**
  400. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  401. * @param str Source string
  402. * @param suffix Suffix to search for in the source string
  403. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  404. */
  405. static StartsWith(str: string, suffix: string): boolean;
  406. /**
  407. * Decodes a buffer into a string
  408. * @param buffer The buffer to decode
  409. * @returns The decoded string
  410. */
  411. static Decode(buffer: Uint8Array | Uint16Array): string;
  412. /**
  413. * Encode a buffer to a base64 string
  414. * @param buffer defines the buffer to encode
  415. * @returns the encoded string
  416. */
  417. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  418. /**
  419. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  420. * @param num the number to convert and pad
  421. * @param length the expected length of the string
  422. * @returns the padded string
  423. */
  424. static PadNumber(num: number, length: number): string;
  425. }
  426. }
  427. declare module BABYLON {
  428. /**
  429. * Class containing a set of static utilities functions for deep copy.
  430. */
  431. export class DeepCopier {
  432. /**
  433. * Tries to copy an object by duplicating every property
  434. * @param source defines the source object
  435. * @param destination defines the target object
  436. * @param doNotCopyList defines a list of properties to avoid
  437. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  438. */
  439. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  440. }
  441. }
  442. declare module BABYLON {
  443. /**
  444. * Class containing a set of static utilities functions for precision date
  445. */
  446. export class PrecisionDate {
  447. /**
  448. * Gets either window.performance.now() if supported or Date.now() else
  449. */
  450. static get Now(): number;
  451. }
  452. }
  453. declare module BABYLON {
  454. /** @hidden */
  455. export class _DevTools {
  456. static WarnImport(name: string): string;
  457. }
  458. }
  459. declare module BABYLON {
  460. /**
  461. * Interface used to define the mechanism to get data from the network
  462. */
  463. export interface IWebRequest {
  464. /**
  465. * Returns client's response url
  466. */
  467. responseURL: string;
  468. /**
  469. * Returns client's status
  470. */
  471. status: number;
  472. /**
  473. * Returns client's status as a text
  474. */
  475. statusText: string;
  476. }
  477. }
  478. declare module BABYLON {
  479. /**
  480. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  481. */
  482. export class WebRequest implements IWebRequest {
  483. private readonly _xhr;
  484. /**
  485. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  486. * i.e. when loading files, where the server/service expects an Authorization header
  487. */
  488. static CustomRequestHeaders: {
  489. [key: string]: string;
  490. };
  491. /**
  492. * Add callback functions in this array to update all the requests before they get sent to the network
  493. */
  494. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  495. private _injectCustomRequestHeaders;
  496. /**
  497. * Gets or sets a function to be called when loading progress changes
  498. */
  499. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  500. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  501. /**
  502. * Returns client's state
  503. */
  504. get readyState(): number;
  505. /**
  506. * Returns client's status
  507. */
  508. get status(): number;
  509. /**
  510. * Returns client's status as a text
  511. */
  512. get statusText(): string;
  513. /**
  514. * Returns client's response
  515. */
  516. get response(): any;
  517. /**
  518. * Returns client's response url
  519. */
  520. get responseURL(): string;
  521. /**
  522. * Returns client's response as text
  523. */
  524. get responseText(): string;
  525. /**
  526. * Gets or sets the expected response type
  527. */
  528. get responseType(): XMLHttpRequestResponseType;
  529. set responseType(value: XMLHttpRequestResponseType);
  530. /** @hidden */
  531. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  532. /** @hidden */
  533. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  534. /**
  535. * Cancels any network activity
  536. */
  537. abort(): void;
  538. /**
  539. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  540. * @param body defines an optional request body
  541. */
  542. send(body?: Document | BodyInit | null): void;
  543. /**
  544. * Sets the request method, request URL
  545. * @param method defines the method to use (GET, POST, etc..)
  546. * @param url defines the url to connect with
  547. */
  548. open(method: string, url: string): void;
  549. /**
  550. * Sets the value of a request header.
  551. * @param name The name of the header whose value is to be set
  552. * @param value The value to set as the body of the header
  553. */
  554. setRequestHeader(name: string, value: string): void;
  555. /**
  556. * Get the string containing the text of a particular header's value.
  557. * @param name The name of the header
  558. * @returns The string containing the text of the given header name
  559. */
  560. getResponseHeader(name: string): Nullable<string>;
  561. }
  562. }
  563. declare module BABYLON {
  564. /**
  565. * File request interface
  566. */
  567. export interface IFileRequest {
  568. /**
  569. * Raised when the request is complete (success or error).
  570. */
  571. onCompleteObservable: Observable<IFileRequest>;
  572. /**
  573. * Aborts the request for a file.
  574. */
  575. abort: () => void;
  576. }
  577. }
  578. declare module BABYLON {
  579. /**
  580. * Define options used to create a render target texture
  581. */
  582. export class RenderTargetCreationOptions {
  583. /**
  584. * Specifies is mipmaps must be generated
  585. */
  586. generateMipMaps?: boolean;
  587. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  588. generateDepthBuffer?: boolean;
  589. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  590. generateStencilBuffer?: boolean;
  591. /** Defines texture type (int by default) */
  592. type?: number;
  593. /** Defines sampling mode (trilinear by default) */
  594. samplingMode?: number;
  595. /** Defines format (RGBA by default) */
  596. format?: number;
  597. }
  598. }
  599. declare module BABYLON {
  600. /** Defines the cross module used constants to avoid circular dependncies */
  601. export class Constants {
  602. /** Defines that alpha blending is disabled */
  603. static readonly ALPHA_DISABLE: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  605. static readonly ALPHA_ADD: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  607. static readonly ALPHA_COMBINE: number;
  608. /** Defines that alpha blending is DEST - SRC * DEST */
  609. static readonly ALPHA_SUBTRACT: number;
  610. /** Defines that alpha blending is SRC * DEST */
  611. static readonly ALPHA_MULTIPLY: number;
  612. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  613. static readonly ALPHA_MAXIMIZED: number;
  614. /** Defines that alpha blending is SRC + DEST */
  615. static readonly ALPHA_ONEONE: number;
  616. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  617. static readonly ALPHA_PREMULTIPLIED: number;
  618. /**
  619. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  620. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  621. */
  622. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  623. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  624. static readonly ALPHA_INTERPOLATE: number;
  625. /**
  626. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  627. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  628. */
  629. static readonly ALPHA_SCREENMODE: number;
  630. /**
  631. * Defines that alpha blending is SRC + DST
  632. * Alpha will be set to SRC ALPHA + DST ALPHA
  633. */
  634. static readonly ALPHA_ONEONE_ONEONE: number;
  635. /**
  636. * Defines that alpha blending is SRC * DST ALPHA + DST
  637. * Alpha will be set to 0
  638. */
  639. static readonly ALPHA_ALPHATOCOLOR: number;
  640. /**
  641. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  642. */
  643. static readonly ALPHA_REVERSEONEMINUS: number;
  644. /**
  645. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  646. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  647. */
  648. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  649. /**
  650. * Defines that alpha blending is SRC + DST
  651. * Alpha will be set to SRC ALPHA
  652. */
  653. static readonly ALPHA_ONEONE_ONEZERO: number;
  654. /**
  655. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  656. * Alpha will be set to DST ALPHA
  657. */
  658. static readonly ALPHA_EXCLUSION: number;
  659. /** Defines that alpha blending equation a SUM */
  660. static readonly ALPHA_EQUATION_ADD: number;
  661. /** Defines that alpha blending equation a SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  663. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  664. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  665. /** Defines that alpha blending equation a MAX operation */
  666. static readonly ALPHA_EQUATION_MAX: number;
  667. /** Defines that alpha blending equation a MIN operation */
  668. static readonly ALPHA_EQUATION_MIN: number;
  669. /**
  670. * Defines that alpha blending equation a DARKEN operation:
  671. * It takes the min of the src and sums the alpha channels.
  672. */
  673. static readonly ALPHA_EQUATION_DARKEN: number;
  674. /** Defines that the ressource is not delayed*/
  675. static readonly DELAYLOADSTATE_NONE: number;
  676. /** Defines that the ressource was successfully delay loaded */
  677. static readonly DELAYLOADSTATE_LOADED: number;
  678. /** Defines that the ressource is currently delay loading */
  679. static readonly DELAYLOADSTATE_LOADING: number;
  680. /** Defines that the ressource is delayed and has not started loading */
  681. static readonly DELAYLOADSTATE_NOTLOADED: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  683. static readonly NEVER: number;
  684. /** 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 */
  685. static readonly ALWAYS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  687. static readonly LESS: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  689. static readonly EQUAL: number;
  690. /** 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 */
  691. static readonly LEQUAL: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  693. static readonly GREATER: number;
  694. /** 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 */
  695. static readonly GEQUAL: number;
  696. /** 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 */
  697. static readonly NOTEQUAL: number;
  698. /** Passed to stencilOperation to specify that stencil value must be kept */
  699. static readonly KEEP: number;
  700. /** Passed to stencilOperation to specify that stencil value must be replaced */
  701. static readonly REPLACE: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented */
  703. static readonly INCR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented */
  705. static readonly DECR: number;
  706. /** Passed to stencilOperation to specify that stencil value must be inverted */
  707. static readonly INVERT: number;
  708. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  709. static readonly INCR_WRAP: number;
  710. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  711. static readonly DECR_WRAP: number;
  712. /** Texture is not repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  714. /** Texture is repeating outside of 0..1 UVs */
  715. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  716. /** Texture is repeating and mirrored */
  717. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  718. /** ALPHA */
  719. static readonly TEXTUREFORMAT_ALPHA: number;
  720. /** LUMINANCE */
  721. static readonly TEXTUREFORMAT_LUMINANCE: number;
  722. /** LUMINANCE_ALPHA */
  723. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  724. /** RGB */
  725. static readonly TEXTUREFORMAT_RGB: number;
  726. /** RGBA */
  727. static readonly TEXTUREFORMAT_RGBA: number;
  728. /** RED */
  729. static readonly TEXTUREFORMAT_RED: number;
  730. /** RED (2nd reference) */
  731. static readonly TEXTUREFORMAT_R: number;
  732. /** RG */
  733. static readonly TEXTUREFORMAT_RG: number;
  734. /** RED_INTEGER */
  735. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  736. /** RED_INTEGER (2nd reference) */
  737. static readonly TEXTUREFORMAT_R_INTEGER: number;
  738. /** RG_INTEGER */
  739. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  740. /** RGB_INTEGER */
  741. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  742. /** RGBA_INTEGER */
  743. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  744. /** UNSIGNED_BYTE */
  745. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  746. /** UNSIGNED_BYTE (2nd reference) */
  747. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  748. /** FLOAT */
  749. static readonly TEXTURETYPE_FLOAT: number;
  750. /** HALF_FLOAT */
  751. static readonly TEXTURETYPE_HALF_FLOAT: number;
  752. /** BYTE */
  753. static readonly TEXTURETYPE_BYTE: number;
  754. /** SHORT */
  755. static readonly TEXTURETYPE_SHORT: number;
  756. /** UNSIGNED_SHORT */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  758. /** INT */
  759. static readonly TEXTURETYPE_INT: number;
  760. /** UNSIGNED_INT */
  761. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  762. /** UNSIGNED_SHORT_4_4_4_4 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  764. /** UNSIGNED_SHORT_5_5_5_1 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  766. /** UNSIGNED_SHORT_5_6_5 */
  767. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  768. /** UNSIGNED_INT_2_10_10_10_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  770. /** UNSIGNED_INT_24_8 */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  772. /** UNSIGNED_INT_10F_11F_11F_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  774. /** UNSIGNED_INT_5_9_9_9_REV */
  775. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  776. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  777. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  778. /** nearest is mag = nearest and min = nearest and no mip */
  779. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  780. /** mag = nearest and min = nearest and mip = none */
  781. static readonly TEXTURE_NEAREST_NEAREST: number;
  782. /** Bilinear is mag = linear and min = linear and no mip */
  783. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  784. /** mag = linear and min = linear and mip = none */
  785. static readonly TEXTURE_LINEAR_LINEAR: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  788. /** Trilinear is mag = linear and min = linear and mip = linear */
  789. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = nearest and mip = nearest */
  791. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = nearest */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  794. /** mag = nearest and min = linear and mip = linear */
  795. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  796. /** mag = nearest and min = linear and mip = none */
  797. static readonly TEXTURE_NEAREST_LINEAR: number;
  798. /** nearest is mag = nearest and min = nearest and mip = linear */
  799. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  800. /** mag = linear and min = nearest and mip = nearest */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  802. /** mag = linear and min = nearest and mip = linear */
  803. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  804. /** Bilinear is mag = linear and min = linear and mip = nearest */
  805. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  806. /** mag = linear and min = nearest and mip = none */
  807. static readonly TEXTURE_LINEAR_NEAREST: number;
  808. /** Explicit coordinates mode */
  809. static readonly TEXTURE_EXPLICIT_MODE: number;
  810. /** Spherical coordinates mode */
  811. static readonly TEXTURE_SPHERICAL_MODE: number;
  812. /** Planar coordinates mode */
  813. static readonly TEXTURE_PLANAR_MODE: number;
  814. /** Cubic coordinates mode */
  815. static readonly TEXTURE_CUBIC_MODE: number;
  816. /** Projection coordinates mode */
  817. static readonly TEXTURE_PROJECTION_MODE: number;
  818. /** Skybox coordinates mode */
  819. static readonly TEXTURE_SKYBOX_MODE: number;
  820. /** Inverse Cubic coordinates mode */
  821. static readonly TEXTURE_INVCUBIC_MODE: number;
  822. /** Equirectangular coordinates mode */
  823. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  826. /** Equirectangular Fixed Mirrored coordinates mode */
  827. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  828. /** Offline (baking) quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  830. /** High quality for texture filtering */
  831. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  832. /** Medium quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  834. /** Low quality for texture filtering */
  835. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  836. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  837. static readonly SCALEMODE_FLOOR: number;
  838. /** Defines that texture rescaling will look for the nearest power of 2 size */
  839. static readonly SCALEMODE_NEAREST: number;
  840. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  841. static readonly SCALEMODE_CEILING: number;
  842. /**
  843. * The dirty texture flag value
  844. */
  845. static readonly MATERIAL_TextureDirtyFlag: number;
  846. /**
  847. * The dirty light flag value
  848. */
  849. static readonly MATERIAL_LightDirtyFlag: number;
  850. /**
  851. * The dirty fresnel flag value
  852. */
  853. static readonly MATERIAL_FresnelDirtyFlag: number;
  854. /**
  855. * The dirty attribute flag value
  856. */
  857. static readonly MATERIAL_AttributesDirtyFlag: number;
  858. /**
  859. * The dirty misc flag value
  860. */
  861. static readonly MATERIAL_MiscDirtyFlag: number;
  862. /**
  863. * The dirty prepass flag value
  864. */
  865. static readonly MATERIAL_PrePassDirtyFlag: number;
  866. /**
  867. * The all dirty flag value
  868. */
  869. static readonly MATERIAL_AllDirtyFlag: number;
  870. /**
  871. * Returns the triangle fill mode
  872. */
  873. static readonly MATERIAL_TriangleFillMode: number;
  874. /**
  875. * Returns the wireframe mode
  876. */
  877. static readonly MATERIAL_WireFrameFillMode: number;
  878. /**
  879. * Returns the point fill mode
  880. */
  881. static readonly MATERIAL_PointFillMode: number;
  882. /**
  883. * Returns the point list draw mode
  884. */
  885. static readonly MATERIAL_PointListDrawMode: number;
  886. /**
  887. * Returns the line list draw mode
  888. */
  889. static readonly MATERIAL_LineListDrawMode: number;
  890. /**
  891. * Returns the line loop draw mode
  892. */
  893. static readonly MATERIAL_LineLoopDrawMode: number;
  894. /**
  895. * Returns the line strip draw mode
  896. */
  897. static readonly MATERIAL_LineStripDrawMode: number;
  898. /**
  899. * Returns the triangle strip draw mode
  900. */
  901. static readonly MATERIAL_TriangleStripDrawMode: number;
  902. /**
  903. * Returns the triangle fan draw mode
  904. */
  905. static readonly MATERIAL_TriangleFanDrawMode: number;
  906. /**
  907. * Stores the clock-wise side orientation
  908. */
  909. static readonly MATERIAL_ClockWiseSideOrientation: number;
  910. /**
  911. * Stores the counter clock-wise side orientation
  912. */
  913. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  914. /**
  915. * Nothing
  916. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_NothingTrigger: number;
  919. /**
  920. * On pick
  921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnPickTrigger: number;
  924. /**
  925. * On left pick
  926. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  927. */
  928. static readonly ACTION_OnLeftPickTrigger: number;
  929. /**
  930. * On right pick
  931. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnRightPickTrigger: number;
  934. /**
  935. * On center pick
  936. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnCenterPickTrigger: number;
  939. /**
  940. * On pick down
  941. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPickDownTrigger: number;
  944. /**
  945. * On double pick
  946. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnDoublePickTrigger: number;
  949. /**
  950. * On pick up
  951. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPickUpTrigger: number;
  954. /**
  955. * On pick out.
  956. * This trigger will only be raised if you also declared a OnPickDown
  957. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  958. */
  959. static readonly ACTION_OnPickOutTrigger: number;
  960. /**
  961. * On long press
  962. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  963. */
  964. static readonly ACTION_OnLongPressTrigger: number;
  965. /**
  966. * On pointer over
  967. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  968. */
  969. static readonly ACTION_OnPointerOverTrigger: number;
  970. /**
  971. * On pointer out
  972. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  973. */
  974. static readonly ACTION_OnPointerOutTrigger: number;
  975. /**
  976. * On every frame
  977. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  978. */
  979. static readonly ACTION_OnEveryFrameTrigger: number;
  980. /**
  981. * On intersection enter
  982. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  983. */
  984. static readonly ACTION_OnIntersectionEnterTrigger: number;
  985. /**
  986. * On intersection exit
  987. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  988. */
  989. static readonly ACTION_OnIntersectionExitTrigger: number;
  990. /**
  991. * On key down
  992. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  993. */
  994. static readonly ACTION_OnKeyDownTrigger: number;
  995. /**
  996. * On key up
  997. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  998. */
  999. static readonly ACTION_OnKeyUpTrigger: number;
  1000. /**
  1001. * Billboard mode will only apply to Y axis
  1002. */
  1003. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  1004. /**
  1005. * Billboard mode will apply to all axes
  1006. */
  1007. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1008. /**
  1009. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1010. */
  1011. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1012. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1013. * Test order :
  1014. * Is the bounding sphere outside the frustum ?
  1015. * If not, are the bounding box vertices outside the frustum ?
  1016. * It not, then the cullable object is in the frustum.
  1017. */
  1018. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1019. /** Culling strategy : Bounding Sphere Only.
  1020. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1021. * It's also less accurate than the standard because some not visible objects can still be selected.
  1022. * Test : is the bounding sphere outside the frustum ?
  1023. * If not, then the cullable object is in the frustum.
  1024. */
  1025. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1026. /** Culling strategy : Optimistic Inclusion.
  1027. * This in an inclusion test first, then the standard exclusion test.
  1028. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1029. * 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.
  1030. * Anyway, it's as accurate as the standard strategy.
  1031. * Test :
  1032. * Is the cullable object bounding sphere center in the frustum ?
  1033. * If not, apply the default culling strategy.
  1034. */
  1035. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1036. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1037. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1038. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1039. * 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.
  1040. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1041. * Test :
  1042. * Is the cullable object bounding sphere center in the frustum ?
  1043. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1044. */
  1045. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1046. /**
  1047. * No logging while loading
  1048. */
  1049. static readonly SCENELOADER_NO_LOGGING: number;
  1050. /**
  1051. * Minimal logging while loading
  1052. */
  1053. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1054. /**
  1055. * Summary logging while loading
  1056. */
  1057. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1058. /**
  1059. * Detailled logging while loading
  1060. */
  1061. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1062. /**
  1063. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1064. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1065. */
  1066. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1067. /**
  1068. * Constant used to retrieve the position texture index in the textures array in the prepass
  1069. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1070. */
  1071. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1072. /**
  1073. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1074. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1075. */
  1076. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1077. /**
  1078. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1079. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1080. */
  1081. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1082. /**
  1083. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1084. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1085. */
  1086. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1087. /**
  1088. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1089. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1090. */
  1091. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1092. /**
  1093. * Constant used to retrieve albedo index in the textures array in the prepass
  1094. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1095. */
  1096. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1097. }
  1098. }
  1099. declare module BABYLON {
  1100. /**
  1101. * This represents the required contract to create a new type of texture loader.
  1102. */
  1103. export interface IInternalTextureLoader {
  1104. /**
  1105. * Defines wether the loader supports cascade loading the different faces.
  1106. */
  1107. supportCascades: boolean;
  1108. /**
  1109. * This returns if the loader support the current file information.
  1110. * @param extension defines the file extension of the file being loaded
  1111. * @param mimeType defines the optional mime type of the file being loaded
  1112. * @returns true if the loader can load the specified file
  1113. */
  1114. canLoad(extension: string, mimeType?: string): boolean;
  1115. /**
  1116. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1117. * @param data contains the texture data
  1118. * @param texture defines the BabylonJS internal texture
  1119. * @param createPolynomials will be true if polynomials have been requested
  1120. * @param onLoad defines the callback to trigger once the texture is ready
  1121. * @param onError defines the callback to trigger in case of error
  1122. * @param options options to be passed to the loader
  1123. */
  1124. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  1125. /**
  1126. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1127. * @param data contains the texture data
  1128. * @param texture defines the BabylonJS internal texture
  1129. * @param callback defines the method to call once ready to upload
  1130. * @param options options to be passed to the loader
  1131. */
  1132. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  1133. }
  1134. }
  1135. declare module BABYLON {
  1136. /**
  1137. * Class used to store and describe the pipeline context associated with an effect
  1138. */
  1139. export interface IPipelineContext {
  1140. /**
  1141. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1142. */
  1143. isAsync: boolean;
  1144. /**
  1145. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1146. */
  1147. isReady: boolean;
  1148. /** @hidden */
  1149. _getVertexShaderCode(): string | null;
  1150. /** @hidden */
  1151. _getFragmentShaderCode(): string | null;
  1152. /** @hidden */
  1153. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1154. }
  1155. }
  1156. declare module BABYLON {
  1157. /**
  1158. * Class used to store gfx data (like WebGLBuffer)
  1159. */
  1160. export class DataBuffer {
  1161. /**
  1162. * Gets or sets the number of objects referencing this buffer
  1163. */
  1164. references: number;
  1165. /** Gets or sets the size of the underlying buffer */
  1166. capacity: number;
  1167. /**
  1168. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1169. */
  1170. is32Bits: boolean;
  1171. /**
  1172. * Gets the underlying buffer
  1173. */
  1174. get underlyingResource(): any;
  1175. }
  1176. }
  1177. declare module BABYLON {
  1178. /** @hidden */
  1179. export interface IShaderProcessor {
  1180. attributeProcessor?: (attribute: string) => string;
  1181. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1182. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1183. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1184. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1185. lineProcessor?: (line: string, isFragment: boolean) => string;
  1186. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1187. postProcessor?: (code: string, defines: string[], isFragment: boolean, engine: ThinEngine) => string;
  1188. }
  1189. }
  1190. declare module BABYLON {
  1191. /** @hidden */
  1192. export interface ProcessingOptions {
  1193. defines: string[];
  1194. indexParameters: any;
  1195. isFragment: boolean;
  1196. shouldUseHighPrecisionShader: boolean;
  1197. supportsUniformBuffers: boolean;
  1198. shadersRepository: string;
  1199. includesShadersStore: {
  1200. [key: string]: string;
  1201. };
  1202. processor?: IShaderProcessor;
  1203. version: string;
  1204. platformName: string;
  1205. lookForClosingBracketForUniformBuffer?: boolean;
  1206. }
  1207. }
  1208. declare module BABYLON {
  1209. /** @hidden */
  1210. export class ShaderCodeNode {
  1211. line: string;
  1212. children: ShaderCodeNode[];
  1213. additionalDefineKey?: string;
  1214. additionalDefineValue?: string;
  1215. isValid(preprocessors: {
  1216. [key: string]: string;
  1217. }): boolean;
  1218. process(preprocessors: {
  1219. [key: string]: string;
  1220. }, options: ProcessingOptions): string;
  1221. }
  1222. }
  1223. declare module BABYLON {
  1224. /** @hidden */
  1225. export class ShaderCodeCursor {
  1226. private _lines;
  1227. lineIndex: number;
  1228. get currentLine(): string;
  1229. get canRead(): boolean;
  1230. set lines(value: string[]);
  1231. }
  1232. }
  1233. declare module BABYLON {
  1234. /** @hidden */
  1235. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1236. process(preprocessors: {
  1237. [key: string]: string;
  1238. }, options: ProcessingOptions): string;
  1239. }
  1240. }
  1241. declare module BABYLON {
  1242. /** @hidden */
  1243. export class ShaderDefineExpression {
  1244. isTrue(preprocessors: {
  1245. [key: string]: string;
  1246. }): boolean;
  1247. private static _OperatorPriority;
  1248. private static _Stack;
  1249. static postfixToInfix(postfix: string[]): string;
  1250. static infixToPostfix(infix: string): string[];
  1251. }
  1252. }
  1253. declare module BABYLON {
  1254. /** @hidden */
  1255. export class ShaderCodeTestNode extends ShaderCodeNode {
  1256. testExpression: ShaderDefineExpression;
  1257. isValid(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module BABYLON {
  1263. /** @hidden */
  1264. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1265. define: string;
  1266. not: boolean;
  1267. constructor(define: string, not?: boolean);
  1268. isTrue(preprocessors: {
  1269. [key: string]: string;
  1270. }): boolean;
  1271. }
  1272. }
  1273. declare module BABYLON {
  1274. /** @hidden */
  1275. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1276. leftOperand: ShaderDefineExpression;
  1277. rightOperand: ShaderDefineExpression;
  1278. isTrue(preprocessors: {
  1279. [key: string]: string;
  1280. }): boolean;
  1281. }
  1282. }
  1283. declare module BABYLON {
  1284. /** @hidden */
  1285. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1286. leftOperand: ShaderDefineExpression;
  1287. rightOperand: ShaderDefineExpression;
  1288. isTrue(preprocessors: {
  1289. [key: string]: string;
  1290. }): boolean;
  1291. }
  1292. }
  1293. declare module BABYLON {
  1294. /** @hidden */
  1295. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1296. define: string;
  1297. operand: string;
  1298. testValue: string;
  1299. constructor(define: string, operand: string, testValue: string);
  1300. isTrue(preprocessors: {
  1301. [key: string]: string;
  1302. }): boolean;
  1303. }
  1304. }
  1305. declare module BABYLON {
  1306. /**
  1307. * Class used to enable access to offline support
  1308. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1309. */
  1310. export interface IOfflineProvider {
  1311. /**
  1312. * Gets a boolean indicating if scene must be saved in the database
  1313. */
  1314. enableSceneOffline: boolean;
  1315. /**
  1316. * Gets a boolean indicating if textures must be saved in the database
  1317. */
  1318. enableTexturesOffline: boolean;
  1319. /**
  1320. * Open the offline support and make it available
  1321. * @param successCallback defines the callback to call on success
  1322. * @param errorCallback defines the callback to call on error
  1323. */
  1324. open(successCallback: () => void, errorCallback: () => void): void;
  1325. /**
  1326. * Loads an image from the offline support
  1327. * @param url defines the url to load from
  1328. * @param image defines the target DOM image
  1329. */
  1330. loadImage(url: string, image: HTMLImageElement): void;
  1331. /**
  1332. * Loads a file from offline support
  1333. * @param url defines the URL to load from
  1334. * @param sceneLoaded defines a callback to call on success
  1335. * @param progressCallBack defines a callback to call when progress changed
  1336. * @param errorCallback defines a callback to call on error
  1337. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1338. */
  1339. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1340. }
  1341. }
  1342. declare module BABYLON {
  1343. /**
  1344. * Class used to help managing file picking and drag'n'drop
  1345. * File Storage
  1346. */
  1347. export class FilesInputStore {
  1348. /**
  1349. * List of files ready to be loaded
  1350. */
  1351. static FilesToLoad: {
  1352. [key: string]: File;
  1353. };
  1354. }
  1355. }
  1356. declare module BABYLON {
  1357. /**
  1358. * Class used to define a retry strategy when error happens while loading assets
  1359. */
  1360. export class RetryStrategy {
  1361. /**
  1362. * Function used to defines an exponential back off strategy
  1363. * @param maxRetries defines the maximum number of retries (3 by default)
  1364. * @param baseInterval defines the interval between retries
  1365. * @returns the strategy function to use
  1366. */
  1367. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1368. }
  1369. }
  1370. declare module BABYLON {
  1371. /**
  1372. * @ignore
  1373. * Application error to support additional information when loading a file
  1374. */
  1375. export abstract class BaseError extends Error {
  1376. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1377. }
  1378. }
  1379. declare module BABYLON {
  1380. /** @ignore */
  1381. export class LoadFileError extends BaseError {
  1382. request?: WebRequest;
  1383. file?: File;
  1384. /**
  1385. * Creates a new LoadFileError
  1386. * @param message defines the message of the error
  1387. * @param request defines the optional web request
  1388. * @param file defines the optional file
  1389. */
  1390. constructor(message: string, object?: WebRequest | File);
  1391. }
  1392. /** @ignore */
  1393. export class RequestFileError extends BaseError {
  1394. request: WebRequest;
  1395. /**
  1396. * Creates a new LoadFileError
  1397. * @param message defines the message of the error
  1398. * @param request defines the optional web request
  1399. */
  1400. constructor(message: string, request: WebRequest);
  1401. }
  1402. /** @ignore */
  1403. export class ReadFileError extends BaseError {
  1404. file: File;
  1405. /**
  1406. * Creates a new ReadFileError
  1407. * @param message defines the message of the error
  1408. * @param file defines the optional file
  1409. */
  1410. constructor(message: string, file: File);
  1411. }
  1412. /**
  1413. * @hidden
  1414. */
  1415. export class FileTools {
  1416. /**
  1417. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1418. */
  1419. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1420. /**
  1421. * Gets or sets the base URL to use to load assets
  1422. */
  1423. static BaseUrl: string;
  1424. /**
  1425. * Default behaviour for cors in the application.
  1426. * It can be a string if the expected behavior is identical in the entire app.
  1427. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1428. */
  1429. static CorsBehavior: string | ((url: string | string[]) => string);
  1430. /**
  1431. * Gets or sets a function used to pre-process url before using them to load assets
  1432. */
  1433. static PreprocessUrl: (url: string) => string;
  1434. /**
  1435. * Removes unwanted characters from an url
  1436. * @param url defines the url to clean
  1437. * @returns the cleaned url
  1438. */
  1439. private static _CleanUrl;
  1440. /**
  1441. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1442. * @param url define the url we are trying
  1443. * @param element define the dom element where to configure the cors policy
  1444. */
  1445. static SetCorsBehavior(url: string | string[], element: {
  1446. crossOrigin: string | null;
  1447. }): void;
  1448. /**
  1449. * Loads an image as an HTMLImageElement.
  1450. * @param input url string, ArrayBuffer, or Blob to load
  1451. * @param onLoad callback called when the image successfully loads
  1452. * @param onError callback called when the image fails to load
  1453. * @param offlineProvider offline provider for caching
  1454. * @param mimeType optional mime type
  1455. * @returns the HTMLImageElement of the loaded image
  1456. */
  1457. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1458. /**
  1459. * Reads a file from a File object
  1460. * @param file defines the file to load
  1461. * @param onSuccess defines the callback to call when data is loaded
  1462. * @param onProgress defines the callback to call during loading process
  1463. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1464. * @param onError defines the callback to call when an error occurs
  1465. * @returns a file request object
  1466. */
  1467. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1468. /**
  1469. * Loads a file from a url
  1470. * @param url url to load
  1471. * @param onSuccess callback called when the file successfully loads
  1472. * @param onProgress callback called while file is loading (if the server supports this mode)
  1473. * @param offlineProvider defines the offline provider for caching
  1474. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1475. * @param onError callback called when the file fails to load
  1476. * @returns a file request object
  1477. */
  1478. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1479. /**
  1480. * Loads a file
  1481. * @param url url to load
  1482. * @param onSuccess callback called when the file successfully loads
  1483. * @param onProgress callback called while file is loading (if the server supports this mode)
  1484. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1485. * @param onError callback called when the file fails to load
  1486. * @param onOpened callback called when the web request is opened
  1487. * @returns a file request object
  1488. */
  1489. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1490. /**
  1491. * Checks if the loaded document was accessed via `file:`-Protocol.
  1492. * @returns boolean
  1493. */
  1494. static IsFileURL(): boolean;
  1495. }
  1496. }
  1497. declare module BABYLON {
  1498. /** @hidden */
  1499. export class ShaderProcessor {
  1500. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  1501. private static _ProcessPrecision;
  1502. private static _ExtractOperation;
  1503. private static _BuildSubExpression;
  1504. private static _BuildExpression;
  1505. private static _MoveCursorWithinIf;
  1506. private static _MoveCursor;
  1507. private static _EvaluatePreProcessors;
  1508. private static _PreparePreProcessors;
  1509. private static _ProcessShaderConversion;
  1510. private static _ProcessIncludes;
  1511. /**
  1512. * Loads a file from a url
  1513. * @param url url to load
  1514. * @param onSuccess callback called when the file successfully loads
  1515. * @param onProgress callback called while file is loading (if the server supports this mode)
  1516. * @param offlineProvider defines the offline provider for caching
  1517. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1518. * @param onError callback called when the file fails to load
  1519. * @returns a file request object
  1520. * @hidden
  1521. */
  1522. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1523. }
  1524. }
  1525. declare module BABYLON {
  1526. /**
  1527. * @hidden
  1528. */
  1529. export interface IColor4Like {
  1530. r: float;
  1531. g: float;
  1532. b: float;
  1533. a: float;
  1534. }
  1535. /**
  1536. * @hidden
  1537. */
  1538. export interface IColor3Like {
  1539. r: float;
  1540. g: float;
  1541. b: float;
  1542. }
  1543. /**
  1544. * @hidden
  1545. */
  1546. export interface IVector4Like {
  1547. x: float;
  1548. y: float;
  1549. z: float;
  1550. w: float;
  1551. }
  1552. /**
  1553. * @hidden
  1554. */
  1555. export interface IVector3Like {
  1556. x: float;
  1557. y: float;
  1558. z: float;
  1559. }
  1560. /**
  1561. * @hidden
  1562. */
  1563. export interface IVector2Like {
  1564. x: float;
  1565. y: float;
  1566. }
  1567. /**
  1568. * @hidden
  1569. */
  1570. export interface IMatrixLike {
  1571. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1572. updateFlag: int;
  1573. }
  1574. /**
  1575. * @hidden
  1576. */
  1577. export interface IViewportLike {
  1578. x: float;
  1579. y: float;
  1580. width: float;
  1581. height: float;
  1582. }
  1583. /**
  1584. * @hidden
  1585. */
  1586. export interface IPlaneLike {
  1587. normal: IVector3Like;
  1588. d: float;
  1589. normalize(): void;
  1590. }
  1591. }
  1592. declare module BABYLON {
  1593. /**
  1594. * Interface used to define common properties for effect fallbacks
  1595. */
  1596. export interface IEffectFallbacks {
  1597. /**
  1598. * Removes the defines that should be removed when falling back.
  1599. * @param currentDefines defines the current define statements for the shader.
  1600. * @param effect defines the current effect we try to compile
  1601. * @returns The resulting defines with defines of the current rank removed.
  1602. */
  1603. reduce(currentDefines: string, effect: Effect): string;
  1604. /**
  1605. * Removes the fallback from the bound mesh.
  1606. */
  1607. unBindMesh(): void;
  1608. /**
  1609. * Checks to see if more fallbacks are still availible.
  1610. */
  1611. hasMoreFallbacks: boolean;
  1612. }
  1613. }
  1614. declare module BABYLON {
  1615. /**
  1616. * Interface for the size containing width and height
  1617. */
  1618. export interface ISize {
  1619. /**
  1620. * Width
  1621. */
  1622. width: number;
  1623. /**
  1624. * Heighht
  1625. */
  1626. height: number;
  1627. }
  1628. /**
  1629. * Size containing widht and height
  1630. */
  1631. export class Size implements ISize {
  1632. /**
  1633. * Width
  1634. */
  1635. width: number;
  1636. /**
  1637. * Height
  1638. */
  1639. height: number;
  1640. /**
  1641. * Creates a Size object from the given width and height (floats).
  1642. * @param width width of the new size
  1643. * @param height height of the new size
  1644. */
  1645. constructor(width: number, height: number);
  1646. /**
  1647. * Returns a string with the Size width and height
  1648. * @returns a string with the Size width and height
  1649. */
  1650. toString(): string;
  1651. /**
  1652. * "Size"
  1653. * @returns the string "Size"
  1654. */
  1655. getClassName(): string;
  1656. /**
  1657. * Returns the Size hash code.
  1658. * @returns a hash code for a unique width and height
  1659. */
  1660. getHashCode(): number;
  1661. /**
  1662. * Updates the current size from the given one.
  1663. * @param src the given size
  1664. */
  1665. copyFrom(src: Size): void;
  1666. /**
  1667. * Updates in place the current Size from the given floats.
  1668. * @param width width of the new size
  1669. * @param height height of the new size
  1670. * @returns the updated Size.
  1671. */
  1672. copyFromFloats(width: number, height: number): Size;
  1673. /**
  1674. * Updates in place the current Size from the given floats.
  1675. * @param width width to set
  1676. * @param height height to set
  1677. * @returns the updated Size.
  1678. */
  1679. set(width: number, height: number): Size;
  1680. /**
  1681. * Multiplies the width and height by numbers
  1682. * @param w factor to multiple the width by
  1683. * @param h factor to multiple the height by
  1684. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  1685. */
  1686. multiplyByFloats(w: number, h: number): Size;
  1687. /**
  1688. * Clones the size
  1689. * @returns a new Size copied from the given one.
  1690. */
  1691. clone(): Size;
  1692. /**
  1693. * True if the current Size and the given one width and height are strictly equal.
  1694. * @param other the other size to compare against
  1695. * @returns True if the current Size and the given one width and height are strictly equal.
  1696. */
  1697. equals(other: Size): boolean;
  1698. /**
  1699. * The surface of the Size : width * height (float).
  1700. */
  1701. get surface(): number;
  1702. /**
  1703. * Create a new size of zero
  1704. * @returns a new Size set to (0.0, 0.0)
  1705. */
  1706. static Zero(): Size;
  1707. /**
  1708. * Sums the width and height of two sizes
  1709. * @param otherSize size to add to this size
  1710. * @returns a new Size set as the addition result of the current Size and the given one.
  1711. */
  1712. add(otherSize: Size): Size;
  1713. /**
  1714. * Subtracts the width and height of two
  1715. * @param otherSize size to subtract to this size
  1716. * @returns a new Size set as the subtraction result of the given one from the current Size.
  1717. */
  1718. subtract(otherSize: Size): Size;
  1719. /**
  1720. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  1721. * @param start starting size to lerp between
  1722. * @param end end size to lerp between
  1723. * @param amount amount to lerp between the start and end values
  1724. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  1725. */
  1726. static Lerp(start: Size, end: Size, amount: number): Size;
  1727. }
  1728. }
  1729. declare module BABYLON {
  1730. /**
  1731. * Base class of all the textures in babylon.
  1732. * It groups all the common properties required to work with Thin Engine.
  1733. */
  1734. export class ThinTexture {
  1735. protected _wrapU: number;
  1736. /**
  1737. * | Value | Type | Description |
  1738. * | ----- | ------------------ | ----------- |
  1739. * | 0 | CLAMP_ADDRESSMODE | |
  1740. * | 1 | WRAP_ADDRESSMODE | |
  1741. * | 2 | MIRROR_ADDRESSMODE | |
  1742. */
  1743. get wrapU(): number;
  1744. set wrapU(value: number);
  1745. protected _wrapV: number;
  1746. /**
  1747. * | Value | Type | Description |
  1748. * | ----- | ------------------ | ----------- |
  1749. * | 0 | CLAMP_ADDRESSMODE | |
  1750. * | 1 | WRAP_ADDRESSMODE | |
  1751. * | 2 | MIRROR_ADDRESSMODE | |
  1752. */
  1753. get wrapV(): number;
  1754. set wrapV(value: number);
  1755. /**
  1756. * | Value | Type | Description |
  1757. * | ----- | ------------------ | ----------- |
  1758. * | 0 | CLAMP_ADDRESSMODE | |
  1759. * | 1 | WRAP_ADDRESSMODE | |
  1760. * | 2 | MIRROR_ADDRESSMODE | |
  1761. */
  1762. wrapR: number;
  1763. /**
  1764. * With compliant hardware and browser (supporting anisotropic filtering)
  1765. * this defines the level of anisotropic filtering in the texture.
  1766. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  1767. */
  1768. anisotropicFilteringLevel: number;
  1769. /**
  1770. * Define the current state of the loading sequence when in delayed load mode.
  1771. */
  1772. delayLoadState: number;
  1773. /**
  1774. * How a texture is mapped.
  1775. * Unused in thin texture mode.
  1776. */
  1777. get coordinatesMode(): number;
  1778. /**
  1779. * Define if the texture is a cube texture or if false a 2d texture.
  1780. */
  1781. get isCube(): boolean;
  1782. set isCube(value: boolean);
  1783. /**
  1784. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  1785. */
  1786. get is3D(): boolean;
  1787. set is3D(value: boolean);
  1788. /**
  1789. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  1790. */
  1791. get is2DArray(): boolean;
  1792. set is2DArray(value: boolean);
  1793. /**
  1794. * Get the class name of the texture.
  1795. * @returns "ThinTexture"
  1796. */
  1797. getClassName(): string;
  1798. /** @hidden */
  1799. _texture: Nullable<InternalTexture>;
  1800. protected _engine: Nullable<ThinEngine>;
  1801. private _cachedSize;
  1802. private _cachedBaseSize;
  1803. /**
  1804. * Instantiates a new ThinTexture.
  1805. * Base class of all the textures in babylon.
  1806. * This can be used as an internal texture wrapper in ThinEngine to benefit from the cache
  1807. * @param internalTexture Define the internalTexture to wrap
  1808. */
  1809. constructor(internalTexture: Nullable<InternalTexture>);
  1810. /**
  1811. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  1812. * @returns true if fully ready
  1813. */
  1814. isReady(): boolean;
  1815. /**
  1816. * Triggers the load sequence in delayed load mode.
  1817. */
  1818. delayLoad(): void;
  1819. /**
  1820. * Get the underlying lower level texture from Babylon.
  1821. * @returns the insternal texture
  1822. */
  1823. getInternalTexture(): Nullable<InternalTexture>;
  1824. /**
  1825. * Get the size of the texture.
  1826. * @returns the texture size.
  1827. */
  1828. getSize(): ISize;
  1829. /**
  1830. * Get the base size of the texture.
  1831. * It can be different from the size if the texture has been resized for POT for instance
  1832. * @returns the base size
  1833. */
  1834. getBaseSize(): ISize;
  1835. /**
  1836. * Update the sampling mode of the texture.
  1837. * Default is Trilinear mode.
  1838. *
  1839. * | Value | Type | Description |
  1840. * | ----- | ------------------ | ----------- |
  1841. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  1842. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  1843. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  1844. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  1845. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  1846. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  1847. * | 7 | NEAREST_LINEAR | |
  1848. * | 8 | NEAREST_NEAREST | |
  1849. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  1850. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  1851. * | 11 | LINEAR_LINEAR | |
  1852. * | 12 | LINEAR_NEAREST | |
  1853. *
  1854. * > _mag_: magnification filter (close to the viewer)
  1855. * > _min_: minification filter (far from the viewer)
  1856. * > _mip_: filter used between mip map levels
  1857. *@param samplingMode Define the new sampling mode of the texture
  1858. */
  1859. updateSamplingMode(samplingMode: number): void;
  1860. /**
  1861. * Release and destroy the underlying lower level texture aka internalTexture.
  1862. */
  1863. releaseInternalTexture(): void;
  1864. /**
  1865. * Dispose the texture and release its associated resources.
  1866. */
  1867. dispose(): void;
  1868. }
  1869. }
  1870. declare module BABYLON {
  1871. /**
  1872. * Defines an array and its length.
  1873. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  1874. */
  1875. export interface ISmartArrayLike<T> {
  1876. /**
  1877. * The data of the array.
  1878. */
  1879. data: Array<T>;
  1880. /**
  1881. * The active length of the array.
  1882. */
  1883. length: number;
  1884. }
  1885. /**
  1886. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  1887. */
  1888. export class SmartArray<T> implements ISmartArrayLike<T> {
  1889. /**
  1890. * The full set of data from the array.
  1891. */
  1892. data: Array<T>;
  1893. /**
  1894. * The active length of the array.
  1895. */
  1896. length: number;
  1897. protected _id: number;
  1898. /**
  1899. * Instantiates a Smart Array.
  1900. * @param capacity defines the default capacity of the array.
  1901. */
  1902. constructor(capacity: number);
  1903. /**
  1904. * Pushes a value at the end of the active data.
  1905. * @param value defines the object to push in the array.
  1906. */
  1907. push(value: T): void;
  1908. /**
  1909. * Iterates over the active data and apply the lambda to them.
  1910. * @param func defines the action to apply on each value.
  1911. */
  1912. forEach(func: (content: T) => void): void;
  1913. /**
  1914. * Sorts the full sets of data.
  1915. * @param compareFn defines the comparison function to apply.
  1916. */
  1917. sort(compareFn: (a: T, b: T) => number): void;
  1918. /**
  1919. * Resets the active data to an empty array.
  1920. */
  1921. reset(): void;
  1922. /**
  1923. * Releases all the data from the array as well as the array.
  1924. */
  1925. dispose(): void;
  1926. /**
  1927. * Concats the active data with a given array.
  1928. * @param array defines the data to concatenate with.
  1929. */
  1930. concat(array: any): void;
  1931. /**
  1932. * Returns the position of a value in the active data.
  1933. * @param value defines the value to find the index for
  1934. * @returns the index if found in the active data otherwise -1
  1935. */
  1936. indexOf(value: T): number;
  1937. /**
  1938. * Returns whether an element is part of the active data.
  1939. * @param value defines the value to look for
  1940. * @returns true if found in the active data otherwise false
  1941. */
  1942. contains(value: T): boolean;
  1943. private static _GlobalId;
  1944. }
  1945. /**
  1946. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  1947. * The data in this array can only be present once
  1948. */
  1949. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  1950. private _duplicateId;
  1951. /**
  1952. * Pushes a value at the end of the active data.
  1953. * THIS DOES NOT PREVENT DUPPLICATE DATA
  1954. * @param value defines the object to push in the array.
  1955. */
  1956. push(value: T): void;
  1957. /**
  1958. * Pushes a value at the end of the active data.
  1959. * If the data is already present, it won t be added again
  1960. * @param value defines the object to push in the array.
  1961. * @returns true if added false if it was already present
  1962. */
  1963. pushNoDuplicate(value: T): boolean;
  1964. /**
  1965. * Resets the active data to an empty array.
  1966. */
  1967. reset(): void;
  1968. /**
  1969. * Concats the active data with a given array.
  1970. * This ensures no dupplicate will be present in the result.
  1971. * @param array defines the data to concatenate with.
  1972. */
  1973. concatWithNoDuplicate(array: any): void;
  1974. }
  1975. }
  1976. declare module BABYLON {
  1977. /**
  1978. * Class used to evalaute queries containing `and` and `or` operators
  1979. */
  1980. export class AndOrNotEvaluator {
  1981. /**
  1982. * Evaluate a query
  1983. * @param query defines the query to evaluate
  1984. * @param evaluateCallback defines the callback used to filter result
  1985. * @returns true if the query matches
  1986. */
  1987. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1988. private static _HandleParenthesisContent;
  1989. private static _SimplifyNegation;
  1990. }
  1991. }
  1992. declare module BABYLON {
  1993. /**
  1994. * Class used to store custom tags
  1995. */
  1996. export class Tags {
  1997. /**
  1998. * Adds support for tags on the given object
  1999. * @param obj defines the object to use
  2000. */
  2001. static EnableFor(obj: any): void;
  2002. /**
  2003. * Removes tags support
  2004. * @param obj defines the object to use
  2005. */
  2006. static DisableFor(obj: any): void;
  2007. /**
  2008. * Gets a boolean indicating if the given object has tags
  2009. * @param obj defines the object to use
  2010. * @returns a boolean
  2011. */
  2012. static HasTags(obj: any): boolean;
  2013. /**
  2014. * Gets the tags available on a given object
  2015. * @param obj defines the object to use
  2016. * @param asString defines if the tags must be returned as a string instead of an array of strings
  2017. * @returns the tags
  2018. */
  2019. static GetTags(obj: any, asString?: boolean): any;
  2020. /**
  2021. * Adds tags to an object
  2022. * @param obj defines the object to use
  2023. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  2024. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  2025. */
  2026. static AddTagsTo(obj: any, tagsString: string): void;
  2027. /**
  2028. * @hidden
  2029. */
  2030. static _AddTagTo(obj: any, tag: string): void;
  2031. /**
  2032. * Removes specific tags from a specific object
  2033. * @param obj defines the object to use
  2034. * @param tagsString defines the tags to remove
  2035. */
  2036. static RemoveTagsFrom(obj: any, tagsString: string): void;
  2037. /**
  2038. * @hidden
  2039. */
  2040. static _RemoveTagFrom(obj: any, tag: string): void;
  2041. /**
  2042. * Defines if tags hosted on an object match a given query
  2043. * @param obj defines the object to use
  2044. * @param tagsQuery defines the tag query
  2045. * @returns a boolean
  2046. */
  2047. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  2048. }
  2049. }
  2050. declare module BABYLON {
  2051. /**
  2052. * Scalar computation library
  2053. */
  2054. export class Scalar {
  2055. /**
  2056. * Two pi constants convenient for computation.
  2057. */
  2058. static TwoPi: number;
  2059. /**
  2060. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2061. * @param a number
  2062. * @param b number
  2063. * @param epsilon (default = 1.401298E-45)
  2064. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2065. */
  2066. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  2067. /**
  2068. * Returns a string : the upper case translation of the number i to hexadecimal.
  2069. * @param i number
  2070. * @returns the upper case translation of the number i to hexadecimal.
  2071. */
  2072. static ToHex(i: number): string;
  2073. /**
  2074. * Returns -1 if value is negative and +1 is value is positive.
  2075. * @param value the value
  2076. * @returns the value itself if it's equal to zero.
  2077. */
  2078. static Sign(value: number): number;
  2079. /**
  2080. * Returns the value itself if it's between min and max.
  2081. * Returns min if the value is lower than min.
  2082. * Returns max if the value is greater than max.
  2083. * @param value the value to clmap
  2084. * @param min the min value to clamp to (default: 0)
  2085. * @param max the max value to clamp to (default: 1)
  2086. * @returns the clamped value
  2087. */
  2088. static Clamp(value: number, min?: number, max?: number): number;
  2089. /**
  2090. * the log2 of value.
  2091. * @param value the value to compute log2 of
  2092. * @returns the log2 of value.
  2093. */
  2094. static Log2(value: number): number;
  2095. /**
  2096. * Loops the value, so that it is never larger than length and never smaller than 0.
  2097. *
  2098. * This is similar to the modulo operator but it works with floating point numbers.
  2099. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  2100. * With t = 5 and length = 2.5, the result would be 0.0.
  2101. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  2102. * @param value the value
  2103. * @param length the length
  2104. * @returns the looped value
  2105. */
  2106. static Repeat(value: number, length: number): number;
  2107. /**
  2108. * Normalize the value between 0.0 and 1.0 using min and max values
  2109. * @param value value to normalize
  2110. * @param min max to normalize between
  2111. * @param max min to normalize between
  2112. * @returns the normalized value
  2113. */
  2114. static Normalize(value: number, min: number, max: number): number;
  2115. /**
  2116. * Denormalize the value from 0.0 and 1.0 using min and max values
  2117. * @param normalized value to denormalize
  2118. * @param min max to denormalize between
  2119. * @param max min to denormalize between
  2120. * @returns the denormalized value
  2121. */
  2122. static Denormalize(normalized: number, min: number, max: number): number;
  2123. /**
  2124. * Calculates the shortest difference between two given angles given in degrees.
  2125. * @param current current angle in degrees
  2126. * @param target target angle in degrees
  2127. * @returns the delta
  2128. */
  2129. static DeltaAngle(current: number, target: number): number;
  2130. /**
  2131. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  2132. * @param tx value
  2133. * @param length length
  2134. * @returns The returned value will move back and forth between 0 and length
  2135. */
  2136. static PingPong(tx: number, length: number): number;
  2137. /**
  2138. * Interpolates between min and max with smoothing at the limits.
  2139. *
  2140. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  2141. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  2142. * @param from from
  2143. * @param to to
  2144. * @param tx value
  2145. * @returns the smooth stepped value
  2146. */
  2147. static SmoothStep(from: number, to: number, tx: number): number;
  2148. /**
  2149. * Moves a value current towards target.
  2150. *
  2151. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  2152. * Negative values of maxDelta pushes the value away from target.
  2153. * @param current current value
  2154. * @param target target value
  2155. * @param maxDelta max distance to move
  2156. * @returns resulting value
  2157. */
  2158. static MoveTowards(current: number, target: number, maxDelta: number): number;
  2159. /**
  2160. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2161. *
  2162. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  2163. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  2164. * @param current current value
  2165. * @param target target value
  2166. * @param maxDelta max distance to move
  2167. * @returns resulting angle
  2168. */
  2169. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  2170. /**
  2171. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  2172. * @param start start value
  2173. * @param end target value
  2174. * @param amount amount to lerp between
  2175. * @returns the lerped value
  2176. */
  2177. static Lerp(start: number, end: number, amount: number): number;
  2178. /**
  2179. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2180. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  2181. * @param start start value
  2182. * @param end target value
  2183. * @param amount amount to lerp between
  2184. * @returns the lerped value
  2185. */
  2186. static LerpAngle(start: number, end: number, amount: number): number;
  2187. /**
  2188. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  2189. * @param a start value
  2190. * @param b target value
  2191. * @param value value between a and b
  2192. * @returns the inverseLerp value
  2193. */
  2194. static InverseLerp(a: number, b: number, value: number): number;
  2195. /**
  2196. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  2197. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  2198. * @param value1 spline value
  2199. * @param tangent1 spline value
  2200. * @param value2 spline value
  2201. * @param tangent2 spline value
  2202. * @param amount input value
  2203. * @returns hermite result
  2204. */
  2205. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  2206. /**
  2207. * Returns a random float number between and min and max values
  2208. * @param min min value of random
  2209. * @param max max value of random
  2210. * @returns random value
  2211. */
  2212. static RandomRange(min: number, max: number): number;
  2213. /**
  2214. * This function returns percentage of a number in a given range.
  2215. *
  2216. * RangeToPercent(40,20,60) will return 0.5 (50%)
  2217. * RangeToPercent(34,0,100) will return 0.34 (34%)
  2218. * @param number to convert to percentage
  2219. * @param min min range
  2220. * @param max max range
  2221. * @returns the percentage
  2222. */
  2223. static RangeToPercent(number: number, min: number, max: number): number;
  2224. /**
  2225. * This function returns number that corresponds to the percentage in a given range.
  2226. *
  2227. * PercentToRange(0.34,0,100) will return 34.
  2228. * @param percent to convert to number
  2229. * @param min min range
  2230. * @param max max range
  2231. * @returns the number
  2232. */
  2233. static PercentToRange(percent: number, min: number, max: number): number;
  2234. /**
  2235. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  2236. * @param angle The angle to normalize in radian.
  2237. * @return The converted angle.
  2238. */
  2239. static NormalizeRadians(angle: number): number;
  2240. }
  2241. }
  2242. declare module BABYLON {
  2243. /**
  2244. * Constant used to convert a value to gamma space
  2245. * @ignorenaming
  2246. */
  2247. export const ToGammaSpace: number;
  2248. /**
  2249. * Constant used to convert a value to linear space
  2250. * @ignorenaming
  2251. */
  2252. export const ToLinearSpace = 2.2;
  2253. /**
  2254. * Constant used to define the minimal number value in Babylon.js
  2255. * @ignorenaming
  2256. */
  2257. let Epsilon: number;
  2258. }
  2259. declare module BABYLON {
  2260. /**
  2261. * Class used to represent a viewport on screen
  2262. */
  2263. export class Viewport {
  2264. /** viewport left coordinate */
  2265. x: number;
  2266. /** viewport top coordinate */
  2267. y: number;
  2268. /**viewport width */
  2269. width: number;
  2270. /** viewport height */
  2271. height: number;
  2272. /**
  2273. * Creates a Viewport object located at (x, y) and sized (width, height)
  2274. * @param x defines viewport left coordinate
  2275. * @param y defines viewport top coordinate
  2276. * @param width defines the viewport width
  2277. * @param height defines the viewport height
  2278. */
  2279. constructor(
  2280. /** viewport left coordinate */
  2281. x: number,
  2282. /** viewport top coordinate */
  2283. y: number,
  2284. /**viewport width */
  2285. width: number,
  2286. /** viewport height */
  2287. height: number);
  2288. /**
  2289. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  2290. * @param renderWidth defines the rendering width
  2291. * @param renderHeight defines the rendering height
  2292. * @returns a new Viewport
  2293. */
  2294. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  2295. /**
  2296. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  2297. * @param renderWidth defines the rendering width
  2298. * @param renderHeight defines the rendering height
  2299. * @param ref defines the target viewport
  2300. * @returns the current viewport
  2301. */
  2302. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  2303. /**
  2304. * Returns a new Viewport copied from the current one
  2305. * @returns a new Viewport
  2306. */
  2307. clone(): Viewport;
  2308. }
  2309. }
  2310. declare module BABYLON {
  2311. /**
  2312. * Class containing a set of static utilities functions for arrays.
  2313. */
  2314. export class ArrayTools {
  2315. /**
  2316. * Returns an array of the given size filled with element built from the given constructor and the paramters
  2317. * @param size the number of element to construct and put in the array
  2318. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  2319. * @returns a new array filled with new objects
  2320. */
  2321. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  2322. }
  2323. }
  2324. declare module BABYLON {
  2325. /**
  2326. * Represents a plane by the equation ax + by + cz + d = 0
  2327. */
  2328. export class Plane {
  2329. private static _TmpMatrix;
  2330. /**
  2331. * Normal of the plane (a,b,c)
  2332. */
  2333. normal: Vector3;
  2334. /**
  2335. * d component of the plane
  2336. */
  2337. d: number;
  2338. /**
  2339. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  2340. * @param a a component of the plane
  2341. * @param b b component of the plane
  2342. * @param c c component of the plane
  2343. * @param d d component of the plane
  2344. */
  2345. constructor(a: number, b: number, c: number, d: number);
  2346. /**
  2347. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2348. */
  2349. asArray(): number[];
  2350. /**
  2351. * @returns a new plane copied from the current Plane.
  2352. */
  2353. clone(): Plane;
  2354. /**
  2355. * @returns the string "Plane".
  2356. */
  2357. getClassName(): string;
  2358. /**
  2359. * @returns the Plane hash code.
  2360. */
  2361. getHashCode(): number;
  2362. /**
  2363. * Normalize the current Plane in place.
  2364. * @returns the updated Plane.
  2365. */
  2366. normalize(): Plane;
  2367. /**
  2368. * Applies a transformation the plane and returns the result
  2369. * @param transformation the transformation matrix to be applied to the plane
  2370. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2371. */
  2372. transform(transformation: DeepImmutable<Matrix>): Plane;
  2373. /**
  2374. * Compute the dot product between the point and the plane normal
  2375. * @param point point to calculate the dot product with
  2376. * @returns the dot product (float) of the point coordinates and the plane normal.
  2377. */
  2378. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2379. /**
  2380. * Updates the current Plane from the plane defined by the three given points.
  2381. * @param point1 one of the points used to contruct the plane
  2382. * @param point2 one of the points used to contruct the plane
  2383. * @param point3 one of the points used to contruct the plane
  2384. * @returns the updated Plane.
  2385. */
  2386. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2387. /**
  2388. * Checks if the plane is facing a given direction (meaning if the plane's normal is pointing in the opposite direction of the given vector).
  2389. * Note that for this function to work as expected you should make sure that:
  2390. * - direction and the plane normal are normalized
  2391. * - epsilon is a number just bigger than -1, something like -0.99 for eg
  2392. * @param direction the direction to check if the plane is facing
  2393. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2394. * @returns True if the plane is facing the given direction
  2395. */
  2396. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2397. /**
  2398. * Calculates the distance to a point
  2399. * @param point point to calculate distance to
  2400. * @returns the signed distance (float) from the given point to the Plane.
  2401. */
  2402. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2403. /**
  2404. * Creates a plane from an array
  2405. * @param array the array to create a plane from
  2406. * @returns a new Plane from the given array.
  2407. */
  2408. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2409. /**
  2410. * Creates a plane from three points
  2411. * @param point1 point used to create the plane
  2412. * @param point2 point used to create the plane
  2413. * @param point3 point used to create the plane
  2414. * @returns a new Plane defined by the three given points.
  2415. */
  2416. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2417. /**
  2418. * Creates a plane from an origin point and a normal
  2419. * @param origin origin of the plane to be constructed
  2420. * @param normal normal of the plane to be constructed
  2421. * @returns a new Plane the normal vector to this plane at the given origin point.
  2422. * Note : the vector "normal" is updated because normalized.
  2423. */
  2424. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2425. /**
  2426. * Calculates the distance from a plane and a point
  2427. * @param origin origin of the plane to be constructed
  2428. * @param normal normal of the plane to be constructed
  2429. * @param point point to calculate distance to
  2430. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2431. */
  2432. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2433. }
  2434. }
  2435. declare module BABYLON {
  2436. /** @hidden */
  2437. export class PerformanceConfigurator {
  2438. /** @hidden */
  2439. static MatrixUse64Bits: boolean;
  2440. /** @hidden */
  2441. static MatrixTrackPrecisionChange: boolean;
  2442. /** @hidden */
  2443. static MatrixCurrentType: any;
  2444. /** @hidden */
  2445. static MatrixTrackedMatrices: Array<any> | null;
  2446. /** @hidden */
  2447. static SetMatrixPrecision(use64bits: boolean): void;
  2448. }
  2449. }
  2450. declare module BABYLON {
  2451. /**
  2452. * Class representing a vector containing 2 coordinates
  2453. */
  2454. export class Vector2 {
  2455. /** defines the first coordinate */
  2456. x: number;
  2457. /** defines the second coordinate */
  2458. y: number;
  2459. /**
  2460. * Creates a new Vector2 from the given x and y coordinates
  2461. * @param x defines the first coordinate
  2462. * @param y defines the second coordinate
  2463. */
  2464. constructor(
  2465. /** defines the first coordinate */
  2466. x?: number,
  2467. /** defines the second coordinate */
  2468. y?: number);
  2469. /**
  2470. * Gets a string with the Vector2 coordinates
  2471. * @returns a string with the Vector2 coordinates
  2472. */
  2473. toString(): string;
  2474. /**
  2475. * Gets class name
  2476. * @returns the string "Vector2"
  2477. */
  2478. getClassName(): string;
  2479. /**
  2480. * Gets current vector hash code
  2481. * @returns the Vector2 hash code as a number
  2482. */
  2483. getHashCode(): number;
  2484. /**
  2485. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2486. * @param array defines the source array
  2487. * @param index defines the offset in source array
  2488. * @returns the current Vector2
  2489. */
  2490. toArray(array: FloatArray, index?: number): Vector2;
  2491. /**
  2492. * Update the current vector from an array
  2493. * @param array defines the destination array
  2494. * @param index defines the offset in the destination array
  2495. * @returns the current Vector3
  2496. */
  2497. fromArray(array: FloatArray, index?: number): Vector2;
  2498. /**
  2499. * Copy the current vector to an array
  2500. * @returns a new array with 2 elements: the Vector2 coordinates.
  2501. */
  2502. asArray(): number[];
  2503. /**
  2504. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2505. * @param source defines the source Vector2
  2506. * @returns the current updated Vector2
  2507. */
  2508. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2509. /**
  2510. * Sets the Vector2 coordinates with the given floats
  2511. * @param x defines the first coordinate
  2512. * @param y defines the second coordinate
  2513. * @returns the current updated Vector2
  2514. */
  2515. copyFromFloats(x: number, y: number): Vector2;
  2516. /**
  2517. * Sets the Vector2 coordinates with the given floats
  2518. * @param x defines the first coordinate
  2519. * @param y defines the second coordinate
  2520. * @returns the current updated Vector2
  2521. */
  2522. set(x: number, y: number): Vector2;
  2523. /**
  2524. * Add another vector with the current one
  2525. * @param otherVector defines the other vector
  2526. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2527. */
  2528. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2529. /**
  2530. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2531. * @param otherVector defines the other vector
  2532. * @param result defines the target vector
  2533. * @returns the unmodified current Vector2
  2534. */
  2535. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2536. /**
  2537. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2538. * @param otherVector defines the other vector
  2539. * @returns the current updated Vector2
  2540. */
  2541. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2542. /**
  2543. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2544. * @param otherVector defines the other vector
  2545. * @returns a new Vector2
  2546. */
  2547. addVector3(otherVector: Vector3): Vector2;
  2548. /**
  2549. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2550. * @param otherVector defines the other vector
  2551. * @returns a new Vector2
  2552. */
  2553. subtract(otherVector: Vector2): Vector2;
  2554. /**
  2555. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2556. * @param otherVector defines the other vector
  2557. * @param result defines the target vector
  2558. * @returns the unmodified current Vector2
  2559. */
  2560. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2561. /**
  2562. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2563. * @param otherVector defines the other vector
  2564. * @returns the current updated Vector2
  2565. */
  2566. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2567. /**
  2568. * Multiplies in place the current Vector2 coordinates by the given ones
  2569. * @param otherVector defines the other vector
  2570. * @returns the current updated Vector2
  2571. */
  2572. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2573. /**
  2574. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2575. * @param otherVector defines the other vector
  2576. * @returns a new Vector2
  2577. */
  2578. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2579. /**
  2580. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2581. * @param otherVector defines the other vector
  2582. * @param result defines the target vector
  2583. * @returns the unmodified current Vector2
  2584. */
  2585. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2586. /**
  2587. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2588. * @param x defines the first coordinate
  2589. * @param y defines the second coordinate
  2590. * @returns a new Vector2
  2591. */
  2592. multiplyByFloats(x: number, y: number): Vector2;
  2593. /**
  2594. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2595. * @param otherVector defines the other vector
  2596. * @returns a new Vector2
  2597. */
  2598. divide(otherVector: Vector2): Vector2;
  2599. /**
  2600. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2601. * @param otherVector defines the other vector
  2602. * @param result defines the target vector
  2603. * @returns the unmodified current Vector2
  2604. */
  2605. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2606. /**
  2607. * Divides the current Vector2 coordinates by the given ones
  2608. * @param otherVector defines the other vector
  2609. * @returns the current updated Vector2
  2610. */
  2611. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2612. /**
  2613. * Gets a new Vector2 with current Vector2 negated coordinates
  2614. * @returns a new Vector2
  2615. */
  2616. negate(): Vector2;
  2617. /**
  2618. * Negate this vector in place
  2619. * @returns this
  2620. */
  2621. negateInPlace(): Vector2;
  2622. /**
  2623. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2624. * @param result defines the Vector3 object where to store the result
  2625. * @returns the current Vector2
  2626. */
  2627. negateToRef(result: Vector2): Vector2;
  2628. /**
  2629. * Multiply the Vector2 coordinates by scale
  2630. * @param scale defines the scaling factor
  2631. * @returns the current updated Vector2
  2632. */
  2633. scaleInPlace(scale: number): Vector2;
  2634. /**
  2635. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2636. * @param scale defines the scaling factor
  2637. * @returns a new Vector2
  2638. */
  2639. scale(scale: number): Vector2;
  2640. /**
  2641. * Scale the current Vector2 values by a factor to a given Vector2
  2642. * @param scale defines the scale factor
  2643. * @param result defines the Vector2 object where to store the result
  2644. * @returns the unmodified current Vector2
  2645. */
  2646. scaleToRef(scale: number, result: Vector2): Vector2;
  2647. /**
  2648. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2649. * @param scale defines the scale factor
  2650. * @param result defines the Vector2 object where to store the result
  2651. * @returns the unmodified current Vector2
  2652. */
  2653. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2654. /**
  2655. * Gets a boolean if two vectors are equals
  2656. * @param otherVector defines the other vector
  2657. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2658. */
  2659. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2660. /**
  2661. * Gets a boolean if two vectors are equals (using an epsilon value)
  2662. * @param otherVector defines the other vector
  2663. * @param epsilon defines the minimal distance to consider equality
  2664. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2665. */
  2666. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2667. /**
  2668. * Gets a new Vector2 from current Vector2 floored values
  2669. * @returns a new Vector2
  2670. */
  2671. floor(): Vector2;
  2672. /**
  2673. * Gets a new Vector2 from current Vector2 floored values
  2674. * @returns a new Vector2
  2675. */
  2676. fract(): Vector2;
  2677. /**
  2678. * Gets the length of the vector
  2679. * @returns the vector length (float)
  2680. */
  2681. length(): number;
  2682. /**
  2683. * Gets the vector squared length
  2684. * @returns the vector squared length (float)
  2685. */
  2686. lengthSquared(): number;
  2687. /**
  2688. * Normalize the vector
  2689. * @returns the current updated Vector2
  2690. */
  2691. normalize(): Vector2;
  2692. /**
  2693. * Gets a new Vector2 copied from the Vector2
  2694. * @returns a new Vector2
  2695. */
  2696. clone(): Vector2;
  2697. /**
  2698. * Gets a new Vector2(0, 0)
  2699. * @returns a new Vector2
  2700. */
  2701. static Zero(): Vector2;
  2702. /**
  2703. * Gets a new Vector2(1, 1)
  2704. * @returns a new Vector2
  2705. */
  2706. static One(): Vector2;
  2707. /**
  2708. * Gets a new Vector2 set from the given index element of the given array
  2709. * @param array defines the data source
  2710. * @param offset defines the offset in the data source
  2711. * @returns a new Vector2
  2712. */
  2713. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2714. /**
  2715. * Sets "result" from the given index element of the given array
  2716. * @param array defines the data source
  2717. * @param offset defines the offset in the data source
  2718. * @param result defines the target vector
  2719. */
  2720. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2721. /**
  2722. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2723. * @param value1 defines 1st point of control
  2724. * @param value2 defines 2nd point of control
  2725. * @param value3 defines 3rd point of control
  2726. * @param value4 defines 4th point of control
  2727. * @param amount defines the interpolation factor
  2728. * @returns a new Vector2
  2729. */
  2730. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2731. /**
  2732. * 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".
  2733. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2734. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2735. * @param value defines the value to clamp
  2736. * @param min defines the lower limit
  2737. * @param max defines the upper limit
  2738. * @returns a new Vector2
  2739. */
  2740. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2741. /**
  2742. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2743. * @param value1 defines the 1st control point
  2744. * @param tangent1 defines the outgoing tangent
  2745. * @param value2 defines the 2nd control point
  2746. * @param tangent2 defines the incoming tangent
  2747. * @param amount defines the interpolation factor
  2748. * @returns a new Vector2
  2749. */
  2750. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2751. /**
  2752. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2753. * @param start defines the start vector
  2754. * @param end defines the end vector
  2755. * @param amount defines the interpolation factor
  2756. * @returns a new Vector2
  2757. */
  2758. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2759. /**
  2760. * Gets the dot product of the vector "left" and the vector "right"
  2761. * @param left defines first vector
  2762. * @param right defines second vector
  2763. * @returns the dot product (float)
  2764. */
  2765. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2766. /**
  2767. * Returns a new Vector2 equal to the normalized given vector
  2768. * @param vector defines the vector to normalize
  2769. * @returns a new Vector2
  2770. */
  2771. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2772. /**
  2773. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2774. * @param left defines 1st vector
  2775. * @param right defines 2nd vector
  2776. * @returns a new Vector2
  2777. */
  2778. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2779. /**
  2780. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2781. * @param left defines 1st vector
  2782. * @param right defines 2nd vector
  2783. * @returns a new Vector2
  2784. */
  2785. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2786. /**
  2787. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2788. * @param vector defines the vector to transform
  2789. * @param transformation defines the matrix to apply
  2790. * @returns a new Vector2
  2791. */
  2792. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2793. /**
  2794. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2795. * @param vector defines the vector to transform
  2796. * @param transformation defines the matrix to apply
  2797. * @param result defines the target vector
  2798. */
  2799. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2800. /**
  2801. * Determines if a given vector is included in a triangle
  2802. * @param p defines the vector to test
  2803. * @param p0 defines 1st triangle point
  2804. * @param p1 defines 2nd triangle point
  2805. * @param p2 defines 3rd triangle point
  2806. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2807. */
  2808. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2809. /**
  2810. * Gets the distance between the vectors "value1" and "value2"
  2811. * @param value1 defines first vector
  2812. * @param value2 defines second vector
  2813. * @returns the distance between vectors
  2814. */
  2815. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2816. /**
  2817. * Returns the squared distance between the vectors "value1" and "value2"
  2818. * @param value1 defines first vector
  2819. * @param value2 defines second vector
  2820. * @returns the squared distance between vectors
  2821. */
  2822. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2823. /**
  2824. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2825. * @param value1 defines first vector
  2826. * @param value2 defines second vector
  2827. * @returns a new Vector2
  2828. */
  2829. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2830. /**
  2831. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2832. * @param p defines the middle point
  2833. * @param segA defines one point of the segment
  2834. * @param segB defines the other point of the segment
  2835. * @returns the shortest distance
  2836. */
  2837. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2838. }
  2839. /**
  2840. * Class used to store (x,y,z) vector representation
  2841. * A Vector3 is the main object used in 3D geometry
  2842. * It can represent etiher the coordinates of a point the space, either a direction
  2843. * Reminder: js uses a left handed forward facing system
  2844. */
  2845. export class Vector3 {
  2846. private static _UpReadOnly;
  2847. private static _ZeroReadOnly;
  2848. /** @hidden */
  2849. _x: number;
  2850. /** @hidden */
  2851. _y: number;
  2852. /** @hidden */
  2853. _z: number;
  2854. /** @hidden */
  2855. _isDirty: boolean;
  2856. /** Gets or sets the x coordinate */
  2857. get x(): number;
  2858. set x(value: number);
  2859. /** Gets or sets the y coordinate */
  2860. get y(): number;
  2861. set y(value: number);
  2862. /** Gets or sets the z coordinate */
  2863. get z(): number;
  2864. set z(value: number);
  2865. /**
  2866. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2867. * @param x defines the first coordinates (on X axis)
  2868. * @param y defines the second coordinates (on Y axis)
  2869. * @param z defines the third coordinates (on Z axis)
  2870. */
  2871. constructor(x?: number, y?: number, z?: number);
  2872. /**
  2873. * Creates a string representation of the Vector3
  2874. * @returns a string with the Vector3 coordinates.
  2875. */
  2876. toString(): string;
  2877. /**
  2878. * Gets the class name
  2879. * @returns the string "Vector3"
  2880. */
  2881. getClassName(): string;
  2882. /**
  2883. * Creates the Vector3 hash code
  2884. * @returns a number which tends to be unique between Vector3 instances
  2885. */
  2886. getHashCode(): number;
  2887. /**
  2888. * Creates an array containing three elements : the coordinates of the Vector3
  2889. * @returns a new array of numbers
  2890. */
  2891. asArray(): number[];
  2892. /**
  2893. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2894. * @param array defines the destination array
  2895. * @param index defines the offset in the destination array
  2896. * @returns the current Vector3
  2897. */
  2898. toArray(array: FloatArray, index?: number): Vector3;
  2899. /**
  2900. * Update the current vector from an array
  2901. * @param array defines the destination array
  2902. * @param index defines the offset in the destination array
  2903. * @returns the current Vector3
  2904. */
  2905. fromArray(array: FloatArray, index?: number): Vector3;
  2906. /**
  2907. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2908. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2909. */
  2910. toQuaternion(): Quaternion;
  2911. /**
  2912. * Adds the given vector to the current Vector3
  2913. * @param otherVector defines the second operand
  2914. * @returns the current updated Vector3
  2915. */
  2916. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2917. /**
  2918. * Adds the given coordinates to the current Vector3
  2919. * @param x defines the x coordinate of the operand
  2920. * @param y defines the y coordinate of the operand
  2921. * @param z defines the z coordinate of the operand
  2922. * @returns the current updated Vector3
  2923. */
  2924. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2925. /**
  2926. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2927. * @param otherVector defines the second operand
  2928. * @returns the resulting Vector3
  2929. */
  2930. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2931. /**
  2932. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2933. * @param otherVector defines the second operand
  2934. * @param result defines the Vector3 object where to store the result
  2935. * @returns the current Vector3
  2936. */
  2937. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2938. /**
  2939. * Subtract the given vector from the current Vector3
  2940. * @param otherVector defines the second operand
  2941. * @returns the current updated Vector3
  2942. */
  2943. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2944. /**
  2945. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2946. * @param otherVector defines the second operand
  2947. * @returns the resulting Vector3
  2948. */
  2949. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2950. /**
  2951. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2952. * @param otherVector defines the second operand
  2953. * @param result defines the Vector3 object where to store the result
  2954. * @returns the current Vector3
  2955. */
  2956. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2957. /**
  2958. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2959. * @param x defines the x coordinate of the operand
  2960. * @param y defines the y coordinate of the operand
  2961. * @param z defines the z coordinate of the operand
  2962. * @returns the resulting Vector3
  2963. */
  2964. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2965. /**
  2966. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2967. * @param x defines the x coordinate of the operand
  2968. * @param y defines the y coordinate of the operand
  2969. * @param z defines the z coordinate of the operand
  2970. * @param result defines the Vector3 object where to store the result
  2971. * @returns the current Vector3
  2972. */
  2973. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2974. /**
  2975. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2976. * @returns a new Vector3
  2977. */
  2978. negate(): Vector3;
  2979. /**
  2980. * Negate this vector in place
  2981. * @returns this
  2982. */
  2983. negateInPlace(): Vector3;
  2984. /**
  2985. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2986. * @param result defines the Vector3 object where to store the result
  2987. * @returns the current Vector3
  2988. */
  2989. negateToRef(result: Vector3): Vector3;
  2990. /**
  2991. * Multiplies the Vector3 coordinates by the float "scale"
  2992. * @param scale defines the multiplier factor
  2993. * @returns the current updated Vector3
  2994. */
  2995. scaleInPlace(scale: number): Vector3;
  2996. /**
  2997. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2998. * @param scale defines the multiplier factor
  2999. * @returns a new Vector3
  3000. */
  3001. scale(scale: number): Vector3;
  3002. /**
  3003. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  3004. * @param scale defines the multiplier factor
  3005. * @param result defines the Vector3 object where to store the result
  3006. * @returns the current Vector3
  3007. */
  3008. scaleToRef(scale: number, result: Vector3): Vector3;
  3009. /**
  3010. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  3011. * @param scale defines the scale factor
  3012. * @param result defines the Vector3 object where to store the result
  3013. * @returns the unmodified current Vector3
  3014. */
  3015. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  3016. /**
  3017. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3018. * @param origin defines the origin of the projection ray
  3019. * @param plane defines the plane to project to
  3020. * @returns the projected vector3
  3021. */
  3022. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  3023. /**
  3024. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3025. * @param origin defines the origin of the projection ray
  3026. * @param plane defines the plane to project to
  3027. * @param result defines the Vector3 where to store the result
  3028. */
  3029. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  3030. /**
  3031. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  3032. * @param otherVector defines the second operand
  3033. * @returns true if both vectors are equals
  3034. */
  3035. equals(otherVector: DeepImmutable<Vector3>): boolean;
  3036. /**
  3037. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  3038. * @param otherVector defines the second operand
  3039. * @param epsilon defines the minimal distance to define values as equals
  3040. * @returns true if both vectors are distant less than epsilon
  3041. */
  3042. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  3043. /**
  3044. * Returns true if the current Vector3 coordinates equals the given floats
  3045. * @param x defines the x coordinate of the operand
  3046. * @param y defines the y coordinate of the operand
  3047. * @param z defines the z coordinate of the operand
  3048. * @returns true if both vectors are equals
  3049. */
  3050. equalsToFloats(x: number, y: number, z: number): boolean;
  3051. /**
  3052. * Multiplies the current Vector3 coordinates by the given ones
  3053. * @param otherVector defines the second operand
  3054. * @returns the current updated Vector3
  3055. */
  3056. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3057. /**
  3058. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  3059. * @param otherVector defines the second operand
  3060. * @returns the new Vector3
  3061. */
  3062. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  3063. /**
  3064. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  3065. * @param otherVector defines the second operand
  3066. * @param result defines the Vector3 object where to store the result
  3067. * @returns the current Vector3
  3068. */
  3069. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3070. /**
  3071. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  3072. * @param x defines the x coordinate of the operand
  3073. * @param y defines the y coordinate of the operand
  3074. * @param z defines the z coordinate of the operand
  3075. * @returns the new Vector3
  3076. */
  3077. multiplyByFloats(x: number, y: number, z: number): Vector3;
  3078. /**
  3079. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  3080. * @param otherVector defines the second operand
  3081. * @returns the new Vector3
  3082. */
  3083. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  3084. /**
  3085. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  3086. * @param otherVector defines the second operand
  3087. * @param result defines the Vector3 object where to store the result
  3088. * @returns the current Vector3
  3089. */
  3090. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3091. /**
  3092. * Divides the current Vector3 coordinates by the given ones.
  3093. * @param otherVector defines the second operand
  3094. * @returns the current updated Vector3
  3095. */
  3096. divideInPlace(otherVector: Vector3): Vector3;
  3097. /**
  3098. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  3099. * @param other defines the second operand
  3100. * @returns the current updated Vector3
  3101. */
  3102. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3103. /**
  3104. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  3105. * @param other defines the second operand
  3106. * @returns the current updated Vector3
  3107. */
  3108. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3109. /**
  3110. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  3111. * @param x defines the x coordinate of the operand
  3112. * @param y defines the y coordinate of the operand
  3113. * @param z defines the z coordinate of the operand
  3114. * @returns the current updated Vector3
  3115. */
  3116. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3117. /**
  3118. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  3119. * @param x defines the x coordinate of the operand
  3120. * @param y defines the y coordinate of the operand
  3121. * @param z defines the z coordinate of the operand
  3122. * @returns the current updated Vector3
  3123. */
  3124. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3125. /**
  3126. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  3127. * Check if is non uniform within a certain amount of decimal places to account for this
  3128. * @param epsilon the amount the values can differ
  3129. * @returns if the the vector is non uniform to a certain number of decimal places
  3130. */
  3131. isNonUniformWithinEpsilon(epsilon: number): boolean;
  3132. /**
  3133. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  3134. */
  3135. get isNonUniform(): boolean;
  3136. /**
  3137. * Gets a new Vector3 from current Vector3 floored values
  3138. * @returns a new Vector3
  3139. */
  3140. floor(): Vector3;
  3141. /**
  3142. * Gets a new Vector3 from current Vector3 floored values
  3143. * @returns a new Vector3
  3144. */
  3145. fract(): Vector3;
  3146. /**
  3147. * Gets the length of the Vector3
  3148. * @returns the length of the Vector3
  3149. */
  3150. length(): number;
  3151. /**
  3152. * Gets the squared length of the Vector3
  3153. * @returns squared length of the Vector3
  3154. */
  3155. lengthSquared(): number;
  3156. /**
  3157. * Normalize the current Vector3.
  3158. * Please note that this is an in place operation.
  3159. * @returns the current updated Vector3
  3160. */
  3161. normalize(): Vector3;
  3162. /**
  3163. * Reorders the x y z properties of the vector in place
  3164. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  3165. * @returns the current updated vector
  3166. */
  3167. reorderInPlace(order: string): this;
  3168. /**
  3169. * Rotates the vector around 0,0,0 by a quaternion
  3170. * @param quaternion the rotation quaternion
  3171. * @param result vector to store the result
  3172. * @returns the resulting vector
  3173. */
  3174. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  3175. /**
  3176. * Rotates a vector around a given point
  3177. * @param quaternion the rotation quaternion
  3178. * @param point the point to rotate around
  3179. * @param result vector to store the result
  3180. * @returns the resulting vector
  3181. */
  3182. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  3183. /**
  3184. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  3185. * The cross product is then orthogonal to both current and "other"
  3186. * @param other defines the right operand
  3187. * @returns the cross product
  3188. */
  3189. cross(other: Vector3): Vector3;
  3190. /**
  3191. * Normalize the current Vector3 with the given input length.
  3192. * Please note that this is an in place operation.
  3193. * @param len the length of the vector
  3194. * @returns the current updated Vector3
  3195. */
  3196. normalizeFromLength(len: number): Vector3;
  3197. /**
  3198. * Normalize the current Vector3 to a new vector
  3199. * @returns the new Vector3
  3200. */
  3201. normalizeToNew(): Vector3;
  3202. /**
  3203. * Normalize the current Vector3 to the reference
  3204. * @param reference define the Vector3 to update
  3205. * @returns the updated Vector3
  3206. */
  3207. normalizeToRef(reference: Vector3): Vector3;
  3208. /**
  3209. * Creates a new Vector3 copied from the current Vector3
  3210. * @returns the new Vector3
  3211. */
  3212. clone(): Vector3;
  3213. /**
  3214. * Copies the given vector coordinates to the current Vector3 ones
  3215. * @param source defines the source Vector3
  3216. * @returns the current updated Vector3
  3217. */
  3218. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  3219. /**
  3220. * Copies the given floats to the current Vector3 coordinates
  3221. * @param x defines the x coordinate of the operand
  3222. * @param y defines the y coordinate of the operand
  3223. * @param z defines the z coordinate of the operand
  3224. * @returns the current updated Vector3
  3225. */
  3226. copyFromFloats(x: number, y: number, z: number): Vector3;
  3227. /**
  3228. * Copies the given floats to the current Vector3 coordinates
  3229. * @param x defines the x coordinate of the operand
  3230. * @param y defines the y coordinate of the operand
  3231. * @param z defines the z coordinate of the operand
  3232. * @returns the current updated Vector3
  3233. */
  3234. set(x: number, y: number, z: number): Vector3;
  3235. /**
  3236. * Copies the given float to the current Vector3 coordinates
  3237. * @param v defines the x, y and z coordinates of the operand
  3238. * @returns the current updated Vector3
  3239. */
  3240. setAll(v: number): Vector3;
  3241. /**
  3242. * Get the clip factor between two vectors
  3243. * @param vector0 defines the first operand
  3244. * @param vector1 defines the second operand
  3245. * @param axis defines the axis to use
  3246. * @param size defines the size along the axis
  3247. * @returns the clip factor
  3248. */
  3249. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  3250. /**
  3251. * Get angle between two vectors
  3252. * @param vector0 angle between vector0 and vector1
  3253. * @param vector1 angle between vector0 and vector1
  3254. * @param normal direction of the normal
  3255. * @return the angle between vector0 and vector1
  3256. */
  3257. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  3258. /**
  3259. * Returns a new Vector3 set from the index "offset" of the given array
  3260. * @param array defines the source array
  3261. * @param offset defines the offset in the source array
  3262. * @returns the new Vector3
  3263. */
  3264. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  3265. /**
  3266. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  3267. * @param array defines the source array
  3268. * @param offset defines the offset in the source array
  3269. * @returns the new Vector3
  3270. * @deprecated Please use FromArray instead.
  3271. */
  3272. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  3273. /**
  3274. * Sets the given vector "result" with the element values from the index "offset" of the given array
  3275. * @param array defines the source array
  3276. * @param offset defines the offset in the source array
  3277. * @param result defines the Vector3 where to store the result
  3278. */
  3279. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  3280. /**
  3281. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  3282. * @param array defines the source array
  3283. * @param offset defines the offset in the source array
  3284. * @param result defines the Vector3 where to store the result
  3285. * @deprecated Please use FromArrayToRef instead.
  3286. */
  3287. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  3288. /**
  3289. * Sets the given vector "result" with the given floats.
  3290. * @param x defines the x coordinate of the source
  3291. * @param y defines the y coordinate of the source
  3292. * @param z defines the z coordinate of the source
  3293. * @param result defines the Vector3 where to store the result
  3294. */
  3295. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  3296. /**
  3297. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  3298. * @returns a new empty Vector3
  3299. */
  3300. static Zero(): Vector3;
  3301. /**
  3302. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  3303. * @returns a new unit Vector3
  3304. */
  3305. static One(): Vector3;
  3306. /**
  3307. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  3308. * @returns a new up Vector3
  3309. */
  3310. static Up(): Vector3;
  3311. /**
  3312. * Gets a up Vector3 that must not be updated
  3313. */
  3314. static get UpReadOnly(): DeepImmutable<Vector3>;
  3315. /**
  3316. * Gets a zero Vector3 that must not be updated
  3317. */
  3318. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  3319. /**
  3320. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  3321. * @returns a new down Vector3
  3322. */
  3323. static Down(): Vector3;
  3324. /**
  3325. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  3326. * @param rightHandedSystem is the scene right-handed (negative z)
  3327. * @returns a new forward Vector3
  3328. */
  3329. static Forward(rightHandedSystem?: boolean): Vector3;
  3330. /**
  3331. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  3332. * @param rightHandedSystem is the scene right-handed (negative-z)
  3333. * @returns a new forward Vector3
  3334. */
  3335. static Backward(rightHandedSystem?: boolean): Vector3;
  3336. /**
  3337. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  3338. * @returns a new right Vector3
  3339. */
  3340. static Right(): Vector3;
  3341. /**
  3342. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3343. * @returns a new left Vector3
  3344. */
  3345. static Left(): Vector3;
  3346. /**
  3347. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3348. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3349. * @param vector defines the Vector3 to transform
  3350. * @param transformation defines the transformation matrix
  3351. * @returns the transformed Vector3
  3352. */
  3353. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3354. /**
  3355. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3356. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3357. * @param vector defines the Vector3 to transform
  3358. * @param transformation defines the transformation matrix
  3359. * @param result defines the Vector3 where to store the result
  3360. */
  3361. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3362. /**
  3363. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3364. * This method computes tranformed coordinates only, not transformed direction vectors
  3365. * @param x define the x coordinate of the source vector
  3366. * @param y define the y coordinate of the source vector
  3367. * @param z define the z coordinate of the source vector
  3368. * @param transformation defines the transformation matrix
  3369. * @param result defines the Vector3 where to store the result
  3370. */
  3371. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3372. /**
  3373. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3374. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3375. * @param vector defines the Vector3 to transform
  3376. * @param transformation defines the transformation matrix
  3377. * @returns the new Vector3
  3378. */
  3379. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3380. /**
  3381. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3382. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3383. * @param vector defines the Vector3 to transform
  3384. * @param transformation defines the transformation matrix
  3385. * @param result defines the Vector3 where to store the result
  3386. */
  3387. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3388. /**
  3389. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3390. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3391. * @param x define the x coordinate of the source vector
  3392. * @param y define the y coordinate of the source vector
  3393. * @param z define the z coordinate of the source vector
  3394. * @param transformation defines the transformation matrix
  3395. * @param result defines the Vector3 where to store the result
  3396. */
  3397. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3398. /**
  3399. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3400. * @param value1 defines the first control point
  3401. * @param value2 defines the second control point
  3402. * @param value3 defines the third control point
  3403. * @param value4 defines the fourth control point
  3404. * @param amount defines the amount on the spline to use
  3405. * @returns the new Vector3
  3406. */
  3407. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3408. /**
  3409. * 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"
  3410. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3411. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3412. * @param value defines the current value
  3413. * @param min defines the lower range value
  3414. * @param max defines the upper range value
  3415. * @returns the new Vector3
  3416. */
  3417. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3418. /**
  3419. * 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"
  3420. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3421. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3422. * @param value defines the current value
  3423. * @param min defines the lower range value
  3424. * @param max defines the upper range value
  3425. * @param result defines the Vector3 where to store the result
  3426. */
  3427. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3428. /**
  3429. * Checks if a given vector is inside a specific range
  3430. * @param v defines the vector to test
  3431. * @param min defines the minimum range
  3432. * @param max defines the maximum range
  3433. */
  3434. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3435. /**
  3436. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3437. * @param value1 defines the first control point
  3438. * @param tangent1 defines the first tangent vector
  3439. * @param value2 defines the second control point
  3440. * @param tangent2 defines the second tangent vector
  3441. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3442. * @returns the new Vector3
  3443. */
  3444. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3445. /**
  3446. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3447. * @param start defines the start value
  3448. * @param end defines the end value
  3449. * @param amount max defines amount between both (between 0 and 1)
  3450. * @returns the new Vector3
  3451. */
  3452. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3453. /**
  3454. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3455. * @param start defines the start value
  3456. * @param end defines the end value
  3457. * @param amount max defines amount between both (between 0 and 1)
  3458. * @param result defines the Vector3 where to store the result
  3459. */
  3460. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3461. /**
  3462. * Returns the dot product (float) between the vectors "left" and "right"
  3463. * @param left defines the left operand
  3464. * @param right defines the right operand
  3465. * @returns the dot product
  3466. */
  3467. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3468. /**
  3469. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3470. * The cross product is then orthogonal to both "left" and "right"
  3471. * @param left defines the left operand
  3472. * @param right defines the right operand
  3473. * @returns the cross product
  3474. */
  3475. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3476. /**
  3477. * Sets the given vector "result" with the cross product of "left" and "right"
  3478. * The cross product is then orthogonal to both "left" and "right"
  3479. * @param left defines the left operand
  3480. * @param right defines the right operand
  3481. * @param result defines the Vector3 where to store the result
  3482. */
  3483. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3484. /**
  3485. * Returns a new Vector3 as the normalization of the given vector
  3486. * @param vector defines the Vector3 to normalize
  3487. * @returns the new Vector3
  3488. */
  3489. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3490. /**
  3491. * Sets the given vector "result" with the normalization of the given first vector
  3492. * @param vector defines the Vector3 to normalize
  3493. * @param result defines the Vector3 where to store the result
  3494. */
  3495. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3496. /**
  3497. * Project a Vector3 onto screen space
  3498. * @param vector defines the Vector3 to project
  3499. * @param world defines the world matrix to use
  3500. * @param transform defines the transform (view x projection) matrix to use
  3501. * @param viewport defines the screen viewport to use
  3502. * @returns the new Vector3
  3503. */
  3504. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3505. /**
  3506. * Project a Vector3 onto screen space to reference
  3507. * @param vector defines the Vector3 to project
  3508. * @param world defines the world matrix to use
  3509. * @param transform defines the transform (view x projection) matrix to use
  3510. * @param viewport defines the screen viewport to use
  3511. * @param result the vector in which the screen space will be stored
  3512. * @returns the new Vector3
  3513. */
  3514. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3515. /** @hidden */
  3516. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3517. /**
  3518. * Unproject from screen space to object space
  3519. * @param source defines the screen space Vector3 to use
  3520. * @param viewportWidth defines the current width of the viewport
  3521. * @param viewportHeight defines the current height of the viewport
  3522. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3523. * @param transform defines the transform (view x projection) matrix to use
  3524. * @returns the new Vector3
  3525. */
  3526. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3527. /**
  3528. * Unproject from screen space to object space
  3529. * @param source defines the screen space Vector3 to use
  3530. * @param viewportWidth defines the current width of the viewport
  3531. * @param viewportHeight defines the current height of the viewport
  3532. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3533. * @param view defines the view matrix to use
  3534. * @param projection defines the projection matrix to use
  3535. * @returns the new Vector3
  3536. */
  3537. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3538. /**
  3539. * Unproject from screen space to object space
  3540. * @param source defines the screen space Vector3 to use
  3541. * @param viewportWidth defines the current width of the viewport
  3542. * @param viewportHeight defines the current height of the viewport
  3543. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3544. * @param view defines the view matrix to use
  3545. * @param projection defines the projection matrix to use
  3546. * @param result defines the Vector3 where to store the result
  3547. */
  3548. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3549. /**
  3550. * Unproject from screen space to object space
  3551. * @param sourceX defines the screen space x coordinate to use
  3552. * @param sourceY defines the screen space y coordinate to use
  3553. * @param sourceZ defines the screen space z coordinate to use
  3554. * @param viewportWidth defines the current width of the viewport
  3555. * @param viewportHeight defines the current height of the viewport
  3556. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3557. * @param view defines the view matrix to use
  3558. * @param projection defines the projection matrix to use
  3559. * @param result defines the Vector3 where to store the result
  3560. */
  3561. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3562. /**
  3563. * Gets the minimal coordinate values between two Vector3
  3564. * @param left defines the first operand
  3565. * @param right defines the second operand
  3566. * @returns the new Vector3
  3567. */
  3568. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3569. /**
  3570. * Gets the maximal coordinate values between two Vector3
  3571. * @param left defines the first operand
  3572. * @param right defines the second operand
  3573. * @returns the new Vector3
  3574. */
  3575. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3576. /**
  3577. * Returns the distance between the vectors "value1" and "value2"
  3578. * @param value1 defines the first operand
  3579. * @param value2 defines the second operand
  3580. * @returns the distance
  3581. */
  3582. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3583. /**
  3584. * Returns the squared distance between the vectors "value1" and "value2"
  3585. * @param value1 defines the first operand
  3586. * @param value2 defines the second operand
  3587. * @returns the squared distance
  3588. */
  3589. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3590. /**
  3591. * Returns a new Vector3 located at the center between "value1" and "value2"
  3592. * @param value1 defines the first operand
  3593. * @param value2 defines the second operand
  3594. * @returns the new Vector3
  3595. */
  3596. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3597. /**
  3598. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3599. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3600. * to something in order to rotate it from its local system to the given target system
  3601. * Note: axis1, axis2 and axis3 are normalized during this operation
  3602. * @param axis1 defines the first axis
  3603. * @param axis2 defines the second axis
  3604. * @param axis3 defines the third axis
  3605. * @returns a new Vector3
  3606. */
  3607. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3608. /**
  3609. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3610. * @param axis1 defines the first axis
  3611. * @param axis2 defines the second axis
  3612. * @param axis3 defines the third axis
  3613. * @param ref defines the Vector3 where to store the result
  3614. */
  3615. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3616. }
  3617. /**
  3618. * Vector4 class created for EulerAngle class conversion to Quaternion
  3619. */
  3620. export class Vector4 {
  3621. /** x value of the vector */
  3622. x: number;
  3623. /** y value of the vector */
  3624. y: number;
  3625. /** z value of the vector */
  3626. z: number;
  3627. /** w value of the vector */
  3628. w: number;
  3629. /**
  3630. * Creates a Vector4 object from the given floats.
  3631. * @param x x value of the vector
  3632. * @param y y value of the vector
  3633. * @param z z value of the vector
  3634. * @param w w value of the vector
  3635. */
  3636. constructor(
  3637. /** x value of the vector */
  3638. x: number,
  3639. /** y value of the vector */
  3640. y: number,
  3641. /** z value of the vector */
  3642. z: number,
  3643. /** w value of the vector */
  3644. w: number);
  3645. /**
  3646. * Returns the string with the Vector4 coordinates.
  3647. * @returns a string containing all the vector values
  3648. */
  3649. toString(): string;
  3650. /**
  3651. * Returns the string "Vector4".
  3652. * @returns "Vector4"
  3653. */
  3654. getClassName(): string;
  3655. /**
  3656. * Returns the Vector4 hash code.
  3657. * @returns a unique hash code
  3658. */
  3659. getHashCode(): number;
  3660. /**
  3661. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3662. * @returns the resulting array
  3663. */
  3664. asArray(): number[];
  3665. /**
  3666. * Populates the given array from the given index with the Vector4 coordinates.
  3667. * @param array array to populate
  3668. * @param index index of the array to start at (default: 0)
  3669. * @returns the Vector4.
  3670. */
  3671. toArray(array: FloatArray, index?: number): Vector4;
  3672. /**
  3673. * Update the current vector from an array
  3674. * @param array defines the destination array
  3675. * @param index defines the offset in the destination array
  3676. * @returns the current Vector3
  3677. */
  3678. fromArray(array: FloatArray, index?: number): Vector4;
  3679. /**
  3680. * Adds the given vector to the current Vector4.
  3681. * @param otherVector the vector to add
  3682. * @returns the updated Vector4.
  3683. */
  3684. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3685. /**
  3686. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3687. * @param otherVector the vector to add
  3688. * @returns the resulting vector
  3689. */
  3690. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3691. /**
  3692. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3693. * @param otherVector the vector to add
  3694. * @param result the vector to store the result
  3695. * @returns the current Vector4.
  3696. */
  3697. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3698. /**
  3699. * Subtract in place the given vector from the current Vector4.
  3700. * @param otherVector the vector to subtract
  3701. * @returns the updated Vector4.
  3702. */
  3703. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3704. /**
  3705. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3706. * @param otherVector the vector to add
  3707. * @returns the new vector with the result
  3708. */
  3709. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3710. /**
  3711. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3712. * @param otherVector the vector to subtract
  3713. * @param result the vector to store the result
  3714. * @returns the current Vector4.
  3715. */
  3716. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3717. /**
  3718. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3719. */
  3720. /**
  3721. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3722. * @param x value to subtract
  3723. * @param y value to subtract
  3724. * @param z value to subtract
  3725. * @param w value to subtract
  3726. * @returns new vector containing the result
  3727. */
  3728. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3729. /**
  3730. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3731. * @param x value to subtract
  3732. * @param y value to subtract
  3733. * @param z value to subtract
  3734. * @param w value to subtract
  3735. * @param result the vector to store the result in
  3736. * @returns the current Vector4.
  3737. */
  3738. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3739. /**
  3740. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3741. * @returns a new vector with the negated values
  3742. */
  3743. negate(): Vector4;
  3744. /**
  3745. * Negate this vector in place
  3746. * @returns this
  3747. */
  3748. negateInPlace(): Vector4;
  3749. /**
  3750. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3751. * @param result defines the Vector3 object where to store the result
  3752. * @returns the current Vector4
  3753. */
  3754. negateToRef(result: Vector4): Vector4;
  3755. /**
  3756. * Multiplies the current Vector4 coordinates by scale (float).
  3757. * @param scale the number to scale with
  3758. * @returns the updated Vector4.
  3759. */
  3760. scaleInPlace(scale: number): Vector4;
  3761. /**
  3762. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3763. * @param scale the number to scale with
  3764. * @returns a new vector with the result
  3765. */
  3766. scale(scale: number): Vector4;
  3767. /**
  3768. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3769. * @param scale the number to scale with
  3770. * @param result a vector to store the result in
  3771. * @returns the current Vector4.
  3772. */
  3773. scaleToRef(scale: number, result: Vector4): Vector4;
  3774. /**
  3775. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3776. * @param scale defines the scale factor
  3777. * @param result defines the Vector4 object where to store the result
  3778. * @returns the unmodified current Vector4
  3779. */
  3780. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3781. /**
  3782. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3783. * @param otherVector the vector to compare against
  3784. * @returns true if they are equal
  3785. */
  3786. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3787. /**
  3788. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3789. * @param otherVector vector to compare against
  3790. * @param epsilon (Default: very small number)
  3791. * @returns true if they are equal
  3792. */
  3793. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3794. /**
  3795. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3796. * @param x x value to compare against
  3797. * @param y y value to compare against
  3798. * @param z z value to compare against
  3799. * @param w w value to compare against
  3800. * @returns true if equal
  3801. */
  3802. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3803. /**
  3804. * Multiplies in place the current Vector4 by the given one.
  3805. * @param otherVector vector to multiple with
  3806. * @returns the updated Vector4.
  3807. */
  3808. multiplyInPlace(otherVector: Vector4): Vector4;
  3809. /**
  3810. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3811. * @param otherVector vector to multiple with
  3812. * @returns resulting new vector
  3813. */
  3814. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3815. /**
  3816. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3817. * @param otherVector vector to multiple with
  3818. * @param result vector to store the result
  3819. * @returns the current Vector4.
  3820. */
  3821. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3822. /**
  3823. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3824. * @param x x value multiply with
  3825. * @param y y value multiply with
  3826. * @param z z value multiply with
  3827. * @param w w value multiply with
  3828. * @returns resulting new vector
  3829. */
  3830. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3831. /**
  3832. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3833. * @param otherVector vector to devide with
  3834. * @returns resulting new vector
  3835. */
  3836. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3837. /**
  3838. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3839. * @param otherVector vector to devide with
  3840. * @param result vector to store the result
  3841. * @returns the current Vector4.
  3842. */
  3843. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3844. /**
  3845. * Divides the current Vector3 coordinates by the given ones.
  3846. * @param otherVector vector to devide with
  3847. * @returns the updated Vector3.
  3848. */
  3849. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3850. /**
  3851. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3852. * @param other defines the second operand
  3853. * @returns the current updated Vector4
  3854. */
  3855. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3856. /**
  3857. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3858. * @param other defines the second operand
  3859. * @returns the current updated Vector4
  3860. */
  3861. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3862. /**
  3863. * Gets a new Vector4 from current Vector4 floored values
  3864. * @returns a new Vector4
  3865. */
  3866. floor(): Vector4;
  3867. /**
  3868. * Gets a new Vector4 from current Vector3 floored values
  3869. * @returns a new Vector4
  3870. */
  3871. fract(): Vector4;
  3872. /**
  3873. * Returns the Vector4 length (float).
  3874. * @returns the length
  3875. */
  3876. length(): number;
  3877. /**
  3878. * Returns the Vector4 squared length (float).
  3879. * @returns the length squared
  3880. */
  3881. lengthSquared(): number;
  3882. /**
  3883. * Normalizes in place the Vector4.
  3884. * @returns the updated Vector4.
  3885. */
  3886. normalize(): Vector4;
  3887. /**
  3888. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3889. * @returns this converted to a new vector3
  3890. */
  3891. toVector3(): Vector3;
  3892. /**
  3893. * Returns a new Vector4 copied from the current one.
  3894. * @returns the new cloned vector
  3895. */
  3896. clone(): Vector4;
  3897. /**
  3898. * Updates the current Vector4 with the given one coordinates.
  3899. * @param source the source vector to copy from
  3900. * @returns the updated Vector4.
  3901. */
  3902. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3903. /**
  3904. * Updates the current Vector4 coordinates with the given floats.
  3905. * @param x float to copy from
  3906. * @param y float to copy from
  3907. * @param z float to copy from
  3908. * @param w float to copy from
  3909. * @returns the updated Vector4.
  3910. */
  3911. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3912. /**
  3913. * Updates the current Vector4 coordinates with the given floats.
  3914. * @param x float to set from
  3915. * @param y float to set from
  3916. * @param z float to set from
  3917. * @param w float to set from
  3918. * @returns the updated Vector4.
  3919. */
  3920. set(x: number, y: number, z: number, w: number): Vector4;
  3921. /**
  3922. * Copies the given float to the current Vector3 coordinates
  3923. * @param v defines the x, y, z and w coordinates of the operand
  3924. * @returns the current updated Vector3
  3925. */
  3926. setAll(v: number): Vector4;
  3927. /**
  3928. * Returns a new Vector4 set from the starting index of the given array.
  3929. * @param array the array to pull values from
  3930. * @param offset the offset into the array to start at
  3931. * @returns the new vector
  3932. */
  3933. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3934. /**
  3935. * Updates the given vector "result" from the starting index of the given array.
  3936. * @param array the array to pull values from
  3937. * @param offset the offset into the array to start at
  3938. * @param result the vector to store the result in
  3939. */
  3940. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3941. /**
  3942. * Updates the given vector "result" from the starting index of the given Float32Array.
  3943. * @param array the array to pull values from
  3944. * @param offset the offset into the array to start at
  3945. * @param result the vector to store the result in
  3946. */
  3947. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3948. /**
  3949. * Updates the given vector "result" coordinates from the given floats.
  3950. * @param x float to set from
  3951. * @param y float to set from
  3952. * @param z float to set from
  3953. * @param w float to set from
  3954. * @param result the vector to the floats in
  3955. */
  3956. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3957. /**
  3958. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3959. * @returns the new vector
  3960. */
  3961. static Zero(): Vector4;
  3962. /**
  3963. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3964. * @returns the new vector
  3965. */
  3966. static One(): Vector4;
  3967. /**
  3968. * Returns a new normalized Vector4 from the given one.
  3969. * @param vector the vector to normalize
  3970. * @returns the vector
  3971. */
  3972. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3973. /**
  3974. * Updates the given vector "result" from the normalization of the given one.
  3975. * @param vector the vector to normalize
  3976. * @param result the vector to store the result in
  3977. */
  3978. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3979. /**
  3980. * Returns a vector with the minimum values from the left and right vectors
  3981. * @param left left vector to minimize
  3982. * @param right right vector to minimize
  3983. * @returns a new vector with the minimum of the left and right vector values
  3984. */
  3985. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3986. /**
  3987. * Returns a vector with the maximum values from the left and right vectors
  3988. * @param left left vector to maximize
  3989. * @param right right vector to maximize
  3990. * @returns a new vector with the maximum of the left and right vector values
  3991. */
  3992. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3993. /**
  3994. * Returns the distance (float) between the vectors "value1" and "value2".
  3995. * @param value1 value to calulate the distance between
  3996. * @param value2 value to calulate the distance between
  3997. * @return the distance between the two vectors
  3998. */
  3999. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4000. /**
  4001. * Returns the squared distance (float) between the vectors "value1" and "value2".
  4002. * @param value1 value to calulate the distance between
  4003. * @param value2 value to calulate the distance between
  4004. * @return the distance between the two vectors squared
  4005. */
  4006. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4007. /**
  4008. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  4009. * @param value1 value to calulate the center between
  4010. * @param value2 value to calulate the center between
  4011. * @return the center between the two vectors
  4012. */
  4013. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  4014. /**
  4015. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  4016. * This methods computes transformed normalized direction vectors only.
  4017. * @param vector the vector to transform
  4018. * @param transformation the transformation matrix to apply
  4019. * @returns the new vector
  4020. */
  4021. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  4022. /**
  4023. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  4024. * This methods computes transformed normalized direction vectors only.
  4025. * @param vector the vector to transform
  4026. * @param transformation the transformation matrix to apply
  4027. * @param result the vector to store the result in
  4028. */
  4029. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4030. /**
  4031. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  4032. * This methods computes transformed normalized direction vectors only.
  4033. * @param x value to transform
  4034. * @param y value to transform
  4035. * @param z value to transform
  4036. * @param w value to transform
  4037. * @param transformation the transformation matrix to apply
  4038. * @param result the vector to store the results in
  4039. */
  4040. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4041. /**
  4042. * Creates a new Vector4 from a Vector3
  4043. * @param source defines the source data
  4044. * @param w defines the 4th component (default is 0)
  4045. * @returns a new Vector4
  4046. */
  4047. static FromVector3(source: Vector3, w?: number): Vector4;
  4048. }
  4049. /**
  4050. * Class used to store quaternion data
  4051. * @see https://en.wikipedia.org/wiki/Quaternion
  4052. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  4053. */
  4054. export class Quaternion {
  4055. /** @hidden */
  4056. _x: number;
  4057. /** @hidden */
  4058. _y: number;
  4059. /** @hidden */
  4060. _z: number;
  4061. /** @hidden */
  4062. _w: number;
  4063. /** @hidden */
  4064. _isDirty: boolean;
  4065. /** Gets or sets the x coordinate */
  4066. get x(): number;
  4067. set x(value: number);
  4068. /** Gets or sets the y coordinate */
  4069. get y(): number;
  4070. set y(value: number);
  4071. /** Gets or sets the z coordinate */
  4072. get z(): number;
  4073. set z(value: number);
  4074. /** Gets or sets the w coordinate */
  4075. get w(): number;
  4076. set w(value: number);
  4077. /**
  4078. * Creates a new Quaternion from the given floats
  4079. * @param x defines the first component (0 by default)
  4080. * @param y defines the second component (0 by default)
  4081. * @param z defines the third component (0 by default)
  4082. * @param w defines the fourth component (1.0 by default)
  4083. */
  4084. constructor(x?: number, y?: number, z?: number, w?: number);
  4085. /**
  4086. * Gets a string representation for the current quaternion
  4087. * @returns a string with the Quaternion coordinates
  4088. */
  4089. toString(): string;
  4090. /**
  4091. * Gets the class name of the quaternion
  4092. * @returns the string "Quaternion"
  4093. */
  4094. getClassName(): string;
  4095. /**
  4096. * Gets a hash code for this quaternion
  4097. * @returns the quaternion hash code
  4098. */
  4099. getHashCode(): number;
  4100. /**
  4101. * Copy the quaternion to an array
  4102. * @returns a new array populated with 4 elements from the quaternion coordinates
  4103. */
  4104. asArray(): number[];
  4105. /**
  4106. * Check if two quaternions are equals
  4107. * @param otherQuaternion defines the second operand
  4108. * @return true if the current quaternion and the given one coordinates are strictly equals
  4109. */
  4110. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  4111. /**
  4112. * Gets a boolean if two quaternions are equals (using an epsilon value)
  4113. * @param otherQuaternion defines the other quaternion
  4114. * @param epsilon defines the minimal distance to consider equality
  4115. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  4116. */
  4117. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  4118. /**
  4119. * Clone the current quaternion
  4120. * @returns a new quaternion copied from the current one
  4121. */
  4122. clone(): Quaternion;
  4123. /**
  4124. * Copy a quaternion to the current one
  4125. * @param other defines the other quaternion
  4126. * @returns the updated current quaternion
  4127. */
  4128. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  4129. /**
  4130. * Updates the current quaternion with the given float coordinates
  4131. * @param x defines the x coordinate
  4132. * @param y defines the y coordinate
  4133. * @param z defines the z coordinate
  4134. * @param w defines the w coordinate
  4135. * @returns the updated current quaternion
  4136. */
  4137. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  4138. /**
  4139. * Updates the current quaternion from the given float coordinates
  4140. * @param x defines the x coordinate
  4141. * @param y defines the y coordinate
  4142. * @param z defines the z coordinate
  4143. * @param w defines the w coordinate
  4144. * @returns the updated current quaternion
  4145. */
  4146. set(x: number, y: number, z: number, w: number): Quaternion;
  4147. /**
  4148. * Adds two quaternions
  4149. * @param other defines the second operand
  4150. * @returns a new quaternion as the addition result of the given one and the current quaternion
  4151. */
  4152. add(other: DeepImmutable<Quaternion>): Quaternion;
  4153. /**
  4154. * Add a quaternion to the current one
  4155. * @param other defines the quaternion to add
  4156. * @returns the current quaternion
  4157. */
  4158. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  4159. /**
  4160. * Subtract two quaternions
  4161. * @param other defines the second operand
  4162. * @returns a new quaternion as the subtraction result of the given one from the current one
  4163. */
  4164. subtract(other: Quaternion): Quaternion;
  4165. /**
  4166. * Multiplies the current quaternion by a scale factor
  4167. * @param value defines the scale factor
  4168. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  4169. */
  4170. scale(value: number): Quaternion;
  4171. /**
  4172. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  4173. * @param scale defines the scale factor
  4174. * @param result defines the Quaternion object where to store the result
  4175. * @returns the unmodified current quaternion
  4176. */
  4177. scaleToRef(scale: number, result: Quaternion): Quaternion;
  4178. /**
  4179. * Multiplies in place the current quaternion by a scale factor
  4180. * @param value defines the scale factor
  4181. * @returns the current modified quaternion
  4182. */
  4183. scaleInPlace(value: number): Quaternion;
  4184. /**
  4185. * Scale the current quaternion values by a factor and add the result to a given quaternion
  4186. * @param scale defines the scale factor
  4187. * @param result defines the Quaternion object where to store the result
  4188. * @returns the unmodified current quaternion
  4189. */
  4190. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  4191. /**
  4192. * Multiplies two quaternions
  4193. * @param q1 defines the second operand
  4194. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  4195. */
  4196. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  4197. /**
  4198. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  4199. * @param q1 defines the second operand
  4200. * @param result defines the target quaternion
  4201. * @returns the current quaternion
  4202. */
  4203. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  4204. /**
  4205. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  4206. * @param q1 defines the second operand
  4207. * @returns the currentupdated quaternion
  4208. */
  4209. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  4210. /**
  4211. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  4212. * @param ref defines the target quaternion
  4213. * @returns the current quaternion
  4214. */
  4215. conjugateToRef(ref: Quaternion): Quaternion;
  4216. /**
  4217. * Conjugates in place (1-q) the current quaternion
  4218. * @returns the current updated quaternion
  4219. */
  4220. conjugateInPlace(): Quaternion;
  4221. /**
  4222. * Conjugates in place (1-q) the current quaternion
  4223. * @returns a new quaternion
  4224. */
  4225. conjugate(): Quaternion;
  4226. /**
  4227. * Gets length of current quaternion
  4228. * @returns the quaternion length (float)
  4229. */
  4230. length(): number;
  4231. /**
  4232. * Normalize in place the current quaternion
  4233. * @returns the current updated quaternion
  4234. */
  4235. normalize(): Quaternion;
  4236. /**
  4237. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  4238. * @param order is a reserved parameter and is ignored for now
  4239. * @returns a new Vector3 containing the Euler angles
  4240. */
  4241. toEulerAngles(order?: string): Vector3;
  4242. /**
  4243. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  4244. * @param result defines the vector which will be filled with the Euler angles
  4245. * @returns the current unchanged quaternion
  4246. */
  4247. toEulerAnglesToRef(result: Vector3): Quaternion;
  4248. /**
  4249. * Updates the given rotation matrix with the current quaternion values
  4250. * @param result defines the target matrix
  4251. * @returns the current unchanged quaternion
  4252. */
  4253. toRotationMatrix(result: Matrix): Quaternion;
  4254. /**
  4255. * Updates the current quaternion from the given rotation matrix values
  4256. * @param matrix defines the source matrix
  4257. * @returns the current updated quaternion
  4258. */
  4259. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4260. /**
  4261. * Creates a new quaternion from a rotation matrix
  4262. * @param matrix defines the source matrix
  4263. * @returns a new quaternion created from the given rotation matrix values
  4264. */
  4265. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4266. /**
  4267. * Updates the given quaternion with the given rotation matrix values
  4268. * @param matrix defines the source matrix
  4269. * @param result defines the target quaternion
  4270. */
  4271. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  4272. /**
  4273. * Returns the dot product (float) between the quaternions "left" and "right"
  4274. * @param left defines the left operand
  4275. * @param right defines the right operand
  4276. * @returns the dot product
  4277. */
  4278. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  4279. /**
  4280. * Checks if the two quaternions are close to each other
  4281. * @param quat0 defines the first quaternion to check
  4282. * @param quat1 defines the second quaternion to check
  4283. * @returns true if the two quaternions are close to each other
  4284. */
  4285. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  4286. /**
  4287. * Creates an empty quaternion
  4288. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  4289. */
  4290. static Zero(): Quaternion;
  4291. /**
  4292. * Inverse a given quaternion
  4293. * @param q defines the source quaternion
  4294. * @returns a new quaternion as the inverted current quaternion
  4295. */
  4296. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  4297. /**
  4298. * Inverse a given quaternion
  4299. * @param q defines the source quaternion
  4300. * @param result the quaternion the result will be stored in
  4301. * @returns the result quaternion
  4302. */
  4303. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  4304. /**
  4305. * Creates an identity quaternion
  4306. * @returns the identity quaternion
  4307. */
  4308. static Identity(): Quaternion;
  4309. /**
  4310. * Gets a boolean indicating if the given quaternion is identity
  4311. * @param quaternion defines the quaternion to check
  4312. * @returns true if the quaternion is identity
  4313. */
  4314. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  4315. /**
  4316. * Creates a quaternion from a rotation around an axis
  4317. * @param axis defines the axis to use
  4318. * @param angle defines the angle to use
  4319. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  4320. */
  4321. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  4322. /**
  4323. * Creates a rotation around an axis and stores it into the given quaternion
  4324. * @param axis defines the axis to use
  4325. * @param angle defines the angle to use
  4326. * @param result defines the target quaternion
  4327. * @returns the target quaternion
  4328. */
  4329. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  4330. /**
  4331. * Creates a new quaternion from data stored into an array
  4332. * @param array defines the data source
  4333. * @param offset defines the offset in the source array where the data starts
  4334. * @returns a new quaternion
  4335. */
  4336. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  4337. /**
  4338. * Updates the given quaternion "result" from the starting index of the given array.
  4339. * @param array the array to pull values from
  4340. * @param offset the offset into the array to start at
  4341. * @param result the quaternion to store the result in
  4342. */
  4343. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  4344. /**
  4345. * Create a quaternion from Euler rotation angles
  4346. * @param x Pitch
  4347. * @param y Yaw
  4348. * @param z Roll
  4349. * @returns the new Quaternion
  4350. */
  4351. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4352. /**
  4353. * Updates a quaternion from Euler rotation angles
  4354. * @param x Pitch
  4355. * @param y Yaw
  4356. * @param z Roll
  4357. * @param result the quaternion to store the result
  4358. * @returns the updated quaternion
  4359. */
  4360. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4361. /**
  4362. * Create a quaternion from Euler rotation vector
  4363. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4364. * @returns the new Quaternion
  4365. */
  4366. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4367. /**
  4368. * Updates a quaternion from Euler rotation vector
  4369. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4370. * @param result the quaternion to store the result
  4371. * @returns the updated quaternion
  4372. */
  4373. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4374. /**
  4375. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4376. * @param yaw defines the rotation around Y axis
  4377. * @param pitch defines the rotation around X axis
  4378. * @param roll defines the rotation around Z axis
  4379. * @returns the new quaternion
  4380. */
  4381. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4382. /**
  4383. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4384. * @param yaw defines the rotation around Y axis
  4385. * @param pitch defines the rotation around X axis
  4386. * @param roll defines the rotation around Z axis
  4387. * @param result defines the target quaternion
  4388. */
  4389. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4390. /**
  4391. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4392. * @param alpha defines the rotation around first axis
  4393. * @param beta defines the rotation around second axis
  4394. * @param gamma defines the rotation around third axis
  4395. * @returns the new quaternion
  4396. */
  4397. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4398. /**
  4399. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4400. * @param alpha defines the rotation around first axis
  4401. * @param beta defines the rotation around second axis
  4402. * @param gamma defines the rotation around third axis
  4403. * @param result defines the target quaternion
  4404. */
  4405. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4406. /**
  4407. * 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)
  4408. * @param axis1 defines the first axis
  4409. * @param axis2 defines the second axis
  4410. * @param axis3 defines the third axis
  4411. * @returns the new quaternion
  4412. */
  4413. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4414. /**
  4415. * 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
  4416. * @param axis1 defines the first axis
  4417. * @param axis2 defines the second axis
  4418. * @param axis3 defines the third axis
  4419. * @param ref defines the target quaternion
  4420. */
  4421. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4422. /**
  4423. * Interpolates between two quaternions
  4424. * @param left defines first quaternion
  4425. * @param right defines second quaternion
  4426. * @param amount defines the gradient to use
  4427. * @returns the new interpolated quaternion
  4428. */
  4429. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4430. /**
  4431. * Interpolates between two quaternions and stores it into a target quaternion
  4432. * @param left defines first quaternion
  4433. * @param right defines second quaternion
  4434. * @param amount defines the gradient to use
  4435. * @param result defines the target quaternion
  4436. */
  4437. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4438. /**
  4439. * Interpolate between two quaternions using Hermite interpolation
  4440. * @param value1 defines first quaternion
  4441. * @param tangent1 defines the incoming tangent
  4442. * @param value2 defines second quaternion
  4443. * @param tangent2 defines the outgoing tangent
  4444. * @param amount defines the target quaternion
  4445. * @returns the new interpolated quaternion
  4446. */
  4447. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4448. }
  4449. /**
  4450. * Class used to store matrix data (4x4)
  4451. */
  4452. export class Matrix {
  4453. /**
  4454. * Gets the precision of matrix computations
  4455. */
  4456. static get Use64Bits(): boolean;
  4457. private static _updateFlagSeed;
  4458. private static _identityReadOnly;
  4459. private _isIdentity;
  4460. private _isIdentityDirty;
  4461. private _isIdentity3x2;
  4462. private _isIdentity3x2Dirty;
  4463. /**
  4464. * Gets the update flag of the matrix which is an unique number for the matrix.
  4465. * It will be incremented every time the matrix data change.
  4466. * You can use it to speed the comparison between two versions of the same matrix.
  4467. */
  4468. updateFlag: number;
  4469. private readonly _m;
  4470. /**
  4471. * Gets the internal data of the matrix
  4472. */
  4473. get m(): DeepImmutable<Float32Array | Array<number>>;
  4474. /** @hidden */
  4475. _markAsUpdated(): void;
  4476. /** @hidden */
  4477. private _updateIdentityStatus;
  4478. /**
  4479. * Creates an empty matrix (filled with zeros)
  4480. */
  4481. constructor();
  4482. /**
  4483. * Check if the current matrix is identity
  4484. * @returns true is the matrix is the identity matrix
  4485. */
  4486. isIdentity(): boolean;
  4487. /**
  4488. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4489. * @returns true is the matrix is the identity matrix
  4490. */
  4491. isIdentityAs3x2(): boolean;
  4492. /**
  4493. * Gets the determinant of the matrix
  4494. * @returns the matrix determinant
  4495. */
  4496. determinant(): number;
  4497. /**
  4498. * Returns the matrix as a Float32Array or Array<number>
  4499. * @returns the matrix underlying array
  4500. */
  4501. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4502. /**
  4503. * Returns the matrix as a Float32Array or Array<number>
  4504. * @returns the matrix underlying array.
  4505. */
  4506. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4507. /**
  4508. * Inverts the current matrix in place
  4509. * @returns the current inverted matrix
  4510. */
  4511. invert(): Matrix;
  4512. /**
  4513. * Sets all the matrix elements to zero
  4514. * @returns the current matrix
  4515. */
  4516. reset(): Matrix;
  4517. /**
  4518. * Adds the current matrix with a second one
  4519. * @param other defines the matrix to add
  4520. * @returns a new matrix as the addition of the current matrix and the given one
  4521. */
  4522. add(other: DeepImmutable<Matrix>): Matrix;
  4523. /**
  4524. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4525. * @param other defines the matrix to add
  4526. * @param result defines the target matrix
  4527. * @returns the current matrix
  4528. */
  4529. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4530. /**
  4531. * Adds in place the given matrix to the current matrix
  4532. * @param other defines the second operand
  4533. * @returns the current updated matrix
  4534. */
  4535. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4536. /**
  4537. * Sets the given matrix to the current inverted Matrix
  4538. * @param other defines the target matrix
  4539. * @returns the unmodified current matrix
  4540. */
  4541. invertToRef(other: Matrix): Matrix;
  4542. /**
  4543. * add a value at the specified position in the current Matrix
  4544. * @param index the index of the value within the matrix. between 0 and 15.
  4545. * @param value the value to be added
  4546. * @returns the current updated matrix
  4547. */
  4548. addAtIndex(index: number, value: number): Matrix;
  4549. /**
  4550. * mutiply the specified position in the current Matrix by a value
  4551. * @param index the index of the value within the matrix. between 0 and 15.
  4552. * @param value the value to be added
  4553. * @returns the current updated matrix
  4554. */
  4555. multiplyAtIndex(index: number, value: number): Matrix;
  4556. /**
  4557. * Inserts the translation vector (using 3 floats) in the current matrix
  4558. * @param x defines the 1st component of the translation
  4559. * @param y defines the 2nd component of the translation
  4560. * @param z defines the 3rd component of the translation
  4561. * @returns the current updated matrix
  4562. */
  4563. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4564. /**
  4565. * Adds the translation vector (using 3 floats) in the current matrix
  4566. * @param x defines the 1st component of the translation
  4567. * @param y defines the 2nd component of the translation
  4568. * @param z defines the 3rd component of the translation
  4569. * @returns the current updated matrix
  4570. */
  4571. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4572. /**
  4573. * Inserts the translation vector in the current matrix
  4574. * @param vector3 defines the translation to insert
  4575. * @returns the current updated matrix
  4576. */
  4577. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4578. /**
  4579. * Gets the translation value of the current matrix
  4580. * @returns a new Vector3 as the extracted translation from the matrix
  4581. */
  4582. getTranslation(): Vector3;
  4583. /**
  4584. * Fill a Vector3 with the extracted translation from the matrix
  4585. * @param result defines the Vector3 where to store the translation
  4586. * @returns the current matrix
  4587. */
  4588. getTranslationToRef(result: Vector3): Matrix;
  4589. /**
  4590. * Remove rotation and scaling part from the matrix
  4591. * @returns the updated matrix
  4592. */
  4593. removeRotationAndScaling(): Matrix;
  4594. /**
  4595. * Multiply two matrices
  4596. * @param other defines the second operand
  4597. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4598. */
  4599. multiply(other: DeepImmutable<Matrix>): Matrix;
  4600. /**
  4601. * Copy the current matrix from the given one
  4602. * @param other defines the source matrix
  4603. * @returns the current updated matrix
  4604. */
  4605. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4606. /**
  4607. * Populates the given array from the starting index with the current matrix values
  4608. * @param array defines the target array
  4609. * @param offset defines the offset in the target array where to start storing values
  4610. * @returns the current matrix
  4611. */
  4612. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4613. /**
  4614. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4615. * @param other defines the second operand
  4616. * @param result defines the matrix where to store the multiplication
  4617. * @returns the current matrix
  4618. */
  4619. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4620. /**
  4621. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4622. * @param other defines the second operand
  4623. * @param result defines the array where to store the multiplication
  4624. * @param offset defines the offset in the target array where to start storing values
  4625. * @returns the current matrix
  4626. */
  4627. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4628. /**
  4629. * Check equality between this matrix and a second one
  4630. * @param value defines the second matrix to compare
  4631. * @returns true is the current matrix and the given one values are strictly equal
  4632. */
  4633. equals(value: DeepImmutable<Matrix>): boolean;
  4634. /**
  4635. * Clone the current matrix
  4636. * @returns a new matrix from the current matrix
  4637. */
  4638. clone(): Matrix;
  4639. /**
  4640. * Returns the name of the current matrix class
  4641. * @returns the string "Matrix"
  4642. */
  4643. getClassName(): string;
  4644. /**
  4645. * Gets the hash code of the current matrix
  4646. * @returns the hash code
  4647. */
  4648. getHashCode(): number;
  4649. /**
  4650. * Decomposes the current Matrix into a translation, rotation and scaling components
  4651. * @param scale defines the scale vector3 given as a reference to update
  4652. * @param rotation defines the rotation quaternion given as a reference to update
  4653. * @param translation defines the translation vector3 given as a reference to update
  4654. * @returns true if operation was successful
  4655. */
  4656. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4657. /**
  4658. * Gets specific row of the matrix
  4659. * @param index defines the number of the row to get
  4660. * @returns the index-th row of the current matrix as a new Vector4
  4661. */
  4662. getRow(index: number): Nullable<Vector4>;
  4663. /**
  4664. * Sets the index-th row of the current matrix to the vector4 values
  4665. * @param index defines the number of the row to set
  4666. * @param row defines the target vector4
  4667. * @returns the updated current matrix
  4668. */
  4669. setRow(index: number, row: Vector4): Matrix;
  4670. /**
  4671. * Compute the transpose of the matrix
  4672. * @returns the new transposed matrix
  4673. */
  4674. transpose(): Matrix;
  4675. /**
  4676. * Compute the transpose of the matrix and store it in a given matrix
  4677. * @param result defines the target matrix
  4678. * @returns the current matrix
  4679. */
  4680. transposeToRef(result: Matrix): Matrix;
  4681. /**
  4682. * Sets the index-th row of the current matrix with the given 4 x float values
  4683. * @param index defines the row index
  4684. * @param x defines the x component to set
  4685. * @param y defines the y component to set
  4686. * @param z defines the z component to set
  4687. * @param w defines the w component to set
  4688. * @returns the updated current matrix
  4689. */
  4690. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4691. /**
  4692. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4693. * @param scale defines the scale factor
  4694. * @returns a new matrix
  4695. */
  4696. scale(scale: number): Matrix;
  4697. /**
  4698. * Scale the current matrix values by a factor to a given result matrix
  4699. * @param scale defines the scale factor
  4700. * @param result defines the matrix to store the result
  4701. * @returns the current matrix
  4702. */
  4703. scaleToRef(scale: number, result: Matrix): Matrix;
  4704. /**
  4705. * Scale the current matrix values by a factor and add the result to a given matrix
  4706. * @param scale defines the scale factor
  4707. * @param result defines the Matrix to store the result
  4708. * @returns the current matrix
  4709. */
  4710. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4711. /**
  4712. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4713. * @param ref matrix to store the result
  4714. */
  4715. toNormalMatrix(ref: Matrix): void;
  4716. /**
  4717. * Gets only rotation part of the current matrix
  4718. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4719. */
  4720. getRotationMatrix(): Matrix;
  4721. /**
  4722. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4723. * @param result defines the target matrix to store data to
  4724. * @returns the current matrix
  4725. */
  4726. getRotationMatrixToRef(result: Matrix): Matrix;
  4727. /**
  4728. * Toggles model matrix from being right handed to left handed in place and vice versa
  4729. */
  4730. toggleModelMatrixHandInPlace(): void;
  4731. /**
  4732. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4733. */
  4734. toggleProjectionMatrixHandInPlace(): void;
  4735. /**
  4736. * Creates a matrix from an array
  4737. * @param array defines the source array
  4738. * @param offset defines an offset in the source array
  4739. * @returns a new Matrix set from the starting index of the given array
  4740. */
  4741. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4742. /**
  4743. * Copy the content of an array into a given matrix
  4744. * @param array defines the source array
  4745. * @param offset defines an offset in the source array
  4746. * @param result defines the target matrix
  4747. */
  4748. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4749. /**
  4750. * Stores an array into a matrix after having multiplied each component by a given factor
  4751. * @param array defines the source array
  4752. * @param offset defines the offset in the source array
  4753. * @param scale defines the scaling factor
  4754. * @param result defines the target matrix
  4755. */
  4756. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4757. /**
  4758. * Gets an identity matrix that must not be updated
  4759. */
  4760. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4761. /**
  4762. * Stores a list of values (16) inside a given matrix
  4763. * @param initialM11 defines 1st value of 1st row
  4764. * @param initialM12 defines 2nd value of 1st row
  4765. * @param initialM13 defines 3rd value of 1st row
  4766. * @param initialM14 defines 4th value of 1st row
  4767. * @param initialM21 defines 1st value of 2nd row
  4768. * @param initialM22 defines 2nd value of 2nd row
  4769. * @param initialM23 defines 3rd value of 2nd row
  4770. * @param initialM24 defines 4th value of 2nd row
  4771. * @param initialM31 defines 1st value of 3rd row
  4772. * @param initialM32 defines 2nd value of 3rd row
  4773. * @param initialM33 defines 3rd value of 3rd row
  4774. * @param initialM34 defines 4th value of 3rd row
  4775. * @param initialM41 defines 1st value of 4th row
  4776. * @param initialM42 defines 2nd value of 4th row
  4777. * @param initialM43 defines 3rd value of 4th row
  4778. * @param initialM44 defines 4th value of 4th row
  4779. * @param result defines the target matrix
  4780. */
  4781. 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;
  4782. /**
  4783. * Creates new matrix from a list of values (16)
  4784. * @param initialM11 defines 1st value of 1st row
  4785. * @param initialM12 defines 2nd value of 1st row
  4786. * @param initialM13 defines 3rd value of 1st row
  4787. * @param initialM14 defines 4th value of 1st row
  4788. * @param initialM21 defines 1st value of 2nd row
  4789. * @param initialM22 defines 2nd value of 2nd row
  4790. * @param initialM23 defines 3rd value of 2nd row
  4791. * @param initialM24 defines 4th value of 2nd row
  4792. * @param initialM31 defines 1st value of 3rd row
  4793. * @param initialM32 defines 2nd value of 3rd row
  4794. * @param initialM33 defines 3rd value of 3rd row
  4795. * @param initialM34 defines 4th value of 3rd row
  4796. * @param initialM41 defines 1st value of 4th row
  4797. * @param initialM42 defines 2nd value of 4th row
  4798. * @param initialM43 defines 3rd value of 4th row
  4799. * @param initialM44 defines 4th value of 4th row
  4800. * @returns the new matrix
  4801. */
  4802. 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;
  4803. /**
  4804. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4805. * @param scale defines the scale vector3
  4806. * @param rotation defines the rotation quaternion
  4807. * @param translation defines the translation vector3
  4808. * @returns a new matrix
  4809. */
  4810. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4811. /**
  4812. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4813. * @param scale defines the scale vector3
  4814. * @param rotation defines the rotation quaternion
  4815. * @param translation defines the translation vector3
  4816. * @param result defines the target matrix
  4817. */
  4818. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4819. /**
  4820. * Creates a new identity matrix
  4821. * @returns a new identity matrix
  4822. */
  4823. static Identity(): Matrix;
  4824. /**
  4825. * Creates a new identity matrix and stores the result in a given matrix
  4826. * @param result defines the target matrix
  4827. */
  4828. static IdentityToRef(result: Matrix): void;
  4829. /**
  4830. * Creates a new zero matrix
  4831. * @returns a new zero matrix
  4832. */
  4833. static Zero(): Matrix;
  4834. /**
  4835. * Creates a new rotation matrix for "angle" radians around the X axis
  4836. * @param angle defines the angle (in radians) to use
  4837. * @return the new matrix
  4838. */
  4839. static RotationX(angle: number): Matrix;
  4840. /**
  4841. * Creates a new matrix as the invert of a given matrix
  4842. * @param source defines the source matrix
  4843. * @returns the new matrix
  4844. */
  4845. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4846. /**
  4847. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4848. * @param angle defines the angle (in radians) to use
  4849. * @param result defines the target matrix
  4850. */
  4851. static RotationXToRef(angle: number, result: Matrix): void;
  4852. /**
  4853. * Creates a new rotation matrix for "angle" radians around the Y axis
  4854. * @param angle defines the angle (in radians) to use
  4855. * @return the new matrix
  4856. */
  4857. static RotationY(angle: number): Matrix;
  4858. /**
  4859. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4860. * @param angle defines the angle (in radians) to use
  4861. * @param result defines the target matrix
  4862. */
  4863. static RotationYToRef(angle: number, result: Matrix): void;
  4864. /**
  4865. * Creates a new rotation matrix for "angle" radians around the Z axis
  4866. * @param angle defines the angle (in radians) to use
  4867. * @return the new matrix
  4868. */
  4869. static RotationZ(angle: number): Matrix;
  4870. /**
  4871. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4872. * @param angle defines the angle (in radians) to use
  4873. * @param result defines the target matrix
  4874. */
  4875. static RotationZToRef(angle: number, result: Matrix): void;
  4876. /**
  4877. * Creates a new rotation matrix for "angle" radians around the given axis
  4878. * @param axis defines the axis to use
  4879. * @param angle defines the angle (in radians) to use
  4880. * @return the new matrix
  4881. */
  4882. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4883. /**
  4884. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4885. * @param axis defines the axis to use
  4886. * @param angle defines the angle (in radians) to use
  4887. * @param result defines the target matrix
  4888. */
  4889. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4890. /**
  4891. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4892. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4893. * @param from defines the vector to align
  4894. * @param to defines the vector to align to
  4895. * @param result defines the target matrix
  4896. */
  4897. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4898. /**
  4899. * Creates a rotation matrix
  4900. * @param yaw defines the yaw angle in radians (Y axis)
  4901. * @param pitch defines the pitch angle in radians (X axis)
  4902. * @param roll defines the roll angle in radians (Z axis)
  4903. * @returns the new rotation matrix
  4904. */
  4905. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4906. /**
  4907. * Creates a rotation matrix and stores it in a given matrix
  4908. * @param yaw defines the yaw angle in radians (Y axis)
  4909. * @param pitch defines the pitch angle in radians (X axis)
  4910. * @param roll defines the roll angle in radians (Z axis)
  4911. * @param result defines the target matrix
  4912. */
  4913. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4914. /**
  4915. * Creates a scaling matrix
  4916. * @param x defines the scale factor on X axis
  4917. * @param y defines the scale factor on Y axis
  4918. * @param z defines the scale factor on Z axis
  4919. * @returns the new matrix
  4920. */
  4921. static Scaling(x: number, y: number, z: number): Matrix;
  4922. /**
  4923. * Creates a scaling matrix and stores it in a given matrix
  4924. * @param x defines the scale factor on X axis
  4925. * @param y defines the scale factor on Y axis
  4926. * @param z defines the scale factor on Z axis
  4927. * @param result defines the target matrix
  4928. */
  4929. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4930. /**
  4931. * Creates a translation matrix
  4932. * @param x defines the translation on X axis
  4933. * @param y defines the translation on Y axis
  4934. * @param z defines the translationon Z axis
  4935. * @returns the new matrix
  4936. */
  4937. static Translation(x: number, y: number, z: number): Matrix;
  4938. /**
  4939. * Creates a translation matrix and stores it in a given matrix
  4940. * @param x defines the translation on X axis
  4941. * @param y defines the translation on Y axis
  4942. * @param z defines the translationon Z axis
  4943. * @param result defines the target matrix
  4944. */
  4945. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4946. /**
  4947. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4948. * @param startValue defines the start value
  4949. * @param endValue defines the end value
  4950. * @param gradient defines the gradient factor
  4951. * @returns the new matrix
  4952. */
  4953. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4954. /**
  4955. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4956. * @param startValue defines the start value
  4957. * @param endValue defines the end value
  4958. * @param gradient defines the gradient factor
  4959. * @param result defines the Matrix object where to store data
  4960. */
  4961. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4962. /**
  4963. * Builds a new matrix whose values are computed by:
  4964. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4965. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4966. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4967. * @param startValue defines the first matrix
  4968. * @param endValue defines the second matrix
  4969. * @param gradient defines the gradient between the two matrices
  4970. * @returns the new matrix
  4971. */
  4972. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4973. /**
  4974. * Update a matrix to values which are computed by:
  4975. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4976. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4977. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4978. * @param startValue defines the first matrix
  4979. * @param endValue defines the second matrix
  4980. * @param gradient defines the gradient between the two matrices
  4981. * @param result defines the target matrix
  4982. */
  4983. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4984. /**
  4985. * 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"
  4986. * This function works in left handed mode
  4987. * @param eye defines the final position of the entity
  4988. * @param target defines where the entity should look at
  4989. * @param up defines the up vector for the entity
  4990. * @returns the new matrix
  4991. */
  4992. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4993. /**
  4994. * 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".
  4995. * This function works in left handed mode
  4996. * @param eye defines the final position of the entity
  4997. * @param target defines where the entity should look at
  4998. * @param up defines the up vector for the entity
  4999. * @param result defines the target matrix
  5000. */
  5001. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5002. /**
  5003. * 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"
  5004. * This function works in right handed mode
  5005. * @param eye defines the final position of the entity
  5006. * @param target defines where the entity should look at
  5007. * @param up defines the up vector for the entity
  5008. * @returns the new matrix
  5009. */
  5010. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5011. /**
  5012. * 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".
  5013. * This function works in right handed mode
  5014. * @param eye defines the final position of the entity
  5015. * @param target defines where the entity should look at
  5016. * @param up defines the up vector for the entity
  5017. * @param result defines the target matrix
  5018. */
  5019. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5020. /**
  5021. * Create a left-handed orthographic projection matrix
  5022. * @param width defines the viewport width
  5023. * @param height defines the viewport height
  5024. * @param znear defines the near clip plane
  5025. * @param zfar defines the far clip plane
  5026. * @returns a new matrix as a left-handed orthographic projection matrix
  5027. */
  5028. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5029. /**
  5030. * Store a left-handed orthographic projection to a given matrix
  5031. * @param width defines the viewport width
  5032. * @param height defines the viewport height
  5033. * @param znear defines the near clip plane
  5034. * @param zfar defines the far clip plane
  5035. * @param result defines the target matrix
  5036. */
  5037. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  5038. /**
  5039. * Create a left-handed orthographic projection matrix
  5040. * @param left defines the viewport left coordinate
  5041. * @param right defines the viewport right coordinate
  5042. * @param bottom defines the viewport bottom coordinate
  5043. * @param top defines the viewport top coordinate
  5044. * @param znear defines the near clip plane
  5045. * @param zfar defines the far clip plane
  5046. * @returns a new matrix as a left-handed orthographic projection matrix
  5047. */
  5048. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5049. /**
  5050. * Stores a left-handed orthographic projection into a given matrix
  5051. * @param left defines the viewport left coordinate
  5052. * @param right defines the viewport right coordinate
  5053. * @param bottom defines the viewport bottom coordinate
  5054. * @param top defines the viewport top coordinate
  5055. * @param znear defines the near clip plane
  5056. * @param zfar defines the far clip plane
  5057. * @param result defines the target matrix
  5058. */
  5059. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5060. /**
  5061. * Creates a right-handed orthographic projection matrix
  5062. * @param left defines the viewport left coordinate
  5063. * @param right defines the viewport right coordinate
  5064. * @param bottom defines the viewport bottom coordinate
  5065. * @param top defines the viewport top coordinate
  5066. * @param znear defines the near clip plane
  5067. * @param zfar defines the far clip plane
  5068. * @returns a new matrix as a right-handed orthographic projection matrix
  5069. */
  5070. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5071. /**
  5072. * Stores a right-handed orthographic projection into a given matrix
  5073. * @param left defines the viewport left coordinate
  5074. * @param right defines the viewport right coordinate
  5075. * @param bottom defines the viewport bottom coordinate
  5076. * @param top defines the viewport top coordinate
  5077. * @param znear defines the near clip plane
  5078. * @param zfar defines the far clip plane
  5079. * @param result defines the target matrix
  5080. */
  5081. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5082. /**
  5083. * Creates a left-handed perspective projection matrix
  5084. * @param width defines the viewport width
  5085. * @param height defines the viewport height
  5086. * @param znear defines the near clip plane
  5087. * @param zfar defines the far clip plane
  5088. * @returns a new matrix as a left-handed perspective projection matrix
  5089. */
  5090. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5091. /**
  5092. * Creates a left-handed perspective projection matrix
  5093. * @param fov defines the horizontal field of view
  5094. * @param aspect defines the aspect ratio
  5095. * @param znear defines the near clip plane
  5096. * @param zfar defines the far clip plane
  5097. * @returns a new matrix as a left-handed perspective projection matrix
  5098. */
  5099. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5100. /**
  5101. * Stores a left-handed perspective projection into a given matrix
  5102. * @param fov defines the horizontal field of view
  5103. * @param aspect defines the aspect ratio
  5104. * @param znear defines the near clip plane
  5105. * @param zfar defines the far clip plane
  5106. * @param result defines the target matrix
  5107. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5108. */
  5109. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5110. /**
  5111. * Stores a left-handed perspective projection into a given matrix with depth reversed
  5112. * @param fov defines the horizontal field of view
  5113. * @param aspect defines the aspect ratio
  5114. * @param znear defines the near clip plane
  5115. * @param zfar not used as infinity is used as far clip
  5116. * @param result defines the target matrix
  5117. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5118. */
  5119. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5120. /**
  5121. * Creates a right-handed perspective projection matrix
  5122. * @param fov defines the horizontal field of view
  5123. * @param aspect defines the aspect ratio
  5124. * @param znear defines the near clip plane
  5125. * @param zfar defines the far clip plane
  5126. * @returns a new matrix as a right-handed perspective projection matrix
  5127. */
  5128. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5129. /**
  5130. * Stores a right-handed perspective projection into a given matrix
  5131. * @param fov defines the horizontal field of view
  5132. * @param aspect defines the aspect ratio
  5133. * @param znear defines the near clip plane
  5134. * @param zfar defines the far clip plane
  5135. * @param result defines the target matrix
  5136. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5137. */
  5138. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5139. /**
  5140. * Stores a right-handed perspective projection into a given matrix
  5141. * @param fov defines the horizontal field of view
  5142. * @param aspect defines the aspect ratio
  5143. * @param znear defines the near clip plane
  5144. * @param zfar not used as infinity is used as far clip
  5145. * @param result defines the target matrix
  5146. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5147. */
  5148. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5149. /**
  5150. * Stores a perspective projection for WebVR info a given matrix
  5151. * @param fov defines the field of view
  5152. * @param znear defines the near clip plane
  5153. * @param zfar defines the far clip plane
  5154. * @param result defines the target matrix
  5155. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  5156. */
  5157. static PerspectiveFovWebVRToRef(fov: {
  5158. upDegrees: number;
  5159. downDegrees: number;
  5160. leftDegrees: number;
  5161. rightDegrees: number;
  5162. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  5163. /**
  5164. * Computes a complete transformation matrix
  5165. * @param viewport defines the viewport to use
  5166. * @param world defines the world matrix
  5167. * @param view defines the view matrix
  5168. * @param projection defines the projection matrix
  5169. * @param zmin defines the near clip plane
  5170. * @param zmax defines the far clip plane
  5171. * @returns the transformation matrix
  5172. */
  5173. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  5174. /**
  5175. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  5176. * @param matrix defines the matrix to use
  5177. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  5178. */
  5179. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5180. /**
  5181. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  5182. * @param matrix defines the matrix to use
  5183. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  5184. */
  5185. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5186. /**
  5187. * Compute the transpose of a given matrix
  5188. * @param matrix defines the matrix to transpose
  5189. * @returns the new matrix
  5190. */
  5191. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  5192. /**
  5193. * Compute the transpose of a matrix and store it in a target matrix
  5194. * @param matrix defines the matrix to transpose
  5195. * @param result defines the target matrix
  5196. */
  5197. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  5198. /**
  5199. * Computes a reflection matrix from a plane
  5200. * @param plane defines the reflection plane
  5201. * @returns a new matrix
  5202. */
  5203. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  5204. /**
  5205. * Computes a reflection matrix from a plane
  5206. * @param plane defines the reflection plane
  5207. * @param result defines the target matrix
  5208. */
  5209. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  5210. /**
  5211. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  5212. * @param xaxis defines the value of the 1st axis
  5213. * @param yaxis defines the value of the 2nd axis
  5214. * @param zaxis defines the value of the 3rd axis
  5215. * @param result defines the target matrix
  5216. */
  5217. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  5218. /**
  5219. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  5220. * @param quat defines the quaternion to use
  5221. * @param result defines the target matrix
  5222. */
  5223. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  5224. }
  5225. /**
  5226. * @hidden
  5227. */
  5228. export class TmpVectors {
  5229. static Vector2: Vector2[];
  5230. static Vector3: Vector3[];
  5231. static Vector4: Vector4[];
  5232. static Quaternion: Quaternion[];
  5233. static Matrix: Matrix[];
  5234. }
  5235. }
  5236. declare module BABYLON {
  5237. /**
  5238. * Defines potential orientation for back face culling
  5239. */
  5240. export enum Orientation {
  5241. /**
  5242. * Clockwise
  5243. */
  5244. CW = 0,
  5245. /** Counter clockwise */
  5246. CCW = 1
  5247. }
  5248. /** Class used to represent a Bezier curve */
  5249. export class BezierCurve {
  5250. /**
  5251. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5252. * @param t defines the time
  5253. * @param x1 defines the left coordinate on X axis
  5254. * @param y1 defines the left coordinate on Y axis
  5255. * @param x2 defines the right coordinate on X axis
  5256. * @param y2 defines the right coordinate on Y axis
  5257. * @returns the interpolated value
  5258. */
  5259. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5260. }
  5261. /**
  5262. * Defines angle representation
  5263. */
  5264. export class Angle {
  5265. private _radians;
  5266. /**
  5267. * Creates an Angle object of "radians" radians (float).
  5268. * @param radians the angle in radians
  5269. */
  5270. constructor(radians: number);
  5271. /**
  5272. * Get value in degrees
  5273. * @returns the Angle value in degrees (float)
  5274. */
  5275. degrees(): number;
  5276. /**
  5277. * Get value in radians
  5278. * @returns the Angle value in radians (float)
  5279. */
  5280. radians(): number;
  5281. /**
  5282. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  5283. * @param a defines first point as the origin
  5284. * @param b defines point
  5285. * @returns a new Angle
  5286. */
  5287. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5288. /**
  5289. * Gets a new Angle object from the given float in radians
  5290. * @param radians defines the angle value in radians
  5291. * @returns a new Angle
  5292. */
  5293. static FromRadians(radians: number): Angle;
  5294. /**
  5295. * Gets a new Angle object from the given float in degrees
  5296. * @param degrees defines the angle value in degrees
  5297. * @returns a new Angle
  5298. */
  5299. static FromDegrees(degrees: number): Angle;
  5300. }
  5301. /**
  5302. * This represents an arc in a 2d space.
  5303. */
  5304. export class Arc2 {
  5305. /** Defines the start point of the arc */
  5306. startPoint: Vector2;
  5307. /** Defines the mid point of the arc */
  5308. midPoint: Vector2;
  5309. /** Defines the end point of the arc */
  5310. endPoint: Vector2;
  5311. /**
  5312. * Defines the center point of the arc.
  5313. */
  5314. centerPoint: Vector2;
  5315. /**
  5316. * Defines the radius of the arc.
  5317. */
  5318. radius: number;
  5319. /**
  5320. * Defines the angle of the arc (from mid point to end point).
  5321. */
  5322. angle: Angle;
  5323. /**
  5324. * Defines the start angle of the arc (from start point to middle point).
  5325. */
  5326. startAngle: Angle;
  5327. /**
  5328. * Defines the orientation of the arc (clock wise/counter clock wise).
  5329. */
  5330. orientation: Orientation;
  5331. /**
  5332. * Creates an Arc object from the three given points : start, middle and end.
  5333. * @param startPoint Defines the start point of the arc
  5334. * @param midPoint Defines the midlle point of the arc
  5335. * @param endPoint Defines the end point of the arc
  5336. */
  5337. constructor(
  5338. /** Defines the start point of the arc */
  5339. startPoint: Vector2,
  5340. /** Defines the mid point of the arc */
  5341. midPoint: Vector2,
  5342. /** Defines the end point of the arc */
  5343. endPoint: Vector2);
  5344. }
  5345. /**
  5346. * Represents a 2D path made up of multiple 2D points
  5347. */
  5348. export class Path2 {
  5349. private _points;
  5350. private _length;
  5351. /**
  5352. * If the path start and end point are the same
  5353. */
  5354. closed: boolean;
  5355. /**
  5356. * Creates a Path2 object from the starting 2D coordinates x and y.
  5357. * @param x the starting points x value
  5358. * @param y the starting points y value
  5359. */
  5360. constructor(x: number, y: number);
  5361. /**
  5362. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5363. * @param x the added points x value
  5364. * @param y the added points y value
  5365. * @returns the updated Path2.
  5366. */
  5367. addLineTo(x: number, y: number): Path2;
  5368. /**
  5369. * 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.
  5370. * @param midX middle point x value
  5371. * @param midY middle point y value
  5372. * @param endX end point x value
  5373. * @param endY end point y value
  5374. * @param numberOfSegments (default: 36)
  5375. * @returns the updated Path2.
  5376. */
  5377. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5378. /**
  5379. * Closes the Path2.
  5380. * @returns the Path2.
  5381. */
  5382. close(): Path2;
  5383. /**
  5384. * Gets the sum of the distance between each sequential point in the path
  5385. * @returns the Path2 total length (float).
  5386. */
  5387. length(): number;
  5388. /**
  5389. * Gets the points which construct the path
  5390. * @returns the Path2 internal array of points.
  5391. */
  5392. getPoints(): Vector2[];
  5393. /**
  5394. * Retreives the point at the distance aways from the starting point
  5395. * @param normalizedLengthPosition the length along the path to retreive the point from
  5396. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5397. */
  5398. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5399. /**
  5400. * Creates a new path starting from an x and y position
  5401. * @param x starting x value
  5402. * @param y starting y value
  5403. * @returns a new Path2 starting at the coordinates (x, y).
  5404. */
  5405. static StartingAt(x: number, y: number): Path2;
  5406. }
  5407. /**
  5408. * Represents a 3D path made up of multiple 3D points
  5409. */
  5410. export class Path3D {
  5411. /**
  5412. * an array of Vector3, the curve axis of the Path3D
  5413. */
  5414. path: Vector3[];
  5415. private _curve;
  5416. private _distances;
  5417. private _tangents;
  5418. private _normals;
  5419. private _binormals;
  5420. private _raw;
  5421. private _alignTangentsWithPath;
  5422. private readonly _pointAtData;
  5423. /**
  5424. * new Path3D(path, normal, raw)
  5425. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5426. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5427. * @param path an array of Vector3, the curve axis of the Path3D
  5428. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5429. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5430. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5431. */
  5432. constructor(
  5433. /**
  5434. * an array of Vector3, the curve axis of the Path3D
  5435. */
  5436. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5437. /**
  5438. * Returns the Path3D array of successive Vector3 designing its curve.
  5439. * @returns the Path3D array of successive Vector3 designing its curve.
  5440. */
  5441. getCurve(): Vector3[];
  5442. /**
  5443. * Returns the Path3D array of successive Vector3 designing its curve.
  5444. * @returns the Path3D array of successive Vector3 designing its curve.
  5445. */
  5446. getPoints(): Vector3[];
  5447. /**
  5448. * @returns the computed length (float) of the path.
  5449. */
  5450. length(): number;
  5451. /**
  5452. * Returns an array populated with tangent vectors on each Path3D curve point.
  5453. * @returns an array populated with tangent vectors on each Path3D curve point.
  5454. */
  5455. getTangents(): Vector3[];
  5456. /**
  5457. * Returns an array populated with normal vectors on each Path3D curve point.
  5458. * @returns an array populated with normal vectors on each Path3D curve point.
  5459. */
  5460. getNormals(): Vector3[];
  5461. /**
  5462. * Returns an array populated with binormal vectors on each Path3D curve point.
  5463. * @returns an array populated with binormal vectors on each Path3D curve point.
  5464. */
  5465. getBinormals(): Vector3[];
  5466. /**
  5467. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5468. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5469. */
  5470. getDistances(): number[];
  5471. /**
  5472. * Returns an interpolated point along this path
  5473. * @param position the position of the point along this path, from 0.0 to 1.0
  5474. * @returns a new Vector3 as the point
  5475. */
  5476. getPointAt(position: number): Vector3;
  5477. /**
  5478. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5479. * @param position the position of the point along this path, from 0.0 to 1.0
  5480. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5481. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5482. */
  5483. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5484. /**
  5485. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5486. * @param position the position of the point along this path, from 0.0 to 1.0
  5487. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5488. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5489. */
  5490. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5491. /**
  5492. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5493. * @param position the position of the point along this path, from 0.0 to 1.0
  5494. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5495. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5496. */
  5497. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5498. /**
  5499. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5500. * @param position the position of the point along this path, from 0.0 to 1.0
  5501. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5502. */
  5503. getDistanceAt(position: number): number;
  5504. /**
  5505. * Returns the array index of the previous point of an interpolated point along this path
  5506. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5507. * @returns the array index
  5508. */
  5509. getPreviousPointIndexAt(position: number): number;
  5510. /**
  5511. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5512. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5513. * @returns the sub position
  5514. */
  5515. getSubPositionAt(position: number): number;
  5516. /**
  5517. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5518. * @param target the vector of which to get the closest position to
  5519. * @returns the position of the closest virtual point on this path to the target vector
  5520. */
  5521. getClosestPositionTo(target: Vector3): number;
  5522. /**
  5523. * Returns a sub path (slice) of this path
  5524. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5525. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5526. * @returns a sub path (slice) of this path
  5527. */
  5528. slice(start?: number, end?: number): Path3D;
  5529. /**
  5530. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5531. * @param path path which all values are copied into the curves points
  5532. * @param firstNormal which should be projected onto the curve
  5533. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5534. * @returns the same object updated.
  5535. */
  5536. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5537. private _compute;
  5538. private _getFirstNonNullVector;
  5539. private _getLastNonNullVector;
  5540. private _normalVector;
  5541. /**
  5542. * Updates the point at data for an interpolated point along this curve
  5543. * @param position the position of the point along this curve, from 0.0 to 1.0
  5544. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5545. * @returns the (updated) point at data
  5546. */
  5547. private _updatePointAtData;
  5548. /**
  5549. * Updates the point at data from the specified parameters
  5550. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5551. * @param point the interpolated point
  5552. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5553. */
  5554. private _setPointAtData;
  5555. /**
  5556. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5557. */
  5558. private _updateInterpolationMatrix;
  5559. }
  5560. /**
  5561. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5562. * A Curve3 is designed from a series of successive Vector3.
  5563. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5564. */
  5565. export class Curve3 {
  5566. private _points;
  5567. private _length;
  5568. /**
  5569. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5570. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5571. * @param v1 (Vector3) the control point
  5572. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5573. * @param nbPoints (integer) the wanted number of points in the curve
  5574. * @returns the created Curve3
  5575. */
  5576. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5577. /**
  5578. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5579. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5580. * @param v1 (Vector3) the first control point
  5581. * @param v2 (Vector3) the second control point
  5582. * @param v3 (Vector3) the end point of the Cubic Bezier
  5583. * @param nbPoints (integer) the wanted number of points in the curve
  5584. * @returns the created Curve3
  5585. */
  5586. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5587. /**
  5588. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5589. * @param p1 (Vector3) the origin point of the Hermite Spline
  5590. * @param t1 (Vector3) the tangent vector at the origin point
  5591. * @param p2 (Vector3) the end point of the Hermite Spline
  5592. * @param t2 (Vector3) the tangent vector at the end point
  5593. * @param nbPoints (integer) the wanted number of points in the curve
  5594. * @returns the created Curve3
  5595. */
  5596. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5597. /**
  5598. * Returns a Curve3 object along a CatmullRom Spline curve :
  5599. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5600. * @param nbPoints (integer) the wanted number of points between each curve control points
  5601. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5602. * @returns the created Curve3
  5603. */
  5604. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5605. /**
  5606. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5607. * A Curve3 is designed from a series of successive Vector3.
  5608. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5609. * @param points points which make up the curve
  5610. */
  5611. constructor(points: Vector3[]);
  5612. /**
  5613. * @returns the Curve3 stored array of successive Vector3
  5614. */
  5615. getPoints(): Vector3[];
  5616. /**
  5617. * @returns the computed length (float) of the curve.
  5618. */
  5619. length(): number;
  5620. /**
  5621. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5622. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5623. * curveA and curveB keep unchanged.
  5624. * @param curve the curve to continue from this curve
  5625. * @returns the newly constructed curve
  5626. */
  5627. continue(curve: DeepImmutable<Curve3>): Curve3;
  5628. private _computeLength;
  5629. }
  5630. }
  5631. declare module BABYLON {
  5632. /**
  5633. * This represents the main contract an easing function should follow.
  5634. * Easing functions are used throughout the animation system.
  5635. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5636. */
  5637. export interface IEasingFunction {
  5638. /**
  5639. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5640. * of the easing function.
  5641. * The link below provides some of the most common examples of easing functions.
  5642. * @see https://easings.net/
  5643. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5644. * @returns the corresponding value on the curve defined by the easing function
  5645. */
  5646. ease(gradient: number): number;
  5647. }
  5648. /**
  5649. * Base class used for every default easing function.
  5650. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5651. */
  5652. export class EasingFunction implements IEasingFunction {
  5653. /**
  5654. * Interpolation follows the mathematical formula associated with the easing function.
  5655. */
  5656. static readonly EASINGMODE_EASEIN: number;
  5657. /**
  5658. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5659. */
  5660. static readonly EASINGMODE_EASEOUT: number;
  5661. /**
  5662. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5663. */
  5664. static readonly EASINGMODE_EASEINOUT: number;
  5665. private _easingMode;
  5666. /**
  5667. * Sets the easing mode of the current function.
  5668. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5669. */
  5670. setEasingMode(easingMode: number): void;
  5671. /**
  5672. * Gets the current easing mode.
  5673. * @returns the easing mode
  5674. */
  5675. getEasingMode(): number;
  5676. /**
  5677. * @hidden
  5678. */
  5679. easeInCore(gradient: number): number;
  5680. /**
  5681. * Given an input gradient between 0 and 1, this returns the corresponding value
  5682. * of the easing function.
  5683. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5684. * @returns the corresponding value on the curve defined by the easing function
  5685. */
  5686. ease(gradient: number): number;
  5687. }
  5688. /**
  5689. * Easing function with a circle shape (see link below).
  5690. * @see https://easings.net/#easeInCirc
  5691. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5692. */
  5693. export class CircleEase extends EasingFunction implements IEasingFunction {
  5694. /** @hidden */
  5695. easeInCore(gradient: number): number;
  5696. }
  5697. /**
  5698. * Easing function with a ease back shape (see link below).
  5699. * @see https://easings.net/#easeInBack
  5700. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5701. */
  5702. export class BackEase extends EasingFunction implements IEasingFunction {
  5703. /** Defines the amplitude of the function */
  5704. amplitude: number;
  5705. /**
  5706. * Instantiates a back ease easing
  5707. * @see https://easings.net/#easeInBack
  5708. * @param amplitude Defines the amplitude of the function
  5709. */
  5710. constructor(
  5711. /** Defines the amplitude of the function */
  5712. amplitude?: number);
  5713. /** @hidden */
  5714. easeInCore(gradient: number): number;
  5715. }
  5716. /**
  5717. * Easing function with a bouncing shape (see link below).
  5718. * @see https://easings.net/#easeInBounce
  5719. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5720. */
  5721. export class BounceEase extends EasingFunction implements IEasingFunction {
  5722. /** Defines the number of bounces */
  5723. bounces: number;
  5724. /** Defines the amplitude of the bounce */
  5725. bounciness: number;
  5726. /**
  5727. * Instantiates a bounce easing
  5728. * @see https://easings.net/#easeInBounce
  5729. * @param bounces Defines the number of bounces
  5730. * @param bounciness Defines the amplitude of the bounce
  5731. */
  5732. constructor(
  5733. /** Defines the number of bounces */
  5734. bounces?: number,
  5735. /** Defines the amplitude of the bounce */
  5736. bounciness?: number);
  5737. /** @hidden */
  5738. easeInCore(gradient: number): number;
  5739. }
  5740. /**
  5741. * Easing function with a power of 3 shape (see link below).
  5742. * @see https://easings.net/#easeInCubic
  5743. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5744. */
  5745. export class CubicEase extends EasingFunction implements IEasingFunction {
  5746. /** @hidden */
  5747. easeInCore(gradient: number): number;
  5748. }
  5749. /**
  5750. * Easing function with an elastic shape (see link below).
  5751. * @see https://easings.net/#easeInElastic
  5752. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5753. */
  5754. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5755. /** Defines the number of oscillations*/
  5756. oscillations: number;
  5757. /** Defines the amplitude of the oscillations*/
  5758. springiness: number;
  5759. /**
  5760. * Instantiates an elastic easing function
  5761. * @see https://easings.net/#easeInElastic
  5762. * @param oscillations Defines the number of oscillations
  5763. * @param springiness Defines the amplitude of the oscillations
  5764. */
  5765. constructor(
  5766. /** Defines the number of oscillations*/
  5767. oscillations?: number,
  5768. /** Defines the amplitude of the oscillations*/
  5769. springiness?: number);
  5770. /** @hidden */
  5771. easeInCore(gradient: number): number;
  5772. }
  5773. /**
  5774. * Easing function with an exponential shape (see link below).
  5775. * @see https://easings.net/#easeInExpo
  5776. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5777. */
  5778. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5779. /** Defines the exponent of the function */
  5780. exponent: number;
  5781. /**
  5782. * Instantiates an exponential easing function
  5783. * @see https://easings.net/#easeInExpo
  5784. * @param exponent Defines the exponent of the function
  5785. */
  5786. constructor(
  5787. /** Defines the exponent of the function */
  5788. exponent?: number);
  5789. /** @hidden */
  5790. easeInCore(gradient: number): number;
  5791. }
  5792. /**
  5793. * Easing function with a power shape (see link below).
  5794. * @see https://easings.net/#easeInQuad
  5795. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5796. */
  5797. export class PowerEase extends EasingFunction implements IEasingFunction {
  5798. /** Defines the power of the function */
  5799. power: number;
  5800. /**
  5801. * Instantiates an power base easing function
  5802. * @see https://easings.net/#easeInQuad
  5803. * @param power Defines the power of the function
  5804. */
  5805. constructor(
  5806. /** Defines the power of the function */
  5807. power?: number);
  5808. /** @hidden */
  5809. easeInCore(gradient: number): number;
  5810. }
  5811. /**
  5812. * Easing function with a power of 2 shape (see link below).
  5813. * @see https://easings.net/#easeInQuad
  5814. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5815. */
  5816. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5817. /** @hidden */
  5818. easeInCore(gradient: number): number;
  5819. }
  5820. /**
  5821. * Easing function with a power of 4 shape (see link below).
  5822. * @see https://easings.net/#easeInQuart
  5823. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5824. */
  5825. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5826. /** @hidden */
  5827. easeInCore(gradient: number): number;
  5828. }
  5829. /**
  5830. * Easing function with a power of 5 shape (see link below).
  5831. * @see https://easings.net/#easeInQuint
  5832. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5833. */
  5834. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5835. /** @hidden */
  5836. easeInCore(gradient: number): number;
  5837. }
  5838. /**
  5839. * Easing function with a sin shape (see link below).
  5840. * @see https://easings.net/#easeInSine
  5841. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5842. */
  5843. export class SineEase extends EasingFunction implements IEasingFunction {
  5844. /** @hidden */
  5845. easeInCore(gradient: number): number;
  5846. }
  5847. /**
  5848. * Easing function with a bezier shape (see link below).
  5849. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5850. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5851. */
  5852. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5853. /** Defines the x component of the start tangent in the bezier curve */
  5854. x1: number;
  5855. /** Defines the y component of the start tangent in the bezier curve */
  5856. y1: number;
  5857. /** Defines the x component of the end tangent in the bezier curve */
  5858. x2: number;
  5859. /** Defines the y component of the end tangent in the bezier curve */
  5860. y2: number;
  5861. /**
  5862. * Instantiates a bezier function
  5863. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5864. * @param x1 Defines the x component of the start tangent in the bezier curve
  5865. * @param y1 Defines the y component of the start tangent in the bezier curve
  5866. * @param x2 Defines the x component of the end tangent in the bezier curve
  5867. * @param y2 Defines the y component of the end tangent in the bezier curve
  5868. */
  5869. constructor(
  5870. /** Defines the x component of the start tangent in the bezier curve */
  5871. x1?: number,
  5872. /** Defines the y component of the start tangent in the bezier curve */
  5873. y1?: number,
  5874. /** Defines the x component of the end tangent in the bezier curve */
  5875. x2?: number,
  5876. /** Defines the y component of the end tangent in the bezier curve */
  5877. y2?: number);
  5878. /** @hidden */
  5879. easeInCore(gradient: number): number;
  5880. }
  5881. }
  5882. declare module BABYLON {
  5883. /**
  5884. * Class used to hold a RBG color
  5885. */
  5886. export class Color3 {
  5887. /**
  5888. * Defines the red component (between 0 and 1, default is 0)
  5889. */
  5890. r: number;
  5891. /**
  5892. * Defines the green component (between 0 and 1, default is 0)
  5893. */
  5894. g: number;
  5895. /**
  5896. * Defines the blue component (between 0 and 1, default is 0)
  5897. */
  5898. b: number;
  5899. /**
  5900. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5901. * @param r defines the red component (between 0 and 1, default is 0)
  5902. * @param g defines the green component (between 0 and 1, default is 0)
  5903. * @param b defines the blue component (between 0 and 1, default is 0)
  5904. */
  5905. constructor(
  5906. /**
  5907. * Defines the red component (between 0 and 1, default is 0)
  5908. */
  5909. r?: number,
  5910. /**
  5911. * Defines the green component (between 0 and 1, default is 0)
  5912. */
  5913. g?: number,
  5914. /**
  5915. * Defines the blue component (between 0 and 1, default is 0)
  5916. */
  5917. b?: number);
  5918. /**
  5919. * Creates a string with the Color3 current values
  5920. * @returns the string representation of the Color3 object
  5921. */
  5922. toString(): string;
  5923. /**
  5924. * Returns the string "Color3"
  5925. * @returns "Color3"
  5926. */
  5927. getClassName(): string;
  5928. /**
  5929. * Compute the Color3 hash code
  5930. * @returns an unique number that can be used to hash Color3 objects
  5931. */
  5932. getHashCode(): number;
  5933. /**
  5934. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5935. * @param array defines the array where to store the r,g,b components
  5936. * @param index defines an optional index in the target array to define where to start storing values
  5937. * @returns the current Color3 object
  5938. */
  5939. toArray(array: FloatArray, index?: number): Color3;
  5940. /**
  5941. * Update the current color with values stored in an array from the starting index of the given array
  5942. * @param array defines the source array
  5943. * @param offset defines an offset in the source array
  5944. * @returns the current Color3 object
  5945. */
  5946. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5947. /**
  5948. * Returns a new Color4 object from the current Color3 and the given alpha
  5949. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5950. * @returns a new Color4 object
  5951. */
  5952. toColor4(alpha?: number): Color4;
  5953. /**
  5954. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5955. * @returns the new array
  5956. */
  5957. asArray(): number[];
  5958. /**
  5959. * Returns the luminance value
  5960. * @returns a float value
  5961. */
  5962. toLuminance(): number;
  5963. /**
  5964. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5965. * @param otherColor defines the second operand
  5966. * @returns the new Color3 object
  5967. */
  5968. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5969. /**
  5970. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5971. * @param otherColor defines the second operand
  5972. * @param result defines the Color3 object where to store the result
  5973. * @returns the current Color3
  5974. */
  5975. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5976. /**
  5977. * Determines equality between Color3 objects
  5978. * @param otherColor defines the second operand
  5979. * @returns true if the rgb values are equal to the given ones
  5980. */
  5981. equals(otherColor: DeepImmutable<Color3>): boolean;
  5982. /**
  5983. * Determines equality between the current Color3 object and a set of r,b,g values
  5984. * @param r defines the red component to check
  5985. * @param g defines the green component to check
  5986. * @param b defines the blue component to check
  5987. * @returns true if the rgb values are equal to the given ones
  5988. */
  5989. equalsFloats(r: number, g: number, b: number): boolean;
  5990. /**
  5991. * Multiplies in place each rgb value by scale
  5992. * @param scale defines the scaling factor
  5993. * @returns the updated Color3
  5994. */
  5995. scale(scale: number): Color3;
  5996. /**
  5997. * Multiplies the rgb values by scale and stores the result into "result"
  5998. * @param scale defines the scaling factor
  5999. * @param result defines the Color3 object where to store the result
  6000. * @returns the unmodified current Color3
  6001. */
  6002. scaleToRef(scale: number, result: Color3): Color3;
  6003. /**
  6004. * Scale the current Color3 values by a factor and add the result to a given Color3
  6005. * @param scale defines the scale factor
  6006. * @param result defines color to store the result into
  6007. * @returns the unmodified current Color3
  6008. */
  6009. scaleAndAddToRef(scale: number, result: Color3): Color3;
  6010. /**
  6011. * Clamps the rgb values by the min and max values and stores the result into "result"
  6012. * @param min defines minimum clamping value (default is 0)
  6013. * @param max defines maximum clamping value (default is 1)
  6014. * @param result defines color to store the result into
  6015. * @returns the original Color3
  6016. */
  6017. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  6018. /**
  6019. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  6020. * @param otherColor defines the second operand
  6021. * @returns the new Color3
  6022. */
  6023. add(otherColor: DeepImmutable<Color3>): Color3;
  6024. /**
  6025. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  6026. * @param otherColor defines the second operand
  6027. * @param result defines Color3 object to store the result into
  6028. * @returns the unmodified current Color3
  6029. */
  6030. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6031. /**
  6032. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  6033. * @param otherColor defines the second operand
  6034. * @returns the new Color3
  6035. */
  6036. subtract(otherColor: DeepImmutable<Color3>): Color3;
  6037. /**
  6038. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  6039. * @param otherColor defines the second operand
  6040. * @param result defines Color3 object to store the result into
  6041. * @returns the unmodified current Color3
  6042. */
  6043. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6044. /**
  6045. * Copy the current object
  6046. * @returns a new Color3 copied the current one
  6047. */
  6048. clone(): Color3;
  6049. /**
  6050. * Copies the rgb values from the source in the current Color3
  6051. * @param source defines the source Color3 object
  6052. * @returns the updated Color3 object
  6053. */
  6054. copyFrom(source: DeepImmutable<Color3>): Color3;
  6055. /**
  6056. * Updates the Color3 rgb values from the given floats
  6057. * @param r defines the red component to read from
  6058. * @param g defines the green component to read from
  6059. * @param b defines the blue component to read from
  6060. * @returns the current Color3 object
  6061. */
  6062. copyFromFloats(r: number, g: number, b: number): Color3;
  6063. /**
  6064. * Updates the Color3 rgb values from the given floats
  6065. * @param r defines the red component to read from
  6066. * @param g defines the green component to read from
  6067. * @param b defines the blue component to read from
  6068. * @returns the current Color3 object
  6069. */
  6070. set(r: number, g: number, b: number): Color3;
  6071. /**
  6072. * Compute the Color3 hexadecimal code as a string
  6073. * @returns a string containing the hexadecimal representation of the Color3 object
  6074. */
  6075. toHexString(): string;
  6076. /**
  6077. * Computes a new Color3 converted from the current one to linear space
  6078. * @returns a new Color3 object
  6079. */
  6080. toLinearSpace(): Color3;
  6081. /**
  6082. * Converts current color in rgb space to HSV values
  6083. * @returns a new color3 representing the HSV values
  6084. */
  6085. toHSV(): Color3;
  6086. /**
  6087. * Converts current color in rgb space to HSV values
  6088. * @param result defines the Color3 where to store the HSV values
  6089. */
  6090. toHSVToRef(result: Color3): void;
  6091. /**
  6092. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  6093. * @param convertedColor defines the Color3 object where to store the linear space version
  6094. * @returns the unmodified Color3
  6095. */
  6096. toLinearSpaceToRef(convertedColor: Color3): Color3;
  6097. /**
  6098. * Computes a new Color3 converted from the current one to gamma space
  6099. * @returns a new Color3 object
  6100. */
  6101. toGammaSpace(): Color3;
  6102. /**
  6103. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  6104. * @param convertedColor defines the Color3 object where to store the gamma space version
  6105. * @returns the unmodified Color3
  6106. */
  6107. toGammaSpaceToRef(convertedColor: Color3): Color3;
  6108. private static _BlackReadOnly;
  6109. /**
  6110. * Convert Hue, saturation and value to a Color3 (RGB)
  6111. * @param hue defines the hue
  6112. * @param saturation defines the saturation
  6113. * @param value defines the value
  6114. * @param result defines the Color3 where to store the RGB values
  6115. */
  6116. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  6117. /**
  6118. * Creates a new Color3 from the string containing valid hexadecimal values
  6119. * @param hex defines a string containing valid hexadecimal values
  6120. * @returns a new Color3 object
  6121. */
  6122. static FromHexString(hex: string): Color3;
  6123. /**
  6124. * Creates a new Color3 from the starting index of the given array
  6125. * @param array defines the source array
  6126. * @param offset defines an offset in the source array
  6127. * @returns a new Color3 object
  6128. */
  6129. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6130. /**
  6131. * Creates a new Color3 from the starting index element of the given array
  6132. * @param array defines the source array to read from
  6133. * @param offset defines the offset in the source array
  6134. * @param result defines the target Color3 object
  6135. */
  6136. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  6137. /**
  6138. * Creates a new Color3 from integer values (< 256)
  6139. * @param r defines the red component to read from (value between 0 and 255)
  6140. * @param g defines the green component to read from (value between 0 and 255)
  6141. * @param b defines the blue component to read from (value between 0 and 255)
  6142. * @returns a new Color3 object
  6143. */
  6144. static FromInts(r: number, g: number, b: number): Color3;
  6145. /**
  6146. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6147. * @param start defines the start Color3 value
  6148. * @param end defines the end Color3 value
  6149. * @param amount defines the gradient value between start and end
  6150. * @returns a new Color3 object
  6151. */
  6152. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  6153. /**
  6154. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6155. * @param left defines the start value
  6156. * @param right defines the end value
  6157. * @param amount defines the gradient factor
  6158. * @param result defines the Color3 object where to store the result
  6159. */
  6160. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  6161. /**
  6162. * Returns a Color3 value containing a red color
  6163. * @returns a new Color3 object
  6164. */
  6165. static Red(): Color3;
  6166. /**
  6167. * Returns a Color3 value containing a green color
  6168. * @returns a new Color3 object
  6169. */
  6170. static Green(): Color3;
  6171. /**
  6172. * Returns a Color3 value containing a blue color
  6173. * @returns a new Color3 object
  6174. */
  6175. static Blue(): Color3;
  6176. /**
  6177. * Returns a Color3 value containing a black color
  6178. * @returns a new Color3 object
  6179. */
  6180. static Black(): Color3;
  6181. /**
  6182. * Gets a Color3 value containing a black color that must not be updated
  6183. */
  6184. static get BlackReadOnly(): DeepImmutable<Color3>;
  6185. /**
  6186. * Returns a Color3 value containing a white color
  6187. * @returns a new Color3 object
  6188. */
  6189. static White(): Color3;
  6190. /**
  6191. * Returns a Color3 value containing a purple color
  6192. * @returns a new Color3 object
  6193. */
  6194. static Purple(): Color3;
  6195. /**
  6196. * Returns a Color3 value containing a magenta color
  6197. * @returns a new Color3 object
  6198. */
  6199. static Magenta(): Color3;
  6200. /**
  6201. * Returns a Color3 value containing a yellow color
  6202. * @returns a new Color3 object
  6203. */
  6204. static Yellow(): Color3;
  6205. /**
  6206. * Returns a Color3 value containing a gray color
  6207. * @returns a new Color3 object
  6208. */
  6209. static Gray(): Color3;
  6210. /**
  6211. * Returns a Color3 value containing a teal color
  6212. * @returns a new Color3 object
  6213. */
  6214. static Teal(): Color3;
  6215. /**
  6216. * Returns a Color3 value containing a random color
  6217. * @returns a new Color3 object
  6218. */
  6219. static Random(): Color3;
  6220. }
  6221. /**
  6222. * Class used to hold a RBGA color
  6223. */
  6224. export class Color4 {
  6225. /**
  6226. * Defines the red component (between 0 and 1, default is 0)
  6227. */
  6228. r: number;
  6229. /**
  6230. * Defines the green component (between 0 and 1, default is 0)
  6231. */
  6232. g: number;
  6233. /**
  6234. * Defines the blue component (between 0 and 1, default is 0)
  6235. */
  6236. b: number;
  6237. /**
  6238. * Defines the alpha component (between 0 and 1, default is 1)
  6239. */
  6240. a: number;
  6241. /**
  6242. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  6243. * @param r defines the red component (between 0 and 1, default is 0)
  6244. * @param g defines the green component (between 0 and 1, default is 0)
  6245. * @param b defines the blue component (between 0 and 1, default is 0)
  6246. * @param a defines the alpha component (between 0 and 1, default is 1)
  6247. */
  6248. constructor(
  6249. /**
  6250. * Defines the red component (between 0 and 1, default is 0)
  6251. */
  6252. r?: number,
  6253. /**
  6254. * Defines the green component (between 0 and 1, default is 0)
  6255. */
  6256. g?: number,
  6257. /**
  6258. * Defines the blue component (between 0 and 1, default is 0)
  6259. */
  6260. b?: number,
  6261. /**
  6262. * Defines the alpha component (between 0 and 1, default is 1)
  6263. */
  6264. a?: number);
  6265. /**
  6266. * Adds in place the given Color4 values to the current Color4 object
  6267. * @param right defines the second operand
  6268. * @returns the current updated Color4 object
  6269. */
  6270. addInPlace(right: DeepImmutable<Color4>): Color4;
  6271. /**
  6272. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  6273. * @returns the new array
  6274. */
  6275. asArray(): number[];
  6276. /**
  6277. * Stores from the starting index in the given array the Color4 successive values
  6278. * @param array defines the array where to store the r,g,b components
  6279. * @param index defines an optional index in the target array to define where to start storing values
  6280. * @returns the current Color4 object
  6281. */
  6282. toArray(array: number[], index?: number): Color4;
  6283. /**
  6284. * Update the current color with values stored in an array from the starting index of the given array
  6285. * @param array defines the source array
  6286. * @param offset defines an offset in the source array
  6287. * @returns the current Color4 object
  6288. */
  6289. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6290. /**
  6291. * Determines equality between Color4 objects
  6292. * @param otherColor defines the second operand
  6293. * @returns true if the rgba values are equal to the given ones
  6294. */
  6295. equals(otherColor: DeepImmutable<Color4>): boolean;
  6296. /**
  6297. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  6298. * @param right defines the second operand
  6299. * @returns a new Color4 object
  6300. */
  6301. add(right: DeepImmutable<Color4>): Color4;
  6302. /**
  6303. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  6304. * @param right defines the second operand
  6305. * @returns a new Color4 object
  6306. */
  6307. subtract(right: DeepImmutable<Color4>): Color4;
  6308. /**
  6309. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  6310. * @param right defines the second operand
  6311. * @param result defines the Color4 object where to store the result
  6312. * @returns the current Color4 object
  6313. */
  6314. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  6315. /**
  6316. * Creates a new Color4 with the current Color4 values multiplied by scale
  6317. * @param scale defines the scaling factor to apply
  6318. * @returns a new Color4 object
  6319. */
  6320. scale(scale: number): Color4;
  6321. /**
  6322. * Multiplies the current Color4 values by scale and stores the result in "result"
  6323. * @param scale defines the scaling factor to apply
  6324. * @param result defines the Color4 object where to store the result
  6325. * @returns the current unmodified Color4
  6326. */
  6327. scaleToRef(scale: number, result: Color4): Color4;
  6328. /**
  6329. * Scale the current Color4 values by a factor and add the result to a given Color4
  6330. * @param scale defines the scale factor
  6331. * @param result defines the Color4 object where to store the result
  6332. * @returns the unmodified current Color4
  6333. */
  6334. scaleAndAddToRef(scale: number, result: Color4): Color4;
  6335. /**
  6336. * Clamps the rgb values by the min and max values and stores the result into "result"
  6337. * @param min defines minimum clamping value (default is 0)
  6338. * @param max defines maximum clamping value (default is 1)
  6339. * @param result defines color to store the result into.
  6340. * @returns the cuurent Color4
  6341. */
  6342. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  6343. /**
  6344. * Multipy an Color4 value by another and return a new Color4 object
  6345. * @param color defines the Color4 value to multiply by
  6346. * @returns a new Color4 object
  6347. */
  6348. multiply(color: Color4): Color4;
  6349. /**
  6350. * Multipy a Color4 value by another and push the result in a reference value
  6351. * @param color defines the Color4 value to multiply by
  6352. * @param result defines the Color4 to fill the result in
  6353. * @returns the result Color4
  6354. */
  6355. multiplyToRef(color: Color4, result: Color4): Color4;
  6356. /**
  6357. * Creates a string with the Color4 current values
  6358. * @returns the string representation of the Color4 object
  6359. */
  6360. toString(): string;
  6361. /**
  6362. * Returns the string "Color4"
  6363. * @returns "Color4"
  6364. */
  6365. getClassName(): string;
  6366. /**
  6367. * Compute the Color4 hash code
  6368. * @returns an unique number that can be used to hash Color4 objects
  6369. */
  6370. getHashCode(): number;
  6371. /**
  6372. * Creates a new Color4 copied from the current one
  6373. * @returns a new Color4 object
  6374. */
  6375. clone(): Color4;
  6376. /**
  6377. * Copies the given Color4 values into the current one
  6378. * @param source defines the source Color4 object
  6379. * @returns the current updated Color4 object
  6380. */
  6381. copyFrom(source: Color4): Color4;
  6382. /**
  6383. * Copies the given float values into the current one
  6384. * @param r defines the red component to read from
  6385. * @param g defines the green component to read from
  6386. * @param b defines the blue component to read from
  6387. * @param a defines the alpha component to read from
  6388. * @returns the current updated Color4 object
  6389. */
  6390. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6391. /**
  6392. * Copies the given float values into the current one
  6393. * @param r defines the red component to read from
  6394. * @param g defines the green component to read from
  6395. * @param b defines the blue component to read from
  6396. * @param a defines the alpha component to read from
  6397. * @returns the current updated Color4 object
  6398. */
  6399. set(r: number, g: number, b: number, a: number): Color4;
  6400. /**
  6401. * Compute the Color4 hexadecimal code as a string
  6402. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6403. * @returns a string containing the hexadecimal representation of the Color4 object
  6404. */
  6405. toHexString(returnAsColor3?: boolean): string;
  6406. /**
  6407. * Computes a new Color4 converted from the current one to linear space
  6408. * @returns a new Color4 object
  6409. */
  6410. toLinearSpace(): Color4;
  6411. /**
  6412. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6413. * @param convertedColor defines the Color4 object where to store the linear space version
  6414. * @returns the unmodified Color4
  6415. */
  6416. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6417. /**
  6418. * Computes a new Color4 converted from the current one to gamma space
  6419. * @returns a new Color4 object
  6420. */
  6421. toGammaSpace(): Color4;
  6422. /**
  6423. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6424. * @param convertedColor defines the Color4 object where to store the gamma space version
  6425. * @returns the unmodified Color4
  6426. */
  6427. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6428. /**
  6429. * Creates a new Color4 from the string containing valid hexadecimal values
  6430. * @param hex defines a string containing valid hexadecimal values
  6431. * @returns a new Color4 object
  6432. */
  6433. static FromHexString(hex: string): Color4;
  6434. /**
  6435. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6436. * @param left defines the start value
  6437. * @param right defines the end value
  6438. * @param amount defines the gradient factor
  6439. * @returns a new Color4 object
  6440. */
  6441. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6442. /**
  6443. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6444. * @param left defines the start value
  6445. * @param right defines the end value
  6446. * @param amount defines the gradient factor
  6447. * @param result defines the Color4 object where to store data
  6448. */
  6449. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6450. /**
  6451. * Creates a new Color4 from a Color3 and an alpha value
  6452. * @param color3 defines the source Color3 to read from
  6453. * @param alpha defines the alpha component (1.0 by default)
  6454. * @returns a new Color4 object
  6455. */
  6456. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6457. /**
  6458. * Creates a new Color4 from the starting index element of the given array
  6459. * @param array defines the source array to read from
  6460. * @param offset defines the offset in the source array
  6461. * @returns a new Color4 object
  6462. */
  6463. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6464. /**
  6465. * Creates a new Color4 from the starting index element of the given array
  6466. * @param array defines the source array to read from
  6467. * @param offset defines the offset in the source array
  6468. * @param result defines the target Color4 object
  6469. */
  6470. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6471. /**
  6472. * Creates a new Color3 from integer values (< 256)
  6473. * @param r defines the red component to read from (value between 0 and 255)
  6474. * @param g defines the green component to read from (value between 0 and 255)
  6475. * @param b defines the blue component to read from (value between 0 and 255)
  6476. * @param a defines the alpha component to read from (value between 0 and 255)
  6477. * @returns a new Color3 object
  6478. */
  6479. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6480. /**
  6481. * Check the content of a given array and convert it to an array containing RGBA data
  6482. * If the original array was already containing count * 4 values then it is returned directly
  6483. * @param colors defines the array to check
  6484. * @param count defines the number of RGBA data to expect
  6485. * @returns an array containing count * 4 values (RGBA)
  6486. */
  6487. static CheckColors4(colors: number[], count: number): number[];
  6488. }
  6489. /**
  6490. * @hidden
  6491. */
  6492. export class TmpColors {
  6493. static Color3: Color3[];
  6494. static Color4: Color4[];
  6495. }
  6496. }
  6497. declare module BABYLON {
  6498. /**
  6499. * Defines an interface which represents an animation key frame
  6500. */
  6501. export interface IAnimationKey {
  6502. /**
  6503. * Frame of the key frame
  6504. */
  6505. frame: number;
  6506. /**
  6507. * Value at the specifies key frame
  6508. */
  6509. value: any;
  6510. /**
  6511. * The input tangent for the cubic hermite spline
  6512. */
  6513. inTangent?: any;
  6514. /**
  6515. * The output tangent for the cubic hermite spline
  6516. */
  6517. outTangent?: any;
  6518. /**
  6519. * The animation interpolation type
  6520. */
  6521. interpolation?: AnimationKeyInterpolation;
  6522. }
  6523. /**
  6524. * Enum for the animation key frame interpolation type
  6525. */
  6526. export enum AnimationKeyInterpolation {
  6527. /**
  6528. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6529. */
  6530. STEP = 1
  6531. }
  6532. }
  6533. declare module BABYLON {
  6534. /**
  6535. * Represents the range of an animation
  6536. */
  6537. export class AnimationRange {
  6538. /**The name of the animation range**/
  6539. name: string;
  6540. /**The starting frame of the animation */
  6541. from: number;
  6542. /**The ending frame of the animation*/
  6543. to: number;
  6544. /**
  6545. * Initializes the range of an animation
  6546. * @param name The name of the animation range
  6547. * @param from The starting frame of the animation
  6548. * @param to The ending frame of the animation
  6549. */
  6550. constructor(
  6551. /**The name of the animation range**/
  6552. name: string,
  6553. /**The starting frame of the animation */
  6554. from: number,
  6555. /**The ending frame of the animation*/
  6556. to: number);
  6557. /**
  6558. * Makes a copy of the animation range
  6559. * @returns A copy of the animation range
  6560. */
  6561. clone(): AnimationRange;
  6562. }
  6563. }
  6564. declare module BABYLON {
  6565. /**
  6566. * Composed of a frame, and an action function
  6567. */
  6568. export class AnimationEvent {
  6569. /** The frame for which the event is triggered **/
  6570. frame: number;
  6571. /** The event to perform when triggered **/
  6572. action: (currentFrame: number) => void;
  6573. /** Specifies if the event should be triggered only once**/
  6574. onlyOnce?: boolean | undefined;
  6575. /**
  6576. * Specifies if the animation event is done
  6577. */
  6578. isDone: boolean;
  6579. /**
  6580. * Initializes the animation event
  6581. * @param frame The frame for which the event is triggered
  6582. * @param action The event to perform when triggered
  6583. * @param onlyOnce Specifies if the event should be triggered only once
  6584. */
  6585. constructor(
  6586. /** The frame for which the event is triggered **/
  6587. frame: number,
  6588. /** The event to perform when triggered **/
  6589. action: (currentFrame: number) => void,
  6590. /** Specifies if the event should be triggered only once**/
  6591. onlyOnce?: boolean | undefined);
  6592. /** @hidden */
  6593. _clone(): AnimationEvent;
  6594. }
  6595. }
  6596. declare module BABYLON {
  6597. /**
  6598. * Interface used to define a behavior
  6599. */
  6600. export interface Behavior<T> {
  6601. /** gets or sets behavior's name */
  6602. name: string;
  6603. /**
  6604. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6605. */
  6606. init(): void;
  6607. /**
  6608. * Called when the behavior is attached to a target
  6609. * @param target defines the target where the behavior is attached to
  6610. */
  6611. attach(target: T): void;
  6612. /**
  6613. * Called when the behavior is detached from its target
  6614. */
  6615. detach(): void;
  6616. }
  6617. /**
  6618. * Interface implemented by classes supporting behaviors
  6619. */
  6620. export interface IBehaviorAware<T> {
  6621. /**
  6622. * Attach a behavior
  6623. * @param behavior defines the behavior to attach
  6624. * @returns the current host
  6625. */
  6626. addBehavior(behavior: Behavior<T>): T;
  6627. /**
  6628. * Remove a behavior from the current object
  6629. * @param behavior defines the behavior to detach
  6630. * @returns the current host
  6631. */
  6632. removeBehavior(behavior: Behavior<T>): T;
  6633. /**
  6634. * Gets a behavior using its name to search
  6635. * @param name defines the name to search
  6636. * @returns the behavior or null if not found
  6637. */
  6638. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6639. }
  6640. }
  6641. declare module BABYLON {
  6642. /**
  6643. * Class used to store data that will be store in GPU memory
  6644. */
  6645. export class Buffer {
  6646. private _engine;
  6647. private _buffer;
  6648. /** @hidden */
  6649. _data: Nullable<DataArray>;
  6650. private _updatable;
  6651. private _instanced;
  6652. private _divisor;
  6653. private _isAlreadyOwned;
  6654. /**
  6655. * Gets the byte stride.
  6656. */
  6657. readonly byteStride: number;
  6658. /**
  6659. * Constructor
  6660. * @param engine the engine
  6661. * @param data the data to use for this buffer
  6662. * @param updatable whether the data is updatable
  6663. * @param stride the stride (optional)
  6664. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6665. * @param instanced whether the buffer is instanced (optional)
  6666. * @param useBytes set to true if the stride in in bytes (optional)
  6667. * @param divisor sets an optional divisor for instances (1 by default)
  6668. */
  6669. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6670. /**
  6671. * Create a new VertexBuffer based on the current buffer
  6672. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6673. * @param offset defines offset in the buffer (0 by default)
  6674. * @param size defines the size in floats of attributes (position is 3 for instance)
  6675. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6676. * @param instanced defines if the vertex buffer contains indexed data
  6677. * @param useBytes defines if the offset and stride are in bytes *
  6678. * @param divisor sets an optional divisor for instances (1 by default)
  6679. * @returns the new vertex buffer
  6680. */
  6681. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6682. /**
  6683. * Gets a boolean indicating if the Buffer is updatable?
  6684. * @returns true if the buffer is updatable
  6685. */
  6686. isUpdatable(): boolean;
  6687. /**
  6688. * Gets current buffer's data
  6689. * @returns a DataArray or null
  6690. */
  6691. getData(): Nullable<DataArray>;
  6692. /**
  6693. * Gets underlying native buffer
  6694. * @returns underlying native buffer
  6695. */
  6696. getBuffer(): Nullable<DataBuffer>;
  6697. /**
  6698. * Gets the stride in float32 units (i.e. byte stride / 4).
  6699. * May not be an integer if the byte stride is not divisible by 4.
  6700. * @returns the stride in float32 units
  6701. * @deprecated Please use byteStride instead.
  6702. */
  6703. getStrideSize(): number;
  6704. /**
  6705. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6706. * @param data defines the data to store
  6707. */
  6708. create(data?: Nullable<DataArray>): void;
  6709. /** @hidden */
  6710. _rebuild(): void;
  6711. /**
  6712. * Update current buffer data
  6713. * @param data defines the data to store
  6714. */
  6715. update(data: DataArray): void;
  6716. /**
  6717. * Updates the data directly.
  6718. * @param data the new data
  6719. * @param offset the new offset
  6720. * @param vertexCount the vertex count (optional)
  6721. * @param useBytes set to true if the offset is in bytes
  6722. */
  6723. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6724. /** @hidden */
  6725. _increaseReferences(): void;
  6726. /**
  6727. * Release all resources
  6728. */
  6729. dispose(): void;
  6730. }
  6731. /**
  6732. * Specialized buffer used to store vertex data
  6733. */
  6734. export class VertexBuffer {
  6735. /** @hidden */
  6736. _buffer: Buffer;
  6737. private _kind;
  6738. private _size;
  6739. private _ownsBuffer;
  6740. private _instanced;
  6741. private _instanceDivisor;
  6742. /**
  6743. * The byte type.
  6744. */
  6745. static readonly BYTE: number;
  6746. /**
  6747. * The unsigned byte type.
  6748. */
  6749. static readonly UNSIGNED_BYTE: number;
  6750. /**
  6751. * The short type.
  6752. */
  6753. static readonly SHORT: number;
  6754. /**
  6755. * The unsigned short type.
  6756. */
  6757. static readonly UNSIGNED_SHORT: number;
  6758. /**
  6759. * The integer type.
  6760. */
  6761. static readonly INT: number;
  6762. /**
  6763. * The unsigned integer type.
  6764. */
  6765. static readonly UNSIGNED_INT: number;
  6766. /**
  6767. * The float type.
  6768. */
  6769. static readonly FLOAT: number;
  6770. /**
  6771. * Gets or sets the instance divisor when in instanced mode
  6772. */
  6773. get instanceDivisor(): number;
  6774. set instanceDivisor(value: number);
  6775. /**
  6776. * Gets the byte stride.
  6777. */
  6778. readonly byteStride: number;
  6779. /**
  6780. * Gets the byte offset.
  6781. */
  6782. readonly byteOffset: number;
  6783. /**
  6784. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6785. */
  6786. readonly normalized: boolean;
  6787. /**
  6788. * Gets the data type of each component in the array.
  6789. */
  6790. readonly type: number;
  6791. /**
  6792. * Constructor
  6793. * @param engine the engine
  6794. * @param data the data to use for this vertex buffer
  6795. * @param kind the vertex buffer kind
  6796. * @param updatable whether the data is updatable
  6797. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6798. * @param stride the stride (optional)
  6799. * @param instanced whether the buffer is instanced (optional)
  6800. * @param offset the offset of the data (optional)
  6801. * @param size the number of components (optional)
  6802. * @param type the type of the component (optional)
  6803. * @param normalized whether the data contains normalized data (optional)
  6804. * @param useBytes set to true if stride and offset are in bytes (optional)
  6805. * @param divisor defines the instance divisor to use (1 by default)
  6806. * @param takeBufferOwnership defines if the buffer should be released when the vertex buffer is disposed
  6807. */
  6808. 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, divisor?: number, takeBufferOwnership?: boolean);
  6809. /** @hidden */
  6810. _rebuild(): void;
  6811. /**
  6812. * Returns the kind of the VertexBuffer (string)
  6813. * @returns a string
  6814. */
  6815. getKind(): string;
  6816. /**
  6817. * Gets a boolean indicating if the VertexBuffer is updatable?
  6818. * @returns true if the buffer is updatable
  6819. */
  6820. isUpdatable(): boolean;
  6821. /**
  6822. * Gets current buffer's data
  6823. * @returns a DataArray or null
  6824. */
  6825. getData(): Nullable<DataArray>;
  6826. /**
  6827. * Gets underlying native buffer
  6828. * @returns underlying native buffer
  6829. */
  6830. getBuffer(): Nullable<DataBuffer>;
  6831. /**
  6832. * Gets the stride in float32 units (i.e. byte stride / 4).
  6833. * May not be an integer if the byte stride is not divisible by 4.
  6834. * @returns the stride in float32 units
  6835. * @deprecated Please use byteStride instead.
  6836. */
  6837. getStrideSize(): number;
  6838. /**
  6839. * Returns the offset as a multiple of the type byte length.
  6840. * @returns the offset in bytes
  6841. * @deprecated Please use byteOffset instead.
  6842. */
  6843. getOffset(): number;
  6844. /**
  6845. * Returns the number of components per vertex attribute (integer)
  6846. * @returns the size in float
  6847. */
  6848. getSize(): number;
  6849. /**
  6850. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6851. * @returns true if this buffer is instanced
  6852. */
  6853. getIsInstanced(): boolean;
  6854. /**
  6855. * Returns the instancing divisor, zero for non-instanced (integer).
  6856. * @returns a number
  6857. */
  6858. getInstanceDivisor(): number;
  6859. /**
  6860. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6861. * @param data defines the data to store
  6862. */
  6863. create(data?: DataArray): void;
  6864. /**
  6865. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6866. * This function will create a new buffer if the current one is not updatable
  6867. * @param data defines the data to store
  6868. */
  6869. update(data: DataArray): void;
  6870. /**
  6871. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6872. * Returns the directly updated WebGLBuffer.
  6873. * @param data the new data
  6874. * @param offset the new offset
  6875. * @param useBytes set to true if the offset is in bytes
  6876. */
  6877. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6878. /**
  6879. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6880. */
  6881. dispose(): void;
  6882. /**
  6883. * Enumerates each value of this vertex buffer as numbers.
  6884. * @param count the number of values to enumerate
  6885. * @param callback the callback function called for each value
  6886. */
  6887. forEach(count: number, callback: (value: number, index: number) => void): void;
  6888. /**
  6889. * Positions
  6890. */
  6891. static readonly PositionKind: string;
  6892. /**
  6893. * Normals
  6894. */
  6895. static readonly NormalKind: string;
  6896. /**
  6897. * Tangents
  6898. */
  6899. static readonly TangentKind: string;
  6900. /**
  6901. * Texture coordinates
  6902. */
  6903. static readonly UVKind: string;
  6904. /**
  6905. * Texture coordinates 2
  6906. */
  6907. static readonly UV2Kind: string;
  6908. /**
  6909. * Texture coordinates 3
  6910. */
  6911. static readonly UV3Kind: string;
  6912. /**
  6913. * Texture coordinates 4
  6914. */
  6915. static readonly UV4Kind: string;
  6916. /**
  6917. * Texture coordinates 5
  6918. */
  6919. static readonly UV5Kind: string;
  6920. /**
  6921. * Texture coordinates 6
  6922. */
  6923. static readonly UV6Kind: string;
  6924. /**
  6925. * Colors
  6926. */
  6927. static readonly ColorKind: string;
  6928. /**
  6929. * Matrix indices (for bones)
  6930. */
  6931. static readonly MatricesIndicesKind: string;
  6932. /**
  6933. * Matrix weights (for bones)
  6934. */
  6935. static readonly MatricesWeightsKind: string;
  6936. /**
  6937. * Additional matrix indices (for bones)
  6938. */
  6939. static readonly MatricesIndicesExtraKind: string;
  6940. /**
  6941. * Additional matrix weights (for bones)
  6942. */
  6943. static readonly MatricesWeightsExtraKind: string;
  6944. /**
  6945. * Deduces the stride given a kind.
  6946. * @param kind The kind string to deduce
  6947. * @returns The deduced stride
  6948. */
  6949. static DeduceStride(kind: string): number;
  6950. /**
  6951. * Gets the byte length of the given type.
  6952. * @param type the type
  6953. * @returns the number of bytes
  6954. */
  6955. static GetTypeByteLength(type: number): number;
  6956. /**
  6957. * Enumerates each value of the given parameters as numbers.
  6958. * @param data the data to enumerate
  6959. * @param byteOffset the byte offset of the data
  6960. * @param byteStride the byte stride of the data
  6961. * @param componentCount the number of components per element
  6962. * @param componentType the type of the component
  6963. * @param count the number of values to enumerate
  6964. * @param normalized whether the data is normalized
  6965. * @param callback the callback function called for each value
  6966. */
  6967. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6968. private static _GetFloatValue;
  6969. }
  6970. }
  6971. declare module BABYLON {
  6972. /**
  6973. * @hidden
  6974. */
  6975. export class IntersectionInfo {
  6976. bu: Nullable<number>;
  6977. bv: Nullable<number>;
  6978. distance: number;
  6979. faceId: number;
  6980. subMeshId: number;
  6981. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6982. }
  6983. }
  6984. declare module BABYLON {
  6985. /**
  6986. * Class used to store bounding sphere information
  6987. */
  6988. export class BoundingSphere {
  6989. /**
  6990. * Gets the center of the bounding sphere in local space
  6991. */
  6992. readonly center: Vector3;
  6993. /**
  6994. * Radius of the bounding sphere in local space
  6995. */
  6996. radius: number;
  6997. /**
  6998. * Gets the center of the bounding sphere in world space
  6999. */
  7000. readonly centerWorld: Vector3;
  7001. /**
  7002. * Radius of the bounding sphere in world space
  7003. */
  7004. radiusWorld: number;
  7005. /**
  7006. * Gets the minimum vector in local space
  7007. */
  7008. readonly minimum: Vector3;
  7009. /**
  7010. * Gets the maximum vector in local space
  7011. */
  7012. readonly maximum: Vector3;
  7013. private _worldMatrix;
  7014. private static readonly TmpVector3;
  7015. /**
  7016. * Creates a new bounding sphere
  7017. * @param min defines the minimum vector (in local space)
  7018. * @param max defines the maximum vector (in local space)
  7019. * @param worldMatrix defines the new world matrix
  7020. */
  7021. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7022. /**
  7023. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7024. * @param min defines the new minimum vector (in local space)
  7025. * @param max defines the new maximum vector (in local space)
  7026. * @param worldMatrix defines the new world matrix
  7027. */
  7028. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7029. /**
  7030. * Scale the current bounding sphere by applying a scale factor
  7031. * @param factor defines the scale factor to apply
  7032. * @returns the current bounding box
  7033. */
  7034. scale(factor: number): BoundingSphere;
  7035. /**
  7036. * Gets the world matrix of the bounding box
  7037. * @returns a matrix
  7038. */
  7039. getWorldMatrix(): DeepImmutable<Matrix>;
  7040. /** @hidden */
  7041. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7042. /**
  7043. * Tests if the bounding sphere is intersecting the frustum planes
  7044. * @param frustumPlanes defines the frustum planes to test
  7045. * @returns true if there is an intersection
  7046. */
  7047. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7048. /**
  7049. * Tests if the bounding sphere center is in between the frustum planes.
  7050. * Used for optimistic fast inclusion.
  7051. * @param frustumPlanes defines the frustum planes to test
  7052. * @returns true if the sphere center is in between the frustum planes
  7053. */
  7054. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7055. /**
  7056. * Tests if a point is inside the bounding sphere
  7057. * @param point defines the point to test
  7058. * @returns true if the point is inside the bounding sphere
  7059. */
  7060. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7061. /**
  7062. * Checks if two sphere intersct
  7063. * @param sphere0 sphere 0
  7064. * @param sphere1 sphere 1
  7065. * @returns true if the speres intersect
  7066. */
  7067. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7068. }
  7069. }
  7070. declare module BABYLON {
  7071. /**
  7072. * Class used to store bounding box information
  7073. */
  7074. export class BoundingBox implements ICullable {
  7075. /**
  7076. * Gets the 8 vectors representing the bounding box in local space
  7077. */
  7078. readonly vectors: Vector3[];
  7079. /**
  7080. * Gets the center of the bounding box in local space
  7081. */
  7082. readonly center: Vector3;
  7083. /**
  7084. * Gets the center of the bounding box in world space
  7085. */
  7086. readonly centerWorld: Vector3;
  7087. /**
  7088. * Gets the extend size in local space
  7089. */
  7090. readonly extendSize: Vector3;
  7091. /**
  7092. * Gets the extend size in world space
  7093. */
  7094. readonly extendSizeWorld: Vector3;
  7095. /**
  7096. * Gets the OBB (object bounding box) directions
  7097. */
  7098. readonly directions: Vector3[];
  7099. /**
  7100. * Gets the 8 vectors representing the bounding box in world space
  7101. */
  7102. readonly vectorsWorld: Vector3[];
  7103. /**
  7104. * Gets the minimum vector in world space
  7105. */
  7106. readonly minimumWorld: Vector3;
  7107. /**
  7108. * Gets the maximum vector in world space
  7109. */
  7110. readonly maximumWorld: Vector3;
  7111. /**
  7112. * Gets the minimum vector in local space
  7113. */
  7114. readonly minimum: Vector3;
  7115. /**
  7116. * Gets the maximum vector in local space
  7117. */
  7118. readonly maximum: Vector3;
  7119. private _worldMatrix;
  7120. private static readonly TmpVector3;
  7121. /**
  7122. * @hidden
  7123. */
  7124. _tag: number;
  7125. /**
  7126. * Creates a new bounding box
  7127. * @param min defines the minimum vector (in local space)
  7128. * @param max defines the maximum vector (in local space)
  7129. * @param worldMatrix defines the new world matrix
  7130. */
  7131. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7132. /**
  7133. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7134. * @param min defines the new minimum vector (in local space)
  7135. * @param max defines the new maximum vector (in local space)
  7136. * @param worldMatrix defines the new world matrix
  7137. */
  7138. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7139. /**
  7140. * Scale the current bounding box by applying a scale factor
  7141. * @param factor defines the scale factor to apply
  7142. * @returns the current bounding box
  7143. */
  7144. scale(factor: number): BoundingBox;
  7145. /**
  7146. * Gets the world matrix of the bounding box
  7147. * @returns a matrix
  7148. */
  7149. getWorldMatrix(): DeepImmutable<Matrix>;
  7150. /** @hidden */
  7151. _update(world: DeepImmutable<Matrix>): void;
  7152. /**
  7153. * Tests if the bounding box is intersecting the frustum planes
  7154. * @param frustumPlanes defines the frustum planes to test
  7155. * @returns true if there is an intersection
  7156. */
  7157. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7158. /**
  7159. * Tests if the bounding box is entirely inside the frustum planes
  7160. * @param frustumPlanes defines the frustum planes to test
  7161. * @returns true if there is an inclusion
  7162. */
  7163. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7164. /**
  7165. * Tests if a point is inside the bounding box
  7166. * @param point defines the point to test
  7167. * @returns true if the point is inside the bounding box
  7168. */
  7169. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7170. /**
  7171. * Tests if the bounding box intersects with a bounding sphere
  7172. * @param sphere defines the sphere to test
  7173. * @returns true if there is an intersection
  7174. */
  7175. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7176. /**
  7177. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7178. * @param min defines the min vector to use
  7179. * @param max defines the max vector to use
  7180. * @returns true if there is an intersection
  7181. */
  7182. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7183. /**
  7184. * Tests if two bounding boxes are intersections
  7185. * @param box0 defines the first box to test
  7186. * @param box1 defines the second box to test
  7187. * @returns true if there is an intersection
  7188. */
  7189. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7190. /**
  7191. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7192. * @param minPoint defines the minimum vector of the bounding box
  7193. * @param maxPoint defines the maximum vector of the bounding box
  7194. * @param sphereCenter defines the sphere center
  7195. * @param sphereRadius defines the sphere radius
  7196. * @returns true if there is an intersection
  7197. */
  7198. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7199. /**
  7200. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7201. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7202. * @param frustumPlanes defines the frustum planes to test
  7203. * @return true if there is an inclusion
  7204. */
  7205. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7206. /**
  7207. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7208. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7209. * @param frustumPlanes defines the frustum planes to test
  7210. * @return true if there is an intersection
  7211. */
  7212. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7213. }
  7214. }
  7215. declare module BABYLON {
  7216. /** @hidden */
  7217. export class Collider {
  7218. /** Define if a collision was found */
  7219. collisionFound: boolean;
  7220. /**
  7221. * Define last intersection point in local space
  7222. */
  7223. intersectionPoint: Vector3;
  7224. /**
  7225. * Define last collided mesh
  7226. */
  7227. collidedMesh: Nullable<AbstractMesh>;
  7228. private _collisionPoint;
  7229. private _planeIntersectionPoint;
  7230. private _tempVector;
  7231. private _tempVector2;
  7232. private _tempVector3;
  7233. private _tempVector4;
  7234. private _edge;
  7235. private _baseToVertex;
  7236. private _destinationPoint;
  7237. private _slidePlaneNormal;
  7238. private _displacementVector;
  7239. /** @hidden */
  7240. _radius: Vector3;
  7241. /** @hidden */
  7242. _retry: number;
  7243. private _velocity;
  7244. private _basePoint;
  7245. private _epsilon;
  7246. /** @hidden */
  7247. _velocityWorldLength: number;
  7248. /** @hidden */
  7249. _basePointWorld: Vector3;
  7250. private _velocityWorld;
  7251. private _normalizedVelocity;
  7252. /** @hidden */
  7253. _initialVelocity: Vector3;
  7254. /** @hidden */
  7255. _initialPosition: Vector3;
  7256. private _nearestDistance;
  7257. private _collisionMask;
  7258. get collisionMask(): number;
  7259. set collisionMask(mask: number);
  7260. /**
  7261. * Gets the plane normal used to compute the sliding response (in local space)
  7262. */
  7263. get slidePlaneNormal(): Vector3;
  7264. /** @hidden */
  7265. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7266. /** @hidden */
  7267. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7268. /** @hidden */
  7269. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7270. /** @hidden */
  7271. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7272. /** @hidden */
  7273. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7274. /** @hidden */
  7275. _getResponse(pos: Vector3, vel: Vector3): void;
  7276. }
  7277. }
  7278. declare module BABYLON {
  7279. /**
  7280. * Interface for cullable objects
  7281. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7282. */
  7283. export interface ICullable {
  7284. /**
  7285. * Checks if the object or part of the object is in the frustum
  7286. * @param frustumPlanes Camera near/planes
  7287. * @returns true if the object is in frustum otherwise false
  7288. */
  7289. isInFrustum(frustumPlanes: Plane[]): boolean;
  7290. /**
  7291. * Checks if a cullable object (mesh...) is in the camera frustum
  7292. * Unlike isInFrustum this cheks the full bounding box
  7293. * @param frustumPlanes Camera near/planes
  7294. * @returns true if the object is in frustum otherwise false
  7295. */
  7296. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7297. }
  7298. /**
  7299. * Info for a bounding data of a mesh
  7300. */
  7301. export class BoundingInfo implements ICullable {
  7302. /**
  7303. * Bounding box for the mesh
  7304. */
  7305. readonly boundingBox: BoundingBox;
  7306. /**
  7307. * Bounding sphere for the mesh
  7308. */
  7309. readonly boundingSphere: BoundingSphere;
  7310. private _isLocked;
  7311. private static readonly TmpVector3;
  7312. /**
  7313. * Constructs bounding info
  7314. * @param minimum min vector of the bounding box/sphere
  7315. * @param maximum max vector of the bounding box/sphere
  7316. * @param worldMatrix defines the new world matrix
  7317. */
  7318. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7319. /**
  7320. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7321. * @param min defines the new minimum vector (in local space)
  7322. * @param max defines the new maximum vector (in local space)
  7323. * @param worldMatrix defines the new world matrix
  7324. */
  7325. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7326. /**
  7327. * min vector of the bounding box/sphere
  7328. */
  7329. get minimum(): Vector3;
  7330. /**
  7331. * max vector of the bounding box/sphere
  7332. */
  7333. get maximum(): Vector3;
  7334. /**
  7335. * If the info is locked and won't be updated to avoid perf overhead
  7336. */
  7337. get isLocked(): boolean;
  7338. set isLocked(value: boolean);
  7339. /**
  7340. * Updates the bounding sphere and box
  7341. * @param world world matrix to be used to update
  7342. */
  7343. update(world: DeepImmutable<Matrix>): void;
  7344. /**
  7345. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7346. * @param center New center of the bounding info
  7347. * @param extend New extend of the bounding info
  7348. * @returns the current bounding info
  7349. */
  7350. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7351. /**
  7352. * Scale the current bounding info by applying a scale factor
  7353. * @param factor defines the scale factor to apply
  7354. * @returns the current bounding info
  7355. */
  7356. scale(factor: number): BoundingInfo;
  7357. /**
  7358. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7359. * @param frustumPlanes defines the frustum to test
  7360. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7361. * @returns true if the bounding info is in the frustum planes
  7362. */
  7363. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7364. /**
  7365. * Gets the world distance between the min and max points of the bounding box
  7366. */
  7367. get diagonalLength(): number;
  7368. /**
  7369. * Checks if a cullable object (mesh...) is in the camera frustum
  7370. * Unlike isInFrustum this cheks the full bounding box
  7371. * @param frustumPlanes Camera near/planes
  7372. * @returns true if the object is in frustum otherwise false
  7373. */
  7374. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7375. /** @hidden */
  7376. _checkCollision(collider: Collider): boolean;
  7377. /**
  7378. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7379. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7380. * @param point the point to check intersection with
  7381. * @returns if the point intersects
  7382. */
  7383. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7384. /**
  7385. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7386. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7387. * @param boundingInfo the bounding info to check intersection with
  7388. * @param precise if the intersection should be done using OBB
  7389. * @returns if the bounding info intersects
  7390. */
  7391. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7392. }
  7393. }
  7394. declare module BABYLON {
  7395. /**
  7396. * Extracts minimum and maximum values from a list of indexed positions
  7397. * @param positions defines the positions to use
  7398. * @param indices defines the indices to the positions
  7399. * @param indexStart defines the start index
  7400. * @param indexCount defines the end index
  7401. * @param bias defines bias value to add to the result
  7402. * @return minimum and maximum values
  7403. */
  7404. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7405. minimum: Vector3;
  7406. maximum: Vector3;
  7407. };
  7408. /**
  7409. * Extracts minimum and maximum values from a list of positions
  7410. * @param positions defines the positions to use
  7411. * @param start defines the start index in the positions array
  7412. * @param count defines the number of positions to handle
  7413. * @param bias defines bias value to add to the result
  7414. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7415. * @return minimum and maximum values
  7416. */
  7417. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7418. minimum: Vector3;
  7419. maximum: Vector3;
  7420. };
  7421. }
  7422. declare module BABYLON {
  7423. /**
  7424. * Class used to manipulate GUIDs
  7425. */
  7426. export class GUID {
  7427. /**
  7428. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  7429. * Be aware Math.random() could cause collisions, but:
  7430. * "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"
  7431. * @returns a pseudo random id
  7432. */
  7433. static RandomId(): string;
  7434. }
  7435. }
  7436. declare module BABYLON {
  7437. /**
  7438. * Base class of all the textures in babylon.
  7439. * It groups all the common properties the materials, post process, lights... might need
  7440. * in order to make a correct use of the texture.
  7441. */
  7442. export class BaseTexture extends ThinTexture implements IAnimatable {
  7443. /**
  7444. * Default anisotropic filtering level for the application.
  7445. * It is set to 4 as a good tradeoff between perf and quality.
  7446. */
  7447. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  7448. /**
  7449. * Gets or sets the unique id of the texture
  7450. */
  7451. uniqueId: number;
  7452. /**
  7453. * Define the name of the texture.
  7454. */
  7455. name: string;
  7456. /**
  7457. * Gets or sets an object used to store user defined information.
  7458. */
  7459. metadata: any;
  7460. /**
  7461. * For internal use only. Please do not use.
  7462. */
  7463. reservedDataStore: any;
  7464. private _hasAlpha;
  7465. /**
  7466. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  7467. */
  7468. set hasAlpha(value: boolean);
  7469. get hasAlpha(): boolean;
  7470. /**
  7471. * Defines if the alpha value should be determined via the rgb values.
  7472. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  7473. */
  7474. getAlphaFromRGB: boolean;
  7475. /**
  7476. * Intensity or strength of the texture.
  7477. * It is commonly used by materials to fine tune the intensity of the texture
  7478. */
  7479. level: number;
  7480. /**
  7481. * Define the UV chanel to use starting from 0 and defaulting to 0.
  7482. * This is part of the texture as textures usually maps to one uv set.
  7483. */
  7484. coordinatesIndex: number;
  7485. protected _coordinatesMode: number;
  7486. /**
  7487. * How a texture is mapped.
  7488. *
  7489. * | Value | Type | Description |
  7490. * | ----- | ----------------------------------- | ----------- |
  7491. * | 0 | EXPLICIT_MODE | |
  7492. * | 1 | SPHERICAL_MODE | |
  7493. * | 2 | PLANAR_MODE | |
  7494. * | 3 | CUBIC_MODE | |
  7495. * | 4 | PROJECTION_MODE | |
  7496. * | 5 | SKYBOX_MODE | |
  7497. * | 6 | INVCUBIC_MODE | |
  7498. * | 7 | EQUIRECTANGULAR_MODE | |
  7499. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  7500. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  7501. */
  7502. set coordinatesMode(value: number);
  7503. get coordinatesMode(): number;
  7504. /**
  7505. * | Value | Type | Description |
  7506. * | ----- | ------------------ | ----------- |
  7507. * | 0 | CLAMP_ADDRESSMODE | |
  7508. * | 1 | WRAP_ADDRESSMODE | |
  7509. * | 2 | MIRROR_ADDRESSMODE | |
  7510. */
  7511. get wrapU(): number;
  7512. set wrapU(value: number);
  7513. /**
  7514. * | Value | Type | Description |
  7515. * | ----- | ------------------ | ----------- |
  7516. * | 0 | CLAMP_ADDRESSMODE | |
  7517. * | 1 | WRAP_ADDRESSMODE | |
  7518. * | 2 | MIRROR_ADDRESSMODE | |
  7519. */
  7520. get wrapV(): number;
  7521. set wrapV(value: number);
  7522. /**
  7523. * | Value | Type | Description |
  7524. * | ----- | ------------------ | ----------- |
  7525. * | 0 | CLAMP_ADDRESSMODE | |
  7526. * | 1 | WRAP_ADDRESSMODE | |
  7527. * | 2 | MIRROR_ADDRESSMODE | |
  7528. */
  7529. wrapR: number;
  7530. /**
  7531. * With compliant hardware and browser (supporting anisotropic filtering)
  7532. * this defines the level of anisotropic filtering in the texture.
  7533. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  7534. */
  7535. anisotropicFilteringLevel: number;
  7536. private _isCube;
  7537. /**
  7538. * Define if the texture is a cube texture or if false a 2d texture.
  7539. */
  7540. get isCube(): boolean;
  7541. set isCube(value: boolean);
  7542. /**
  7543. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  7544. */
  7545. get is3D(): boolean;
  7546. set is3D(value: boolean);
  7547. /**
  7548. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  7549. */
  7550. get is2DArray(): boolean;
  7551. set is2DArray(value: boolean);
  7552. private _gammaSpace;
  7553. /**
  7554. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  7555. * HDR texture are usually stored in linear space.
  7556. * This only impacts the PBR and Background materials
  7557. */
  7558. get gammaSpace(): boolean;
  7559. set gammaSpace(gamma: boolean);
  7560. /**
  7561. * Gets or sets whether or not the texture contains RGBD data.
  7562. */
  7563. get isRGBD(): boolean;
  7564. set isRGBD(value: boolean);
  7565. /**
  7566. * Is Z inverted in the texture (useful in a cube texture).
  7567. */
  7568. invertZ: boolean;
  7569. /**
  7570. * Are mip maps generated for this texture or not.
  7571. */
  7572. get noMipmap(): boolean;
  7573. /**
  7574. * @hidden
  7575. */
  7576. lodLevelInAlpha: boolean;
  7577. /**
  7578. * With prefiltered texture, defined the offset used during the prefiltering steps.
  7579. */
  7580. get lodGenerationOffset(): number;
  7581. set lodGenerationOffset(value: number);
  7582. /**
  7583. * With prefiltered texture, defined the scale used during the prefiltering steps.
  7584. */
  7585. get lodGenerationScale(): number;
  7586. set lodGenerationScale(value: number);
  7587. /**
  7588. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  7589. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  7590. * average roughness values.
  7591. */
  7592. get linearSpecularLOD(): boolean;
  7593. set linearSpecularLOD(value: boolean);
  7594. /**
  7595. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  7596. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  7597. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  7598. */
  7599. get irradianceTexture(): Nullable<BaseTexture>;
  7600. set irradianceTexture(value: Nullable<BaseTexture>);
  7601. /**
  7602. * Define if the texture is a render target.
  7603. */
  7604. isRenderTarget: boolean;
  7605. /**
  7606. * Define the unique id of the texture in the scene.
  7607. */
  7608. get uid(): string;
  7609. /** @hidden */
  7610. _prefiltered: boolean;
  7611. /**
  7612. * Return a string representation of the texture.
  7613. * @returns the texture as a string
  7614. */
  7615. toString(): string;
  7616. /**
  7617. * Get the class name of the texture.
  7618. * @returns "BaseTexture"
  7619. */
  7620. getClassName(): string;
  7621. /**
  7622. * Define the list of animation attached to the texture.
  7623. */
  7624. animations: Animation[];
  7625. /**
  7626. * An event triggered when the texture is disposed.
  7627. */
  7628. onDisposeObservable: Observable<BaseTexture>;
  7629. private _onDisposeObserver;
  7630. /**
  7631. * Callback triggered when the texture has been disposed.
  7632. * Kept for back compatibility, you can use the onDisposeObservable instead.
  7633. */
  7634. set onDispose(callback: () => void);
  7635. protected _scene: Nullable<Scene>;
  7636. /** @hidden */
  7637. _texture: Nullable<InternalTexture>;
  7638. private _uid;
  7639. /**
  7640. * Define if the texture is preventinga material to render or not.
  7641. * If not and the texture is not ready, the engine will use a default black texture instead.
  7642. */
  7643. get isBlocking(): boolean;
  7644. /**
  7645. * Instantiates a new BaseTexture.
  7646. * Base class of all the textures in babylon.
  7647. * It groups all the common properties the materials, post process, lights... might need
  7648. * in order to make a correct use of the texture.
  7649. * @param sceneOrEngine Define the scene or engine the texture blongs to
  7650. */
  7651. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  7652. /**
  7653. * Get the scene the texture belongs to.
  7654. * @returns the scene or null if undefined
  7655. */
  7656. getScene(): Nullable<Scene>;
  7657. /** @hidden */
  7658. protected _getEngine(): Nullable<ThinEngine>;
  7659. /**
  7660. * Checks if the texture has the same transform matrix than another texture
  7661. * @param texture texture to check against
  7662. * @returns true if the transforms are the same, else false
  7663. */
  7664. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  7665. /**
  7666. * Get the texture transform matrix used to offset tile the texture for istance.
  7667. * @returns the transformation matrix
  7668. */
  7669. getTextureMatrix(): Matrix;
  7670. /**
  7671. * Get the texture reflection matrix used to rotate/transform the reflection.
  7672. * @returns the reflection matrix
  7673. */
  7674. getReflectionTextureMatrix(): Matrix;
  7675. /**
  7676. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  7677. * @returns true if ready or not blocking
  7678. */
  7679. isReadyOrNotBlocking(): boolean;
  7680. /**
  7681. * Scales the texture if is `canRescale()`
  7682. * @param ratio the resize factor we want to use to rescale
  7683. */
  7684. scale(ratio: number): void;
  7685. /**
  7686. * Get if the texture can rescale.
  7687. */
  7688. get canRescale(): boolean;
  7689. /** @hidden */
  7690. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  7691. /** @hidden */
  7692. _rebuild(): void;
  7693. /**
  7694. * Clones the texture.
  7695. * @returns the cloned texture
  7696. */
  7697. clone(): Nullable<BaseTexture>;
  7698. /**
  7699. * Get the texture underlying type (INT, FLOAT...)
  7700. */
  7701. get textureType(): number;
  7702. /**
  7703. * Get the texture underlying format (RGB, RGBA...)
  7704. */
  7705. get textureFormat(): number;
  7706. /**
  7707. * Indicates that textures need to be re-calculated for all materials
  7708. */
  7709. protected _markAllSubMeshesAsTexturesDirty(): void;
  7710. /**
  7711. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  7712. * This will returns an RGBA array buffer containing either in values (0-255) or
  7713. * float values (0-1) depending of the underlying buffer type.
  7714. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  7715. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  7716. * @param buffer defines a user defined buffer to fill with data (can be null)
  7717. * @returns The Array buffer containing the pixels data.
  7718. */
  7719. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  7720. /** @hidden */
  7721. get _lodTextureHigh(): Nullable<BaseTexture>;
  7722. /** @hidden */
  7723. get _lodTextureMid(): Nullable<BaseTexture>;
  7724. /** @hidden */
  7725. get _lodTextureLow(): Nullable<BaseTexture>;
  7726. /**
  7727. * Dispose the texture and release its associated resources.
  7728. */
  7729. dispose(): void;
  7730. /**
  7731. * Serialize the texture into a JSON representation that can be parsed later on.
  7732. * @returns the JSON representation of the texture
  7733. */
  7734. serialize(): any;
  7735. /**
  7736. * Helper function to be called back once a list of texture contains only ready textures.
  7737. * @param textures Define the list of textures to wait for
  7738. * @param callback Define the callback triggered once the entire list will be ready
  7739. */
  7740. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  7741. private static _isScene;
  7742. }
  7743. }
  7744. declare module BABYLON {
  7745. /** @hidden */
  7746. export class WebGLDataBuffer extends DataBuffer {
  7747. private _buffer;
  7748. constructor(resource: WebGLBuffer);
  7749. get underlyingResource(): any;
  7750. }
  7751. }
  7752. declare module BABYLON {
  7753. /** @hidden */
  7754. export class WebGLPipelineContext implements IPipelineContext {
  7755. engine: ThinEngine;
  7756. program: Nullable<WebGLProgram>;
  7757. context?: WebGLRenderingContext;
  7758. vertexShader?: WebGLShader;
  7759. fragmentShader?: WebGLShader;
  7760. isParallelCompiled: boolean;
  7761. onCompiled?: () => void;
  7762. transformFeedback?: WebGLTransformFeedback | null;
  7763. vertexCompilationError: Nullable<string>;
  7764. fragmentCompilationError: Nullable<string>;
  7765. programLinkError: Nullable<string>;
  7766. programValidationError: Nullable<string>;
  7767. get isAsync(): boolean;
  7768. get isReady(): boolean;
  7769. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7770. _getVertexShaderCode(): string | null;
  7771. _getFragmentShaderCode(): string | null;
  7772. }
  7773. }
  7774. declare module BABYLON {
  7775. interface ThinEngine {
  7776. /**
  7777. * Create an uniform buffer
  7778. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7779. * @param elements defines the content of the uniform buffer
  7780. * @returns the webGL uniform buffer
  7781. */
  7782. createUniformBuffer(elements: FloatArray): DataBuffer;
  7783. /**
  7784. * Create a dynamic uniform buffer
  7785. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7786. * @param elements defines the content of the uniform buffer
  7787. * @returns the webGL uniform buffer
  7788. */
  7789. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7790. /**
  7791. * Update an existing uniform buffer
  7792. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7793. * @param uniformBuffer defines the target uniform buffer
  7794. * @param elements defines the content to update
  7795. * @param offset defines the offset in the uniform buffer where update should start
  7796. * @param count defines the size of the data to update
  7797. */
  7798. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7799. /**
  7800. * Bind an uniform buffer to the current webGL context
  7801. * @param buffer defines the buffer to bind
  7802. */
  7803. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7804. /**
  7805. * Bind a buffer to the current webGL context at a given location
  7806. * @param buffer defines the buffer to bind
  7807. * @param location defines the index where to bind the buffer
  7808. */
  7809. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7810. /**
  7811. * Bind a specific block at a given index in a specific shader program
  7812. * @param pipelineContext defines the pipeline context to use
  7813. * @param blockName defines the block name
  7814. * @param index defines the index where to bind the block
  7815. */
  7816. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7817. }
  7818. }
  7819. declare module BABYLON {
  7820. /**
  7821. * Uniform buffer objects.
  7822. *
  7823. * Handles blocks of uniform on the GPU.
  7824. *
  7825. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7826. *
  7827. * For more information, please refer to :
  7828. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7829. */
  7830. export class UniformBuffer {
  7831. private _engine;
  7832. private _buffer;
  7833. private _data;
  7834. private _bufferData;
  7835. private _dynamic?;
  7836. private _uniformLocations;
  7837. private _uniformSizes;
  7838. private _uniformLocationPointer;
  7839. private _needSync;
  7840. private _noUBO;
  7841. private _currentEffect;
  7842. /** @hidden */
  7843. _alreadyBound: boolean;
  7844. private static _MAX_UNIFORM_SIZE;
  7845. private static _tempBuffer;
  7846. /**
  7847. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7848. * This is dynamic to allow compat with webgl 1 and 2.
  7849. * You will need to pass the name of the uniform as well as the value.
  7850. */
  7851. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7852. /**
  7853. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7854. * This is dynamic to allow compat with webgl 1 and 2.
  7855. * You will need to pass the name of the uniform as well as the value.
  7856. */
  7857. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7858. /**
  7859. * Lambda to Update a single float in a uniform buffer.
  7860. * This is dynamic to allow compat with webgl 1 and 2.
  7861. * You will need to pass the name of the uniform as well as the value.
  7862. */
  7863. updateFloat: (name: string, x: number) => void;
  7864. /**
  7865. * Lambda to Update a vec2 of float in a uniform buffer.
  7866. * This is dynamic to allow compat with webgl 1 and 2.
  7867. * You will need to pass the name of the uniform as well as the value.
  7868. */
  7869. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7870. /**
  7871. * Lambda to Update a vec3 of float in a uniform buffer.
  7872. * This is dynamic to allow compat with webgl 1 and 2.
  7873. * You will need to pass the name of the uniform as well as the value.
  7874. */
  7875. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7876. /**
  7877. * Lambda to Update a vec4 of float in a uniform buffer.
  7878. * This is dynamic to allow compat with webgl 1 and 2.
  7879. * You will need to pass the name of the uniform as well as the value.
  7880. */
  7881. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7882. /**
  7883. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7884. * This is dynamic to allow compat with webgl 1 and 2.
  7885. * You will need to pass the name of the uniform as well as the value.
  7886. */
  7887. updateMatrix: (name: string, mat: Matrix) => void;
  7888. /**
  7889. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7890. * This is dynamic to allow compat with webgl 1 and 2.
  7891. * You will need to pass the name of the uniform as well as the value.
  7892. */
  7893. updateVector3: (name: string, vector: Vector3) => void;
  7894. /**
  7895. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7896. * This is dynamic to allow compat with webgl 1 and 2.
  7897. * You will need to pass the name of the uniform as well as the value.
  7898. */
  7899. updateVector4: (name: string, vector: Vector4) => void;
  7900. /**
  7901. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7902. * This is dynamic to allow compat with webgl 1 and 2.
  7903. * You will need to pass the name of the uniform as well as the value.
  7904. */
  7905. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7906. /**
  7907. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7908. * This is dynamic to allow compat with webgl 1 and 2.
  7909. * You will need to pass the name of the uniform as well as the value.
  7910. */
  7911. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7912. /**
  7913. * Instantiates a new Uniform buffer objects.
  7914. *
  7915. * Handles blocks of uniform on the GPU.
  7916. *
  7917. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7918. *
  7919. * For more information, please refer to :
  7920. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7921. * @param engine Define the engine the buffer is associated with
  7922. * @param data Define the data contained in the buffer
  7923. * @param dynamic Define if the buffer is updatable
  7924. */
  7925. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7926. /**
  7927. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7928. * or just falling back on setUniformXXX calls.
  7929. */
  7930. get useUbo(): boolean;
  7931. /**
  7932. * Indicates if the WebGL underlying uniform buffer is in sync
  7933. * with the javascript cache data.
  7934. */
  7935. get isSync(): boolean;
  7936. /**
  7937. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7938. * Also, a dynamic UniformBuffer will disable cache verification and always
  7939. * update the underlying WebGL uniform buffer to the GPU.
  7940. * @returns if Dynamic, otherwise false
  7941. */
  7942. isDynamic(): boolean;
  7943. /**
  7944. * The data cache on JS side.
  7945. * @returns the underlying data as a float array
  7946. */
  7947. getData(): Float32Array;
  7948. /**
  7949. * The underlying WebGL Uniform buffer.
  7950. * @returns the webgl buffer
  7951. */
  7952. getBuffer(): Nullable<DataBuffer>;
  7953. /**
  7954. * std140 layout specifies how to align data within an UBO structure.
  7955. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7956. * for specs.
  7957. */
  7958. private _fillAlignment;
  7959. /**
  7960. * Adds an uniform in the buffer.
  7961. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7962. * for the layout to be correct !
  7963. * @param name Name of the uniform, as used in the uniform block in the shader.
  7964. * @param size Data size, or data directly.
  7965. */
  7966. addUniform(name: string, size: number | number[]): void;
  7967. /**
  7968. * Adds a Matrix 4x4 to the uniform buffer.
  7969. * @param name Name of the uniform, as used in the uniform block in the shader.
  7970. * @param mat A 4x4 matrix.
  7971. */
  7972. addMatrix(name: string, mat: Matrix): void;
  7973. /**
  7974. * Adds a vec2 to the uniform buffer.
  7975. * @param name Name of the uniform, as used in the uniform block in the shader.
  7976. * @param x Define the x component value of the vec2
  7977. * @param y Define the y component value of the vec2
  7978. */
  7979. addFloat2(name: string, x: number, y: number): void;
  7980. /**
  7981. * Adds a vec3 to the uniform buffer.
  7982. * @param name Name of the uniform, as used in the uniform block in the shader.
  7983. * @param x Define the x component value of the vec3
  7984. * @param y Define the y component value of the vec3
  7985. * @param z Define the z component value of the vec3
  7986. */
  7987. addFloat3(name: string, x: number, y: number, z: number): void;
  7988. /**
  7989. * Adds a vec3 to the uniform buffer.
  7990. * @param name Name of the uniform, as used in the uniform block in the shader.
  7991. * @param color Define the vec3 from a Color
  7992. */
  7993. addColor3(name: string, color: Color3): void;
  7994. /**
  7995. * Adds a vec4 to the uniform buffer.
  7996. * @param name Name of the uniform, as used in the uniform block in the shader.
  7997. * @param color Define the rgb components from a Color
  7998. * @param alpha Define the a component of the vec4
  7999. */
  8000. addColor4(name: string, color: Color3, alpha: number): void;
  8001. /**
  8002. * Adds a vec3 to the uniform buffer.
  8003. * @param name Name of the uniform, as used in the uniform block in the shader.
  8004. * @param vector Define the vec3 components from a Vector
  8005. */
  8006. addVector3(name: string, vector: Vector3): void;
  8007. /**
  8008. * Adds a Matrix 3x3 to the uniform buffer.
  8009. * @param name Name of the uniform, as used in the uniform block in the shader.
  8010. */
  8011. addMatrix3x3(name: string): void;
  8012. /**
  8013. * Adds a Matrix 2x2 to the uniform buffer.
  8014. * @param name Name of the uniform, as used in the uniform block in the shader.
  8015. */
  8016. addMatrix2x2(name: string): void;
  8017. /**
  8018. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  8019. */
  8020. create(): void;
  8021. /** @hidden */
  8022. _rebuild(): void;
  8023. /**
  8024. * Updates the WebGL Uniform Buffer on the GPU.
  8025. * If the `dynamic` flag is set to true, no cache comparison is done.
  8026. * Otherwise, the buffer will be updated only if the cache differs.
  8027. */
  8028. update(): void;
  8029. /**
  8030. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8031. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8032. * @param data Define the flattened data
  8033. * @param size Define the size of the data.
  8034. */
  8035. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  8036. private _valueCache;
  8037. private _cacheMatrix;
  8038. private _updateMatrix3x3ForUniform;
  8039. private _updateMatrix3x3ForEffect;
  8040. private _updateMatrix2x2ForEffect;
  8041. private _updateMatrix2x2ForUniform;
  8042. private _updateFloatForEffect;
  8043. private _updateFloatForUniform;
  8044. private _updateFloat2ForEffect;
  8045. private _updateFloat2ForUniform;
  8046. private _updateFloat3ForEffect;
  8047. private _updateFloat3ForUniform;
  8048. private _updateFloat4ForEffect;
  8049. private _updateFloat4ForUniform;
  8050. private _updateMatrixForEffect;
  8051. private _updateMatrixForUniform;
  8052. private _updateVector3ForEffect;
  8053. private _updateVector3ForUniform;
  8054. private _updateVector4ForEffect;
  8055. private _updateVector4ForUniform;
  8056. private _updateColor3ForEffect;
  8057. private _updateColor3ForUniform;
  8058. private _updateColor4ForEffect;
  8059. private _updateColor4ForUniform;
  8060. /**
  8061. * Sets a sampler uniform on the effect.
  8062. * @param name Define the name of the sampler.
  8063. * @param texture Define the texture to set in the sampler
  8064. */
  8065. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  8066. /**
  8067. * Directly updates the value of the uniform in the cache AND on the GPU.
  8068. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8069. * @param data Define the flattened data
  8070. */
  8071. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  8072. /**
  8073. * Binds this uniform buffer to an effect.
  8074. * @param effect Define the effect to bind the buffer to
  8075. * @param name Name of the uniform block in the shader.
  8076. */
  8077. bindToEffect(effect: Effect, name: string): void;
  8078. /**
  8079. * Disposes the uniform buffer.
  8080. */
  8081. dispose(): void;
  8082. }
  8083. }
  8084. declare module BABYLON {
  8085. /**
  8086. * Manages the defines for the Material
  8087. */
  8088. export class MaterialDefines {
  8089. /** @hidden */
  8090. protected _keys: string[];
  8091. private _isDirty;
  8092. /** @hidden */
  8093. _renderId: number;
  8094. /** @hidden */
  8095. _areLightsDirty: boolean;
  8096. /** @hidden */
  8097. _areLightsDisposed: boolean;
  8098. /** @hidden */
  8099. _areAttributesDirty: boolean;
  8100. /** @hidden */
  8101. _areTexturesDirty: boolean;
  8102. /** @hidden */
  8103. _areFresnelDirty: boolean;
  8104. /** @hidden */
  8105. _areMiscDirty: boolean;
  8106. /** @hidden */
  8107. _arePrePassDirty: boolean;
  8108. /** @hidden */
  8109. _areImageProcessingDirty: boolean;
  8110. /** @hidden */
  8111. _normals: boolean;
  8112. /** @hidden */
  8113. _uvs: boolean;
  8114. /** @hidden */
  8115. _needNormals: boolean;
  8116. /** @hidden */
  8117. _needUVs: boolean;
  8118. [id: string]: any;
  8119. /**
  8120. * Specifies if the material needs to be re-calculated
  8121. */
  8122. get isDirty(): boolean;
  8123. /**
  8124. * Marks the material to indicate that it has been re-calculated
  8125. */
  8126. markAsProcessed(): void;
  8127. /**
  8128. * Marks the material to indicate that it needs to be re-calculated
  8129. */
  8130. markAsUnprocessed(): void;
  8131. /**
  8132. * Marks the material to indicate all of its defines need to be re-calculated
  8133. */
  8134. markAllAsDirty(): void;
  8135. /**
  8136. * Marks the material to indicate that image processing needs to be re-calculated
  8137. */
  8138. markAsImageProcessingDirty(): void;
  8139. /**
  8140. * Marks the material to indicate the lights need to be re-calculated
  8141. * @param disposed Defines whether the light is dirty due to dispose or not
  8142. */
  8143. markAsLightDirty(disposed?: boolean): void;
  8144. /**
  8145. * Marks the attribute state as changed
  8146. */
  8147. markAsAttributesDirty(): void;
  8148. /**
  8149. * Marks the texture state as changed
  8150. */
  8151. markAsTexturesDirty(): void;
  8152. /**
  8153. * Marks the fresnel state as changed
  8154. */
  8155. markAsFresnelDirty(): void;
  8156. /**
  8157. * Marks the misc state as changed
  8158. */
  8159. markAsMiscDirty(): void;
  8160. /**
  8161. * Marks the prepass state as changed
  8162. */
  8163. markAsPrePassDirty(): void;
  8164. /**
  8165. * Rebuilds the material defines
  8166. */
  8167. rebuild(): void;
  8168. /**
  8169. * Specifies if two material defines are equal
  8170. * @param other - A material define instance to compare to
  8171. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8172. */
  8173. isEqual(other: MaterialDefines): boolean;
  8174. /**
  8175. * Clones this instance's defines to another instance
  8176. * @param other - material defines to clone values to
  8177. */
  8178. cloneTo(other: MaterialDefines): void;
  8179. /**
  8180. * Resets the material define values
  8181. */
  8182. reset(): void;
  8183. /**
  8184. * Converts the material define values to a string
  8185. * @returns - String of material define information
  8186. */
  8187. toString(): string;
  8188. }
  8189. }
  8190. declare module BABYLON {
  8191. /**
  8192. * Enum that determines the text-wrapping mode to use.
  8193. */
  8194. export enum InspectableType {
  8195. /**
  8196. * Checkbox for booleans
  8197. */
  8198. Checkbox = 0,
  8199. /**
  8200. * Sliders for numbers
  8201. */
  8202. Slider = 1,
  8203. /**
  8204. * Vector3
  8205. */
  8206. Vector3 = 2,
  8207. /**
  8208. * Quaternions
  8209. */
  8210. Quaternion = 3,
  8211. /**
  8212. * Color3
  8213. */
  8214. Color3 = 4,
  8215. /**
  8216. * String
  8217. */
  8218. String = 5
  8219. }
  8220. /**
  8221. * Interface used to define custom inspectable properties.
  8222. * This interface is used by the inspector to display custom property grids
  8223. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8224. */
  8225. export interface IInspectable {
  8226. /**
  8227. * Gets the label to display
  8228. */
  8229. label: string;
  8230. /**
  8231. * Gets the name of the property to edit
  8232. */
  8233. propertyName: string;
  8234. /**
  8235. * Gets the type of the editor to use
  8236. */
  8237. type: InspectableType;
  8238. /**
  8239. * Gets the minimum value of the property when using in "slider" mode
  8240. */
  8241. min?: number;
  8242. /**
  8243. * Gets the maximum value of the property when using in "slider" mode
  8244. */
  8245. max?: number;
  8246. /**
  8247. * Gets the setp to use when using in "slider" mode
  8248. */
  8249. step?: number;
  8250. }
  8251. }
  8252. declare module BABYLON {
  8253. /**
  8254. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  8255. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  8256. * 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.
  8257. */
  8258. export abstract class Light extends Node {
  8259. /**
  8260. * Falloff Default: light is falling off following the material specification:
  8261. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  8262. */
  8263. static readonly FALLOFF_DEFAULT: number;
  8264. /**
  8265. * Falloff Physical: light is falling off following the inverse squared distance law.
  8266. */
  8267. static readonly FALLOFF_PHYSICAL: number;
  8268. /**
  8269. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  8270. * to enhance interoperability with other engines.
  8271. */
  8272. static readonly FALLOFF_GLTF: number;
  8273. /**
  8274. * Falloff Standard: light is falling off like in the standard material
  8275. * to enhance interoperability with other materials.
  8276. */
  8277. static readonly FALLOFF_STANDARD: number;
  8278. /**
  8279. * If every light affecting the material is in this lightmapMode,
  8280. * material.lightmapTexture adds or multiplies
  8281. * (depends on material.useLightmapAsShadowmap)
  8282. * after every other light calculations.
  8283. */
  8284. static readonly LIGHTMAP_DEFAULT: number;
  8285. /**
  8286. * material.lightmapTexture as only diffuse lighting from this light
  8287. * adds only specular lighting from this light
  8288. * adds dynamic shadows
  8289. */
  8290. static readonly LIGHTMAP_SPECULAR: number;
  8291. /**
  8292. * material.lightmapTexture as only lighting
  8293. * no light calculation from this light
  8294. * only adds dynamic shadows from this light
  8295. */
  8296. static readonly LIGHTMAP_SHADOWSONLY: number;
  8297. /**
  8298. * Each light type uses the default quantity according to its type:
  8299. * point/spot lights use luminous intensity
  8300. * directional lights use illuminance
  8301. */
  8302. static readonly INTENSITYMODE_AUTOMATIC: number;
  8303. /**
  8304. * lumen (lm)
  8305. */
  8306. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  8307. /**
  8308. * candela (lm/sr)
  8309. */
  8310. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  8311. /**
  8312. * lux (lm/m^2)
  8313. */
  8314. static readonly INTENSITYMODE_ILLUMINANCE: number;
  8315. /**
  8316. * nit (cd/m^2)
  8317. */
  8318. static readonly INTENSITYMODE_LUMINANCE: number;
  8319. /**
  8320. * Light type const id of the point light.
  8321. */
  8322. static readonly LIGHTTYPEID_POINTLIGHT: number;
  8323. /**
  8324. * Light type const id of the directional light.
  8325. */
  8326. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  8327. /**
  8328. * Light type const id of the spot light.
  8329. */
  8330. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  8331. /**
  8332. * Light type const id of the hemispheric light.
  8333. */
  8334. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  8335. /**
  8336. * Diffuse gives the basic color to an object.
  8337. */
  8338. diffuse: Color3;
  8339. /**
  8340. * Specular produces a highlight color on an object.
  8341. * Note: This is note affecting PBR materials.
  8342. */
  8343. specular: Color3;
  8344. /**
  8345. * Defines the falloff type for this light. This lets overrriding how punctual light are
  8346. * falling off base on range or angle.
  8347. * This can be set to any values in Light.FALLOFF_x.
  8348. *
  8349. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  8350. * other types of materials.
  8351. */
  8352. falloffType: number;
  8353. /**
  8354. * Strength of the light.
  8355. * Note: By default it is define in the framework own unit.
  8356. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  8357. */
  8358. intensity: number;
  8359. private _range;
  8360. protected _inverseSquaredRange: number;
  8361. /**
  8362. * Defines how far from the source the light is impacting in scene units.
  8363. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  8364. */
  8365. get range(): number;
  8366. /**
  8367. * Defines how far from the source the light is impacting in scene units.
  8368. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  8369. */
  8370. set range(value: number);
  8371. /**
  8372. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  8373. * of light.
  8374. */
  8375. private _photometricScale;
  8376. private _intensityMode;
  8377. /**
  8378. * Gets the photometric scale used to interpret the intensity.
  8379. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  8380. */
  8381. get intensityMode(): number;
  8382. /**
  8383. * Sets the photometric scale used to interpret the intensity.
  8384. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  8385. */
  8386. set intensityMode(value: number);
  8387. private _radius;
  8388. /**
  8389. * Gets the light radius used by PBR Materials to simulate soft area lights.
  8390. */
  8391. get radius(): number;
  8392. /**
  8393. * sets the light radius used by PBR Materials to simulate soft area lights.
  8394. */
  8395. set radius(value: number);
  8396. private _renderPriority;
  8397. /**
  8398. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  8399. * exceeding the number allowed of the materials.
  8400. */
  8401. renderPriority: number;
  8402. private _shadowEnabled;
  8403. /**
  8404. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  8405. * the current shadow generator.
  8406. */
  8407. get shadowEnabled(): boolean;
  8408. /**
  8409. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  8410. * the current shadow generator.
  8411. */
  8412. set shadowEnabled(value: boolean);
  8413. private _includedOnlyMeshes;
  8414. /**
  8415. * Gets the only meshes impacted by this light.
  8416. */
  8417. get includedOnlyMeshes(): AbstractMesh[];
  8418. /**
  8419. * Sets the only meshes impacted by this light.
  8420. */
  8421. set includedOnlyMeshes(value: AbstractMesh[]);
  8422. private _excludedMeshes;
  8423. /**
  8424. * Gets the meshes not impacted by this light.
  8425. */
  8426. get excludedMeshes(): AbstractMesh[];
  8427. /**
  8428. * Sets the meshes not impacted by this light.
  8429. */
  8430. set excludedMeshes(value: AbstractMesh[]);
  8431. private _excludeWithLayerMask;
  8432. /**
  8433. * Gets the layer id use to find what meshes are not impacted by the light.
  8434. * Inactive if 0
  8435. */
  8436. get excludeWithLayerMask(): number;
  8437. /**
  8438. * Sets the layer id use to find what meshes are not impacted by the light.
  8439. * Inactive if 0
  8440. */
  8441. set excludeWithLayerMask(value: number);
  8442. private _includeOnlyWithLayerMask;
  8443. /**
  8444. * Gets the layer id use to find what meshes are impacted by the light.
  8445. * Inactive if 0
  8446. */
  8447. get includeOnlyWithLayerMask(): number;
  8448. /**
  8449. * Sets the layer id use to find what meshes are impacted by the light.
  8450. * Inactive if 0
  8451. */
  8452. set includeOnlyWithLayerMask(value: number);
  8453. private _lightmapMode;
  8454. /**
  8455. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  8456. */
  8457. get lightmapMode(): number;
  8458. /**
  8459. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  8460. */
  8461. set lightmapMode(value: number);
  8462. /**
  8463. * Shadow generator associted to the light.
  8464. * @hidden Internal use only.
  8465. */
  8466. _shadowGenerator: Nullable<IShadowGenerator>;
  8467. /**
  8468. * @hidden Internal use only.
  8469. */
  8470. _excludedMeshesIds: string[];
  8471. /**
  8472. * @hidden Internal use only.
  8473. */
  8474. _includedOnlyMeshesIds: string[];
  8475. /**
  8476. * The current light unifom buffer.
  8477. * @hidden Internal use only.
  8478. */
  8479. _uniformBuffer: UniformBuffer;
  8480. /** @hidden */
  8481. _renderId: number;
  8482. /**
  8483. * Creates a Light object in the scene.
  8484. * Documentation : https://doc.babylonjs.com/babylon101/lights
  8485. * @param name The firendly name of the light
  8486. * @param scene The scene the light belongs too
  8487. */
  8488. constructor(name: string, scene: Scene);
  8489. protected abstract _buildUniformLayout(): void;
  8490. /**
  8491. * Sets the passed Effect "effect" with the Light information.
  8492. * @param effect The effect to update
  8493. * @param lightIndex The index of the light in the effect to update
  8494. * @returns The light
  8495. */
  8496. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  8497. /**
  8498. * Sets the passed Effect "effect" with the Light textures.
  8499. * @param effect The effect to update
  8500. * @param lightIndex The index of the light in the effect to update
  8501. * @returns The light
  8502. */
  8503. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  8504. /**
  8505. * Binds the lights information from the scene to the effect for the given mesh.
  8506. * @param lightIndex Light index
  8507. * @param scene The scene where the light belongs to
  8508. * @param effect The effect we are binding the data to
  8509. * @param useSpecular Defines if specular is supported
  8510. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8511. */
  8512. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  8513. /**
  8514. * Sets the passed Effect "effect" with the Light information.
  8515. * @param effect The effect to update
  8516. * @param lightDataUniformName The uniform used to store light data (position or direction)
  8517. * @returns The light
  8518. */
  8519. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  8520. /**
  8521. * Returns the string "Light".
  8522. * @returns the class name
  8523. */
  8524. getClassName(): string;
  8525. /** @hidden */
  8526. readonly _isLight: boolean;
  8527. /**
  8528. * Converts the light information to a readable string for debug purpose.
  8529. * @param fullDetails Supports for multiple levels of logging within scene loading
  8530. * @returns the human readable light info
  8531. */
  8532. toString(fullDetails?: boolean): string;
  8533. /** @hidden */
  8534. protected _syncParentEnabledState(): void;
  8535. /**
  8536. * Set the enabled state of this node.
  8537. * @param value - the new enabled state
  8538. */
  8539. setEnabled(value: boolean): void;
  8540. /**
  8541. * Returns the Light associated shadow generator if any.
  8542. * @return the associated shadow generator.
  8543. */
  8544. getShadowGenerator(): Nullable<IShadowGenerator>;
  8545. /**
  8546. * Returns a Vector3, the absolute light position in the World.
  8547. * @returns the world space position of the light
  8548. */
  8549. getAbsolutePosition(): Vector3;
  8550. /**
  8551. * Specifies if the light will affect the passed mesh.
  8552. * @param mesh The mesh to test against the light
  8553. * @return true the mesh is affected otherwise, false.
  8554. */
  8555. canAffectMesh(mesh: AbstractMesh): boolean;
  8556. /**
  8557. * Sort function to order lights for rendering.
  8558. * @param a First Light object to compare to second.
  8559. * @param b Second Light object to compare first.
  8560. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  8561. */
  8562. static CompareLightsPriority(a: Light, b: Light): number;
  8563. /**
  8564. * Releases resources associated with this node.
  8565. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8566. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8567. */
  8568. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8569. /**
  8570. * Returns the light type ID (integer).
  8571. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  8572. */
  8573. getTypeID(): number;
  8574. /**
  8575. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  8576. * @returns the scaled intensity in intensity mode unit
  8577. */
  8578. getScaledIntensity(): number;
  8579. /**
  8580. * Returns a new Light object, named "name", from the current one.
  8581. * @param name The name of the cloned light
  8582. * @param newParent The parent of this light, if it has one
  8583. * @returns the new created light
  8584. */
  8585. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  8586. /**
  8587. * Serializes the current light into a Serialization object.
  8588. * @returns the serialized object.
  8589. */
  8590. serialize(): any;
  8591. /**
  8592. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  8593. * This new light is named "name" and added to the passed scene.
  8594. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  8595. * @param name The friendly name of the light
  8596. * @param scene The scene the new light will belong to
  8597. * @returns the constructor function
  8598. */
  8599. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  8600. /**
  8601. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  8602. * @param parsedLight The JSON representation of the light
  8603. * @param scene The scene to create the parsed light in
  8604. * @returns the created light after parsing
  8605. */
  8606. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  8607. private _hookArrayForExcluded;
  8608. private _hookArrayForIncludedOnly;
  8609. private _resyncMeshes;
  8610. /**
  8611. * Forces the meshes to update their light related information in their rendering used effects
  8612. * @hidden Internal Use Only
  8613. */
  8614. _markMeshesAsLightDirty(): void;
  8615. /**
  8616. * Recomputes the cached photometric scale if needed.
  8617. */
  8618. private _computePhotometricScale;
  8619. /**
  8620. * Returns the Photometric Scale according to the light type and intensity mode.
  8621. */
  8622. private _getPhotometricScale;
  8623. /**
  8624. * Reorder the light in the scene according to their defined priority.
  8625. * @hidden Internal Use Only
  8626. */
  8627. _reorderLightsInScene(): void;
  8628. /**
  8629. * Prepares the list of defines specific to the light type.
  8630. * @param defines the list of defines
  8631. * @param lightIndex defines the index of the light for the effect
  8632. */
  8633. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  8634. }
  8635. }
  8636. declare module BABYLON {
  8637. /** Defines supported spaces */
  8638. export enum Space {
  8639. /** Local (object) space */
  8640. LOCAL = 0,
  8641. /** World space */
  8642. WORLD = 1,
  8643. /** Bone space */
  8644. BONE = 2
  8645. }
  8646. /** Defines the 3 main axes */
  8647. export class Axis {
  8648. /** X axis */
  8649. static X: Vector3;
  8650. /** Y axis */
  8651. static Y: Vector3;
  8652. /** Z axis */
  8653. static Z: Vector3;
  8654. }
  8655. /**
  8656. * Defines cartesian components.
  8657. */
  8658. export enum Coordinate {
  8659. /** X axis */
  8660. X = 0,
  8661. /** Y axis */
  8662. Y = 1,
  8663. /** Z axis */
  8664. Z = 2
  8665. }
  8666. }
  8667. declare module BABYLON {
  8668. /**
  8669. * Interface describing all the common properties and methods a shadow light needs to implement.
  8670. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8671. * as well as binding the different shadow properties to the effects.
  8672. */
  8673. export interface IShadowLight extends Light {
  8674. /**
  8675. * The light id in the scene (used in scene.findLighById for instance)
  8676. */
  8677. id: string;
  8678. /**
  8679. * The position the shdow will be casted from.
  8680. */
  8681. position: Vector3;
  8682. /**
  8683. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8684. */
  8685. direction: Vector3;
  8686. /**
  8687. * The transformed position. Position of the light in world space taking parenting in account.
  8688. */
  8689. transformedPosition: Vector3;
  8690. /**
  8691. * The transformed direction. Direction of the light in world space taking parenting in account.
  8692. */
  8693. transformedDirection: Vector3;
  8694. /**
  8695. * The friendly name of the light in the scene.
  8696. */
  8697. name: string;
  8698. /**
  8699. * Defines the shadow projection clipping minimum z value.
  8700. */
  8701. shadowMinZ: number;
  8702. /**
  8703. * Defines the shadow projection clipping maximum z value.
  8704. */
  8705. shadowMaxZ: number;
  8706. /**
  8707. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8708. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8709. */
  8710. computeTransformedInformation(): boolean;
  8711. /**
  8712. * Gets the scene the light belongs to.
  8713. * @returns The scene
  8714. */
  8715. getScene(): Scene;
  8716. /**
  8717. * Callback defining a custom Projection Matrix Builder.
  8718. * This can be used to override the default projection matrix computation.
  8719. */
  8720. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8721. /**
  8722. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8723. * @param matrix The materix to updated with the projection information
  8724. * @param viewMatrix The transform matrix of the light
  8725. * @param renderList The list of mesh to render in the map
  8726. * @returns The current light
  8727. */
  8728. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8729. /**
  8730. * Gets the current depth scale used in ESM.
  8731. * @returns The scale
  8732. */
  8733. getDepthScale(): number;
  8734. /**
  8735. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8736. * @returns true if a cube texture needs to be use
  8737. */
  8738. needCube(): boolean;
  8739. /**
  8740. * Detects if the projection matrix requires to be recomputed this frame.
  8741. * @returns true if it requires to be recomputed otherwise, false.
  8742. */
  8743. needProjectionMatrixCompute(): boolean;
  8744. /**
  8745. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8746. */
  8747. forceProjectionMatrixCompute(): void;
  8748. /**
  8749. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8750. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8751. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8752. */
  8753. getShadowDirection(faceIndex?: number): Vector3;
  8754. /**
  8755. * Gets the minZ used for shadow according to both the scene and the light.
  8756. * @param activeCamera The camera we are returning the min for
  8757. * @returns the depth min z
  8758. */
  8759. getDepthMinZ(activeCamera: Camera): number;
  8760. /**
  8761. * Gets the maxZ used for shadow according to both the scene and the light.
  8762. * @param activeCamera The camera we are returning the max for
  8763. * @returns the depth max z
  8764. */
  8765. getDepthMaxZ(activeCamera: Camera): number;
  8766. }
  8767. /**
  8768. * Base implementation IShadowLight
  8769. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8770. */
  8771. export abstract class ShadowLight extends Light implements IShadowLight {
  8772. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8773. protected _position: Vector3;
  8774. protected _setPosition(value: Vector3): void;
  8775. /**
  8776. * Sets the position the shadow will be casted from. Also use as the light position for both
  8777. * point and spot lights.
  8778. */
  8779. get position(): Vector3;
  8780. /**
  8781. * Sets the position the shadow will be casted from. Also use as the light position for both
  8782. * point and spot lights.
  8783. */
  8784. set position(value: Vector3);
  8785. protected _direction: Vector3;
  8786. protected _setDirection(value: Vector3): void;
  8787. /**
  8788. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8789. * Also use as the light direction on spot and directional lights.
  8790. */
  8791. get direction(): Vector3;
  8792. /**
  8793. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8794. * Also use as the light direction on spot and directional lights.
  8795. */
  8796. set direction(value: Vector3);
  8797. protected _shadowMinZ: number;
  8798. /**
  8799. * Gets the shadow projection clipping minimum z value.
  8800. */
  8801. get shadowMinZ(): number;
  8802. /**
  8803. * Sets the shadow projection clipping minimum z value.
  8804. */
  8805. set shadowMinZ(value: number);
  8806. protected _shadowMaxZ: number;
  8807. /**
  8808. * Sets the shadow projection clipping maximum z value.
  8809. */
  8810. get shadowMaxZ(): number;
  8811. /**
  8812. * Gets the shadow projection clipping maximum z value.
  8813. */
  8814. set shadowMaxZ(value: number);
  8815. /**
  8816. * Callback defining a custom Projection Matrix Builder.
  8817. * This can be used to override the default projection matrix computation.
  8818. */
  8819. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8820. /**
  8821. * The transformed position. Position of the light in world space taking parenting in account.
  8822. */
  8823. transformedPosition: Vector3;
  8824. /**
  8825. * The transformed direction. Direction of the light in world space taking parenting in account.
  8826. */
  8827. transformedDirection: Vector3;
  8828. private _needProjectionMatrixCompute;
  8829. /**
  8830. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8831. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8832. */
  8833. computeTransformedInformation(): boolean;
  8834. /**
  8835. * Return the depth scale used for the shadow map.
  8836. * @returns the depth scale.
  8837. */
  8838. getDepthScale(): number;
  8839. /**
  8840. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8841. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8842. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8843. */
  8844. getShadowDirection(faceIndex?: number): Vector3;
  8845. /**
  8846. * Returns the ShadowLight absolute position in the World.
  8847. * @returns the position vector in world space
  8848. */
  8849. getAbsolutePosition(): Vector3;
  8850. /**
  8851. * Sets the ShadowLight direction toward the passed target.
  8852. * @param target The point to target in local space
  8853. * @returns the updated ShadowLight direction
  8854. */
  8855. setDirectionToTarget(target: Vector3): Vector3;
  8856. /**
  8857. * Returns the light rotation in euler definition.
  8858. * @returns the x y z rotation in local space.
  8859. */
  8860. getRotation(): Vector3;
  8861. /**
  8862. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8863. * @returns true if a cube texture needs to be use
  8864. */
  8865. needCube(): boolean;
  8866. /**
  8867. * Detects if the projection matrix requires to be recomputed this frame.
  8868. * @returns true if it requires to be recomputed otherwise, false.
  8869. */
  8870. needProjectionMatrixCompute(): boolean;
  8871. /**
  8872. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8873. */
  8874. forceProjectionMatrixCompute(): void;
  8875. /** @hidden */
  8876. _initCache(): void;
  8877. /** @hidden */
  8878. _isSynchronized(): boolean;
  8879. /**
  8880. * Computes the world matrix of the node
  8881. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8882. * @returns the world matrix
  8883. */
  8884. computeWorldMatrix(force?: boolean): Matrix;
  8885. /**
  8886. * Gets the minZ used for shadow according to both the scene and the light.
  8887. * @param activeCamera The camera we are returning the min for
  8888. * @returns the depth min z
  8889. */
  8890. getDepthMinZ(activeCamera: Camera): number;
  8891. /**
  8892. * Gets the maxZ used for shadow according to both the scene and the light.
  8893. * @param activeCamera The camera we are returning the max for
  8894. * @returns the depth max z
  8895. */
  8896. getDepthMaxZ(activeCamera: Camera): number;
  8897. /**
  8898. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8899. * @param matrix The materix to updated with the projection information
  8900. * @param viewMatrix The transform matrix of the light
  8901. * @param renderList The list of mesh to render in the map
  8902. * @returns The current light
  8903. */
  8904. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8905. }
  8906. }
  8907. declare module BABYLON {
  8908. /**
  8909. * Configuration needed for prepass-capable materials
  8910. */
  8911. export class PrePassConfiguration {
  8912. /**
  8913. * Previous world matrices of meshes carrying this material
  8914. * Used for computing velocity
  8915. */
  8916. previousWorldMatrices: {
  8917. [index: number]: Matrix;
  8918. };
  8919. /**
  8920. * Previous view project matrix
  8921. * Used for computing velocity
  8922. */
  8923. previousViewProjection: Matrix;
  8924. /**
  8925. * Previous bones of meshes carrying this material
  8926. * Used for computing velocity
  8927. */
  8928. previousBones: {
  8929. [index: number]: Float32Array;
  8930. };
  8931. /**
  8932. * Add the required uniforms to the current list.
  8933. * @param uniforms defines the current uniform list.
  8934. */
  8935. static AddUniforms(uniforms: string[]): void;
  8936. /**
  8937. * Add the required samplers to the current list.
  8938. * @param samplers defines the current sampler list.
  8939. */
  8940. static AddSamplers(samplers: string[]): void;
  8941. /**
  8942. * Binds the material data.
  8943. * @param effect defines the effect to update
  8944. * @param scene defines the scene the material belongs to.
  8945. * @param mesh The mesh
  8946. * @param world World matrix of this mesh
  8947. * @param isFrozen Is the material frozen
  8948. */
  8949. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  8950. }
  8951. }
  8952. declare module BABYLON {
  8953. /**
  8954. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8955. * This is the base of the follow, arc rotate cameras and Free camera
  8956. * @see https://doc.babylonjs.com/features/cameras
  8957. */
  8958. export class TargetCamera extends Camera {
  8959. private static _RigCamTransformMatrix;
  8960. private static _TargetTransformMatrix;
  8961. private static _TargetFocalPoint;
  8962. private _tmpUpVector;
  8963. private _tmpTargetVector;
  8964. /**
  8965. * Define the current direction the camera is moving to
  8966. */
  8967. cameraDirection: Vector3;
  8968. /**
  8969. * Define the current rotation the camera is rotating to
  8970. */
  8971. cameraRotation: Vector2;
  8972. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  8973. ignoreParentScaling: boolean;
  8974. /**
  8975. * When set, the up vector of the camera will be updated by the rotation of the camera
  8976. */
  8977. updateUpVectorFromRotation: boolean;
  8978. private _tmpQuaternion;
  8979. /**
  8980. * Define the current rotation of the camera
  8981. */
  8982. rotation: Vector3;
  8983. /**
  8984. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8985. */
  8986. rotationQuaternion: Quaternion;
  8987. /**
  8988. * Define the current speed of the camera
  8989. */
  8990. speed: number;
  8991. /**
  8992. * Add constraint to the camera to prevent it to move freely in all directions and
  8993. * around all axis.
  8994. */
  8995. noRotationConstraint: boolean;
  8996. /**
  8997. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8998. * panning
  8999. */
  9000. invertRotation: boolean;
  9001. /**
  9002. * Speed multiplier for inverse camera panning
  9003. */
  9004. inverseRotationSpeed: number;
  9005. /**
  9006. * Define the current target of the camera as an object or a position.
  9007. */
  9008. lockedTarget: any;
  9009. /** @hidden */
  9010. _currentTarget: Vector3;
  9011. /** @hidden */
  9012. _initialFocalDistance: number;
  9013. /** @hidden */
  9014. _viewMatrix: Matrix;
  9015. /** @hidden */
  9016. _camMatrix: Matrix;
  9017. /** @hidden */
  9018. _cameraTransformMatrix: Matrix;
  9019. /** @hidden */
  9020. _cameraRotationMatrix: Matrix;
  9021. /** @hidden */
  9022. _referencePoint: Vector3;
  9023. /** @hidden */
  9024. _transformedReferencePoint: Vector3;
  9025. /** @hidden */
  9026. _reset: () => void;
  9027. private _defaultUp;
  9028. /**
  9029. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  9030. * This is the base of the follow, arc rotate cameras and Free camera
  9031. * @see https://doc.babylonjs.com/features/cameras
  9032. * @param name Defines the name of the camera in the scene
  9033. * @param position Defines the start position of the camera in the scene
  9034. * @param scene Defines the scene the camera belongs to
  9035. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  9036. */
  9037. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9038. /**
  9039. * Gets the position in front of the camera at a given distance.
  9040. * @param distance The distance from the camera we want the position to be
  9041. * @returns the position
  9042. */
  9043. getFrontPosition(distance: number): Vector3;
  9044. /** @hidden */
  9045. _getLockedTargetPosition(): Nullable<Vector3>;
  9046. private _storedPosition;
  9047. private _storedRotation;
  9048. private _storedRotationQuaternion;
  9049. /**
  9050. * Store current camera state of the camera (fov, position, rotation, etc..)
  9051. * @returns the camera
  9052. */
  9053. storeState(): Camera;
  9054. /**
  9055. * Restored camera state. You must call storeState() first
  9056. * @returns whether it was successful or not
  9057. * @hidden
  9058. */
  9059. _restoreStateValues(): boolean;
  9060. /** @hidden */
  9061. _initCache(): void;
  9062. /** @hidden */
  9063. _updateCache(ignoreParentClass?: boolean): void;
  9064. /** @hidden */
  9065. _isSynchronizedViewMatrix(): boolean;
  9066. /** @hidden */
  9067. _computeLocalCameraSpeed(): number;
  9068. /**
  9069. * Defines the target the camera should look at.
  9070. * @param target Defines the new target as a Vector or a mesh
  9071. */
  9072. setTarget(target: Vector3): void;
  9073. /**
  9074. * Defines the target point of the camera.
  9075. * The camera looks towards it form the radius distance.
  9076. */
  9077. get target(): Vector3;
  9078. set target(value: Vector3);
  9079. /**
  9080. * Return the current target position of the camera. This value is expressed in local space.
  9081. * @returns the target position
  9082. */
  9083. getTarget(): Vector3;
  9084. /** @hidden */
  9085. _decideIfNeedsToMove(): boolean;
  9086. /** @hidden */
  9087. _updatePosition(): void;
  9088. /** @hidden */
  9089. _checkInputs(): void;
  9090. protected _updateCameraRotationMatrix(): void;
  9091. /**
  9092. * 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)
  9093. * @returns the current camera
  9094. */
  9095. private _rotateUpVectorWithCameraRotationMatrix;
  9096. private _cachedRotationZ;
  9097. private _cachedQuaternionRotationZ;
  9098. /** @hidden */
  9099. _getViewMatrix(): Matrix;
  9100. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  9101. /**
  9102. * @hidden
  9103. */
  9104. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  9105. /**
  9106. * @hidden
  9107. */
  9108. _updateRigCameras(): void;
  9109. private _getRigCamPositionAndTarget;
  9110. /**
  9111. * Gets the current object class name.
  9112. * @return the class name
  9113. */
  9114. getClassName(): string;
  9115. }
  9116. }
  9117. declare module BABYLON {
  9118. /**
  9119. * @ignore
  9120. * This is a list of all the different input types that are available in the application.
  9121. * Fo instance: ArcRotateCameraGamepadInput...
  9122. */
  9123. export var CameraInputTypes: {};
  9124. /**
  9125. * This is the contract to implement in order to create a new input class.
  9126. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  9127. */
  9128. export interface ICameraInput<TCamera extends Camera> {
  9129. /**
  9130. * Defines the camera the input is attached to.
  9131. */
  9132. camera: Nullable<TCamera>;
  9133. /**
  9134. * Gets the class name of the current intput.
  9135. * @returns the class name
  9136. */
  9137. getClassName(): string;
  9138. /**
  9139. * Get the friendly name associated with the input class.
  9140. * @returns the input friendly name
  9141. */
  9142. getSimpleName(): string;
  9143. /**
  9144. * Attach the input controls to a specific dom element to get the input from.
  9145. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9146. */
  9147. attachControl(noPreventDefault?: boolean): void;
  9148. /**
  9149. * Detach the current controls from the specified dom element.
  9150. */
  9151. detachControl(): void;
  9152. /**
  9153. * Update the current camera state depending on the inputs that have been used this frame.
  9154. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9155. */
  9156. checkInputs?: () => void;
  9157. }
  9158. /**
  9159. * Represents a map of input types to input instance or input index to input instance.
  9160. */
  9161. export interface CameraInputsMap<TCamera extends Camera> {
  9162. /**
  9163. * Accessor to the input by input type.
  9164. */
  9165. [name: string]: ICameraInput<TCamera>;
  9166. /**
  9167. * Accessor to the input by input index.
  9168. */
  9169. [idx: number]: ICameraInput<TCamera>;
  9170. }
  9171. /**
  9172. * This represents the input manager used within a camera.
  9173. * It helps dealing with all the different kind of input attached to a camera.
  9174. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9175. */
  9176. export class CameraInputsManager<TCamera extends Camera> {
  9177. /**
  9178. * Defines the list of inputs attahed to the camera.
  9179. */
  9180. attached: CameraInputsMap<TCamera>;
  9181. /**
  9182. * Defines the dom element the camera is collecting inputs from.
  9183. * This is null if the controls have not been attached.
  9184. */
  9185. attachedToElement: boolean;
  9186. /**
  9187. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9188. */
  9189. noPreventDefault: boolean;
  9190. /**
  9191. * Defined the camera the input manager belongs to.
  9192. */
  9193. camera: TCamera;
  9194. /**
  9195. * Update the current camera state depending on the inputs that have been used this frame.
  9196. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9197. */
  9198. checkInputs: () => void;
  9199. /**
  9200. * Instantiate a new Camera Input Manager.
  9201. * @param camera Defines the camera the input manager blongs to
  9202. */
  9203. constructor(camera: TCamera);
  9204. /**
  9205. * Add an input method to a camera
  9206. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9207. * @param input camera input method
  9208. */
  9209. add(input: ICameraInput<TCamera>): void;
  9210. /**
  9211. * Remove a specific input method from a camera
  9212. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  9213. * @param inputToRemove camera input method
  9214. */
  9215. remove(inputToRemove: ICameraInput<TCamera>): void;
  9216. /**
  9217. * Remove a specific input type from a camera
  9218. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  9219. * @param inputType the type of the input to remove
  9220. */
  9221. removeByType(inputType: string): void;
  9222. private _addCheckInputs;
  9223. /**
  9224. * Attach the input controls to the currently attached dom element to listen the events from.
  9225. * @param input Defines the input to attach
  9226. */
  9227. attachInput(input: ICameraInput<TCamera>): void;
  9228. /**
  9229. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  9230. * @param element Defines the dom element to collect the events from
  9231. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9232. */
  9233. attachElement(noPreventDefault?: boolean): void;
  9234. /**
  9235. * Detach the current manager inputs controls from a specific dom element.
  9236. * @param element Defines the dom element to collect the events from
  9237. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  9238. */
  9239. detachElement(disconnect?: boolean): void;
  9240. /**
  9241. * Rebuild the dynamic inputCheck function from the current list of
  9242. * defined inputs in the manager.
  9243. */
  9244. rebuildInputCheck(): void;
  9245. /**
  9246. * Remove all attached input methods from a camera
  9247. */
  9248. clear(): void;
  9249. /**
  9250. * Serialize the current input manager attached to a camera.
  9251. * This ensures than once parsed,
  9252. * the input associated to the camera will be identical to the current ones
  9253. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9254. */
  9255. serialize(serializedCamera: any): void;
  9256. /**
  9257. * Parses an input manager serialized JSON to restore the previous list of inputs
  9258. * and states associated to a camera.
  9259. * @param parsedCamera Defines the JSON to parse
  9260. */
  9261. parse(parsedCamera: any): void;
  9262. }
  9263. }
  9264. declare module BABYLON {
  9265. /**
  9266. * Gather the list of keyboard event types as constants.
  9267. */
  9268. export class KeyboardEventTypes {
  9269. /**
  9270. * The keydown event is fired when a key becomes active (pressed).
  9271. */
  9272. static readonly KEYDOWN: number;
  9273. /**
  9274. * The keyup event is fired when a key has been released.
  9275. */
  9276. static readonly KEYUP: number;
  9277. }
  9278. /**
  9279. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9280. */
  9281. export class KeyboardInfo {
  9282. /**
  9283. * Defines the type of event (KeyboardEventTypes)
  9284. */
  9285. type: number;
  9286. /**
  9287. * Defines the related dom event
  9288. */
  9289. event: KeyboardEvent;
  9290. /**
  9291. * Instantiates a new keyboard info.
  9292. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9293. * @param type Defines the type of event (KeyboardEventTypes)
  9294. * @param event Defines the related dom event
  9295. */
  9296. constructor(
  9297. /**
  9298. * Defines the type of event (KeyboardEventTypes)
  9299. */
  9300. type: number,
  9301. /**
  9302. * Defines the related dom event
  9303. */
  9304. event: KeyboardEvent);
  9305. }
  9306. /**
  9307. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9308. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9309. */
  9310. export class KeyboardInfoPre extends KeyboardInfo {
  9311. /**
  9312. * Defines the type of event (KeyboardEventTypes)
  9313. */
  9314. type: number;
  9315. /**
  9316. * Defines the related dom event
  9317. */
  9318. event: KeyboardEvent;
  9319. /**
  9320. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9321. */
  9322. skipOnPointerObservable: boolean;
  9323. /**
  9324. * Instantiates a new keyboard pre info.
  9325. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9326. * @param type Defines the type of event (KeyboardEventTypes)
  9327. * @param event Defines the related dom event
  9328. */
  9329. constructor(
  9330. /**
  9331. * Defines the type of event (KeyboardEventTypes)
  9332. */
  9333. type: number,
  9334. /**
  9335. * Defines the related dom event
  9336. */
  9337. event: KeyboardEvent);
  9338. }
  9339. }
  9340. declare module BABYLON {
  9341. /**
  9342. * Manage the keyboard inputs to control the movement of a free camera.
  9343. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9344. */
  9345. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9346. /**
  9347. * Defines the camera the input is attached to.
  9348. */
  9349. camera: FreeCamera;
  9350. /**
  9351. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9352. */
  9353. keysUp: number[];
  9354. /**
  9355. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  9356. */
  9357. keysUpward: number[];
  9358. /**
  9359. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9360. */
  9361. keysDown: number[];
  9362. /**
  9363. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  9364. */
  9365. keysDownward: number[];
  9366. /**
  9367. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9368. */
  9369. keysLeft: number[];
  9370. /**
  9371. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9372. */
  9373. keysRight: number[];
  9374. private _keys;
  9375. private _onCanvasBlurObserver;
  9376. private _onKeyboardObserver;
  9377. private _engine;
  9378. private _scene;
  9379. /**
  9380. * Attach the input controls to a specific dom element to get the input from.
  9381. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9382. */
  9383. attachControl(noPreventDefault?: boolean): void;
  9384. /**
  9385. * Detach the current controls from the specified dom element.
  9386. */
  9387. detachControl(): void;
  9388. /**
  9389. * Update the current camera state depending on the inputs that have been used this frame.
  9390. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9391. */
  9392. checkInputs(): void;
  9393. /**
  9394. * Gets the class name of the current intput.
  9395. * @returns the class name
  9396. */
  9397. getClassName(): string;
  9398. /** @hidden */
  9399. _onLostFocus(): void;
  9400. /**
  9401. * Get the friendly name associated with the input class.
  9402. * @returns the input friendly name
  9403. */
  9404. getSimpleName(): string;
  9405. }
  9406. }
  9407. declare module BABYLON {
  9408. /**
  9409. * Interface used to define Action
  9410. */
  9411. export interface IAction {
  9412. /**
  9413. * Trigger for the action
  9414. */
  9415. trigger: number;
  9416. /** Options of the trigger */
  9417. triggerOptions: any;
  9418. /**
  9419. * Gets the trigger parameters
  9420. * @returns the trigger parameters
  9421. */
  9422. getTriggerParameter(): any;
  9423. /**
  9424. * Internal only - executes current action event
  9425. * @hidden
  9426. */
  9427. _executeCurrent(evt?: ActionEvent): void;
  9428. /**
  9429. * Serialize placeholder for child classes
  9430. * @param parent of child
  9431. * @returns the serialized object
  9432. */
  9433. serialize(parent: any): any;
  9434. /**
  9435. * Internal only
  9436. * @hidden
  9437. */
  9438. _prepare(): void;
  9439. /**
  9440. * Internal only - manager for action
  9441. * @hidden
  9442. */
  9443. _actionManager: Nullable<AbstractActionManager>;
  9444. /**
  9445. * Adds action to chain of actions, may be a DoNothingAction
  9446. * @param action defines the next action to execute
  9447. * @returns The action passed in
  9448. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9449. */
  9450. then(action: IAction): IAction;
  9451. }
  9452. /**
  9453. * The action to be carried out following a trigger
  9454. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9455. */
  9456. export class Action implements IAction {
  9457. /** the trigger, with or without parameters, for the action */
  9458. triggerOptions: any;
  9459. /**
  9460. * Trigger for the action
  9461. */
  9462. trigger: number;
  9463. /**
  9464. * Internal only - manager for action
  9465. * @hidden
  9466. */
  9467. _actionManager: ActionManager;
  9468. private _nextActiveAction;
  9469. private _child;
  9470. private _condition?;
  9471. private _triggerParameter;
  9472. /**
  9473. * An event triggered prior to action being executed.
  9474. */
  9475. onBeforeExecuteObservable: Observable<Action>;
  9476. /**
  9477. * Creates a new Action
  9478. * @param triggerOptions the trigger, with or without parameters, for the action
  9479. * @param condition an optional determinant of action
  9480. */
  9481. constructor(
  9482. /** the trigger, with or without parameters, for the action */
  9483. triggerOptions: any, condition?: Condition);
  9484. /**
  9485. * Internal only
  9486. * @hidden
  9487. */
  9488. _prepare(): void;
  9489. /**
  9490. * Gets the trigger parameters
  9491. * @returns the trigger parameters
  9492. */
  9493. getTriggerParameter(): any;
  9494. /**
  9495. * Internal only - executes current action event
  9496. * @hidden
  9497. */
  9498. _executeCurrent(evt?: ActionEvent): void;
  9499. /**
  9500. * Execute placeholder for child classes
  9501. * @param evt optional action event
  9502. */
  9503. execute(evt?: ActionEvent): void;
  9504. /**
  9505. * Skips to next active action
  9506. */
  9507. skipToNextActiveAction(): void;
  9508. /**
  9509. * Adds action to chain of actions, may be a DoNothingAction
  9510. * @param action defines the next action to execute
  9511. * @returns The action passed in
  9512. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9513. */
  9514. then(action: Action): Action;
  9515. /**
  9516. * Internal only
  9517. * @hidden
  9518. */
  9519. _getProperty(propertyPath: string): string;
  9520. /**
  9521. * Internal only
  9522. * @hidden
  9523. */
  9524. _getEffectiveTarget(target: any, propertyPath: string): any;
  9525. /**
  9526. * Serialize placeholder for child classes
  9527. * @param parent of child
  9528. * @returns the serialized object
  9529. */
  9530. serialize(parent: any): any;
  9531. /**
  9532. * Internal only called by serialize
  9533. * @hidden
  9534. */
  9535. protected _serialize(serializedAction: any, parent?: any): any;
  9536. /**
  9537. * Internal only
  9538. * @hidden
  9539. */
  9540. static _SerializeValueAsString: (value: any) => string;
  9541. /**
  9542. * Internal only
  9543. * @hidden
  9544. */
  9545. static _GetTargetProperty: (target: Scene | Node) => {
  9546. name: string;
  9547. targetType: string;
  9548. value: string;
  9549. };
  9550. }
  9551. }
  9552. declare module BABYLON {
  9553. /**
  9554. * A Condition applied to an Action
  9555. */
  9556. export class Condition {
  9557. /**
  9558. * Internal only - manager for action
  9559. * @hidden
  9560. */
  9561. _actionManager: ActionManager;
  9562. /**
  9563. * Internal only
  9564. * @hidden
  9565. */
  9566. _evaluationId: number;
  9567. /**
  9568. * Internal only
  9569. * @hidden
  9570. */
  9571. _currentResult: boolean;
  9572. /**
  9573. * Creates a new Condition
  9574. * @param actionManager the manager of the action the condition is applied to
  9575. */
  9576. constructor(actionManager: ActionManager);
  9577. /**
  9578. * Check if the current condition is valid
  9579. * @returns a boolean
  9580. */
  9581. isValid(): boolean;
  9582. /**
  9583. * Internal only
  9584. * @hidden
  9585. */
  9586. _getProperty(propertyPath: string): string;
  9587. /**
  9588. * Internal only
  9589. * @hidden
  9590. */
  9591. _getEffectiveTarget(target: any, propertyPath: string): any;
  9592. /**
  9593. * Serialize placeholder for child classes
  9594. * @returns the serialized object
  9595. */
  9596. serialize(): any;
  9597. /**
  9598. * Internal only
  9599. * @hidden
  9600. */
  9601. protected _serialize(serializedCondition: any): any;
  9602. }
  9603. /**
  9604. * Defines specific conditional operators as extensions of Condition
  9605. */
  9606. export class ValueCondition extends Condition {
  9607. /** path to specify the property of the target the conditional operator uses */
  9608. propertyPath: string;
  9609. /** the value compared by the conditional operator against the current value of the property */
  9610. value: any;
  9611. /** the conditional operator, default ValueCondition.IsEqual */
  9612. operator: number;
  9613. /**
  9614. * Internal only
  9615. * @hidden
  9616. */
  9617. private static _IsEqual;
  9618. /**
  9619. * Internal only
  9620. * @hidden
  9621. */
  9622. private static _IsDifferent;
  9623. /**
  9624. * Internal only
  9625. * @hidden
  9626. */
  9627. private static _IsGreater;
  9628. /**
  9629. * Internal only
  9630. * @hidden
  9631. */
  9632. private static _IsLesser;
  9633. /**
  9634. * returns the number for IsEqual
  9635. */
  9636. static get IsEqual(): number;
  9637. /**
  9638. * Returns the number for IsDifferent
  9639. */
  9640. static get IsDifferent(): number;
  9641. /**
  9642. * Returns the number for IsGreater
  9643. */
  9644. static get IsGreater(): number;
  9645. /**
  9646. * Returns the number for IsLesser
  9647. */
  9648. static get IsLesser(): number;
  9649. /**
  9650. * Internal only The action manager for the condition
  9651. * @hidden
  9652. */
  9653. _actionManager: ActionManager;
  9654. /**
  9655. * Internal only
  9656. * @hidden
  9657. */
  9658. private _target;
  9659. /**
  9660. * Internal only
  9661. * @hidden
  9662. */
  9663. private _effectiveTarget;
  9664. /**
  9665. * Internal only
  9666. * @hidden
  9667. */
  9668. private _property;
  9669. /**
  9670. * Creates a new ValueCondition
  9671. * @param actionManager manager for the action the condition applies to
  9672. * @param target for the action
  9673. * @param propertyPath path to specify the property of the target the conditional operator uses
  9674. * @param value the value compared by the conditional operator against the current value of the property
  9675. * @param operator the conditional operator, default ValueCondition.IsEqual
  9676. */
  9677. constructor(actionManager: ActionManager, target: any,
  9678. /** path to specify the property of the target the conditional operator uses */
  9679. propertyPath: string,
  9680. /** the value compared by the conditional operator against the current value of the property */
  9681. value: any,
  9682. /** the conditional operator, default ValueCondition.IsEqual */
  9683. operator?: number);
  9684. /**
  9685. * Compares the given value with the property value for the specified conditional operator
  9686. * @returns the result of the comparison
  9687. */
  9688. isValid(): boolean;
  9689. /**
  9690. * Serialize the ValueCondition into a JSON compatible object
  9691. * @returns serialization object
  9692. */
  9693. serialize(): any;
  9694. /**
  9695. * Gets the name of the conditional operator for the ValueCondition
  9696. * @param operator the conditional operator
  9697. * @returns the name
  9698. */
  9699. static GetOperatorName(operator: number): string;
  9700. }
  9701. /**
  9702. * Defines a predicate condition as an extension of Condition
  9703. */
  9704. export class PredicateCondition extends Condition {
  9705. /** defines the predicate function used to validate the condition */
  9706. predicate: () => boolean;
  9707. /**
  9708. * Internal only - manager for action
  9709. * @hidden
  9710. */
  9711. _actionManager: ActionManager;
  9712. /**
  9713. * Creates a new PredicateCondition
  9714. * @param actionManager manager for the action the condition applies to
  9715. * @param predicate defines the predicate function used to validate the condition
  9716. */
  9717. constructor(actionManager: ActionManager,
  9718. /** defines the predicate function used to validate the condition */
  9719. predicate: () => boolean);
  9720. /**
  9721. * @returns the validity of the predicate condition
  9722. */
  9723. isValid(): boolean;
  9724. }
  9725. /**
  9726. * Defines a state condition as an extension of Condition
  9727. */
  9728. export class StateCondition extends Condition {
  9729. /** Value to compare with target state */
  9730. value: string;
  9731. /**
  9732. * Internal only - manager for action
  9733. * @hidden
  9734. */
  9735. _actionManager: ActionManager;
  9736. /**
  9737. * Internal only
  9738. * @hidden
  9739. */
  9740. private _target;
  9741. /**
  9742. * Creates a new StateCondition
  9743. * @param actionManager manager for the action the condition applies to
  9744. * @param target of the condition
  9745. * @param value to compare with target state
  9746. */
  9747. constructor(actionManager: ActionManager, target: any,
  9748. /** Value to compare with target state */
  9749. value: string);
  9750. /**
  9751. * Gets a boolean indicating if the current condition is met
  9752. * @returns the validity of the state
  9753. */
  9754. isValid(): boolean;
  9755. /**
  9756. * Serialize the StateCondition into a JSON compatible object
  9757. * @returns serialization object
  9758. */
  9759. serialize(): any;
  9760. }
  9761. }
  9762. declare module BABYLON {
  9763. /**
  9764. * This defines an action responsible to toggle a boolean once triggered.
  9765. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9766. */
  9767. export class SwitchBooleanAction extends Action {
  9768. /**
  9769. * The path to the boolean property in the target object
  9770. */
  9771. propertyPath: string;
  9772. private _target;
  9773. private _effectiveTarget;
  9774. private _property;
  9775. /**
  9776. * Instantiate the action
  9777. * @param triggerOptions defines the trigger options
  9778. * @param target defines the object containing the boolean
  9779. * @param propertyPath defines the path to the boolean property in the target object
  9780. * @param condition defines the trigger related conditions
  9781. */
  9782. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9783. /** @hidden */
  9784. _prepare(): void;
  9785. /**
  9786. * Execute the action toggle the boolean value.
  9787. */
  9788. execute(): void;
  9789. /**
  9790. * Serializes the actions and its related information.
  9791. * @param parent defines the object to serialize in
  9792. * @returns the serialized object
  9793. */
  9794. serialize(parent: any): any;
  9795. }
  9796. /**
  9797. * This defines an action responsible to set a the state field of the target
  9798. * to a desired value once triggered.
  9799. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9800. */
  9801. export class SetStateAction extends Action {
  9802. /**
  9803. * The value to store in the state field.
  9804. */
  9805. value: string;
  9806. private _target;
  9807. /**
  9808. * Instantiate the action
  9809. * @param triggerOptions defines the trigger options
  9810. * @param target defines the object containing the state property
  9811. * @param value defines the value to store in the state field
  9812. * @param condition defines the trigger related conditions
  9813. */
  9814. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9815. /**
  9816. * Execute the action and store the value on the target state property.
  9817. */
  9818. execute(): void;
  9819. /**
  9820. * Serializes the actions and its related information.
  9821. * @param parent defines the object to serialize in
  9822. * @returns the serialized object
  9823. */
  9824. serialize(parent: any): any;
  9825. }
  9826. /**
  9827. * This defines an action responsible to set a property of the target
  9828. * to a desired value once triggered.
  9829. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9830. */
  9831. export class SetValueAction extends Action {
  9832. /**
  9833. * The path of the property to set in the target.
  9834. */
  9835. propertyPath: string;
  9836. /**
  9837. * The value to set in the property
  9838. */
  9839. value: any;
  9840. private _target;
  9841. private _effectiveTarget;
  9842. private _property;
  9843. /**
  9844. * Instantiate the action
  9845. * @param triggerOptions defines the trigger options
  9846. * @param target defines the object containing the property
  9847. * @param propertyPath defines the path of the property to set in the target
  9848. * @param value defines the value to set in the property
  9849. * @param condition defines the trigger related conditions
  9850. */
  9851. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9852. /** @hidden */
  9853. _prepare(): void;
  9854. /**
  9855. * Execute the action and set the targetted property to the desired value.
  9856. */
  9857. execute(): void;
  9858. /**
  9859. * Serializes the actions and its related information.
  9860. * @param parent defines the object to serialize in
  9861. * @returns the serialized object
  9862. */
  9863. serialize(parent: any): any;
  9864. }
  9865. /**
  9866. * This defines an action responsible to increment the target value
  9867. * to a desired value once triggered.
  9868. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9869. */
  9870. export class IncrementValueAction extends Action {
  9871. /**
  9872. * The path of the property to increment in the target.
  9873. */
  9874. propertyPath: string;
  9875. /**
  9876. * The value we should increment the property by.
  9877. */
  9878. value: any;
  9879. private _target;
  9880. private _effectiveTarget;
  9881. private _property;
  9882. /**
  9883. * Instantiate the action
  9884. * @param triggerOptions defines the trigger options
  9885. * @param target defines the object containing the property
  9886. * @param propertyPath defines the path of the property to increment in the target
  9887. * @param value defines the value value we should increment the property by
  9888. * @param condition defines the trigger related conditions
  9889. */
  9890. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9891. /** @hidden */
  9892. _prepare(): void;
  9893. /**
  9894. * Execute the action and increment the target of the value amount.
  9895. */
  9896. execute(): void;
  9897. /**
  9898. * Serializes the actions and its related information.
  9899. * @param parent defines the object to serialize in
  9900. * @returns the serialized object
  9901. */
  9902. serialize(parent: any): any;
  9903. }
  9904. /**
  9905. * This defines an action responsible to start an animation once triggered.
  9906. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9907. */
  9908. export class PlayAnimationAction extends Action {
  9909. /**
  9910. * Where the animation should start (animation frame)
  9911. */
  9912. from: number;
  9913. /**
  9914. * Where the animation should stop (animation frame)
  9915. */
  9916. to: number;
  9917. /**
  9918. * Define if the animation should loop or stop after the first play.
  9919. */
  9920. loop?: boolean;
  9921. private _target;
  9922. /**
  9923. * Instantiate the action
  9924. * @param triggerOptions defines the trigger options
  9925. * @param target defines the target animation or animation name
  9926. * @param from defines from where the animation should start (animation frame)
  9927. * @param end defines where the animation should stop (animation frame)
  9928. * @param loop defines if the animation should loop or stop after the first play
  9929. * @param condition defines the trigger related conditions
  9930. */
  9931. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9932. /** @hidden */
  9933. _prepare(): void;
  9934. /**
  9935. * Execute the action and play the animation.
  9936. */
  9937. execute(): void;
  9938. /**
  9939. * Serializes the actions and its related information.
  9940. * @param parent defines the object to serialize in
  9941. * @returns the serialized object
  9942. */
  9943. serialize(parent: any): any;
  9944. }
  9945. /**
  9946. * This defines an action responsible to stop an animation once triggered.
  9947. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9948. */
  9949. export class StopAnimationAction extends Action {
  9950. private _target;
  9951. /**
  9952. * Instantiate the action
  9953. * @param triggerOptions defines the trigger options
  9954. * @param target defines the target animation or animation name
  9955. * @param condition defines the trigger related conditions
  9956. */
  9957. constructor(triggerOptions: any, target: any, condition?: Condition);
  9958. /** @hidden */
  9959. _prepare(): void;
  9960. /**
  9961. * Execute the action and stop the animation.
  9962. */
  9963. execute(): void;
  9964. /**
  9965. * Serializes the actions and its related information.
  9966. * @param parent defines the object to serialize in
  9967. * @returns the serialized object
  9968. */
  9969. serialize(parent: any): any;
  9970. }
  9971. /**
  9972. * This defines an action responsible that does nothing once triggered.
  9973. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9974. */
  9975. export class DoNothingAction extends Action {
  9976. /**
  9977. * Instantiate the action
  9978. * @param triggerOptions defines the trigger options
  9979. * @param condition defines the trigger related conditions
  9980. */
  9981. constructor(triggerOptions?: any, condition?: Condition);
  9982. /**
  9983. * Execute the action and do nothing.
  9984. */
  9985. execute(): void;
  9986. /**
  9987. * Serializes the actions and its related information.
  9988. * @param parent defines the object to serialize in
  9989. * @returns the serialized object
  9990. */
  9991. serialize(parent: any): any;
  9992. }
  9993. /**
  9994. * This defines an action responsible to trigger several actions once triggered.
  9995. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9996. */
  9997. export class CombineAction extends Action {
  9998. /**
  9999. * The list of aggregated animations to run.
  10000. */
  10001. children: Action[];
  10002. /**
  10003. * Instantiate the action
  10004. * @param triggerOptions defines the trigger options
  10005. * @param children defines the list of aggregated animations to run
  10006. * @param condition defines the trigger related conditions
  10007. */
  10008. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10009. /** @hidden */
  10010. _prepare(): void;
  10011. /**
  10012. * Execute the action and executes all the aggregated actions.
  10013. */
  10014. execute(evt: ActionEvent): void;
  10015. /**
  10016. * Serializes the actions and its related information.
  10017. * @param parent defines the object to serialize in
  10018. * @returns the serialized object
  10019. */
  10020. serialize(parent: any): any;
  10021. }
  10022. /**
  10023. * This defines an action responsible to run code (external event) once triggered.
  10024. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10025. */
  10026. export class ExecuteCodeAction extends Action {
  10027. /**
  10028. * The callback function to run.
  10029. */
  10030. func: (evt: ActionEvent) => void;
  10031. /**
  10032. * Instantiate the action
  10033. * @param triggerOptions defines the trigger options
  10034. * @param func defines the callback function to run
  10035. * @param condition defines the trigger related conditions
  10036. */
  10037. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10038. /**
  10039. * Execute the action and run the attached code.
  10040. */
  10041. execute(evt: ActionEvent): void;
  10042. }
  10043. /**
  10044. * This defines an action responsible to set the parent property of the target once triggered.
  10045. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10046. */
  10047. export class SetParentAction extends Action {
  10048. private _parent;
  10049. private _target;
  10050. /**
  10051. * Instantiate the action
  10052. * @param triggerOptions defines the trigger options
  10053. * @param target defines the target containing the parent property
  10054. * @param parent defines from where the animation should start (animation frame)
  10055. * @param condition defines the trigger related conditions
  10056. */
  10057. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10058. /** @hidden */
  10059. _prepare(): void;
  10060. /**
  10061. * Execute the action and set the parent property.
  10062. */
  10063. execute(): void;
  10064. /**
  10065. * Serializes the actions and its related information.
  10066. * @param parent defines the object to serialize in
  10067. * @returns the serialized object
  10068. */
  10069. serialize(parent: any): any;
  10070. }
  10071. }
  10072. declare module BABYLON {
  10073. /**
  10074. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10075. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10076. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10077. */
  10078. export class ActionManager extends AbstractActionManager {
  10079. /**
  10080. * Nothing
  10081. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10082. */
  10083. static readonly NothingTrigger: number;
  10084. /**
  10085. * On pick
  10086. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10087. */
  10088. static readonly OnPickTrigger: number;
  10089. /**
  10090. * On left pick
  10091. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10092. */
  10093. static readonly OnLeftPickTrigger: number;
  10094. /**
  10095. * On right pick
  10096. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10097. */
  10098. static readonly OnRightPickTrigger: number;
  10099. /**
  10100. * On center pick
  10101. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10102. */
  10103. static readonly OnCenterPickTrigger: number;
  10104. /**
  10105. * On pick down
  10106. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10107. */
  10108. static readonly OnPickDownTrigger: number;
  10109. /**
  10110. * On double pick
  10111. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10112. */
  10113. static readonly OnDoublePickTrigger: number;
  10114. /**
  10115. * On pick up
  10116. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10117. */
  10118. static readonly OnPickUpTrigger: number;
  10119. /**
  10120. * On pick out.
  10121. * This trigger will only be raised if you also declared a OnPickDown
  10122. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10123. */
  10124. static readonly OnPickOutTrigger: number;
  10125. /**
  10126. * On long press
  10127. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10128. */
  10129. static readonly OnLongPressTrigger: number;
  10130. /**
  10131. * On pointer over
  10132. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10133. */
  10134. static readonly OnPointerOverTrigger: number;
  10135. /**
  10136. * On pointer out
  10137. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10138. */
  10139. static readonly OnPointerOutTrigger: number;
  10140. /**
  10141. * On every frame
  10142. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10143. */
  10144. static readonly OnEveryFrameTrigger: number;
  10145. /**
  10146. * On intersection enter
  10147. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10148. */
  10149. static readonly OnIntersectionEnterTrigger: number;
  10150. /**
  10151. * On intersection exit
  10152. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10153. */
  10154. static readonly OnIntersectionExitTrigger: number;
  10155. /**
  10156. * On key down
  10157. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10158. */
  10159. static readonly OnKeyDownTrigger: number;
  10160. /**
  10161. * On key up
  10162. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10163. */
  10164. static readonly OnKeyUpTrigger: number;
  10165. private _scene;
  10166. /**
  10167. * Creates a new action manager
  10168. * @param scene defines the hosting scene
  10169. */
  10170. constructor(scene: Scene);
  10171. /**
  10172. * Releases all associated resources
  10173. */
  10174. dispose(): void;
  10175. /**
  10176. * Gets hosting scene
  10177. * @returns the hosting scene
  10178. */
  10179. getScene(): Scene;
  10180. /**
  10181. * Does this action manager handles actions of any of the given triggers
  10182. * @param triggers defines the triggers to be tested
  10183. * @return a boolean indicating whether one (or more) of the triggers is handled
  10184. */
  10185. hasSpecificTriggers(triggers: number[]): boolean;
  10186. /**
  10187. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10188. * speed.
  10189. * @param triggerA defines the trigger to be tested
  10190. * @param triggerB defines the trigger to be tested
  10191. * @return a boolean indicating whether one (or more) of the triggers is handled
  10192. */
  10193. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10194. /**
  10195. * Does this action manager handles actions of a given trigger
  10196. * @param trigger defines the trigger to be tested
  10197. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10198. * @return whether the trigger is handled
  10199. */
  10200. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10201. /**
  10202. * Does this action manager has pointer triggers
  10203. */
  10204. get hasPointerTriggers(): boolean;
  10205. /**
  10206. * Does this action manager has pick triggers
  10207. */
  10208. get hasPickTriggers(): boolean;
  10209. /**
  10210. * Registers an action to this action manager
  10211. * @param action defines the action to be registered
  10212. * @return the action amended (prepared) after registration
  10213. */
  10214. registerAction(action: IAction): Nullable<IAction>;
  10215. /**
  10216. * Unregisters an action to this action manager
  10217. * @param action defines the action to be unregistered
  10218. * @return a boolean indicating whether the action has been unregistered
  10219. */
  10220. unregisterAction(action: IAction): Boolean;
  10221. /**
  10222. * Process a specific trigger
  10223. * @param trigger defines the trigger to process
  10224. * @param evt defines the event details to be processed
  10225. */
  10226. processTrigger(trigger: number, evt?: IActionEvent): void;
  10227. /** @hidden */
  10228. _getEffectiveTarget(target: any, propertyPath: string): any;
  10229. /** @hidden */
  10230. _getProperty(propertyPath: string): string;
  10231. /**
  10232. * Serialize this manager to a JSON object
  10233. * @param name defines the property name to store this manager
  10234. * @returns a JSON representation of this manager
  10235. */
  10236. serialize(name: string): any;
  10237. /**
  10238. * Creates a new ActionManager from a JSON data
  10239. * @param parsedActions defines the JSON data to read from
  10240. * @param object defines the hosting mesh
  10241. * @param scene defines the hosting scene
  10242. */
  10243. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10244. /**
  10245. * Get a trigger name by index
  10246. * @param trigger defines the trigger index
  10247. * @returns a trigger name
  10248. */
  10249. static GetTriggerName(trigger: number): string;
  10250. }
  10251. }
  10252. declare module BABYLON {
  10253. /**
  10254. * Class representing a ray with position and direction
  10255. */
  10256. export class Ray {
  10257. /** origin point */
  10258. origin: Vector3;
  10259. /** direction */
  10260. direction: Vector3;
  10261. /** length of the ray */
  10262. length: number;
  10263. private static readonly _TmpVector3;
  10264. private _tmpRay;
  10265. /**
  10266. * Creates a new ray
  10267. * @param origin origin point
  10268. * @param direction direction
  10269. * @param length length of the ray
  10270. */
  10271. constructor(
  10272. /** origin point */
  10273. origin: Vector3,
  10274. /** direction */
  10275. direction: Vector3,
  10276. /** length of the ray */
  10277. length?: number);
  10278. /**
  10279. * Checks if the ray intersects a box
  10280. * This does not account for the ray lenght by design to improve perfs.
  10281. * @param minimum bound of the box
  10282. * @param maximum bound of the box
  10283. * @param intersectionTreshold extra extend to be added to the box in all direction
  10284. * @returns if the box was hit
  10285. */
  10286. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10287. /**
  10288. * Checks if the ray intersects a box
  10289. * This does not account for the ray lenght by design to improve perfs.
  10290. * @param box the bounding box to check
  10291. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10292. * @returns if the box was hit
  10293. */
  10294. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10295. /**
  10296. * If the ray hits a sphere
  10297. * @param sphere the bounding sphere to check
  10298. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10299. * @returns true if it hits the sphere
  10300. */
  10301. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10302. /**
  10303. * If the ray hits a triange
  10304. * @param vertex0 triangle vertex
  10305. * @param vertex1 triangle vertex
  10306. * @param vertex2 triangle vertex
  10307. * @returns intersection information if hit
  10308. */
  10309. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10310. /**
  10311. * Checks if ray intersects a plane
  10312. * @param plane the plane to check
  10313. * @returns the distance away it was hit
  10314. */
  10315. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10316. /**
  10317. * Calculate the intercept of a ray on a given axis
  10318. * @param axis to check 'x' | 'y' | 'z'
  10319. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10320. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10321. */
  10322. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10323. /**
  10324. * Checks if ray intersects a mesh
  10325. * @param mesh the mesh to check
  10326. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10327. * @returns picking info of the intersecton
  10328. */
  10329. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10330. /**
  10331. * Checks if ray intersects a mesh
  10332. * @param meshes the meshes to check
  10333. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10334. * @param results array to store result in
  10335. * @returns Array of picking infos
  10336. */
  10337. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10338. private _comparePickingInfo;
  10339. private static smallnum;
  10340. private static rayl;
  10341. /**
  10342. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10343. * @param sega the first point of the segment to test the intersection against
  10344. * @param segb the second point of the segment to test the intersection against
  10345. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10346. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10347. */
  10348. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10349. /**
  10350. * Update the ray from viewport position
  10351. * @param x position
  10352. * @param y y position
  10353. * @param viewportWidth viewport width
  10354. * @param viewportHeight viewport height
  10355. * @param world world matrix
  10356. * @param view view matrix
  10357. * @param projection projection matrix
  10358. * @returns this ray updated
  10359. */
  10360. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10361. /**
  10362. * Creates a ray with origin and direction of 0,0,0
  10363. * @returns the new ray
  10364. */
  10365. static Zero(): Ray;
  10366. /**
  10367. * Creates a new ray from screen space and viewport
  10368. * @param x position
  10369. * @param y y position
  10370. * @param viewportWidth viewport width
  10371. * @param viewportHeight viewport height
  10372. * @param world world matrix
  10373. * @param view view matrix
  10374. * @param projection projection matrix
  10375. * @returns new ray
  10376. */
  10377. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10378. /**
  10379. * 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
  10380. * transformed to the given world matrix.
  10381. * @param origin The origin point
  10382. * @param end The end point
  10383. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10384. * @returns the new ray
  10385. */
  10386. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10387. /**
  10388. * Transforms a ray by a matrix
  10389. * @param ray ray to transform
  10390. * @param matrix matrix to apply
  10391. * @returns the resulting new ray
  10392. */
  10393. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10394. /**
  10395. * Transforms a ray by a matrix
  10396. * @param ray ray to transform
  10397. * @param matrix matrix to apply
  10398. * @param result ray to store result in
  10399. */
  10400. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10401. /**
  10402. * Unproject a ray from screen space to object space
  10403. * @param sourceX defines the screen space x coordinate to use
  10404. * @param sourceY defines the screen space y coordinate to use
  10405. * @param viewportWidth defines the current width of the viewport
  10406. * @param viewportHeight defines the current height of the viewport
  10407. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10408. * @param view defines the view matrix to use
  10409. * @param projection defines the projection matrix to use
  10410. */
  10411. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10412. }
  10413. /**
  10414. * Type used to define predicate used to select faces when a mesh intersection is detected
  10415. */
  10416. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10417. interface Scene {
  10418. /** @hidden */
  10419. _tempPickingRay: Nullable<Ray>;
  10420. /** @hidden */
  10421. _cachedRayForTransform: Ray;
  10422. /** @hidden */
  10423. _pickWithRayInverseMatrix: Matrix;
  10424. /** @hidden */
  10425. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10426. /** @hidden */
  10427. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10428. /** @hidden */
  10429. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  10430. }
  10431. }
  10432. declare module BABYLON {
  10433. /**
  10434. * Groups all the scene component constants in one place to ease maintenance.
  10435. * @hidden
  10436. */
  10437. export class SceneComponentConstants {
  10438. static readonly NAME_EFFECTLAYER: string;
  10439. static readonly NAME_LAYER: string;
  10440. static readonly NAME_LENSFLARESYSTEM: string;
  10441. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10442. static readonly NAME_PARTICLESYSTEM: string;
  10443. static readonly NAME_GAMEPAD: string;
  10444. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10445. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10446. static readonly NAME_PREPASSRENDERER: string;
  10447. static readonly NAME_DEPTHRENDERER: string;
  10448. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10449. static readonly NAME_SPRITE: string;
  10450. static readonly NAME_SUBSURFACE: string;
  10451. static readonly NAME_OUTLINERENDERER: string;
  10452. static readonly NAME_PROCEDURALTEXTURE: string;
  10453. static readonly NAME_SHADOWGENERATOR: string;
  10454. static readonly NAME_OCTREE: string;
  10455. static readonly NAME_PHYSICSENGINE: string;
  10456. static readonly NAME_AUDIO: string;
  10457. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10458. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10459. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10460. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10461. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10462. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10463. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10464. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10465. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10466. static readonly STEP_BEFORERENDERINGMESH_PREPASS: number;
  10467. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10468. static readonly STEP_AFTERRENDERINGMESH_PREPASS: number;
  10469. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10470. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10471. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10472. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10473. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10474. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10475. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10476. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10477. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10478. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10479. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10480. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10481. static readonly STEP_AFTERRENDER_AUDIO: number;
  10482. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10483. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10484. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10485. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10486. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10487. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10488. static readonly STEP_POINTERMOVE_SPRITE: number;
  10489. static readonly STEP_POINTERDOWN_SPRITE: number;
  10490. static readonly STEP_POINTERUP_SPRITE: number;
  10491. }
  10492. /**
  10493. * This represents a scene component.
  10494. *
  10495. * This is used to decouple the dependency the scene is having on the different workloads like
  10496. * layers, post processes...
  10497. */
  10498. export interface ISceneComponent {
  10499. /**
  10500. * The name of the component. Each component must have a unique name.
  10501. */
  10502. name: string;
  10503. /**
  10504. * The scene the component belongs to.
  10505. */
  10506. scene: Scene;
  10507. /**
  10508. * Register the component to one instance of a scene.
  10509. */
  10510. register(): void;
  10511. /**
  10512. * Rebuilds the elements related to this component in case of
  10513. * context lost for instance.
  10514. */
  10515. rebuild(): void;
  10516. /**
  10517. * Disposes the component and the associated ressources.
  10518. */
  10519. dispose(): void;
  10520. }
  10521. /**
  10522. * This represents a SERIALIZABLE scene component.
  10523. *
  10524. * This extends Scene Component to add Serialization methods on top.
  10525. */
  10526. export interface ISceneSerializableComponent extends ISceneComponent {
  10527. /**
  10528. * Adds all the elements from the container to the scene
  10529. * @param container the container holding the elements
  10530. */
  10531. addFromContainer(container: AbstractScene): void;
  10532. /**
  10533. * Removes all the elements in the container from the scene
  10534. * @param container contains the elements to remove
  10535. * @param dispose if the removed element should be disposed (default: false)
  10536. */
  10537. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10538. /**
  10539. * Serializes the component data to the specified json object
  10540. * @param serializationObject The object to serialize to
  10541. */
  10542. serialize(serializationObject: any): void;
  10543. }
  10544. /**
  10545. * Strong typing of a Mesh related stage step action
  10546. */
  10547. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10548. /**
  10549. * Strong typing of a Evaluate Sub Mesh related stage step action
  10550. */
  10551. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10552. /**
  10553. * Strong typing of a pre active Mesh related stage step action
  10554. */
  10555. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  10556. /**
  10557. * Strong typing of a Camera related stage step action
  10558. */
  10559. export type CameraStageAction = (camera: Camera) => void;
  10560. /**
  10561. * Strong typing of a Camera Frame buffer related stage step action
  10562. */
  10563. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10564. /**
  10565. * Strong typing of a Render Target related stage step action
  10566. */
  10567. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10568. /**
  10569. * Strong typing of a RenderingGroup related stage step action
  10570. */
  10571. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10572. /**
  10573. * Strong typing of a Mesh Render related stage step action
  10574. */
  10575. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch, effect: Nullable<Effect>) => void;
  10576. /**
  10577. * Strong typing of a simple stage step action
  10578. */
  10579. export type SimpleStageAction = () => void;
  10580. /**
  10581. * Strong typing of a render target action.
  10582. */
  10583. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10584. /**
  10585. * Strong typing of a pointer move action.
  10586. */
  10587. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10588. /**
  10589. * Strong typing of a pointer up/down action.
  10590. */
  10591. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10592. /**
  10593. * Representation of a stage in the scene (Basically a list of ordered steps)
  10594. * @hidden
  10595. */
  10596. export class Stage<T extends Function> extends Array<{
  10597. index: number;
  10598. component: ISceneComponent;
  10599. action: T;
  10600. }> {
  10601. /**
  10602. * Hide ctor from the rest of the world.
  10603. * @param items The items to add.
  10604. */
  10605. private constructor();
  10606. /**
  10607. * Creates a new Stage.
  10608. * @returns A new instance of a Stage
  10609. */
  10610. static Create<T extends Function>(): Stage<T>;
  10611. /**
  10612. * Registers a step in an ordered way in the targeted stage.
  10613. * @param index Defines the position to register the step in
  10614. * @param component Defines the component attached to the step
  10615. * @param action Defines the action to launch during the step
  10616. */
  10617. registerStep(index: number, component: ISceneComponent, action: T): void;
  10618. /**
  10619. * Clears all the steps from the stage.
  10620. */
  10621. clear(): void;
  10622. }
  10623. }
  10624. declare module BABYLON {
  10625. interface Scene {
  10626. /** @hidden */
  10627. _pointerOverSprite: Nullable<Sprite>;
  10628. /** @hidden */
  10629. _pickedDownSprite: Nullable<Sprite>;
  10630. /** @hidden */
  10631. _tempSpritePickingRay: Nullable<Ray>;
  10632. /**
  10633. * All of the sprite managers added to this scene
  10634. * @see https://doc.babylonjs.com/babylon101/sprites
  10635. */
  10636. spriteManagers: Array<ISpriteManager>;
  10637. /**
  10638. * An event triggered when sprites rendering is about to start
  10639. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10640. */
  10641. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10642. /**
  10643. * An event triggered when sprites rendering is done
  10644. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10645. */
  10646. onAfterSpritesRenderingObservable: Observable<Scene>;
  10647. /** @hidden */
  10648. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10649. /** Launch a ray to try to pick a sprite in the scene
  10650. * @param x position on screen
  10651. * @param y position on screen
  10652. * @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
  10653. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10654. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10655. * @returns a PickingInfo
  10656. */
  10657. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10658. /** Use the given ray to pick a sprite in the scene
  10659. * @param ray The ray (in world space) to use to pick meshes
  10660. * @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
  10661. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10662. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10663. * @returns a PickingInfo
  10664. */
  10665. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10666. /** @hidden */
  10667. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10668. /** Launch a ray to try to pick sprites in the scene
  10669. * @param x position on screen
  10670. * @param y position on screen
  10671. * @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
  10672. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10673. * @returns a PickingInfo array
  10674. */
  10675. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10676. /** Use the given ray to pick sprites in the scene
  10677. * @param ray The ray (in world space) to use to pick meshes
  10678. * @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
  10679. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10680. * @returns a PickingInfo array
  10681. */
  10682. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10683. /**
  10684. * Force the sprite under the pointer
  10685. * @param sprite defines the sprite to use
  10686. */
  10687. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10688. /**
  10689. * Gets the sprite under the pointer
  10690. * @returns a Sprite or null if no sprite is under the pointer
  10691. */
  10692. getPointerOverSprite(): Nullable<Sprite>;
  10693. }
  10694. /**
  10695. * Defines the sprite scene component responsible to manage sprites
  10696. * in a given scene.
  10697. */
  10698. export class SpriteSceneComponent implements ISceneComponent {
  10699. /**
  10700. * The component name helpfull to identify the component in the list of scene components.
  10701. */
  10702. readonly name: string;
  10703. /**
  10704. * The scene the component belongs to.
  10705. */
  10706. scene: Scene;
  10707. /** @hidden */
  10708. private _spritePredicate;
  10709. /**
  10710. * Creates a new instance of the component for the given scene
  10711. * @param scene Defines the scene to register the component in
  10712. */
  10713. constructor(scene: Scene);
  10714. /**
  10715. * Registers the component in a given scene
  10716. */
  10717. register(): void;
  10718. /**
  10719. * Rebuilds the elements related to this component in case of
  10720. * context lost for instance.
  10721. */
  10722. rebuild(): void;
  10723. /**
  10724. * Disposes the component and the associated ressources.
  10725. */
  10726. dispose(): void;
  10727. private _pickSpriteButKeepRay;
  10728. private _pointerMove;
  10729. private _pointerDown;
  10730. private _pointerUp;
  10731. }
  10732. }
  10733. declare module BABYLON {
  10734. /**
  10735. * Class used to provide helper for timing
  10736. */
  10737. export class TimingTools {
  10738. /**
  10739. * Polyfill for setImmediate
  10740. * @param action defines the action to execute after the current execution block
  10741. */
  10742. static SetImmediate(action: () => void): void;
  10743. }
  10744. }
  10745. declare module BABYLON {
  10746. /**
  10747. * Class used to enable instatition of objects by class name
  10748. */
  10749. export class InstantiationTools {
  10750. /**
  10751. * Use this object to register external classes like custom textures or material
  10752. * to allow the laoders to instantiate them
  10753. */
  10754. static RegisteredExternalClasses: {
  10755. [key: string]: Object;
  10756. };
  10757. /**
  10758. * Tries to instantiate a new object from a given class name
  10759. * @param className defines the class name to instantiate
  10760. * @returns the new object or null if the system was not able to do the instantiation
  10761. */
  10762. static Instantiate(className: string): any;
  10763. }
  10764. }
  10765. declare module BABYLON {
  10766. /**
  10767. * Class used to host copy specific utilities
  10768. */
  10769. export class CopyTools {
  10770. /**
  10771. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  10772. * @param texture defines the texture to read pixels from
  10773. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  10774. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  10775. * @returns The base64 encoded string or null
  10776. */
  10777. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Nullable<string>;
  10778. }
  10779. }
  10780. declare module BABYLON {
  10781. /**
  10782. * Define options used to create a depth texture
  10783. */
  10784. export class DepthTextureCreationOptions {
  10785. /** Specifies whether or not a stencil should be allocated in the texture */
  10786. generateStencil?: boolean;
  10787. /** Specifies whether or not bilinear filtering is enable on the texture */
  10788. bilinearFiltering?: boolean;
  10789. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  10790. comparisonFunction?: number;
  10791. /** Specifies if the created texture is a cube texture */
  10792. isCube?: boolean;
  10793. }
  10794. }
  10795. declare module BABYLON {
  10796. interface ThinEngine {
  10797. /**
  10798. * Creates a depth stencil cube texture.
  10799. * This is only available in WebGL 2.
  10800. * @param size The size of face edge in the cube texture.
  10801. * @param options The options defining the cube texture.
  10802. * @returns The cube texture
  10803. */
  10804. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  10805. /**
  10806. * Creates a cube texture
  10807. * @param rootUrl defines the url where the files to load is located
  10808. * @param scene defines the current scene
  10809. * @param files defines the list of files to load (1 per face)
  10810. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  10811. * @param onLoad defines an optional callback raised when the texture is loaded
  10812. * @param onError defines an optional callback raised if there is an issue to load the texture
  10813. * @param format defines the format of the data
  10814. * @param forcedExtension defines the extension to use to pick the right loader
  10815. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  10816. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  10817. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  10818. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  10819. * @param loaderOptions options to be passed to the loader
  10820. * @returns the cube texture as an InternalTexture
  10821. */
  10822. 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>, loaderOptions: any): InternalTexture;
  10823. /**
  10824. * Creates a cube texture
  10825. * @param rootUrl defines the url where the files to load is located
  10826. * @param scene defines the current scene
  10827. * @param files defines the list of files to load (1 per face)
  10828. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  10829. * @param onLoad defines an optional callback raised when the texture is loaded
  10830. * @param onError defines an optional callback raised if there is an issue to load the texture
  10831. * @param format defines the format of the data
  10832. * @param forcedExtension defines the extension to use to pick the right loader
  10833. * @returns the cube texture as an InternalTexture
  10834. */
  10835. 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;
  10836. /**
  10837. * Creates a cube texture
  10838. * @param rootUrl defines the url where the files to load is located
  10839. * @param scene defines the current scene
  10840. * @param files defines the list of files to load (1 per face)
  10841. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  10842. * @param onLoad defines an optional callback raised when the texture is loaded
  10843. * @param onError defines an optional callback raised if there is an issue to load the texture
  10844. * @param format defines the format of the data
  10845. * @param forcedExtension defines the extension to use to pick the right loader
  10846. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  10847. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  10848. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  10849. * @returns the cube texture as an InternalTexture
  10850. */
  10851. 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;
  10852. /** @hidden */
  10853. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  10854. /** @hidden */
  10855. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  10856. /** @hidden */
  10857. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  10858. /** @hidden */
  10859. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  10860. /**
  10861. * @hidden
  10862. */
  10863. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  10864. }
  10865. }
  10866. declare module BABYLON {
  10867. /**
  10868. * Class for creating a cube texture
  10869. */
  10870. export class CubeTexture extends BaseTexture {
  10871. private _delayedOnLoad;
  10872. /**
  10873. * Observable triggered once the texture has been loaded.
  10874. */
  10875. onLoadObservable: Observable<CubeTexture>;
  10876. /**
  10877. * The url of the texture
  10878. */
  10879. url: string;
  10880. /**
  10881. * Gets or sets the center of the bounding box associated with the cube texture.
  10882. * It must define where the camera used to render the texture was set
  10883. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  10884. */
  10885. boundingBoxPosition: Vector3;
  10886. private _boundingBoxSize;
  10887. /**
  10888. * Gets or sets the size of the bounding box associated with the cube texture
  10889. * When defined, the cubemap will switch to local mode
  10890. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  10891. * @example https://www.babylonjs-playground.com/#RNASML
  10892. */
  10893. set boundingBoxSize(value: Vector3);
  10894. /**
  10895. * Returns the bounding box size
  10896. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  10897. */
  10898. get boundingBoxSize(): Vector3;
  10899. protected _rotationY: number;
  10900. /**
  10901. * Sets texture matrix rotation angle around Y axis in radians.
  10902. */
  10903. set rotationY(value: number);
  10904. /**
  10905. * Gets texture matrix rotation angle around Y axis radians.
  10906. */
  10907. get rotationY(): number;
  10908. /**
  10909. * Are mip maps generated for this texture or not.
  10910. */
  10911. get noMipmap(): boolean;
  10912. private _noMipmap;
  10913. private _files;
  10914. protected _forcedExtension: Nullable<string>;
  10915. private _extensions;
  10916. private _textureMatrix;
  10917. private _format;
  10918. private _createPolynomials;
  10919. private _loaderOptions;
  10920. /**
  10921. * Creates a cube texture from an array of image urls
  10922. * @param files defines an array of image urls
  10923. * @param scene defines the hosting scene
  10924. * @param noMipmap specifies if mip maps are not used
  10925. * @returns a cube texture
  10926. */
  10927. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  10928. /**
  10929. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  10930. * @param url defines the url of the prefiltered texture
  10931. * @param scene defines the scene the texture is attached to
  10932. * @param forcedExtension defines the extension of the file if different from the url
  10933. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  10934. * @return the prefiltered texture
  10935. */
  10936. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  10937. /**
  10938. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  10939. * as prefiltered data.
  10940. * @param rootUrl defines the url of the texture or the root name of the six images
  10941. * @param null defines the scene or engine the texture is attached to
  10942. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  10943. * @param noMipmap defines if mipmaps should be created or not
  10944. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  10945. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  10946. * @param onError defines a callback triggered in case of error during load
  10947. * @param format defines the internal format to use for the texture once loaded
  10948. * @param prefiltered defines whether or not the texture is created from prefiltered data
  10949. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  10950. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  10951. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  10952. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  10953. * @param loaderOptions options to be passed to the loader
  10954. * @return the cube texture
  10955. */
  10956. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, 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, loaderOptions?: any);
  10957. /**
  10958. * Get the current class name of the texture useful for serialization or dynamic coding.
  10959. * @returns "CubeTexture"
  10960. */
  10961. getClassName(): string;
  10962. /**
  10963. * Update the url (and optional buffer) of this texture if url was null during construction.
  10964. * @param url the url of the texture
  10965. * @param forcedExtension defines the extension to use
  10966. * @param onLoad callback called when the texture is loaded (defaults to null)
  10967. * @param prefiltered Defines whether the updated texture is prefiltered or not
  10968. */
  10969. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  10970. /**
  10971. * Delays loading of the cube texture
  10972. * @param forcedExtension defines the extension to use
  10973. */
  10974. delayLoad(forcedExtension?: string): void;
  10975. /**
  10976. * Returns the reflection texture matrix
  10977. * @returns the reflection texture matrix
  10978. */
  10979. getReflectionTextureMatrix(): Matrix;
  10980. /**
  10981. * Sets the reflection texture matrix
  10982. * @param value Reflection texture matrix
  10983. */
  10984. setReflectionTextureMatrix(value: Matrix): void;
  10985. /**
  10986. * Parses text to create a cube texture
  10987. * @param parsedTexture define the serialized text to read from
  10988. * @param scene defines the hosting scene
  10989. * @param rootUrl defines the root url of the cube texture
  10990. * @returns a cube texture
  10991. */
  10992. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  10993. /**
  10994. * Makes a clone, or deep copy, of the cube texture
  10995. * @returns a new cube texture
  10996. */
  10997. clone(): CubeTexture;
  10998. }
  10999. }
  11000. declare module BABYLON {
  11001. /**
  11002. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  11003. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  11004. * 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;
  11005. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  11006. */
  11007. export class ColorCurves {
  11008. private _dirty;
  11009. private _tempColor;
  11010. private _globalCurve;
  11011. private _highlightsCurve;
  11012. private _midtonesCurve;
  11013. private _shadowsCurve;
  11014. private _positiveCurve;
  11015. private _negativeCurve;
  11016. private _globalHue;
  11017. private _globalDensity;
  11018. private _globalSaturation;
  11019. private _globalExposure;
  11020. /**
  11021. * Gets the global Hue value.
  11022. * 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).
  11023. */
  11024. get globalHue(): number;
  11025. /**
  11026. * Sets the global Hue value.
  11027. * 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).
  11028. */
  11029. set globalHue(value: number);
  11030. /**
  11031. * Gets the global Density value.
  11032. * 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.
  11033. * Values less than zero provide a filter of opposite hue.
  11034. */
  11035. get globalDensity(): number;
  11036. /**
  11037. * Sets the global Density value.
  11038. * 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.
  11039. * Values less than zero provide a filter of opposite hue.
  11040. */
  11041. set globalDensity(value: number);
  11042. /**
  11043. * Gets the global Saturation value.
  11044. * 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.
  11045. */
  11046. get globalSaturation(): number;
  11047. /**
  11048. * Sets the global Saturation value.
  11049. * 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.
  11050. */
  11051. set globalSaturation(value: number);
  11052. /**
  11053. * Gets the global Exposure value.
  11054. * 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.
  11055. */
  11056. get globalExposure(): number;
  11057. /**
  11058. * Sets the global Exposure value.
  11059. * 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.
  11060. */
  11061. set globalExposure(value: number);
  11062. private _highlightsHue;
  11063. private _highlightsDensity;
  11064. private _highlightsSaturation;
  11065. private _highlightsExposure;
  11066. /**
  11067. * Gets the highlights Hue value.
  11068. * 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).
  11069. */
  11070. get highlightsHue(): number;
  11071. /**
  11072. * Sets the highlights Hue value.
  11073. * 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).
  11074. */
  11075. set highlightsHue(value: number);
  11076. /**
  11077. * Gets the highlights Density value.
  11078. * 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.
  11079. * Values less than zero provide a filter of opposite hue.
  11080. */
  11081. get highlightsDensity(): number;
  11082. /**
  11083. * Sets the highlights Density value.
  11084. * 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.
  11085. * Values less than zero provide a filter of opposite hue.
  11086. */
  11087. set highlightsDensity(value: number);
  11088. /**
  11089. * Gets the highlights Saturation value.
  11090. * 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.
  11091. */
  11092. get highlightsSaturation(): number;
  11093. /**
  11094. * Sets the highlights Saturation value.
  11095. * 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.
  11096. */
  11097. set highlightsSaturation(value: number);
  11098. /**
  11099. * Gets the highlights Exposure value.
  11100. * 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.
  11101. */
  11102. get highlightsExposure(): number;
  11103. /**
  11104. * Sets the highlights Exposure value.
  11105. * 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.
  11106. */
  11107. set highlightsExposure(value: number);
  11108. private _midtonesHue;
  11109. private _midtonesDensity;
  11110. private _midtonesSaturation;
  11111. private _midtonesExposure;
  11112. /**
  11113. * Gets the midtones Hue value.
  11114. * 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).
  11115. */
  11116. get midtonesHue(): number;
  11117. /**
  11118. * Sets the midtones Hue value.
  11119. * 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).
  11120. */
  11121. set midtonesHue(value: number);
  11122. /**
  11123. * Gets the midtones Density value.
  11124. * 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.
  11125. * Values less than zero provide a filter of opposite hue.
  11126. */
  11127. get midtonesDensity(): number;
  11128. /**
  11129. * Sets the midtones Density value.
  11130. * 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.
  11131. * Values less than zero provide a filter of opposite hue.
  11132. */
  11133. set midtonesDensity(value: number);
  11134. /**
  11135. * Gets the midtones Saturation value.
  11136. * 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.
  11137. */
  11138. get midtonesSaturation(): number;
  11139. /**
  11140. * Sets the midtones Saturation value.
  11141. * 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.
  11142. */
  11143. set midtonesSaturation(value: number);
  11144. /**
  11145. * Gets the midtones Exposure value.
  11146. * 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.
  11147. */
  11148. get midtonesExposure(): number;
  11149. /**
  11150. * Sets the midtones Exposure value.
  11151. * 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.
  11152. */
  11153. set midtonesExposure(value: number);
  11154. private _shadowsHue;
  11155. private _shadowsDensity;
  11156. private _shadowsSaturation;
  11157. private _shadowsExposure;
  11158. /**
  11159. * Gets the shadows Hue value.
  11160. * 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).
  11161. */
  11162. get shadowsHue(): number;
  11163. /**
  11164. * Sets the shadows Hue value.
  11165. * 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).
  11166. */
  11167. set shadowsHue(value: number);
  11168. /**
  11169. * Gets the shadows Density value.
  11170. * 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.
  11171. * Values less than zero provide a filter of opposite hue.
  11172. */
  11173. get shadowsDensity(): number;
  11174. /**
  11175. * Sets the shadows Density value.
  11176. * 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.
  11177. * Values less than zero provide a filter of opposite hue.
  11178. */
  11179. set shadowsDensity(value: number);
  11180. /**
  11181. * Gets the shadows Saturation value.
  11182. * 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.
  11183. */
  11184. get shadowsSaturation(): number;
  11185. /**
  11186. * Sets the shadows Saturation value.
  11187. * 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.
  11188. */
  11189. set shadowsSaturation(value: number);
  11190. /**
  11191. * Gets the shadows Exposure value.
  11192. * 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.
  11193. */
  11194. get shadowsExposure(): number;
  11195. /**
  11196. * Sets the shadows Exposure value.
  11197. * 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.
  11198. */
  11199. set shadowsExposure(value: number);
  11200. /**
  11201. * Returns the class name
  11202. * @returns The class name
  11203. */
  11204. getClassName(): string;
  11205. /**
  11206. * Binds the color curves to the shader.
  11207. * @param colorCurves The color curve to bind
  11208. * @param effect The effect to bind to
  11209. * @param positiveUniform The positive uniform shader parameter
  11210. * @param neutralUniform The neutral uniform shader parameter
  11211. * @param negativeUniform The negative uniform shader parameter
  11212. */
  11213. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  11214. /**
  11215. * Prepare the list of uniforms associated with the ColorCurves effects.
  11216. * @param uniformsList The list of uniforms used in the effect
  11217. */
  11218. static PrepareUniforms(uniformsList: string[]): void;
  11219. /**
  11220. * Returns color grading data based on a hue, density, saturation and exposure value.
  11221. * @param filterHue The hue of the color filter.
  11222. * @param filterDensity The density of the color filter.
  11223. * @param saturation The saturation.
  11224. * @param exposure The exposure.
  11225. * @param result The result data container.
  11226. */
  11227. private getColorGradingDataToRef;
  11228. /**
  11229. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  11230. * @param value The input slider value in range [-100,100].
  11231. * @returns Adjusted value.
  11232. */
  11233. private static applyColorGradingSliderNonlinear;
  11234. /**
  11235. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  11236. * @param hue The hue (H) input.
  11237. * @param saturation The saturation (S) input.
  11238. * @param brightness The brightness (B) input.
  11239. * @result An RGBA color represented as Vector4.
  11240. */
  11241. private static fromHSBToRef;
  11242. /**
  11243. * Returns a value clamped between min and max
  11244. * @param value The value to clamp
  11245. * @param min The minimum of value
  11246. * @param max The maximum of value
  11247. * @returns The clamped value.
  11248. */
  11249. private static clamp;
  11250. /**
  11251. * Clones the current color curve instance.
  11252. * @return The cloned curves
  11253. */
  11254. clone(): ColorCurves;
  11255. /**
  11256. * Serializes the current color curve instance to a json representation.
  11257. * @return a JSON representation
  11258. */
  11259. serialize(): any;
  11260. /**
  11261. * Parses the color curve from a json representation.
  11262. * @param source the JSON source to parse
  11263. * @return The parsed curves
  11264. */
  11265. static Parse(source: any): ColorCurves;
  11266. }
  11267. }
  11268. declare module BABYLON {
  11269. /**
  11270. * Interface to follow in your material defines to integrate easily the
  11271. * Image proccessing functions.
  11272. * @hidden
  11273. */
  11274. export interface IImageProcessingConfigurationDefines {
  11275. IMAGEPROCESSING: boolean;
  11276. VIGNETTE: boolean;
  11277. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11278. VIGNETTEBLENDMODEOPAQUE: boolean;
  11279. TONEMAPPING: boolean;
  11280. TONEMAPPING_ACES: boolean;
  11281. CONTRAST: boolean;
  11282. EXPOSURE: boolean;
  11283. COLORCURVES: boolean;
  11284. COLORGRADING: boolean;
  11285. COLORGRADING3D: boolean;
  11286. SAMPLER3DGREENDEPTH: boolean;
  11287. SAMPLER3DBGRMAP: boolean;
  11288. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11289. }
  11290. /**
  11291. * @hidden
  11292. */
  11293. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  11294. IMAGEPROCESSING: boolean;
  11295. VIGNETTE: boolean;
  11296. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11297. VIGNETTEBLENDMODEOPAQUE: boolean;
  11298. TONEMAPPING: boolean;
  11299. TONEMAPPING_ACES: boolean;
  11300. CONTRAST: boolean;
  11301. COLORCURVES: boolean;
  11302. COLORGRADING: boolean;
  11303. COLORGRADING3D: boolean;
  11304. SAMPLER3DGREENDEPTH: boolean;
  11305. SAMPLER3DBGRMAP: boolean;
  11306. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11307. EXPOSURE: boolean;
  11308. constructor();
  11309. }
  11310. /**
  11311. * This groups together the common properties used for image processing either in direct forward pass
  11312. * or through post processing effect depending on the use of the image processing pipeline in your scene
  11313. * or not.
  11314. */
  11315. export class ImageProcessingConfiguration {
  11316. /**
  11317. * Default tone mapping applied in BabylonJS.
  11318. */
  11319. static readonly TONEMAPPING_STANDARD: number;
  11320. /**
  11321. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  11322. * to other engines rendering to increase portability.
  11323. */
  11324. static readonly TONEMAPPING_ACES: number;
  11325. /**
  11326. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  11327. */
  11328. colorCurves: Nullable<ColorCurves>;
  11329. private _colorCurvesEnabled;
  11330. /**
  11331. * Gets wether the color curves effect is enabled.
  11332. */
  11333. get colorCurvesEnabled(): boolean;
  11334. /**
  11335. * Sets wether the color curves effect is enabled.
  11336. */
  11337. set colorCurvesEnabled(value: boolean);
  11338. private _colorGradingTexture;
  11339. /**
  11340. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11341. */
  11342. get colorGradingTexture(): Nullable<BaseTexture>;
  11343. /**
  11344. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11345. */
  11346. set colorGradingTexture(value: Nullable<BaseTexture>);
  11347. private _colorGradingEnabled;
  11348. /**
  11349. * Gets wether the color grading effect is enabled.
  11350. */
  11351. get colorGradingEnabled(): boolean;
  11352. /**
  11353. * Sets wether the color grading effect is enabled.
  11354. */
  11355. set colorGradingEnabled(value: boolean);
  11356. private _colorGradingWithGreenDepth;
  11357. /**
  11358. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  11359. */
  11360. get colorGradingWithGreenDepth(): boolean;
  11361. /**
  11362. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  11363. */
  11364. set colorGradingWithGreenDepth(value: boolean);
  11365. private _colorGradingBGR;
  11366. /**
  11367. * Gets wether the color grading texture contains BGR values.
  11368. */
  11369. get colorGradingBGR(): boolean;
  11370. /**
  11371. * Sets wether the color grading texture contains BGR values.
  11372. */
  11373. set colorGradingBGR(value: boolean);
  11374. /** @hidden */
  11375. _exposure: number;
  11376. /**
  11377. * Gets the Exposure used in the effect.
  11378. */
  11379. get exposure(): number;
  11380. /**
  11381. * Sets the Exposure used in the effect.
  11382. */
  11383. set exposure(value: number);
  11384. private _toneMappingEnabled;
  11385. /**
  11386. * Gets wether the tone mapping effect is enabled.
  11387. */
  11388. get toneMappingEnabled(): boolean;
  11389. /**
  11390. * Sets wether the tone mapping effect is enabled.
  11391. */
  11392. set toneMappingEnabled(value: boolean);
  11393. private _toneMappingType;
  11394. /**
  11395. * Gets the type of tone mapping effect.
  11396. */
  11397. get toneMappingType(): number;
  11398. /**
  11399. * Sets the type of tone mapping effect used in BabylonJS.
  11400. */
  11401. set toneMappingType(value: number);
  11402. protected _contrast: number;
  11403. /**
  11404. * Gets the contrast used in the effect.
  11405. */
  11406. get contrast(): number;
  11407. /**
  11408. * Sets the contrast used in the effect.
  11409. */
  11410. set contrast(value: number);
  11411. /**
  11412. * Vignette stretch size.
  11413. */
  11414. vignetteStretch: number;
  11415. /**
  11416. * Vignette centre X Offset.
  11417. */
  11418. vignetteCentreX: number;
  11419. /**
  11420. * Vignette centre Y Offset.
  11421. */
  11422. vignetteCentreY: number;
  11423. /**
  11424. * Vignette weight or intensity of the vignette effect.
  11425. */
  11426. vignetteWeight: number;
  11427. /**
  11428. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  11429. * if vignetteEnabled is set to true.
  11430. */
  11431. vignetteColor: Color4;
  11432. /**
  11433. * Camera field of view used by the Vignette effect.
  11434. */
  11435. vignetteCameraFov: number;
  11436. private _vignetteBlendMode;
  11437. /**
  11438. * Gets the vignette blend mode allowing different kind of effect.
  11439. */
  11440. get vignetteBlendMode(): number;
  11441. /**
  11442. * Sets the vignette blend mode allowing different kind of effect.
  11443. */
  11444. set vignetteBlendMode(value: number);
  11445. private _vignetteEnabled;
  11446. /**
  11447. * Gets wether the vignette effect is enabled.
  11448. */
  11449. get vignetteEnabled(): boolean;
  11450. /**
  11451. * Sets wether the vignette effect is enabled.
  11452. */
  11453. set vignetteEnabled(value: boolean);
  11454. private _applyByPostProcess;
  11455. /**
  11456. * Gets wether the image processing is applied through a post process or not.
  11457. */
  11458. get applyByPostProcess(): boolean;
  11459. /**
  11460. * Sets wether the image processing is applied through a post process or not.
  11461. */
  11462. set applyByPostProcess(value: boolean);
  11463. private _isEnabled;
  11464. /**
  11465. * Gets wether the image processing is enabled or not.
  11466. */
  11467. get isEnabled(): boolean;
  11468. /**
  11469. * Sets wether the image processing is enabled or not.
  11470. */
  11471. set isEnabled(value: boolean);
  11472. /**
  11473. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  11474. */
  11475. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  11476. /**
  11477. * Method called each time the image processing information changes requires to recompile the effect.
  11478. */
  11479. protected _updateParameters(): void;
  11480. /**
  11481. * Gets the current class name.
  11482. * @return "ImageProcessingConfiguration"
  11483. */
  11484. getClassName(): string;
  11485. /**
  11486. * Prepare the list of uniforms associated with the Image Processing effects.
  11487. * @param uniforms The list of uniforms used in the effect
  11488. * @param defines the list of defines currently in use
  11489. */
  11490. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  11491. /**
  11492. * Prepare the list of samplers associated with the Image Processing effects.
  11493. * @param samplersList The list of uniforms used in the effect
  11494. * @param defines the list of defines currently in use
  11495. */
  11496. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  11497. /**
  11498. * Prepare the list of defines associated to the shader.
  11499. * @param defines the list of defines to complete
  11500. * @param forPostProcess Define if we are currently in post process mode or not
  11501. */
  11502. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  11503. /**
  11504. * Returns true if all the image processing information are ready.
  11505. * @returns True if ready, otherwise, false
  11506. */
  11507. isReady(): boolean;
  11508. /**
  11509. * Binds the image processing to the shader.
  11510. * @param effect The effect to bind to
  11511. * @param overrideAspectRatio Override the aspect ratio of the effect
  11512. */
  11513. bind(effect: Effect, overrideAspectRatio?: number): void;
  11514. /**
  11515. * Clones the current image processing instance.
  11516. * @return The cloned image processing
  11517. */
  11518. clone(): ImageProcessingConfiguration;
  11519. /**
  11520. * Serializes the current image processing instance to a json representation.
  11521. * @return a JSON representation
  11522. */
  11523. serialize(): any;
  11524. /**
  11525. * Parses the image processing from a json representation.
  11526. * @param source the JSON source to parse
  11527. * @return The parsed image processing
  11528. */
  11529. static Parse(source: any): ImageProcessingConfiguration;
  11530. private static _VIGNETTEMODE_MULTIPLY;
  11531. private static _VIGNETTEMODE_OPAQUE;
  11532. /**
  11533. * Used to apply the vignette as a mix with the pixel color.
  11534. */
  11535. static get VIGNETTEMODE_MULTIPLY(): number;
  11536. /**
  11537. * Used to apply the vignette as a replacement of the pixel color.
  11538. */
  11539. static get VIGNETTEMODE_OPAQUE(): number;
  11540. }
  11541. }
  11542. declare module BABYLON {
  11543. /** @hidden */
  11544. export var postprocessVertexShader: {
  11545. name: string;
  11546. shader: string;
  11547. };
  11548. }
  11549. declare module BABYLON {
  11550. /**
  11551. * Type used to define a render target texture size (either with a number or with a rect width and height)
  11552. */
  11553. export type RenderTargetTextureSize = number | {
  11554. width: number;
  11555. height: number;
  11556. layers?: number;
  11557. };
  11558. interface ThinEngine {
  11559. /**
  11560. * Creates a new render target texture
  11561. * @param size defines the size of the texture
  11562. * @param options defines the options used to create the texture
  11563. * @returns a new render target texture stored in an InternalTexture
  11564. */
  11565. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11566. /**
  11567. * Creates a depth stencil texture.
  11568. * This is only available in WebGL 2 or with the depth texture extension available.
  11569. * @param size The size of face edge in the texture.
  11570. * @param options The options defining the texture.
  11571. * @returns The texture
  11572. */
  11573. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  11574. /** @hidden */
  11575. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  11576. }
  11577. }
  11578. declare module BABYLON {
  11579. /**
  11580. * Defines the kind of connection point for node based material
  11581. */
  11582. export enum NodeMaterialBlockConnectionPointTypes {
  11583. /** Float */
  11584. Float = 1,
  11585. /** Int */
  11586. Int = 2,
  11587. /** Vector2 */
  11588. Vector2 = 4,
  11589. /** Vector3 */
  11590. Vector3 = 8,
  11591. /** Vector4 */
  11592. Vector4 = 16,
  11593. /** Color3 */
  11594. Color3 = 32,
  11595. /** Color4 */
  11596. Color4 = 64,
  11597. /** Matrix */
  11598. Matrix = 128,
  11599. /** Custom object */
  11600. Object = 256,
  11601. /** Detect type based on connection */
  11602. AutoDetect = 1024,
  11603. /** Output type that will be defined by input type */
  11604. BasedOnInput = 2048
  11605. }
  11606. }
  11607. declare module BABYLON {
  11608. /**
  11609. * Enum used to define the target of a block
  11610. */
  11611. export enum NodeMaterialBlockTargets {
  11612. /** Vertex shader */
  11613. Vertex = 1,
  11614. /** Fragment shader */
  11615. Fragment = 2,
  11616. /** Neutral */
  11617. Neutral = 4,
  11618. /** Vertex and Fragment */
  11619. VertexAndFragment = 3
  11620. }
  11621. }
  11622. declare module BABYLON {
  11623. /**
  11624. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  11625. */
  11626. export enum NodeMaterialBlockConnectionPointMode {
  11627. /** Value is an uniform */
  11628. Uniform = 0,
  11629. /** Value is a mesh attribute */
  11630. Attribute = 1,
  11631. /** Value is a varying between vertex and fragment shaders */
  11632. Varying = 2,
  11633. /** Mode is undefined */
  11634. Undefined = 3
  11635. }
  11636. }
  11637. declare module BABYLON {
  11638. /**
  11639. * Enum used to define system values e.g. values automatically provided by the system
  11640. */
  11641. export enum NodeMaterialSystemValues {
  11642. /** World */
  11643. World = 1,
  11644. /** View */
  11645. View = 2,
  11646. /** Projection */
  11647. Projection = 3,
  11648. /** ViewProjection */
  11649. ViewProjection = 4,
  11650. /** WorldView */
  11651. WorldView = 5,
  11652. /** WorldViewProjection */
  11653. WorldViewProjection = 6,
  11654. /** CameraPosition */
  11655. CameraPosition = 7,
  11656. /** Fog Color */
  11657. FogColor = 8,
  11658. /** Delta time */
  11659. DeltaTime = 9
  11660. }
  11661. }
  11662. declare module BABYLON {
  11663. /**
  11664. * Represents a camera frustum
  11665. */
  11666. export class Frustum {
  11667. /**
  11668. * Gets the planes representing the frustum
  11669. * @param transform matrix to be applied to the returned planes
  11670. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  11671. */
  11672. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  11673. /**
  11674. * Gets the near frustum plane transformed by the transform matrix
  11675. * @param transform transformation matrix to be applied to the resulting frustum plane
  11676. * @param frustumPlane the resuling frustum plane
  11677. */
  11678. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11679. /**
  11680. * Gets the far frustum plane transformed by the transform matrix
  11681. * @param transform transformation matrix to be applied to the resulting frustum plane
  11682. * @param frustumPlane the resuling frustum plane
  11683. */
  11684. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11685. /**
  11686. * Gets the left frustum plane transformed by the transform matrix
  11687. * @param transform transformation matrix to be applied to the resulting frustum plane
  11688. * @param frustumPlane the resuling frustum plane
  11689. */
  11690. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11691. /**
  11692. * Gets the right frustum plane transformed by the transform matrix
  11693. * @param transform transformation matrix to be applied to the resulting frustum plane
  11694. * @param frustumPlane the resuling frustum plane
  11695. */
  11696. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11697. /**
  11698. * Gets the top frustum plane transformed by the transform matrix
  11699. * @param transform transformation matrix to be applied to the resulting frustum plane
  11700. * @param frustumPlane the resuling frustum plane
  11701. */
  11702. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11703. /**
  11704. * Gets the bottom frustum plane transformed by the transform matrix
  11705. * @param transform transformation matrix to be applied to the resulting frustum plane
  11706. * @param frustumPlane the resuling frustum plane
  11707. */
  11708. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11709. /**
  11710. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  11711. * @param transform transformation matrix to be applied to the resulting frustum planes
  11712. * @param frustumPlanes the resuling frustum planes
  11713. */
  11714. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  11715. }
  11716. }
  11717. declare module BABYLON {
  11718. /**
  11719. * Contains position and normal vectors for a vertex
  11720. */
  11721. export class PositionNormalVertex {
  11722. /** the position of the vertex (defaut: 0,0,0) */
  11723. position: Vector3;
  11724. /** the normal of the vertex (defaut: 0,1,0) */
  11725. normal: Vector3;
  11726. /**
  11727. * Creates a PositionNormalVertex
  11728. * @param position the position of the vertex (defaut: 0,0,0)
  11729. * @param normal the normal of the vertex (defaut: 0,1,0)
  11730. */
  11731. constructor(
  11732. /** the position of the vertex (defaut: 0,0,0) */
  11733. position?: Vector3,
  11734. /** the normal of the vertex (defaut: 0,1,0) */
  11735. normal?: Vector3);
  11736. /**
  11737. * Clones the PositionNormalVertex
  11738. * @returns the cloned PositionNormalVertex
  11739. */
  11740. clone(): PositionNormalVertex;
  11741. }
  11742. /**
  11743. * Contains position, normal and uv vectors for a vertex
  11744. */
  11745. export class PositionNormalTextureVertex {
  11746. /** the position of the vertex (defaut: 0,0,0) */
  11747. position: Vector3;
  11748. /** the normal of the vertex (defaut: 0,1,0) */
  11749. normal: Vector3;
  11750. /** the uv of the vertex (default: 0,0) */
  11751. uv: Vector2;
  11752. /**
  11753. * Creates a PositionNormalTextureVertex
  11754. * @param position the position of the vertex (defaut: 0,0,0)
  11755. * @param normal the normal of the vertex (defaut: 0,1,0)
  11756. * @param uv the uv of the vertex (default: 0,0)
  11757. */
  11758. constructor(
  11759. /** the position of the vertex (defaut: 0,0,0) */
  11760. position?: Vector3,
  11761. /** the normal of the vertex (defaut: 0,1,0) */
  11762. normal?: Vector3,
  11763. /** the uv of the vertex (default: 0,0) */
  11764. uv?: Vector2);
  11765. /**
  11766. * Clones the PositionNormalTextureVertex
  11767. * @returns the cloned PositionNormalTextureVertex
  11768. */
  11769. clone(): PositionNormalTextureVertex;
  11770. }
  11771. }
  11772. declare module BABYLON {
  11773. /**
  11774. * Enum defining the type of animations supported by InputBlock
  11775. */
  11776. export enum AnimatedInputBlockTypes {
  11777. /** No animation */
  11778. None = 0,
  11779. /** Time based animation. Will only work for floats */
  11780. Time = 1
  11781. }
  11782. }
  11783. declare module BABYLON {
  11784. /**
  11785. * Block used to expose an input value
  11786. */
  11787. export class InputBlock extends NodeMaterialBlock {
  11788. private _mode;
  11789. private _associatedVariableName;
  11790. private _storedValue;
  11791. private _valueCallback;
  11792. private _type;
  11793. private _animationType;
  11794. /** Gets or set a value used to limit the range of float values */
  11795. min: number;
  11796. /** Gets or set a value used to limit the range of float values */
  11797. max: number;
  11798. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  11799. isBoolean: boolean;
  11800. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  11801. matrixMode: number;
  11802. /** @hidden */
  11803. _systemValue: Nullable<NodeMaterialSystemValues>;
  11804. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  11805. isConstant: boolean;
  11806. /** Gets or sets the group to use to display this block in the Inspector */
  11807. groupInInspector: string;
  11808. /** Gets an observable raised when the value is changed */
  11809. onValueChangedObservable: Observable<InputBlock>;
  11810. /** Gets or sets a boolean indicating if content needs to be converted to gamma space (for color3/4 only) */
  11811. convertToGammaSpace: boolean;
  11812. /** Gets or sets a boolean indicating if content needs to be converted to linear space (for color3/4 only) */
  11813. convertToLinearSpace: boolean;
  11814. /**
  11815. * Gets or sets the connection point type (default is float)
  11816. */
  11817. get type(): NodeMaterialBlockConnectionPointTypes;
  11818. /**
  11819. * Creates a new InputBlock
  11820. * @param name defines the block name
  11821. * @param target defines the target of that block (Vertex by default)
  11822. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  11823. */
  11824. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  11825. /**
  11826. * Validates if a name is a reserve word.
  11827. * @param newName the new name to be given to the node.
  11828. * @returns false if the name is a reserve word, else true.
  11829. */
  11830. validateBlockName(newName: string): boolean;
  11831. /**
  11832. * Gets the output component
  11833. */
  11834. get output(): NodeMaterialConnectionPoint;
  11835. /**
  11836. * Set the source of this connection point to a vertex attribute
  11837. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  11838. * @returns the current connection point
  11839. */
  11840. setAsAttribute(attributeName?: string): InputBlock;
  11841. /**
  11842. * Set the source of this connection point to a system value
  11843. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  11844. * @returns the current connection point
  11845. */
  11846. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  11847. /**
  11848. * Gets or sets the value of that point.
  11849. * Please note that this value will be ignored if valueCallback is defined
  11850. */
  11851. get value(): any;
  11852. set value(value: any);
  11853. /**
  11854. * Gets or sets a callback used to get the value of that point.
  11855. * Please note that setting this value will force the connection point to ignore the value property
  11856. */
  11857. get valueCallback(): () => any;
  11858. set valueCallback(value: () => any);
  11859. /**
  11860. * Gets or sets the associated variable name in the shader
  11861. */
  11862. get associatedVariableName(): string;
  11863. set associatedVariableName(value: string);
  11864. /** Gets or sets the type of animation applied to the input */
  11865. get animationType(): AnimatedInputBlockTypes;
  11866. set animationType(value: AnimatedInputBlockTypes);
  11867. /**
  11868. * Gets a boolean indicating that this connection point not defined yet
  11869. */
  11870. get isUndefined(): boolean;
  11871. /**
  11872. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  11873. * In this case the connection point name must be the name of the uniform to use.
  11874. * Can only be set on inputs
  11875. */
  11876. get isUniform(): boolean;
  11877. set isUniform(value: boolean);
  11878. /**
  11879. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  11880. * In this case the connection point name must be the name of the attribute to use
  11881. * Can only be set on inputs
  11882. */
  11883. get isAttribute(): boolean;
  11884. set isAttribute(value: boolean);
  11885. /**
  11886. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  11887. * Can only be set on exit points
  11888. */
  11889. get isVarying(): boolean;
  11890. set isVarying(value: boolean);
  11891. /**
  11892. * Gets a boolean indicating that the current connection point is a system value
  11893. */
  11894. get isSystemValue(): boolean;
  11895. /**
  11896. * Gets or sets the current well known value or null if not defined as a system value
  11897. */
  11898. get systemValue(): Nullable<NodeMaterialSystemValues>;
  11899. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  11900. /**
  11901. * Gets the current class name
  11902. * @returns the class name
  11903. */
  11904. getClassName(): string;
  11905. /**
  11906. * Animate the input if animationType !== None
  11907. * @param scene defines the rendering scene
  11908. */
  11909. animate(scene: Scene): void;
  11910. private _emitDefine;
  11911. initialize(state: NodeMaterialBuildState): void;
  11912. /**
  11913. * Set the input block to its default value (based on its type)
  11914. */
  11915. setDefaultValue(): void;
  11916. private _emitConstant;
  11917. /** @hidden */
  11918. get _noContextSwitch(): boolean;
  11919. private _emit;
  11920. /** @hidden */
  11921. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  11922. /** @hidden */
  11923. _transmit(effect: Effect, scene: Scene): void;
  11924. protected _buildBlock(state: NodeMaterialBuildState): void;
  11925. protected _dumpPropertiesCode(): string;
  11926. dispose(): void;
  11927. serialize(): any;
  11928. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  11929. }
  11930. }
  11931. declare module BABYLON {
  11932. /**
  11933. * Enum used to define the compatibility state between two connection points
  11934. */
  11935. export enum NodeMaterialConnectionPointCompatibilityStates {
  11936. /** Points are compatibles */
  11937. Compatible = 0,
  11938. /** Points are incompatible because of their types */
  11939. TypeIncompatible = 1,
  11940. /** Points are incompatible because of their targets (vertex vs fragment) */
  11941. TargetIncompatible = 2
  11942. }
  11943. /**
  11944. * Defines the direction of a connection point
  11945. */
  11946. export enum NodeMaterialConnectionPointDirection {
  11947. /** Input */
  11948. Input = 0,
  11949. /** Output */
  11950. Output = 1
  11951. }
  11952. /**
  11953. * Defines a connection point for a block
  11954. */
  11955. export class NodeMaterialConnectionPoint {
  11956. /**
  11957. * Checks if two types are equivalent
  11958. * @param type1 type 1 to check
  11959. * @param type2 type 2 to check
  11960. * @returns true if both types are equivalent, else false
  11961. */
  11962. static AreEquivalentTypes(type1: number, type2: number): boolean;
  11963. /** @hidden */
  11964. _ownerBlock: NodeMaterialBlock;
  11965. /** @hidden */
  11966. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  11967. private _endpoints;
  11968. private _associatedVariableName;
  11969. private _direction;
  11970. /** @hidden */
  11971. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  11972. /** @hidden */
  11973. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  11974. /** @hidden */
  11975. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  11976. private _type;
  11977. /** @hidden */
  11978. _enforceAssociatedVariableName: boolean;
  11979. /** Gets the direction of the point */
  11980. get direction(): NodeMaterialConnectionPointDirection;
  11981. /** Indicates that this connection point needs dual validation before being connected to another point */
  11982. needDualDirectionValidation: boolean;
  11983. /**
  11984. * Gets or sets the additional types supported by this connection point
  11985. */
  11986. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  11987. /**
  11988. * Gets or sets the additional types excluded by this connection point
  11989. */
  11990. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  11991. /**
  11992. * Observable triggered when this point is connected
  11993. */
  11994. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  11995. /**
  11996. * Gets or sets the associated variable name in the shader
  11997. */
  11998. get associatedVariableName(): string;
  11999. set associatedVariableName(value: string);
  12000. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  12001. get innerType(): NodeMaterialBlockConnectionPointTypes;
  12002. /**
  12003. * Gets or sets the connection point type (default is float)
  12004. */
  12005. get type(): NodeMaterialBlockConnectionPointTypes;
  12006. set type(value: NodeMaterialBlockConnectionPointTypes);
  12007. /**
  12008. * Gets or sets the connection point name
  12009. */
  12010. name: string;
  12011. /**
  12012. * Gets or sets the connection point name
  12013. */
  12014. displayName: string;
  12015. /**
  12016. * Gets or sets a boolean indicating that this connection point can be omitted
  12017. */
  12018. isOptional: boolean;
  12019. /**
  12020. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  12021. */
  12022. isExposedOnFrame: boolean;
  12023. /**
  12024. * Gets or sets number indicating the position that the port is exposed to on a frame
  12025. */
  12026. exposedPortPosition: number;
  12027. /**
  12028. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  12029. */
  12030. define: string;
  12031. /** @hidden */
  12032. _prioritizeVertex: boolean;
  12033. private _target;
  12034. /** Gets or sets the target of that connection point */
  12035. get target(): NodeMaterialBlockTargets;
  12036. set target(value: NodeMaterialBlockTargets);
  12037. /**
  12038. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  12039. */
  12040. get isConnected(): boolean;
  12041. /**
  12042. * Gets a boolean indicating that the current point is connected to an input block
  12043. */
  12044. get isConnectedToInputBlock(): boolean;
  12045. /**
  12046. * Gets a the connected input block (if any)
  12047. */
  12048. get connectInputBlock(): Nullable<InputBlock>;
  12049. /** Get the other side of the connection (if any) */
  12050. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  12051. /** Get the block that owns this connection point */
  12052. get ownerBlock(): NodeMaterialBlock;
  12053. /** Get the block connected on the other side of this connection (if any) */
  12054. get sourceBlock(): Nullable<NodeMaterialBlock>;
  12055. /** Get the block connected on the endpoints of this connection (if any) */
  12056. get connectedBlocks(): Array<NodeMaterialBlock>;
  12057. /** Gets the list of connected endpoints */
  12058. get endpoints(): NodeMaterialConnectionPoint[];
  12059. /** Gets a boolean indicating if that output point is connected to at least one input */
  12060. get hasEndpoints(): boolean;
  12061. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  12062. get isConnectedInVertexShader(): boolean;
  12063. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  12064. get isConnectedInFragmentShader(): boolean;
  12065. /**
  12066. * Creates a block suitable to be used as an input for this input point.
  12067. * If null is returned, a block based on the point type will be created.
  12068. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  12069. */
  12070. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12071. /**
  12072. * Creates a new connection point
  12073. * @param name defines the connection point name
  12074. * @param ownerBlock defines the block hosting this connection point
  12075. * @param direction defines the direction of the connection point
  12076. */
  12077. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  12078. /**
  12079. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  12080. * @returns the class name
  12081. */
  12082. getClassName(): string;
  12083. /**
  12084. * Gets a boolean indicating if the current point can be connected to another point
  12085. * @param connectionPoint defines the other connection point
  12086. * @returns a boolean
  12087. */
  12088. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  12089. /**
  12090. * Gets a number indicating if the current point can be connected to another point
  12091. * @param connectionPoint defines the other connection point
  12092. * @returns a number defining the compatibility state
  12093. */
  12094. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12095. /**
  12096. * Connect this point to another connection point
  12097. * @param connectionPoint defines the other connection point
  12098. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  12099. * @returns the current connection point
  12100. */
  12101. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  12102. /**
  12103. * Disconnect this point from one of his endpoint
  12104. * @param endpoint defines the other connection point
  12105. * @returns the current connection point
  12106. */
  12107. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  12108. /**
  12109. * Serializes this point in a JSON representation
  12110. * @param isInput defines if the connection point is an input (default is true)
  12111. * @returns the serialized point object
  12112. */
  12113. serialize(isInput?: boolean): any;
  12114. /**
  12115. * Release resources
  12116. */
  12117. dispose(): void;
  12118. }
  12119. }
  12120. declare module BABYLON {
  12121. /**
  12122. * Enum used to define the material modes
  12123. */
  12124. export enum NodeMaterialModes {
  12125. /** Regular material */
  12126. Material = 0,
  12127. /** For post process */
  12128. PostProcess = 1,
  12129. /** For particle system */
  12130. Particle = 2,
  12131. /** For procedural texture */
  12132. ProceduralTexture = 3
  12133. }
  12134. }
  12135. declare module BABYLON {
  12136. /** @hidden */
  12137. export var helperFunctions: {
  12138. name: string;
  12139. shader: string;
  12140. };
  12141. }
  12142. declare module BABYLON {
  12143. /**
  12144. * Block used to read a texture from a sampler
  12145. */
  12146. export class TextureBlock extends NodeMaterialBlock {
  12147. private _defineName;
  12148. private _linearDefineName;
  12149. private _gammaDefineName;
  12150. private _tempTextureRead;
  12151. private _samplerName;
  12152. private _transformedUVName;
  12153. private _textureTransformName;
  12154. private _textureInfoName;
  12155. private _mainUVName;
  12156. private _mainUVDefineName;
  12157. private _fragmentOnly;
  12158. /**
  12159. * Gets or sets the texture associated with the node
  12160. */
  12161. texture: Nullable<Texture>;
  12162. /**
  12163. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12164. */
  12165. convertToGammaSpace: boolean;
  12166. /**
  12167. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12168. */
  12169. convertToLinearSpace: boolean;
  12170. /**
  12171. * Create a new TextureBlock
  12172. * @param name defines the block name
  12173. */
  12174. constructor(name: string, fragmentOnly?: boolean);
  12175. /**
  12176. * Gets the current class name
  12177. * @returns the class name
  12178. */
  12179. getClassName(): string;
  12180. /**
  12181. * Gets the uv input component
  12182. */
  12183. get uv(): NodeMaterialConnectionPoint;
  12184. /**
  12185. * Gets the rgba output component
  12186. */
  12187. get rgba(): NodeMaterialConnectionPoint;
  12188. /**
  12189. * Gets the rgb output component
  12190. */
  12191. get rgb(): NodeMaterialConnectionPoint;
  12192. /**
  12193. * Gets the r output component
  12194. */
  12195. get r(): NodeMaterialConnectionPoint;
  12196. /**
  12197. * Gets the g output component
  12198. */
  12199. get g(): NodeMaterialConnectionPoint;
  12200. /**
  12201. * Gets the b output component
  12202. */
  12203. get b(): NodeMaterialConnectionPoint;
  12204. /**
  12205. * Gets the a output component
  12206. */
  12207. get a(): NodeMaterialConnectionPoint;
  12208. get target(): NodeMaterialBlockTargets;
  12209. autoConfigure(material: NodeMaterial): void;
  12210. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  12211. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12212. isReady(): boolean;
  12213. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12214. private get _isMixed();
  12215. private _injectVertexCode;
  12216. private _writeTextureRead;
  12217. private _writeOutput;
  12218. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12219. protected _dumpPropertiesCode(): string;
  12220. serialize(): any;
  12221. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12222. }
  12223. }
  12224. declare module BABYLON {
  12225. /** @hidden */
  12226. export var reflectionFunction: {
  12227. name: string;
  12228. shader: string;
  12229. };
  12230. }
  12231. declare module BABYLON {
  12232. /**
  12233. * Base block used to read a reflection texture from a sampler
  12234. */
  12235. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  12236. /** @hidden */
  12237. _define3DName: string;
  12238. /** @hidden */
  12239. _defineCubicName: string;
  12240. /** @hidden */
  12241. _defineExplicitName: string;
  12242. /** @hidden */
  12243. _defineProjectionName: string;
  12244. /** @hidden */
  12245. _defineLocalCubicName: string;
  12246. /** @hidden */
  12247. _defineSphericalName: string;
  12248. /** @hidden */
  12249. _definePlanarName: string;
  12250. /** @hidden */
  12251. _defineEquirectangularName: string;
  12252. /** @hidden */
  12253. _defineMirroredEquirectangularFixedName: string;
  12254. /** @hidden */
  12255. _defineEquirectangularFixedName: string;
  12256. /** @hidden */
  12257. _defineSkyboxName: string;
  12258. /** @hidden */
  12259. _defineOppositeZ: string;
  12260. /** @hidden */
  12261. _cubeSamplerName: string;
  12262. /** @hidden */
  12263. _2DSamplerName: string;
  12264. protected _positionUVWName: string;
  12265. protected _directionWName: string;
  12266. protected _reflectionVectorName: string;
  12267. /** @hidden */
  12268. _reflectionCoordsName: string;
  12269. /** @hidden */
  12270. _reflectionMatrixName: string;
  12271. protected _reflectionColorName: string;
  12272. /**
  12273. * Gets or sets the texture associated with the node
  12274. */
  12275. texture: Nullable<BaseTexture>;
  12276. /**
  12277. * Create a new ReflectionTextureBaseBlock
  12278. * @param name defines the block name
  12279. */
  12280. constructor(name: string);
  12281. /**
  12282. * Gets the current class name
  12283. * @returns the class name
  12284. */
  12285. getClassName(): string;
  12286. /**
  12287. * Gets the world position input component
  12288. */
  12289. abstract get position(): NodeMaterialConnectionPoint;
  12290. /**
  12291. * Gets the world position input component
  12292. */
  12293. abstract get worldPosition(): NodeMaterialConnectionPoint;
  12294. /**
  12295. * Gets the world normal input component
  12296. */
  12297. abstract get worldNormal(): NodeMaterialConnectionPoint;
  12298. /**
  12299. * Gets the world input component
  12300. */
  12301. abstract get world(): NodeMaterialConnectionPoint;
  12302. /**
  12303. * Gets the camera (or eye) position component
  12304. */
  12305. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  12306. /**
  12307. * Gets the view input component
  12308. */
  12309. abstract get view(): NodeMaterialConnectionPoint;
  12310. protected _getTexture(): Nullable<BaseTexture>;
  12311. autoConfigure(material: NodeMaterial): void;
  12312. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12313. isReady(): boolean;
  12314. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12315. /**
  12316. * Gets the code to inject in the vertex shader
  12317. * @param state current state of the node material building
  12318. * @returns the shader code
  12319. */
  12320. handleVertexSide(state: NodeMaterialBuildState): string;
  12321. /**
  12322. * Handles the inits for the fragment code path
  12323. * @param state node material build state
  12324. */
  12325. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  12326. /**
  12327. * Generates the reflection coords code for the fragment code path
  12328. * @param worldNormalVarName name of the world normal variable
  12329. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  12330. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  12331. * @returns the shader code
  12332. */
  12333. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  12334. /**
  12335. * Generates the reflection color code for the fragment code path
  12336. * @param lodVarName name of the lod variable
  12337. * @param swizzleLookupTexture swizzle to use for the final color variable
  12338. * @returns the shader code
  12339. */
  12340. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  12341. /**
  12342. * Generates the code corresponding to the connected output points
  12343. * @param state node material build state
  12344. * @param varName name of the variable to output
  12345. * @returns the shader code
  12346. */
  12347. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  12348. protected _buildBlock(state: NodeMaterialBuildState): this;
  12349. protected _dumpPropertiesCode(): string;
  12350. serialize(): any;
  12351. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12352. }
  12353. }
  12354. declare module BABYLON {
  12355. /**
  12356. * Defines a connection point to be used for points with a custom object type
  12357. */
  12358. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  12359. private _blockType;
  12360. private _blockName;
  12361. private _nameForCheking?;
  12362. /**
  12363. * Creates a new connection point
  12364. * @param name defines the connection point name
  12365. * @param ownerBlock defines the block hosting this connection point
  12366. * @param direction defines the direction of the connection point
  12367. */
  12368. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  12369. /**
  12370. * Gets a number indicating if the current point can be connected to another point
  12371. * @param connectionPoint defines the other connection point
  12372. * @returns a number defining the compatibility state
  12373. */
  12374. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12375. /**
  12376. * Creates a block suitable to be used as an input for this input point.
  12377. * If null is returned, a block based on the point type will be created.
  12378. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  12379. */
  12380. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12381. }
  12382. }
  12383. declare module BABYLON {
  12384. /**
  12385. * Enum defining the type of properties that can be edited in the property pages in the NME
  12386. */
  12387. export enum PropertyTypeForEdition {
  12388. /** property is a boolean */
  12389. Boolean = 0,
  12390. /** property is a float */
  12391. Float = 1,
  12392. /** property is a Vector2 */
  12393. Vector2 = 2,
  12394. /** property is a list of values */
  12395. List = 3
  12396. }
  12397. /**
  12398. * Interface that defines an option in a variable of type list
  12399. */
  12400. export interface IEditablePropertyListOption {
  12401. /** label of the option */
  12402. "label": string;
  12403. /** value of the option */
  12404. "value": number;
  12405. }
  12406. /**
  12407. * Interface that defines the options available for an editable property
  12408. */
  12409. export interface IEditablePropertyOption {
  12410. /** min value */
  12411. "min"?: number;
  12412. /** max value */
  12413. "max"?: number;
  12414. /** notifiers: indicates which actions to take when the property is changed */
  12415. "notifiers"?: {
  12416. /** the material should be rebuilt */
  12417. "rebuild"?: boolean;
  12418. /** the preview should be updated */
  12419. "update"?: boolean;
  12420. };
  12421. /** list of the options for a variable of type list */
  12422. "options"?: IEditablePropertyListOption[];
  12423. }
  12424. /**
  12425. * Interface that describes an editable property
  12426. */
  12427. export interface IPropertyDescriptionForEdition {
  12428. /** name of the property */
  12429. "propertyName": string;
  12430. /** display name of the property */
  12431. "displayName": string;
  12432. /** type of the property */
  12433. "type": PropertyTypeForEdition;
  12434. /** group of the property - all properties with the same group value will be displayed in a specific section */
  12435. "groupName": string;
  12436. /** options for the property */
  12437. "options": IEditablePropertyOption;
  12438. }
  12439. /**
  12440. * Decorator that flags a property in a node material block as being editable
  12441. */
  12442. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  12443. }
  12444. declare module BABYLON {
  12445. /**
  12446. * Block used to implement the refraction part of the sub surface module of the PBR material
  12447. */
  12448. export class RefractionBlock extends NodeMaterialBlock {
  12449. /** @hidden */
  12450. _define3DName: string;
  12451. /** @hidden */
  12452. _refractionMatrixName: string;
  12453. /** @hidden */
  12454. _defineLODRefractionAlpha: string;
  12455. /** @hidden */
  12456. _defineLinearSpecularRefraction: string;
  12457. /** @hidden */
  12458. _defineOppositeZ: string;
  12459. /** @hidden */
  12460. _cubeSamplerName: string;
  12461. /** @hidden */
  12462. _2DSamplerName: string;
  12463. /** @hidden */
  12464. _vRefractionMicrosurfaceInfosName: string;
  12465. /** @hidden */
  12466. _vRefractionInfosName: string;
  12467. private _scene;
  12468. /**
  12469. * The properties below are set by the main PBR block prior to calling methods of this class.
  12470. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  12471. * It's less burden on the user side in the editor part.
  12472. */
  12473. /** @hidden */
  12474. viewConnectionPoint: NodeMaterialConnectionPoint;
  12475. /** @hidden */
  12476. indexOfRefractionConnectionPoint: NodeMaterialConnectionPoint;
  12477. /**
  12478. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  12479. * Materials half opaque for instance using refraction could benefit from this control.
  12480. */
  12481. linkRefractionWithTransparency: boolean;
  12482. /**
  12483. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  12484. */
  12485. invertRefractionY: boolean;
  12486. /**
  12487. * Gets or sets the texture associated with the node
  12488. */
  12489. texture: Nullable<BaseTexture>;
  12490. /**
  12491. * Create a new RefractionBlock
  12492. * @param name defines the block name
  12493. */
  12494. constructor(name: string);
  12495. /**
  12496. * Gets the current class name
  12497. * @returns the class name
  12498. */
  12499. getClassName(): string;
  12500. /**
  12501. * Gets the intensity input component
  12502. */
  12503. get intensity(): NodeMaterialConnectionPoint;
  12504. /**
  12505. * Gets the tint at distance input component
  12506. */
  12507. get tintAtDistance(): NodeMaterialConnectionPoint;
  12508. /**
  12509. * Gets the view input component
  12510. */
  12511. get view(): NodeMaterialConnectionPoint;
  12512. /**
  12513. * Gets the refraction object output component
  12514. */
  12515. get refraction(): NodeMaterialConnectionPoint;
  12516. /**
  12517. * Returns true if the block has a texture
  12518. */
  12519. get hasTexture(): boolean;
  12520. protected _getTexture(): Nullable<BaseTexture>;
  12521. autoConfigure(material: NodeMaterial): void;
  12522. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12523. isReady(): boolean;
  12524. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  12525. /**
  12526. * Gets the main code of the block (fragment side)
  12527. * @param state current state of the node material building
  12528. * @returns the shader code
  12529. */
  12530. getCode(state: NodeMaterialBuildState): string;
  12531. protected _buildBlock(state: NodeMaterialBuildState): this;
  12532. protected _dumpPropertiesCode(): string;
  12533. serialize(): any;
  12534. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12535. }
  12536. }
  12537. declare module BABYLON {
  12538. /**
  12539. * Base block used as input for post process
  12540. */
  12541. export class CurrentScreenBlock extends NodeMaterialBlock {
  12542. private _samplerName;
  12543. private _linearDefineName;
  12544. private _gammaDefineName;
  12545. private _mainUVName;
  12546. private _tempTextureRead;
  12547. /**
  12548. * Gets or sets the texture associated with the node
  12549. */
  12550. texture: Nullable<BaseTexture>;
  12551. /**
  12552. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12553. */
  12554. convertToGammaSpace: boolean;
  12555. /**
  12556. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12557. */
  12558. convertToLinearSpace: boolean;
  12559. /**
  12560. * Create a new CurrentScreenBlock
  12561. * @param name defines the block name
  12562. */
  12563. constructor(name: string);
  12564. /**
  12565. * Gets the current class name
  12566. * @returns the class name
  12567. */
  12568. getClassName(): string;
  12569. /**
  12570. * Gets the uv input component
  12571. */
  12572. get uv(): NodeMaterialConnectionPoint;
  12573. /**
  12574. * Gets the rgba output component
  12575. */
  12576. get rgba(): NodeMaterialConnectionPoint;
  12577. /**
  12578. * Gets the rgb output component
  12579. */
  12580. get rgb(): NodeMaterialConnectionPoint;
  12581. /**
  12582. * Gets the r output component
  12583. */
  12584. get r(): NodeMaterialConnectionPoint;
  12585. /**
  12586. * Gets the g output component
  12587. */
  12588. get g(): NodeMaterialConnectionPoint;
  12589. /**
  12590. * Gets the b output component
  12591. */
  12592. get b(): NodeMaterialConnectionPoint;
  12593. /**
  12594. * Gets the a output component
  12595. */
  12596. get a(): NodeMaterialConnectionPoint;
  12597. /**
  12598. * Initialize the block and prepare the context for build
  12599. * @param state defines the state that will be used for the build
  12600. */
  12601. initialize(state: NodeMaterialBuildState): void;
  12602. get target(): NodeMaterialBlockTargets;
  12603. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12604. isReady(): boolean;
  12605. private _injectVertexCode;
  12606. private _writeTextureRead;
  12607. private _writeOutput;
  12608. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12609. serialize(): any;
  12610. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12611. }
  12612. }
  12613. declare module BABYLON {
  12614. /**
  12615. * Base block used for the particle texture
  12616. */
  12617. export class ParticleTextureBlock extends NodeMaterialBlock {
  12618. private _samplerName;
  12619. private _linearDefineName;
  12620. private _gammaDefineName;
  12621. private _tempTextureRead;
  12622. /**
  12623. * Gets or sets the texture associated with the node
  12624. */
  12625. texture: Nullable<BaseTexture>;
  12626. /**
  12627. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12628. */
  12629. convertToGammaSpace: boolean;
  12630. /**
  12631. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12632. */
  12633. convertToLinearSpace: boolean;
  12634. /**
  12635. * Create a new ParticleTextureBlock
  12636. * @param name defines the block name
  12637. */
  12638. constructor(name: string);
  12639. /**
  12640. * Gets the current class name
  12641. * @returns the class name
  12642. */
  12643. getClassName(): string;
  12644. /**
  12645. * Gets the uv input component
  12646. */
  12647. get uv(): NodeMaterialConnectionPoint;
  12648. /**
  12649. * Gets the rgba output component
  12650. */
  12651. get rgba(): NodeMaterialConnectionPoint;
  12652. /**
  12653. * Gets the rgb output component
  12654. */
  12655. get rgb(): NodeMaterialConnectionPoint;
  12656. /**
  12657. * Gets the r output component
  12658. */
  12659. get r(): NodeMaterialConnectionPoint;
  12660. /**
  12661. * Gets the g output component
  12662. */
  12663. get g(): NodeMaterialConnectionPoint;
  12664. /**
  12665. * Gets the b output component
  12666. */
  12667. get b(): NodeMaterialConnectionPoint;
  12668. /**
  12669. * Gets the a output component
  12670. */
  12671. get a(): NodeMaterialConnectionPoint;
  12672. /**
  12673. * Initialize the block and prepare the context for build
  12674. * @param state defines the state that will be used for the build
  12675. */
  12676. initialize(state: NodeMaterialBuildState): void;
  12677. autoConfigure(material: NodeMaterial): void;
  12678. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12679. isReady(): boolean;
  12680. private _writeOutput;
  12681. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12682. serialize(): any;
  12683. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12684. }
  12685. }
  12686. declare module BABYLON {
  12687. /**
  12688. * Class used to store shared data between 2 NodeMaterialBuildState
  12689. */
  12690. export class NodeMaterialBuildStateSharedData {
  12691. /**
  12692. * Gets the list of emitted varyings
  12693. */
  12694. temps: string[];
  12695. /**
  12696. * Gets the list of emitted varyings
  12697. */
  12698. varyings: string[];
  12699. /**
  12700. * Gets the varying declaration string
  12701. */
  12702. varyingDeclaration: string;
  12703. /**
  12704. * Input blocks
  12705. */
  12706. inputBlocks: InputBlock[];
  12707. /**
  12708. * Input blocks
  12709. */
  12710. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  12711. /**
  12712. * Bindable blocks (Blocks that need to set data to the effect)
  12713. */
  12714. bindableBlocks: NodeMaterialBlock[];
  12715. /**
  12716. * List of blocks that can provide a compilation fallback
  12717. */
  12718. blocksWithFallbacks: NodeMaterialBlock[];
  12719. /**
  12720. * List of blocks that can provide a define update
  12721. */
  12722. blocksWithDefines: NodeMaterialBlock[];
  12723. /**
  12724. * List of blocks that can provide a repeatable content
  12725. */
  12726. repeatableContentBlocks: NodeMaterialBlock[];
  12727. /**
  12728. * List of blocks that can provide a dynamic list of uniforms
  12729. */
  12730. dynamicUniformBlocks: NodeMaterialBlock[];
  12731. /**
  12732. * List of blocks that can block the isReady function for the material
  12733. */
  12734. blockingBlocks: NodeMaterialBlock[];
  12735. /**
  12736. * Gets the list of animated inputs
  12737. */
  12738. animatedInputs: InputBlock[];
  12739. /**
  12740. * Build Id used to avoid multiple recompilations
  12741. */
  12742. buildId: number;
  12743. /** List of emitted variables */
  12744. variableNames: {
  12745. [key: string]: number;
  12746. };
  12747. /** List of emitted defines */
  12748. defineNames: {
  12749. [key: string]: number;
  12750. };
  12751. /** Should emit comments? */
  12752. emitComments: boolean;
  12753. /** Emit build activity */
  12754. verbose: boolean;
  12755. /** Gets or sets the hosting scene */
  12756. scene: Scene;
  12757. /**
  12758. * Gets the compilation hints emitted at compilation time
  12759. */
  12760. hints: {
  12761. needWorldViewMatrix: boolean;
  12762. needWorldViewProjectionMatrix: boolean;
  12763. needAlphaBlending: boolean;
  12764. needAlphaTesting: boolean;
  12765. };
  12766. /**
  12767. * List of compilation checks
  12768. */
  12769. checks: {
  12770. emitVertex: boolean;
  12771. emitFragment: boolean;
  12772. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  12773. };
  12774. /**
  12775. * Is vertex program allowed to be empty?
  12776. */
  12777. allowEmptyVertexProgram: boolean;
  12778. /** Creates a new shared data */
  12779. constructor();
  12780. /**
  12781. * Emits console errors and exceptions if there is a failing check
  12782. */
  12783. emitErrors(): void;
  12784. }
  12785. }
  12786. declare module BABYLON {
  12787. /**
  12788. * Class used to store node based material build state
  12789. */
  12790. export class NodeMaterialBuildState {
  12791. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  12792. supportUniformBuffers: boolean;
  12793. /**
  12794. * Gets the list of emitted attributes
  12795. */
  12796. attributes: string[];
  12797. /**
  12798. * Gets the list of emitted uniforms
  12799. */
  12800. uniforms: string[];
  12801. /**
  12802. * Gets the list of emitted constants
  12803. */
  12804. constants: string[];
  12805. /**
  12806. * Gets the list of emitted samplers
  12807. */
  12808. samplers: string[];
  12809. /**
  12810. * Gets the list of emitted functions
  12811. */
  12812. functions: {
  12813. [key: string]: string;
  12814. };
  12815. /**
  12816. * Gets the list of emitted extensions
  12817. */
  12818. extensions: {
  12819. [key: string]: string;
  12820. };
  12821. /**
  12822. * Gets the target of the compilation state
  12823. */
  12824. target: NodeMaterialBlockTargets;
  12825. /**
  12826. * Gets the list of emitted counters
  12827. */
  12828. counters: {
  12829. [key: string]: number;
  12830. };
  12831. /**
  12832. * Shared data between multiple NodeMaterialBuildState instances
  12833. */
  12834. sharedData: NodeMaterialBuildStateSharedData;
  12835. /** @hidden */
  12836. _vertexState: NodeMaterialBuildState;
  12837. /** @hidden */
  12838. _attributeDeclaration: string;
  12839. /** @hidden */
  12840. _uniformDeclaration: string;
  12841. /** @hidden */
  12842. _constantDeclaration: string;
  12843. /** @hidden */
  12844. _samplerDeclaration: string;
  12845. /** @hidden */
  12846. _varyingTransfer: string;
  12847. /** @hidden */
  12848. _injectAtEnd: string;
  12849. private _repeatableContentAnchorIndex;
  12850. /** @hidden */
  12851. _builtCompilationString: string;
  12852. /**
  12853. * Gets the emitted compilation strings
  12854. */
  12855. compilationString: string;
  12856. /**
  12857. * Finalize the compilation strings
  12858. * @param state defines the current compilation state
  12859. */
  12860. finalize(state: NodeMaterialBuildState): void;
  12861. /** @hidden */
  12862. get _repeatableContentAnchor(): string;
  12863. /** @hidden */
  12864. _getFreeVariableName(prefix: string): string;
  12865. /** @hidden */
  12866. _getFreeDefineName(prefix: string): string;
  12867. /** @hidden */
  12868. _excludeVariableName(name: string): void;
  12869. /** @hidden */
  12870. _emit2DSampler(name: string): void;
  12871. /** @hidden */
  12872. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  12873. /** @hidden */
  12874. _emitExtension(name: string, extension: string, define?: string): void;
  12875. /** @hidden */
  12876. _emitFunction(name: string, code: string, comments: string): void;
  12877. /** @hidden */
  12878. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  12879. replaceStrings?: {
  12880. search: RegExp;
  12881. replace: string;
  12882. }[];
  12883. repeatKey?: string;
  12884. }): string;
  12885. /** @hidden */
  12886. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  12887. repeatKey?: string;
  12888. removeAttributes?: boolean;
  12889. removeUniforms?: boolean;
  12890. removeVaryings?: boolean;
  12891. removeIfDef?: boolean;
  12892. replaceStrings?: {
  12893. search: RegExp;
  12894. replace: string;
  12895. }[];
  12896. }, storeKey?: string): void;
  12897. /** @hidden */
  12898. _registerTempVariable(name: string): boolean;
  12899. /** @hidden */
  12900. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  12901. /** @hidden */
  12902. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  12903. /** @hidden */
  12904. _emitFloat(value: number): string;
  12905. }
  12906. }
  12907. declare module BABYLON {
  12908. /**
  12909. * Helper class used to generate session unique ID
  12910. */
  12911. export class UniqueIdGenerator {
  12912. private static _UniqueIdCounter;
  12913. /**
  12914. * Gets an unique (relatively to the current scene) Id
  12915. */
  12916. static get UniqueId(): number;
  12917. }
  12918. }
  12919. declare module BABYLON {
  12920. /**
  12921. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  12922. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  12923. */
  12924. export class EffectFallbacks implements IEffectFallbacks {
  12925. private _defines;
  12926. private _currentRank;
  12927. private _maxRank;
  12928. private _mesh;
  12929. /**
  12930. * Removes the fallback from the bound mesh.
  12931. */
  12932. unBindMesh(): void;
  12933. /**
  12934. * Adds a fallback on the specified property.
  12935. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  12936. * @param define The name of the define in the shader
  12937. */
  12938. addFallback(rank: number, define: string): void;
  12939. /**
  12940. * Sets the mesh to use CPU skinning when needing to fallback.
  12941. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  12942. * @param mesh The mesh to use the fallbacks.
  12943. */
  12944. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  12945. /**
  12946. * Checks to see if more fallbacks are still availible.
  12947. */
  12948. get hasMoreFallbacks(): boolean;
  12949. /**
  12950. * Removes the defines that should be removed when falling back.
  12951. * @param currentDefines defines the current define statements for the shader.
  12952. * @param effect defines the current effect we try to compile
  12953. * @returns The resulting defines with defines of the current rank removed.
  12954. */
  12955. reduce(currentDefines: string, effect: Effect): string;
  12956. }
  12957. }
  12958. declare module BABYLON {
  12959. /**
  12960. * Defines a block that can be used inside a node based material
  12961. */
  12962. export class NodeMaterialBlock {
  12963. private _buildId;
  12964. private _buildTarget;
  12965. private _target;
  12966. private _isFinalMerger;
  12967. private _isInput;
  12968. private _name;
  12969. protected _isUnique: boolean;
  12970. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  12971. inputsAreExclusive: boolean;
  12972. /** @hidden */
  12973. _codeVariableName: string;
  12974. /** @hidden */
  12975. _inputs: NodeMaterialConnectionPoint[];
  12976. /** @hidden */
  12977. _outputs: NodeMaterialConnectionPoint[];
  12978. /** @hidden */
  12979. _preparationId: number;
  12980. /**
  12981. * Gets the name of the block
  12982. */
  12983. get name(): string;
  12984. /**
  12985. * Sets the name of the block. Will check if the name is valid.
  12986. */
  12987. set name(newName: string);
  12988. /**
  12989. * Gets or sets the unique id of the node
  12990. */
  12991. uniqueId: number;
  12992. /**
  12993. * Gets or sets the comments associated with this block
  12994. */
  12995. comments: string;
  12996. /**
  12997. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  12998. */
  12999. get isUnique(): boolean;
  13000. /**
  13001. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  13002. */
  13003. get isFinalMerger(): boolean;
  13004. /**
  13005. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  13006. */
  13007. get isInput(): boolean;
  13008. /**
  13009. * Gets or sets the build Id
  13010. */
  13011. get buildId(): number;
  13012. set buildId(value: number);
  13013. /**
  13014. * Gets or sets the target of the block
  13015. */
  13016. get target(): NodeMaterialBlockTargets;
  13017. set target(value: NodeMaterialBlockTargets);
  13018. /**
  13019. * Gets the list of input points
  13020. */
  13021. get inputs(): NodeMaterialConnectionPoint[];
  13022. /** Gets the list of output points */
  13023. get outputs(): NodeMaterialConnectionPoint[];
  13024. /**
  13025. * Find an input by its name
  13026. * @param name defines the name of the input to look for
  13027. * @returns the input or null if not found
  13028. */
  13029. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13030. /**
  13031. * Find an output by its name
  13032. * @param name defines the name of the outputto look for
  13033. * @returns the output or null if not found
  13034. */
  13035. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13036. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  13037. visibleInInspector: boolean;
  13038. /**
  13039. * Creates a new NodeMaterialBlock
  13040. * @param name defines the block name
  13041. * @param target defines the target of that block (Vertex by default)
  13042. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  13043. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  13044. */
  13045. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  13046. /**
  13047. * Initialize the block and prepare the context for build
  13048. * @param state defines the state that will be used for the build
  13049. */
  13050. initialize(state: NodeMaterialBuildState): void;
  13051. /**
  13052. * Bind data to effect. Will only be called for blocks with isBindable === true
  13053. * @param effect defines the effect to bind data to
  13054. * @param nodeMaterial defines the hosting NodeMaterial
  13055. * @param mesh defines the mesh that will be rendered
  13056. * @param subMesh defines the submesh that will be rendered
  13057. */
  13058. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13059. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  13060. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  13061. protected _writeFloat(value: number): string;
  13062. /**
  13063. * Gets the current class name e.g. "NodeMaterialBlock"
  13064. * @returns the class name
  13065. */
  13066. getClassName(): string;
  13067. /**
  13068. * Register a new input. Must be called inside a block constructor
  13069. * @param name defines the connection point name
  13070. * @param type defines the connection point type
  13071. * @param isOptional defines a boolean indicating that this input can be omitted
  13072. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13073. * @param point an already created connection point. If not provided, create a new one
  13074. * @returns the current block
  13075. */
  13076. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13077. /**
  13078. * Register a new output. Must be called inside a block constructor
  13079. * @param name defines the connection point name
  13080. * @param type defines the connection point type
  13081. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13082. * @param point an already created connection point. If not provided, create a new one
  13083. * @returns the current block
  13084. */
  13085. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13086. /**
  13087. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  13088. * @param forOutput defines an optional connection point to check compatibility with
  13089. * @returns the first available input or null
  13090. */
  13091. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  13092. /**
  13093. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  13094. * @param forBlock defines an optional block to check compatibility with
  13095. * @returns the first available input or null
  13096. */
  13097. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  13098. /**
  13099. * Gets the sibling of the given output
  13100. * @param current defines the current output
  13101. * @returns the next output in the list or null
  13102. */
  13103. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  13104. /**
  13105. * Connect current block with another block
  13106. * @param other defines the block to connect with
  13107. * @param options define the various options to help pick the right connections
  13108. * @returns the current block
  13109. */
  13110. connectTo(other: NodeMaterialBlock, options?: {
  13111. input?: string;
  13112. output?: string;
  13113. outputSwizzle?: string;
  13114. }): this | undefined;
  13115. protected _buildBlock(state: NodeMaterialBuildState): void;
  13116. /**
  13117. * Add uniforms, samplers and uniform buffers at compilation time
  13118. * @param state defines the state to update
  13119. * @param nodeMaterial defines the node material requesting the update
  13120. * @param defines defines the material defines to update
  13121. * @param uniformBuffers defines the list of uniform buffer names
  13122. */
  13123. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  13124. /**
  13125. * Add potential fallbacks if shader compilation fails
  13126. * @param mesh defines the mesh to be rendered
  13127. * @param fallbacks defines the current prioritized list of fallbacks
  13128. */
  13129. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  13130. /**
  13131. * Initialize defines for shader compilation
  13132. * @param mesh defines the mesh to be rendered
  13133. * @param nodeMaterial defines the node material requesting the update
  13134. * @param defines defines the material defines to update
  13135. * @param useInstances specifies that instances should be used
  13136. */
  13137. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  13138. /**
  13139. * Update defines for shader compilation
  13140. * @param mesh defines the mesh to be rendered
  13141. * @param nodeMaterial defines the node material requesting the update
  13142. * @param defines defines the material defines to update
  13143. * @param useInstances specifies that instances should be used
  13144. * @param subMesh defines which submesh to render
  13145. */
  13146. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13147. /**
  13148. * Lets the block try to connect some inputs automatically
  13149. * @param material defines the hosting NodeMaterial
  13150. */
  13151. autoConfigure(material: NodeMaterial): void;
  13152. /**
  13153. * Function called when a block is declared as repeatable content generator
  13154. * @param vertexShaderState defines the current compilation state for the vertex shader
  13155. * @param fragmentShaderState defines the current compilation state for the fragment shader
  13156. * @param mesh defines the mesh to be rendered
  13157. * @param defines defines the material defines to update
  13158. */
  13159. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  13160. /**
  13161. * Checks if the block is ready
  13162. * @param mesh defines the mesh to be rendered
  13163. * @param nodeMaterial defines the node material requesting the update
  13164. * @param defines defines the material defines to update
  13165. * @param useInstances specifies that instances should be used
  13166. * @returns true if the block is ready
  13167. */
  13168. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  13169. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  13170. private _processBuild;
  13171. /**
  13172. * Validates the new name for the block node.
  13173. * @param newName the new name to be given to the node.
  13174. * @returns false if the name is a reserve word, else true.
  13175. */
  13176. validateBlockName(newName: string): boolean;
  13177. /**
  13178. * Compile the current node and generate the shader code
  13179. * @param state defines the current compilation state (uniforms, samplers, current string)
  13180. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  13181. * @returns true if already built
  13182. */
  13183. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  13184. protected _inputRename(name: string): string;
  13185. protected _outputRename(name: string): string;
  13186. protected _dumpPropertiesCode(): string;
  13187. /** @hidden */
  13188. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  13189. /** @hidden */
  13190. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  13191. /**
  13192. * Clone the current block to a new identical block
  13193. * @param scene defines the hosting scene
  13194. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  13195. * @returns a copy of the current block
  13196. */
  13197. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  13198. /**
  13199. * Serializes this block in a JSON representation
  13200. * @returns the serialized block object
  13201. */
  13202. serialize(): any;
  13203. /** @hidden */
  13204. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13205. private _deserializePortDisplayNamesAndExposedOnFrame;
  13206. /**
  13207. * Release resources
  13208. */
  13209. dispose(): void;
  13210. }
  13211. }
  13212. declare module BABYLON {
  13213. /**
  13214. * Base class of materials working in push mode in babylon JS
  13215. * @hidden
  13216. */
  13217. export class PushMaterial extends Material {
  13218. protected _activeEffect: Effect;
  13219. protected _normalMatrix: Matrix;
  13220. constructor(name: string, scene: Scene);
  13221. getEffect(): Effect;
  13222. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13223. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  13224. /**
  13225. * Binds the given world matrix to the active effect
  13226. *
  13227. * @param world the matrix to bind
  13228. */
  13229. bindOnlyWorldMatrix(world: Matrix): void;
  13230. /**
  13231. * Binds the given normal matrix to the active effect
  13232. *
  13233. * @param normalMatrix the matrix to bind
  13234. */
  13235. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  13236. bind(world: Matrix, mesh?: Mesh): void;
  13237. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  13238. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  13239. }
  13240. }
  13241. declare module BABYLON {
  13242. /**
  13243. * Root class for all node material optimizers
  13244. */
  13245. export class NodeMaterialOptimizer {
  13246. /**
  13247. * Function used to optimize a NodeMaterial graph
  13248. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  13249. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  13250. */
  13251. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  13252. }
  13253. }
  13254. declare module BABYLON {
  13255. /**
  13256. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  13257. */
  13258. export class TransformBlock extends NodeMaterialBlock {
  13259. /**
  13260. * Defines the value to use to complement W value to transform it to a Vector4
  13261. */
  13262. complementW: number;
  13263. /**
  13264. * Defines the value to use to complement z value to transform it to a Vector4
  13265. */
  13266. complementZ: number;
  13267. /**
  13268. * Creates a new TransformBlock
  13269. * @param name defines the block name
  13270. */
  13271. constructor(name: string);
  13272. /**
  13273. * Gets the current class name
  13274. * @returns the class name
  13275. */
  13276. getClassName(): string;
  13277. /**
  13278. * Gets the vector input
  13279. */
  13280. get vector(): NodeMaterialConnectionPoint;
  13281. /**
  13282. * Gets the output component
  13283. */
  13284. get output(): NodeMaterialConnectionPoint;
  13285. /**
  13286. * Gets the xyz output component
  13287. */
  13288. get xyz(): NodeMaterialConnectionPoint;
  13289. /**
  13290. * Gets the matrix transform input
  13291. */
  13292. get transform(): NodeMaterialConnectionPoint;
  13293. protected _buildBlock(state: NodeMaterialBuildState): this;
  13294. /**
  13295. * Update defines for shader compilation
  13296. * @param mesh defines the mesh to be rendered
  13297. * @param nodeMaterial defines the node material requesting the update
  13298. * @param defines defines the material defines to update
  13299. * @param useInstances specifies that instances should be used
  13300. * @param subMesh defines which submesh to render
  13301. */
  13302. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13303. serialize(): any;
  13304. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13305. protected _dumpPropertiesCode(): string;
  13306. }
  13307. }
  13308. declare module BABYLON {
  13309. /**
  13310. * Block used to output the vertex position
  13311. */
  13312. export class VertexOutputBlock extends NodeMaterialBlock {
  13313. /**
  13314. * Creates a new VertexOutputBlock
  13315. * @param name defines the block name
  13316. */
  13317. constructor(name: string);
  13318. /**
  13319. * Gets the current class name
  13320. * @returns the class name
  13321. */
  13322. getClassName(): string;
  13323. /**
  13324. * Gets the vector input component
  13325. */
  13326. get vector(): NodeMaterialConnectionPoint;
  13327. protected _buildBlock(state: NodeMaterialBuildState): this;
  13328. }
  13329. }
  13330. declare module BABYLON {
  13331. /**
  13332. * Block used to output the final color
  13333. */
  13334. export class FragmentOutputBlock extends NodeMaterialBlock {
  13335. /**
  13336. * Create a new FragmentOutputBlock
  13337. * @param name defines the block name
  13338. */
  13339. constructor(name: string);
  13340. /**
  13341. * Gets the current class name
  13342. * @returns the class name
  13343. */
  13344. getClassName(): string;
  13345. /**
  13346. * Gets the rgba input component
  13347. */
  13348. get rgba(): NodeMaterialConnectionPoint;
  13349. /**
  13350. * Gets the rgb input component
  13351. */
  13352. get rgb(): NodeMaterialConnectionPoint;
  13353. /**
  13354. * Gets the a input component
  13355. */
  13356. get a(): NodeMaterialConnectionPoint;
  13357. protected _buildBlock(state: NodeMaterialBuildState): this;
  13358. }
  13359. }
  13360. declare module BABYLON {
  13361. /**
  13362. * Block used for the particle ramp gradient section
  13363. */
  13364. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  13365. /**
  13366. * Create a new ParticleRampGradientBlock
  13367. * @param name defines the block name
  13368. */
  13369. constructor(name: string);
  13370. /**
  13371. * Gets the current class name
  13372. * @returns the class name
  13373. */
  13374. getClassName(): string;
  13375. /**
  13376. * Gets the color input component
  13377. */
  13378. get color(): NodeMaterialConnectionPoint;
  13379. /**
  13380. * Gets the rampColor output component
  13381. */
  13382. get rampColor(): NodeMaterialConnectionPoint;
  13383. /**
  13384. * Initialize the block and prepare the context for build
  13385. * @param state defines the state that will be used for the build
  13386. */
  13387. initialize(state: NodeMaterialBuildState): void;
  13388. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13389. }
  13390. }
  13391. declare module BABYLON {
  13392. /**
  13393. * Block used for the particle blend multiply section
  13394. */
  13395. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  13396. /**
  13397. * Create a new ParticleBlendMultiplyBlock
  13398. * @param name defines the block name
  13399. */
  13400. constructor(name: string);
  13401. /**
  13402. * Gets the current class name
  13403. * @returns the class name
  13404. */
  13405. getClassName(): string;
  13406. /**
  13407. * Gets the color input component
  13408. */
  13409. get color(): NodeMaterialConnectionPoint;
  13410. /**
  13411. * Gets the alphaTexture input component
  13412. */
  13413. get alphaTexture(): NodeMaterialConnectionPoint;
  13414. /**
  13415. * Gets the alphaColor input component
  13416. */
  13417. get alphaColor(): NodeMaterialConnectionPoint;
  13418. /**
  13419. * Gets the blendColor output component
  13420. */
  13421. get blendColor(): NodeMaterialConnectionPoint;
  13422. /**
  13423. * Initialize the block and prepare the context for build
  13424. * @param state defines the state that will be used for the build
  13425. */
  13426. initialize(state: NodeMaterialBuildState): void;
  13427. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13428. }
  13429. }
  13430. declare module BABYLON {
  13431. /**
  13432. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  13433. */
  13434. export class VectorMergerBlock extends NodeMaterialBlock {
  13435. /**
  13436. * Create a new VectorMergerBlock
  13437. * @param name defines the block name
  13438. */
  13439. constructor(name: string);
  13440. /**
  13441. * Gets the current class name
  13442. * @returns the class name
  13443. */
  13444. getClassName(): string;
  13445. /**
  13446. * Gets the xyz component (input)
  13447. */
  13448. get xyzIn(): NodeMaterialConnectionPoint;
  13449. /**
  13450. * Gets the xy component (input)
  13451. */
  13452. get xyIn(): NodeMaterialConnectionPoint;
  13453. /**
  13454. * Gets the x component (input)
  13455. */
  13456. get x(): NodeMaterialConnectionPoint;
  13457. /**
  13458. * Gets the y component (input)
  13459. */
  13460. get y(): NodeMaterialConnectionPoint;
  13461. /**
  13462. * Gets the z component (input)
  13463. */
  13464. get z(): NodeMaterialConnectionPoint;
  13465. /**
  13466. * Gets the w component (input)
  13467. */
  13468. get w(): NodeMaterialConnectionPoint;
  13469. /**
  13470. * Gets the xyzw component (output)
  13471. */
  13472. get xyzw(): NodeMaterialConnectionPoint;
  13473. /**
  13474. * Gets the xyz component (output)
  13475. */
  13476. get xyzOut(): NodeMaterialConnectionPoint;
  13477. /**
  13478. * Gets the xy component (output)
  13479. */
  13480. get xyOut(): NodeMaterialConnectionPoint;
  13481. /**
  13482. * Gets the xy component (output)
  13483. * @deprecated Please use xyOut instead.
  13484. */
  13485. get xy(): NodeMaterialConnectionPoint;
  13486. /**
  13487. * Gets the xyz component (output)
  13488. * @deprecated Please use xyzOut instead.
  13489. */
  13490. get xyz(): NodeMaterialConnectionPoint;
  13491. protected _buildBlock(state: NodeMaterialBuildState): this;
  13492. }
  13493. }
  13494. declare module BABYLON {
  13495. /**
  13496. * Block used to remap a float from a range to a new one
  13497. */
  13498. export class RemapBlock extends NodeMaterialBlock {
  13499. /**
  13500. * Gets or sets the source range
  13501. */
  13502. sourceRange: Vector2;
  13503. /**
  13504. * Gets or sets the target range
  13505. */
  13506. targetRange: Vector2;
  13507. /**
  13508. * Creates a new RemapBlock
  13509. * @param name defines the block name
  13510. */
  13511. constructor(name: string);
  13512. /**
  13513. * Gets the current class name
  13514. * @returns the class name
  13515. */
  13516. getClassName(): string;
  13517. /**
  13518. * Gets the input component
  13519. */
  13520. get input(): NodeMaterialConnectionPoint;
  13521. /**
  13522. * Gets the source min input component
  13523. */
  13524. get sourceMin(): NodeMaterialConnectionPoint;
  13525. /**
  13526. * Gets the source max input component
  13527. */
  13528. get sourceMax(): NodeMaterialConnectionPoint;
  13529. /**
  13530. * Gets the target min input component
  13531. */
  13532. get targetMin(): NodeMaterialConnectionPoint;
  13533. /**
  13534. * Gets the target max input component
  13535. */
  13536. get targetMax(): NodeMaterialConnectionPoint;
  13537. /**
  13538. * Gets the output component
  13539. */
  13540. get output(): NodeMaterialConnectionPoint;
  13541. protected _buildBlock(state: NodeMaterialBuildState): this;
  13542. protected _dumpPropertiesCode(): string;
  13543. serialize(): any;
  13544. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13545. }
  13546. }
  13547. declare module BABYLON {
  13548. /**
  13549. * Block used to multiply 2 values
  13550. */
  13551. export class MultiplyBlock extends NodeMaterialBlock {
  13552. /**
  13553. * Creates a new MultiplyBlock
  13554. * @param name defines the block name
  13555. */
  13556. constructor(name: string);
  13557. /**
  13558. * Gets the current class name
  13559. * @returns the class name
  13560. */
  13561. getClassName(): string;
  13562. /**
  13563. * Gets the left operand input component
  13564. */
  13565. get left(): NodeMaterialConnectionPoint;
  13566. /**
  13567. * Gets the right operand input component
  13568. */
  13569. get right(): NodeMaterialConnectionPoint;
  13570. /**
  13571. * Gets the output component
  13572. */
  13573. get output(): NodeMaterialConnectionPoint;
  13574. protected _buildBlock(state: NodeMaterialBuildState): this;
  13575. }
  13576. }
  13577. declare module BABYLON {
  13578. /** Interface used by value gradients (color, factor, ...) */
  13579. export interface IValueGradient {
  13580. /**
  13581. * Gets or sets the gradient value (between 0 and 1)
  13582. */
  13583. gradient: number;
  13584. }
  13585. /** Class used to store color4 gradient */
  13586. export class ColorGradient implements IValueGradient {
  13587. /**
  13588. * Gets or sets the gradient value (between 0 and 1)
  13589. */
  13590. gradient: number;
  13591. /**
  13592. * Gets or sets first associated color
  13593. */
  13594. color1: Color4;
  13595. /**
  13596. * Gets or sets second associated color
  13597. */
  13598. color2?: Color4 | undefined;
  13599. /**
  13600. * Creates a new color4 gradient
  13601. * @param gradient gets or sets the gradient value (between 0 and 1)
  13602. * @param color1 gets or sets first associated color
  13603. * @param color2 gets or sets first second color
  13604. */
  13605. constructor(
  13606. /**
  13607. * Gets or sets the gradient value (between 0 and 1)
  13608. */
  13609. gradient: number,
  13610. /**
  13611. * Gets or sets first associated color
  13612. */
  13613. color1: Color4,
  13614. /**
  13615. * Gets or sets second associated color
  13616. */
  13617. color2?: Color4 | undefined);
  13618. /**
  13619. * Will get a color picked randomly between color1 and color2.
  13620. * If color2 is undefined then color1 will be used
  13621. * @param result defines the target Color4 to store the result in
  13622. */
  13623. getColorToRef(result: Color4): void;
  13624. }
  13625. /** Class used to store color 3 gradient */
  13626. export class Color3Gradient implements IValueGradient {
  13627. /**
  13628. * Gets or sets the gradient value (between 0 and 1)
  13629. */
  13630. gradient: number;
  13631. /**
  13632. * Gets or sets the associated color
  13633. */
  13634. color: Color3;
  13635. /**
  13636. * Creates a new color3 gradient
  13637. * @param gradient gets or sets the gradient value (between 0 and 1)
  13638. * @param color gets or sets associated color
  13639. */
  13640. constructor(
  13641. /**
  13642. * Gets or sets the gradient value (between 0 and 1)
  13643. */
  13644. gradient: number,
  13645. /**
  13646. * Gets or sets the associated color
  13647. */
  13648. color: Color3);
  13649. }
  13650. /** Class used to store factor gradient */
  13651. export class FactorGradient implements IValueGradient {
  13652. /**
  13653. * Gets or sets the gradient value (between 0 and 1)
  13654. */
  13655. gradient: number;
  13656. /**
  13657. * Gets or sets first associated factor
  13658. */
  13659. factor1: number;
  13660. /**
  13661. * Gets or sets second associated factor
  13662. */
  13663. factor2?: number | undefined;
  13664. /**
  13665. * Creates a new factor gradient
  13666. * @param gradient gets or sets the gradient value (between 0 and 1)
  13667. * @param factor1 gets or sets first associated factor
  13668. * @param factor2 gets or sets second associated factor
  13669. */
  13670. constructor(
  13671. /**
  13672. * Gets or sets the gradient value (between 0 and 1)
  13673. */
  13674. gradient: number,
  13675. /**
  13676. * Gets or sets first associated factor
  13677. */
  13678. factor1: number,
  13679. /**
  13680. * Gets or sets second associated factor
  13681. */
  13682. factor2?: number | undefined);
  13683. /**
  13684. * Will get a number picked randomly between factor1 and factor2.
  13685. * If factor2 is undefined then factor1 will be used
  13686. * @returns the picked number
  13687. */
  13688. getFactor(): number;
  13689. }
  13690. /**
  13691. * Helper used to simplify some generic gradient tasks
  13692. */
  13693. export class GradientHelper {
  13694. /**
  13695. * Gets the current gradient from an array of IValueGradient
  13696. * @param ratio defines the current ratio to get
  13697. * @param gradients defines the array of IValueGradient
  13698. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  13699. */
  13700. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  13701. }
  13702. }
  13703. declare module BABYLON {
  13704. interface ThinEngine {
  13705. /**
  13706. * Creates a raw texture
  13707. * @param data defines the data to store in the texture
  13708. * @param width defines the width of the texture
  13709. * @param height defines the height of the texture
  13710. * @param format defines the format of the data
  13711. * @param generateMipMaps defines if the engine should generate the mip levels
  13712. * @param invertY defines if data must be stored with Y axis inverted
  13713. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  13714. * @param compression defines the compression used (null by default)
  13715. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  13716. * @returns the raw texture inside an InternalTexture
  13717. */
  13718. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  13719. /**
  13720. * Update a raw texture
  13721. * @param texture defines the texture to update
  13722. * @param data defines the data to store in the texture
  13723. * @param format defines the format of the data
  13724. * @param invertY defines if data must be stored with Y axis inverted
  13725. */
  13726. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  13727. /**
  13728. * Update a raw texture
  13729. * @param texture defines the texture to update
  13730. * @param data defines the data to store in the texture
  13731. * @param format defines the format of the data
  13732. * @param invertY defines if data must be stored with Y axis inverted
  13733. * @param compression defines the compression used (null by default)
  13734. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  13735. */
  13736. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  13737. /**
  13738. * Creates a new raw cube texture
  13739. * @param data defines the array of data to use to create each face
  13740. * @param size defines the size of the textures
  13741. * @param format defines the format of the data
  13742. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  13743. * @param generateMipMaps defines if the engine should generate the mip levels
  13744. * @param invertY defines if data must be stored with Y axis inverted
  13745. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  13746. * @param compression defines the compression used (null by default)
  13747. * @returns the cube texture as an InternalTexture
  13748. */
  13749. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  13750. /**
  13751. * Update a raw cube texture
  13752. * @param texture defines the texture to udpdate
  13753. * @param data defines the data to store
  13754. * @param format defines the data format
  13755. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  13756. * @param invertY defines if data must be stored with Y axis inverted
  13757. */
  13758. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  13759. /**
  13760. * Update a raw cube texture
  13761. * @param texture defines the texture to udpdate
  13762. * @param data defines the data to store
  13763. * @param format defines the data format
  13764. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  13765. * @param invertY defines if data must be stored with Y axis inverted
  13766. * @param compression defines the compression used (null by default)
  13767. */
  13768. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  13769. /**
  13770. * Update a raw cube texture
  13771. * @param texture defines the texture to udpdate
  13772. * @param data defines the data to store
  13773. * @param format defines the data format
  13774. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  13775. * @param invertY defines if data must be stored with Y axis inverted
  13776. * @param compression defines the compression used (null by default)
  13777. * @param level defines which level of the texture to update
  13778. */
  13779. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  13780. /**
  13781. * Creates a new raw cube texture from a specified url
  13782. * @param url defines the url where the data is located
  13783. * @param scene defines the current scene
  13784. * @param size defines the size of the textures
  13785. * @param format defines the format of the data
  13786. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  13787. * @param noMipmap defines if the engine should avoid generating the mip levels
  13788. * @param callback defines a callback used to extract texture data from loaded data
  13789. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  13790. * @param onLoad defines a callback called when texture is loaded
  13791. * @param onError defines a callback called if there is an error
  13792. * @returns the cube texture as an InternalTexture
  13793. */
  13794. createRawCubeTextureFromUrl(url: string, scene: Nullable<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;
  13795. /**
  13796. * Creates a new raw cube texture from a specified url
  13797. * @param url defines the url where the data is located
  13798. * @param scene defines the current scene
  13799. * @param size defines the size of the textures
  13800. * @param format defines the format of the data
  13801. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  13802. * @param noMipmap defines if the engine should avoid generating the mip levels
  13803. * @param callback defines a callback used to extract texture data from loaded data
  13804. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  13805. * @param onLoad defines a callback called when texture is loaded
  13806. * @param onError defines a callback called if there is an error
  13807. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  13808. * @param invertY defines if data must be stored with Y axis inverted
  13809. * @returns the cube texture as an InternalTexture
  13810. */
  13811. createRawCubeTextureFromUrl(url: string, scene: Nullable<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;
  13812. /**
  13813. * Creates a new raw 3D texture
  13814. * @param data defines the data used to create the texture
  13815. * @param width defines the width of the texture
  13816. * @param height defines the height of the texture
  13817. * @param depth defines the depth of the texture
  13818. * @param format defines the format of the texture
  13819. * @param generateMipMaps defines if the engine must generate mip levels
  13820. * @param invertY defines if data must be stored with Y axis inverted
  13821. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  13822. * @param compression defines the compressed used (can be null)
  13823. * @param textureType defines the compressed used (can be null)
  13824. * @returns a new raw 3D texture (stored in an InternalTexture)
  13825. */
  13826. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  13827. /**
  13828. * Update a raw 3D texture
  13829. * @param texture defines the texture to update
  13830. * @param data defines the data to store
  13831. * @param format defines the data format
  13832. * @param invertY defines if data must be stored with Y axis inverted
  13833. */
  13834. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  13835. /**
  13836. * Update a raw 3D texture
  13837. * @param texture defines the texture to update
  13838. * @param data defines the data to store
  13839. * @param format defines the data format
  13840. * @param invertY defines if data must be stored with Y axis inverted
  13841. * @param compression defines the used compression (can be null)
  13842. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  13843. */
  13844. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  13845. /**
  13846. * Creates a new raw 2D array texture
  13847. * @param data defines the data used to create the texture
  13848. * @param width defines the width of the texture
  13849. * @param height defines the height of the texture
  13850. * @param depth defines the number of layers of the texture
  13851. * @param format defines the format of the texture
  13852. * @param generateMipMaps defines if the engine must generate mip levels
  13853. * @param invertY defines if data must be stored with Y axis inverted
  13854. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  13855. * @param compression defines the compressed used (can be null)
  13856. * @param textureType defines the compressed used (can be null)
  13857. * @returns a new raw 2D array texture (stored in an InternalTexture)
  13858. */
  13859. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  13860. /**
  13861. * Update a raw 2D array texture
  13862. * @param texture defines the texture to update
  13863. * @param data defines the data to store
  13864. * @param format defines the data format
  13865. * @param invertY defines if data must be stored with Y axis inverted
  13866. */
  13867. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  13868. /**
  13869. * Update a raw 2D array texture
  13870. * @param texture defines the texture to update
  13871. * @param data defines the data to store
  13872. * @param format defines the data format
  13873. * @param invertY defines if data must be stored with Y axis inverted
  13874. * @param compression defines the used compression (can be null)
  13875. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  13876. */
  13877. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  13878. }
  13879. }
  13880. declare module BABYLON {
  13881. /**
  13882. * Raw texture can help creating a texture directly from an array of data.
  13883. * This can be super useful if you either get the data from an uncompressed source or
  13884. * if you wish to create your texture pixel by pixel.
  13885. */
  13886. export class RawTexture extends Texture {
  13887. /**
  13888. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13889. */
  13890. format: number;
  13891. /**
  13892. * Instantiates a new RawTexture.
  13893. * Raw texture can help creating a texture directly from an array of data.
  13894. * This can be super useful if you either get the data from an uncompressed source or
  13895. * if you wish to create your texture pixel by pixel.
  13896. * @param data define the array of data to use to create the texture
  13897. * @param width define the width of the texture
  13898. * @param height define the height of the texture
  13899. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13900. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13901. * @param generateMipMaps define whether mip maps should be generated or not
  13902. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13903. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13904. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13905. */
  13906. constructor(data: ArrayBufferView, width: number, height: number,
  13907. /**
  13908. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13909. */
  13910. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  13911. /**
  13912. * Updates the texture underlying data.
  13913. * @param data Define the new data of the texture
  13914. */
  13915. update(data: ArrayBufferView): void;
  13916. /**
  13917. * Creates a luminance texture from some data.
  13918. * @param data Define the texture data
  13919. * @param width Define the width of the texture
  13920. * @param height Define the height of the texture
  13921. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13922. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13923. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13924. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13925. * @returns the luminance texture
  13926. */
  13927. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13928. /**
  13929. * Creates a luminance alpha texture from some data.
  13930. * @param data Define the texture data
  13931. * @param width Define the width of the texture
  13932. * @param height Define the height of the texture
  13933. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13934. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13935. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13936. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13937. * @returns the luminance alpha texture
  13938. */
  13939. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13940. /**
  13941. * Creates an alpha texture from some data.
  13942. * @param data Define the texture data
  13943. * @param width Define the width of the texture
  13944. * @param height Define the height of the texture
  13945. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13946. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13947. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13948. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13949. * @returns the alpha texture
  13950. */
  13951. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13952. /**
  13953. * Creates a RGB texture from some data.
  13954. * @param data Define the texture data
  13955. * @param width Define the width of the texture
  13956. * @param height Define the height of the texture
  13957. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13958. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13959. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13960. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13961. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13962. * @returns the RGB alpha texture
  13963. */
  13964. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13965. /**
  13966. * Creates a RGBA texture from some data.
  13967. * @param data Define the texture data
  13968. * @param width Define the width of the texture
  13969. * @param height Define the height of the texture
  13970. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13971. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13972. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13973. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13974. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13975. * @returns the RGBA texture
  13976. */
  13977. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13978. /**
  13979. * Creates a R texture from some data.
  13980. * @param data Define the texture data
  13981. * @param width Define the width of the texture
  13982. * @param height Define the height of the texture
  13983. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13984. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13985. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13986. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13987. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13988. * @returns the R texture
  13989. */
  13990. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13991. }
  13992. }
  13993. declare module BABYLON {
  13994. interface ThinEngine {
  13995. /**
  13996. * Update a dynamic index buffer
  13997. * @param indexBuffer defines the target index buffer
  13998. * @param indices defines the data to update
  13999. * @param offset defines the offset in the target index buffer where update should start
  14000. */
  14001. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  14002. /**
  14003. * Updates a dynamic vertex buffer.
  14004. * @param vertexBuffer the vertex buffer to update
  14005. * @param data the data used to update the vertex buffer
  14006. * @param byteOffset the byte offset of the data
  14007. * @param byteLength the byte length of the data
  14008. */
  14009. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  14010. }
  14011. }
  14012. declare module BABYLON {
  14013. interface AbstractScene {
  14014. /**
  14015. * The list of procedural textures added to the scene
  14016. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14017. */
  14018. proceduralTextures: Array<ProceduralTexture>;
  14019. }
  14020. /**
  14021. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14022. * in a given scene.
  14023. */
  14024. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14025. /**
  14026. * The component name helpfull to identify the component in the list of scene components.
  14027. */
  14028. readonly name: string;
  14029. /**
  14030. * The scene the component belongs to.
  14031. */
  14032. scene: Scene;
  14033. /**
  14034. * Creates a new instance of the component for the given scene
  14035. * @param scene Defines the scene to register the component in
  14036. */
  14037. constructor(scene: Scene);
  14038. /**
  14039. * Registers the component in a given scene
  14040. */
  14041. register(): void;
  14042. /**
  14043. * Rebuilds the elements related to this component in case of
  14044. * context lost for instance.
  14045. */
  14046. rebuild(): void;
  14047. /**
  14048. * Disposes the component and the associated ressources.
  14049. */
  14050. dispose(): void;
  14051. private _beforeClear;
  14052. }
  14053. }
  14054. declare module BABYLON {
  14055. interface ThinEngine {
  14056. /**
  14057. * Creates a new render target cube texture
  14058. * @param size defines the size of the texture
  14059. * @param options defines the options used to create the texture
  14060. * @returns a new render target cube texture stored in an InternalTexture
  14061. */
  14062. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14063. }
  14064. }
  14065. declare module BABYLON {
  14066. /** @hidden */
  14067. export var proceduralVertexShader: {
  14068. name: string;
  14069. shader: string;
  14070. };
  14071. }
  14072. declare module BABYLON {
  14073. /**
  14074. * 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.
  14075. * This is the base class of any Procedural texture and contains most of the shareable code.
  14076. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14077. */
  14078. export class ProceduralTexture extends Texture {
  14079. /**
  14080. * Define if the texture is enabled or not (disabled texture will not render)
  14081. */
  14082. isEnabled: boolean;
  14083. /**
  14084. * Define if the texture must be cleared before rendering (default is true)
  14085. */
  14086. autoClear: boolean;
  14087. /**
  14088. * Callback called when the texture is generated
  14089. */
  14090. onGenerated: () => void;
  14091. /**
  14092. * Event raised when the texture is generated
  14093. */
  14094. onGeneratedObservable: Observable<ProceduralTexture>;
  14095. /**
  14096. * Event raised before the texture is generated
  14097. */
  14098. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  14099. /**
  14100. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  14101. */
  14102. nodeMaterialSource: Nullable<NodeMaterial>;
  14103. /** @hidden */
  14104. _generateMipMaps: boolean;
  14105. /** @hidden **/
  14106. _effect: Effect;
  14107. /** @hidden */
  14108. _textures: {
  14109. [key: string]: Texture;
  14110. };
  14111. /** @hidden */
  14112. protected _fallbackTexture: Nullable<Texture>;
  14113. private _size;
  14114. private _currentRefreshId;
  14115. private _frameId;
  14116. private _refreshRate;
  14117. private _vertexBuffers;
  14118. private _indexBuffer;
  14119. private _uniforms;
  14120. private _samplers;
  14121. private _fragment;
  14122. private _floats;
  14123. private _ints;
  14124. private _floatsArrays;
  14125. private _colors3;
  14126. private _colors4;
  14127. private _vectors2;
  14128. private _vectors3;
  14129. private _matrices;
  14130. private _fallbackTextureUsed;
  14131. private _fullEngine;
  14132. private _cachedDefines;
  14133. private _contentUpdateId;
  14134. private _contentData;
  14135. /**
  14136. * Instantiates a new procedural texture.
  14137. * 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.
  14138. * This is the base class of any Procedural texture and contains most of the shareable code.
  14139. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14140. * @param name Define the name of the texture
  14141. * @param size Define the size of the texture to create
  14142. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14143. * @param scene Define the scene the texture belongs to
  14144. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14145. * @param generateMipMaps Define if the texture should creates mip maps or not
  14146. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14147. * @param textureType The FBO internal texture type
  14148. */
  14149. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  14150. /**
  14151. * The effect that is created when initializing the post process.
  14152. * @returns The created effect corresponding the the postprocess.
  14153. */
  14154. getEffect(): Effect;
  14155. /**
  14156. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14157. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14158. */
  14159. getContent(): Nullable<ArrayBufferView>;
  14160. private _createIndexBuffer;
  14161. /** @hidden */
  14162. _rebuild(): void;
  14163. /**
  14164. * Resets the texture in order to recreate its associated resources.
  14165. * This can be called in case of context loss
  14166. */
  14167. reset(): void;
  14168. protected _getDefines(): string;
  14169. /**
  14170. * Is the texture ready to be used ? (rendered at least once)
  14171. * @returns true if ready, otherwise, false.
  14172. */
  14173. isReady(): boolean;
  14174. /**
  14175. * Resets the refresh counter of the texture and start bak from scratch.
  14176. * Could be useful to regenerate the texture if it is setup to render only once.
  14177. */
  14178. resetRefreshCounter(): void;
  14179. /**
  14180. * Set the fragment shader to use in order to render the texture.
  14181. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14182. */
  14183. setFragment(fragment: any): void;
  14184. /**
  14185. * Define the refresh rate of the texture or the rendering frequency.
  14186. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14187. */
  14188. get refreshRate(): number;
  14189. set refreshRate(value: number);
  14190. /** @hidden */
  14191. _shouldRender(): boolean;
  14192. /**
  14193. * Get the size the texture is rendering at.
  14194. * @returns the size (on cube texture it is always squared)
  14195. */
  14196. getRenderSize(): RenderTargetTextureSize;
  14197. /**
  14198. * Resize the texture to new value.
  14199. * @param size Define the new size the texture should have
  14200. * @param generateMipMaps Define whether the new texture should create mip maps
  14201. */
  14202. resize(size: number, generateMipMaps: boolean): void;
  14203. private _checkUniform;
  14204. /**
  14205. * Set a texture in the shader program used to render.
  14206. * @param name Define the name of the uniform samplers as defined in the shader
  14207. * @param texture Define the texture to bind to this sampler
  14208. * @return the texture itself allowing "fluent" like uniform updates
  14209. */
  14210. setTexture(name: string, texture: Texture): ProceduralTexture;
  14211. /**
  14212. * Set a float in the shader.
  14213. * @param name Define the name of the uniform as defined in the shader
  14214. * @param value Define the value to give to the uniform
  14215. * @return the texture itself allowing "fluent" like uniform updates
  14216. */
  14217. setFloat(name: string, value: number): ProceduralTexture;
  14218. /**
  14219. * Set a int in the shader.
  14220. * @param name Define the name of the uniform as defined in the shader
  14221. * @param value Define the value to give to the uniform
  14222. * @return the texture itself allowing "fluent" like uniform updates
  14223. */
  14224. setInt(name: string, value: number): ProceduralTexture;
  14225. /**
  14226. * Set an array of floats in the shader.
  14227. * @param name Define the name of the uniform as defined in the shader
  14228. * @param value Define the value to give to the uniform
  14229. * @return the texture itself allowing "fluent" like uniform updates
  14230. */
  14231. setFloats(name: string, value: number[]): ProceduralTexture;
  14232. /**
  14233. * Set a vec3 in the shader from a Color3.
  14234. * @param name Define the name of the uniform as defined in the shader
  14235. * @param value Define the value to give to the uniform
  14236. * @return the texture itself allowing "fluent" like uniform updates
  14237. */
  14238. setColor3(name: string, value: Color3): ProceduralTexture;
  14239. /**
  14240. * Set a vec4 in the shader from a Color4.
  14241. * @param name Define the name of the uniform as defined in the shader
  14242. * @param value Define the value to give to the uniform
  14243. * @return the texture itself allowing "fluent" like uniform updates
  14244. */
  14245. setColor4(name: string, value: Color4): ProceduralTexture;
  14246. /**
  14247. * Set a vec2 in the shader from a Vector2.
  14248. * @param name Define the name of the uniform as defined in the shader
  14249. * @param value Define the value to give to the uniform
  14250. * @return the texture itself allowing "fluent" like uniform updates
  14251. */
  14252. setVector2(name: string, value: Vector2): ProceduralTexture;
  14253. /**
  14254. * Set a vec3 in the shader from a Vector3.
  14255. * @param name Define the name of the uniform as defined in the shader
  14256. * @param value Define the value to give to the uniform
  14257. * @return the texture itself allowing "fluent" like uniform updates
  14258. */
  14259. setVector3(name: string, value: Vector3): ProceduralTexture;
  14260. /**
  14261. * Set a mat4 in the shader from a MAtrix.
  14262. * @param name Define the name of the uniform as defined in the shader
  14263. * @param value Define the value to give to the uniform
  14264. * @return the texture itself allowing "fluent" like uniform updates
  14265. */
  14266. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14267. /**
  14268. * Render the texture to its associated render target.
  14269. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14270. */
  14271. render(useCameraPostProcess?: boolean): void;
  14272. /**
  14273. * Clone the texture.
  14274. * @returns the cloned texture
  14275. */
  14276. clone(): ProceduralTexture;
  14277. /**
  14278. * Dispose the texture and release its asoociated resources.
  14279. */
  14280. dispose(): void;
  14281. }
  14282. }
  14283. declare module BABYLON {
  14284. /**
  14285. * This represents the base class for particle system in Babylon.
  14286. * 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.
  14287. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14288. * @example https://doc.babylonjs.com/babylon101/particles
  14289. */
  14290. export class BaseParticleSystem {
  14291. /**
  14292. * Source color is added to the destination color without alpha affecting the result
  14293. */
  14294. static BLENDMODE_ONEONE: number;
  14295. /**
  14296. * Blend current color and particle color using particle’s alpha
  14297. */
  14298. static BLENDMODE_STANDARD: number;
  14299. /**
  14300. * Add current color and particle color multiplied by particle’s alpha
  14301. */
  14302. static BLENDMODE_ADD: number;
  14303. /**
  14304. * Multiply current color with particle color
  14305. */
  14306. static BLENDMODE_MULTIPLY: number;
  14307. /**
  14308. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14309. */
  14310. static BLENDMODE_MULTIPLYADD: number;
  14311. /**
  14312. * List of animations used by the particle system.
  14313. */
  14314. animations: Animation[];
  14315. /**
  14316. * Gets or sets the unique id of the particle system
  14317. */
  14318. uniqueId: number;
  14319. /**
  14320. * The id of the Particle system.
  14321. */
  14322. id: string;
  14323. /**
  14324. * The friendly name of the Particle system.
  14325. */
  14326. name: string;
  14327. /**
  14328. * Snippet ID if the particle system was created from the snippet server
  14329. */
  14330. snippetId: string;
  14331. /**
  14332. * The rendering group used by the Particle system to chose when to render.
  14333. */
  14334. renderingGroupId: number;
  14335. /**
  14336. * The emitter represents the Mesh or position we are attaching the particle system to.
  14337. */
  14338. emitter: Nullable<AbstractMesh | Vector3>;
  14339. /**
  14340. * The maximum number of particles to emit per frame
  14341. */
  14342. emitRate: number;
  14343. /**
  14344. * If you want to launch only a few particles at once, that can be done, as well.
  14345. */
  14346. manualEmitCount: number;
  14347. /**
  14348. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14349. */
  14350. updateSpeed: number;
  14351. /**
  14352. * The amount of time the particle system is running (depends of the overall update speed).
  14353. */
  14354. targetStopDuration: number;
  14355. /**
  14356. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14357. */
  14358. disposeOnStop: boolean;
  14359. /**
  14360. * Minimum power of emitting particles.
  14361. */
  14362. minEmitPower: number;
  14363. /**
  14364. * Maximum power of emitting particles.
  14365. */
  14366. maxEmitPower: number;
  14367. /**
  14368. * Minimum life time of emitting particles.
  14369. */
  14370. minLifeTime: number;
  14371. /**
  14372. * Maximum life time of emitting particles.
  14373. */
  14374. maxLifeTime: number;
  14375. /**
  14376. * Minimum Size of emitting particles.
  14377. */
  14378. minSize: number;
  14379. /**
  14380. * Maximum Size of emitting particles.
  14381. */
  14382. maxSize: number;
  14383. /**
  14384. * Minimum scale of emitting particles on X axis.
  14385. */
  14386. minScaleX: number;
  14387. /**
  14388. * Maximum scale of emitting particles on X axis.
  14389. */
  14390. maxScaleX: number;
  14391. /**
  14392. * Minimum scale of emitting particles on Y axis.
  14393. */
  14394. minScaleY: number;
  14395. /**
  14396. * Maximum scale of emitting particles on Y axis.
  14397. */
  14398. maxScaleY: number;
  14399. /**
  14400. * Gets or sets the minimal initial rotation in radians.
  14401. */
  14402. minInitialRotation: number;
  14403. /**
  14404. * Gets or sets the maximal initial rotation in radians.
  14405. */
  14406. maxInitialRotation: number;
  14407. /**
  14408. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14409. */
  14410. minAngularSpeed: number;
  14411. /**
  14412. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14413. */
  14414. maxAngularSpeed: number;
  14415. /**
  14416. * The texture used to render each particle. (this can be a spritesheet)
  14417. */
  14418. particleTexture: Nullable<BaseTexture>;
  14419. /**
  14420. * The layer mask we are rendering the particles through.
  14421. */
  14422. layerMask: number;
  14423. /**
  14424. * This can help using your own shader to render the particle system.
  14425. * The according effect will be created
  14426. */
  14427. customShader: any;
  14428. /**
  14429. * By default particle system starts as soon as they are created. This prevents the
  14430. * automatic start to happen and let you decide when to start emitting particles.
  14431. */
  14432. preventAutoStart: boolean;
  14433. private _noiseTexture;
  14434. /**
  14435. * Gets or sets a texture used to add random noise to particle positions
  14436. */
  14437. get noiseTexture(): Nullable<ProceduralTexture>;
  14438. set noiseTexture(value: Nullable<ProceduralTexture>);
  14439. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14440. noiseStrength: Vector3;
  14441. /**
  14442. * Callback triggered when the particle animation is ending.
  14443. */
  14444. onAnimationEnd: Nullable<() => void>;
  14445. /**
  14446. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14447. */
  14448. blendMode: number;
  14449. /**
  14450. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14451. * to override the particles.
  14452. */
  14453. forceDepthWrite: boolean;
  14454. /** 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 */
  14455. preWarmCycles: number;
  14456. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14457. preWarmStepOffset: number;
  14458. /**
  14459. * 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)
  14460. */
  14461. spriteCellChangeSpeed: number;
  14462. /**
  14463. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14464. */
  14465. startSpriteCellID: number;
  14466. /**
  14467. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14468. */
  14469. endSpriteCellID: number;
  14470. /**
  14471. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14472. */
  14473. spriteCellWidth: number;
  14474. /**
  14475. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14476. */
  14477. spriteCellHeight: number;
  14478. /**
  14479. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14480. */
  14481. spriteRandomStartCell: boolean;
  14482. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14483. translationPivot: Vector2;
  14484. /** @hidden */
  14485. protected _isAnimationSheetEnabled: boolean;
  14486. /**
  14487. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14488. */
  14489. beginAnimationOnStart: boolean;
  14490. /**
  14491. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14492. */
  14493. beginAnimationFrom: number;
  14494. /**
  14495. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14496. */
  14497. beginAnimationTo: number;
  14498. /**
  14499. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14500. */
  14501. beginAnimationLoop: boolean;
  14502. /**
  14503. * Gets or sets a world offset applied to all particles
  14504. */
  14505. worldOffset: Vector3;
  14506. /**
  14507. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14508. */
  14509. get isAnimationSheetEnabled(): boolean;
  14510. set isAnimationSheetEnabled(value: boolean);
  14511. /**
  14512. * Get hosting scene
  14513. * @returns the scene
  14514. */
  14515. getScene(): Nullable<Scene>;
  14516. /**
  14517. * You can use gravity if you want to give an orientation to your particles.
  14518. */
  14519. gravity: Vector3;
  14520. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14521. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14522. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14523. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14524. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14525. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14526. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14527. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14528. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14529. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14530. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14531. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14532. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14533. /**
  14534. * Defines the delay in milliseconds before starting the system (0 by default)
  14535. */
  14536. startDelay: number;
  14537. /**
  14538. * Gets the current list of drag gradients.
  14539. * You must use addDragGradient and removeDragGradient to udpate this list
  14540. * @returns the list of drag gradients
  14541. */
  14542. getDragGradients(): Nullable<Array<FactorGradient>>;
  14543. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14544. limitVelocityDamping: number;
  14545. /**
  14546. * Gets the current list of limit velocity gradients.
  14547. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14548. * @returns the list of limit velocity gradients
  14549. */
  14550. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14551. /**
  14552. * Gets the current list of color gradients.
  14553. * You must use addColorGradient and removeColorGradient to udpate this list
  14554. * @returns the list of color gradients
  14555. */
  14556. getColorGradients(): Nullable<Array<ColorGradient>>;
  14557. /**
  14558. * Gets the current list of size gradients.
  14559. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14560. * @returns the list of size gradients
  14561. */
  14562. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14563. /**
  14564. * Gets the current list of color remap gradients.
  14565. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14566. * @returns the list of color remap gradients
  14567. */
  14568. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14569. /**
  14570. * Gets the current list of alpha remap gradients.
  14571. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14572. * @returns the list of alpha remap gradients
  14573. */
  14574. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14575. /**
  14576. * Gets the current list of life time gradients.
  14577. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14578. * @returns the list of life time gradients
  14579. */
  14580. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14581. /**
  14582. * Gets the current list of angular speed gradients.
  14583. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14584. * @returns the list of angular speed gradients
  14585. */
  14586. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14587. /**
  14588. * Gets the current list of velocity gradients.
  14589. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14590. * @returns the list of velocity gradients
  14591. */
  14592. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14593. /**
  14594. * Gets the current list of start size gradients.
  14595. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14596. * @returns the list of start size gradients
  14597. */
  14598. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14599. /**
  14600. * Gets the current list of emit rate gradients.
  14601. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14602. * @returns the list of emit rate gradients
  14603. */
  14604. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14605. /**
  14606. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14607. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14608. */
  14609. get direction1(): Vector3;
  14610. set direction1(value: Vector3);
  14611. /**
  14612. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14613. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14614. */
  14615. get direction2(): Vector3;
  14616. set direction2(value: Vector3);
  14617. /**
  14618. * 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.
  14619. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14620. */
  14621. get minEmitBox(): Vector3;
  14622. set minEmitBox(value: Vector3);
  14623. /**
  14624. * 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.
  14625. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14626. */
  14627. get maxEmitBox(): Vector3;
  14628. set maxEmitBox(value: Vector3);
  14629. /**
  14630. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14631. */
  14632. color1: Color4;
  14633. /**
  14634. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14635. */
  14636. color2: Color4;
  14637. /**
  14638. * Color the particle will have at the end of its lifetime
  14639. */
  14640. colorDead: Color4;
  14641. /**
  14642. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14643. */
  14644. textureMask: Color4;
  14645. /**
  14646. * The particle emitter type defines the emitter used by the particle system.
  14647. * It can be for example box, sphere, or cone...
  14648. */
  14649. particleEmitterType: IParticleEmitterType;
  14650. /** @hidden */
  14651. _isSubEmitter: boolean;
  14652. /**
  14653. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14654. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14655. */
  14656. billboardMode: number;
  14657. protected _isBillboardBased: boolean;
  14658. /**
  14659. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14660. */
  14661. get isBillboardBased(): boolean;
  14662. set isBillboardBased(value: boolean);
  14663. /**
  14664. * The scene the particle system belongs to.
  14665. */
  14666. protected _scene: Nullable<Scene>;
  14667. /**
  14668. * The engine the particle system belongs to.
  14669. */
  14670. protected _engine: ThinEngine;
  14671. /**
  14672. * Local cache of defines for image processing.
  14673. */
  14674. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14675. /**
  14676. * Default configuration related to image processing available in the standard Material.
  14677. */
  14678. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  14679. /**
  14680. * Gets the image processing configuration used either in this material.
  14681. */
  14682. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  14683. /**
  14684. * Sets the Default image processing configuration used either in the this material.
  14685. *
  14686. * If sets to null, the scene one is in use.
  14687. */
  14688. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  14689. /**
  14690. * Attaches a new image processing configuration to the Standard Material.
  14691. * @param configuration
  14692. */
  14693. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14694. /** @hidden */
  14695. protected _reset(): void;
  14696. /** @hidden */
  14697. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14698. /**
  14699. * Instantiates a particle system.
  14700. * 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.
  14701. * @param name The name of the particle system
  14702. */
  14703. constructor(name: string);
  14704. /**
  14705. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14706. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14707. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14708. * @returns the emitter
  14709. */
  14710. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14711. /**
  14712. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14713. * @param radius The radius of the hemisphere to emit from
  14714. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14715. * @returns the emitter
  14716. */
  14717. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14718. /**
  14719. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14720. * @param radius The radius of the sphere to emit from
  14721. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14722. * @returns the emitter
  14723. */
  14724. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14725. /**
  14726. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14727. * @param radius The radius of the sphere to emit from
  14728. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14729. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14730. * @returns the emitter
  14731. */
  14732. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14733. /**
  14734. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14735. * @param radius The radius of the emission cylinder
  14736. * @param height The height of the emission cylinder
  14737. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14738. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14739. * @returns the emitter
  14740. */
  14741. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14742. /**
  14743. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14744. * @param radius The radius of the cylinder to emit from
  14745. * @param height The height of the emission cylinder
  14746. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14747. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14748. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14749. * @returns the emitter
  14750. */
  14751. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14752. /**
  14753. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14754. * @param radius The radius of the cone to emit from
  14755. * @param angle The base angle of the cone
  14756. * @returns the emitter
  14757. */
  14758. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14759. /**
  14760. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14761. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14762. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14763. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14764. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14765. * @returns the emitter
  14766. */
  14767. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14768. }
  14769. }
  14770. declare module BABYLON {
  14771. /**
  14772. * Type of sub emitter
  14773. */
  14774. export enum SubEmitterType {
  14775. /**
  14776. * Attached to the particle over it's lifetime
  14777. */
  14778. ATTACHED = 0,
  14779. /**
  14780. * Created when the particle dies
  14781. */
  14782. END = 1
  14783. }
  14784. /**
  14785. * Sub emitter class used to emit particles from an existing particle
  14786. */
  14787. export class SubEmitter {
  14788. /**
  14789. * the particle system to be used by the sub emitter
  14790. */
  14791. particleSystem: ParticleSystem;
  14792. /**
  14793. * Type of the submitter (Default: END)
  14794. */
  14795. type: SubEmitterType;
  14796. /**
  14797. * 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)
  14798. * Note: This only is supported when using an emitter of type Mesh
  14799. */
  14800. inheritDirection: boolean;
  14801. /**
  14802. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14803. */
  14804. inheritedVelocityAmount: number;
  14805. /**
  14806. * Creates a sub emitter
  14807. * @param particleSystem the particle system to be used by the sub emitter
  14808. */
  14809. constructor(
  14810. /**
  14811. * the particle system to be used by the sub emitter
  14812. */
  14813. particleSystem: ParticleSystem);
  14814. /**
  14815. * Clones the sub emitter
  14816. * @returns the cloned sub emitter
  14817. */
  14818. clone(): SubEmitter;
  14819. /**
  14820. * Serialize current object to a JSON object
  14821. * @returns the serialized object
  14822. */
  14823. serialize(): any;
  14824. /** @hidden */
  14825. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  14826. /**
  14827. * Creates a new SubEmitter from a serialized JSON version
  14828. * @param serializationObject defines the JSON object to read from
  14829. * @param sceneOrEngine defines the hosting scene or the hosting engine
  14830. * @param rootUrl defines the rootUrl for data loading
  14831. * @returns a new SubEmitter
  14832. */
  14833. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  14834. /** Release associated resources */
  14835. dispose(): void;
  14836. }
  14837. }
  14838. declare module BABYLON {
  14839. /** @hidden */
  14840. export var clipPlaneFragmentDeclaration: {
  14841. name: string;
  14842. shader: string;
  14843. };
  14844. }
  14845. declare module BABYLON {
  14846. /** @hidden */
  14847. export var imageProcessingDeclaration: {
  14848. name: string;
  14849. shader: string;
  14850. };
  14851. }
  14852. declare module BABYLON {
  14853. /** @hidden */
  14854. export var imageProcessingFunctions: {
  14855. name: string;
  14856. shader: string;
  14857. };
  14858. }
  14859. declare module BABYLON {
  14860. /** @hidden */
  14861. export var clipPlaneFragment: {
  14862. name: string;
  14863. shader: string;
  14864. };
  14865. }
  14866. declare module BABYLON {
  14867. /** @hidden */
  14868. export var particlesPixelShader: {
  14869. name: string;
  14870. shader: string;
  14871. };
  14872. }
  14873. declare module BABYLON {
  14874. /** @hidden */
  14875. export var clipPlaneVertexDeclaration: {
  14876. name: string;
  14877. shader: string;
  14878. };
  14879. }
  14880. declare module BABYLON {
  14881. /** @hidden */
  14882. export var clipPlaneVertex: {
  14883. name: string;
  14884. shader: string;
  14885. };
  14886. }
  14887. declare module BABYLON {
  14888. /** @hidden */
  14889. export var particlesVertexShader: {
  14890. name: string;
  14891. shader: string;
  14892. };
  14893. }
  14894. declare module BABYLON {
  14895. /**
  14896. * Interface used to define entities containing multiple clip planes
  14897. */
  14898. export interface IClipPlanesHolder {
  14899. /**
  14900. * Gets or sets the active clipplane 1
  14901. */
  14902. clipPlane: Nullable<Plane>;
  14903. /**
  14904. * Gets or sets the active clipplane 2
  14905. */
  14906. clipPlane2: Nullable<Plane>;
  14907. /**
  14908. * Gets or sets the active clipplane 3
  14909. */
  14910. clipPlane3: Nullable<Plane>;
  14911. /**
  14912. * Gets or sets the active clipplane 4
  14913. */
  14914. clipPlane4: Nullable<Plane>;
  14915. /**
  14916. * Gets or sets the active clipplane 5
  14917. */
  14918. clipPlane5: Nullable<Plane>;
  14919. /**
  14920. * Gets or sets the active clipplane 6
  14921. */
  14922. clipPlane6: Nullable<Plane>;
  14923. }
  14924. }
  14925. declare module BABYLON {
  14926. /**
  14927. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  14928. *
  14929. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  14930. *
  14931. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  14932. */
  14933. export class ThinMaterialHelper {
  14934. /**
  14935. * Binds the clip plane information from the holder to the effect.
  14936. * @param effect The effect we are binding the data to
  14937. * @param holder The entity containing the clip plane information
  14938. */
  14939. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  14940. }
  14941. }
  14942. declare module BABYLON {
  14943. interface ThinEngine {
  14944. /**
  14945. * Sets alpha constants used by some alpha blending modes
  14946. * @param r defines the red component
  14947. * @param g defines the green component
  14948. * @param b defines the blue component
  14949. * @param a defines the alpha component
  14950. */
  14951. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  14952. /**
  14953. * Sets the current alpha mode
  14954. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  14955. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  14956. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  14957. */
  14958. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  14959. /**
  14960. * Gets the current alpha mode
  14961. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  14962. * @returns the current alpha mode
  14963. */
  14964. getAlphaMode(): number;
  14965. /**
  14966. * Sets the current alpha equation
  14967. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  14968. */
  14969. setAlphaEquation(equation: number): void;
  14970. /**
  14971. * Gets the current alpha equation.
  14972. * @returns the current alpha equation
  14973. */
  14974. getAlphaEquation(): number;
  14975. }
  14976. }
  14977. declare module BABYLON {
  14978. /**
  14979. * This represents a particle system in Babylon.
  14980. * 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.
  14981. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14982. * @example https://doc.babylonjs.com/babylon101/particles
  14983. */
  14984. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14985. /**
  14986. * Billboard mode will only apply to Y axis
  14987. */
  14988. static readonly BILLBOARDMODE_Y: number;
  14989. /**
  14990. * Billboard mode will apply to all axes
  14991. */
  14992. static readonly BILLBOARDMODE_ALL: number;
  14993. /**
  14994. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14995. */
  14996. static readonly BILLBOARDMODE_STRETCHED: number;
  14997. /**
  14998. * This function can be defined to provide custom update for active particles.
  14999. * This function will be called instead of regular update (age, position, color, etc.).
  15000. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15001. */
  15002. updateFunction: (particles: Particle[]) => void;
  15003. private _emitterWorldMatrix;
  15004. /**
  15005. * This function can be defined to specify initial direction for every new particle.
  15006. * It by default use the emitterType defined function
  15007. */
  15008. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15009. /**
  15010. * This function can be defined to specify initial position for every new particle.
  15011. * It by default use the emitterType defined function
  15012. */
  15013. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15014. /**
  15015. * @hidden
  15016. */
  15017. _inheritedVelocityOffset: Vector3;
  15018. /**
  15019. * An event triggered when the system is disposed
  15020. */
  15021. onDisposeObservable: Observable<IParticleSystem>;
  15022. /**
  15023. * An event triggered when the system is stopped
  15024. */
  15025. onStoppedObservable: Observable<IParticleSystem>;
  15026. private _onDisposeObserver;
  15027. /**
  15028. * Sets a callback that will be triggered when the system is disposed
  15029. */
  15030. set onDispose(callback: () => void);
  15031. private _particles;
  15032. private _epsilon;
  15033. private _capacity;
  15034. private _stockParticles;
  15035. private _newPartsExcess;
  15036. private _vertexData;
  15037. private _vertexBuffer;
  15038. private _vertexBuffers;
  15039. private _spriteBuffer;
  15040. private _indexBuffer;
  15041. private _effect;
  15042. private _customEffect;
  15043. private _cachedDefines;
  15044. private _scaledColorStep;
  15045. private _colorDiff;
  15046. private _scaledDirection;
  15047. private _scaledGravity;
  15048. private _currentRenderId;
  15049. private _alive;
  15050. private _useInstancing;
  15051. private _vertexArrayObject;
  15052. private _started;
  15053. private _stopped;
  15054. private _actualFrame;
  15055. private _scaledUpdateSpeed;
  15056. private _vertexBufferSize;
  15057. /** @hidden */
  15058. _currentEmitRateGradient: Nullable<FactorGradient>;
  15059. /** @hidden */
  15060. _currentEmitRate1: number;
  15061. /** @hidden */
  15062. _currentEmitRate2: number;
  15063. /** @hidden */
  15064. _currentStartSizeGradient: Nullable<FactorGradient>;
  15065. /** @hidden */
  15066. _currentStartSize1: number;
  15067. /** @hidden */
  15068. _currentStartSize2: number;
  15069. private readonly _rawTextureWidth;
  15070. private _rampGradientsTexture;
  15071. private _useRampGradients;
  15072. /** Gets or sets a matrix to use to compute projection */
  15073. defaultProjectionMatrix: Matrix;
  15074. /** Gets or sets a matrix to use to compute view */
  15075. defaultViewMatrix: Matrix;
  15076. /** Gets or sets a boolean indicating that ramp gradients must be used
  15077. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15078. */
  15079. get useRampGradients(): boolean;
  15080. set useRampGradients(value: boolean);
  15081. /**
  15082. * 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.
  15083. * 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: [])
  15084. */
  15085. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15086. private _subEmitters;
  15087. /**
  15088. * @hidden
  15089. * If the particle systems emitter should be disposed when the particle system is disposed
  15090. */
  15091. _disposeEmitterOnDispose: boolean;
  15092. /**
  15093. * The current active Sub-systems, this property is used by the root particle system only.
  15094. */
  15095. activeSubSystems: Array<ParticleSystem>;
  15096. /**
  15097. * Specifies if the particles are updated in emitter local space or world space
  15098. */
  15099. isLocal: boolean;
  15100. private _rootParticleSystem;
  15101. /**
  15102. * Gets the current list of active particles
  15103. */
  15104. get particles(): Particle[];
  15105. /**
  15106. * Gets the number of particles active at the same time.
  15107. * @returns The number of active particles.
  15108. */
  15109. getActiveCount(): number;
  15110. /**
  15111. * Returns the string "ParticleSystem"
  15112. * @returns a string containing the class name
  15113. */
  15114. getClassName(): string;
  15115. /**
  15116. * Gets a boolean indicating that the system is stopping
  15117. * @returns true if the system is currently stopping
  15118. */
  15119. isStopping(): boolean;
  15120. /**
  15121. * Gets the custom effect used to render the particles
  15122. * @param blendMode Blend mode for which the effect should be retrieved
  15123. * @returns The effect
  15124. */
  15125. getCustomEffect(blendMode?: number): Nullable<Effect>;
  15126. /**
  15127. * Sets the custom effect used to render the particles
  15128. * @param effect The effect to set
  15129. * @param blendMode Blend mode for which the effect should be set
  15130. */
  15131. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  15132. /** @hidden */
  15133. private _onBeforeDrawParticlesObservable;
  15134. /**
  15135. * Observable that will be called just before the particles are drawn
  15136. */
  15137. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  15138. /**
  15139. * Gets the name of the particle vertex shader
  15140. */
  15141. get vertexShaderName(): string;
  15142. /**
  15143. * Instantiates a particle system.
  15144. * 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.
  15145. * @param name The name of the particle system
  15146. * @param capacity The max number of particles alive at the same time
  15147. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  15148. * @param customEffect a custom effect used to change the way particles are rendered by default
  15149. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15150. * @param epsilon Offset used to render the particles
  15151. */
  15152. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15153. private _addFactorGradient;
  15154. private _removeFactorGradient;
  15155. /**
  15156. * Adds a new life time gradient
  15157. * @param gradient defines the gradient to use (between 0 and 1)
  15158. * @param factor defines the life time factor to affect to the specified gradient
  15159. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15160. * @returns the current particle system
  15161. */
  15162. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15163. /**
  15164. * Remove a specific life time gradient
  15165. * @param gradient defines the gradient to remove
  15166. * @returns the current particle system
  15167. */
  15168. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15169. /**
  15170. * Adds a new size gradient
  15171. * @param gradient defines the gradient to use (between 0 and 1)
  15172. * @param factor defines the size factor to affect to the specified gradient
  15173. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15174. * @returns the current particle system
  15175. */
  15176. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15177. /**
  15178. * Remove a specific size gradient
  15179. * @param gradient defines the gradient to remove
  15180. * @returns the current particle system
  15181. */
  15182. removeSizeGradient(gradient: number): IParticleSystem;
  15183. /**
  15184. * Adds a new color remap gradient
  15185. * @param gradient defines the gradient to use (between 0 and 1)
  15186. * @param min defines the color remap minimal range
  15187. * @param max defines the color remap maximal range
  15188. * @returns the current particle system
  15189. */
  15190. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15191. /**
  15192. * Remove a specific color remap gradient
  15193. * @param gradient defines the gradient to remove
  15194. * @returns the current particle system
  15195. */
  15196. removeColorRemapGradient(gradient: number): IParticleSystem;
  15197. /**
  15198. * Adds a new alpha remap gradient
  15199. * @param gradient defines the gradient to use (between 0 and 1)
  15200. * @param min defines the alpha remap minimal range
  15201. * @param max defines the alpha remap maximal range
  15202. * @returns the current particle system
  15203. */
  15204. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15205. /**
  15206. * Remove a specific alpha remap gradient
  15207. * @param gradient defines the gradient to remove
  15208. * @returns the current particle system
  15209. */
  15210. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15211. /**
  15212. * Adds a new angular speed gradient
  15213. * @param gradient defines the gradient to use (between 0 and 1)
  15214. * @param factor defines the angular speed to affect to the specified gradient
  15215. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15216. * @returns the current particle system
  15217. */
  15218. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15219. /**
  15220. * Remove a specific angular speed gradient
  15221. * @param gradient defines the gradient to remove
  15222. * @returns the current particle system
  15223. */
  15224. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15225. /**
  15226. * Adds a new velocity gradient
  15227. * @param gradient defines the gradient to use (between 0 and 1)
  15228. * @param factor defines the velocity to affect to the specified gradient
  15229. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15230. * @returns the current particle system
  15231. */
  15232. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15233. /**
  15234. * Remove a specific velocity gradient
  15235. * @param gradient defines the gradient to remove
  15236. * @returns the current particle system
  15237. */
  15238. removeVelocityGradient(gradient: number): IParticleSystem;
  15239. /**
  15240. * Adds a new limit velocity gradient
  15241. * @param gradient defines the gradient to use (between 0 and 1)
  15242. * @param factor defines the limit velocity value to affect to the specified gradient
  15243. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15244. * @returns the current particle system
  15245. */
  15246. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15247. /**
  15248. * Remove a specific limit velocity gradient
  15249. * @param gradient defines the gradient to remove
  15250. * @returns the current particle system
  15251. */
  15252. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15253. /**
  15254. * Adds a new drag gradient
  15255. * @param gradient defines the gradient to use (between 0 and 1)
  15256. * @param factor defines the drag value to affect to the specified gradient
  15257. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15258. * @returns the current particle system
  15259. */
  15260. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15261. /**
  15262. * Remove a specific drag gradient
  15263. * @param gradient defines the gradient to remove
  15264. * @returns the current particle system
  15265. */
  15266. removeDragGradient(gradient: number): IParticleSystem;
  15267. /**
  15268. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15269. * @param gradient defines the gradient to use (between 0 and 1)
  15270. * @param factor defines the emit rate value to affect to the specified gradient
  15271. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15272. * @returns the current particle system
  15273. */
  15274. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15275. /**
  15276. * Remove a specific emit rate gradient
  15277. * @param gradient defines the gradient to remove
  15278. * @returns the current particle system
  15279. */
  15280. removeEmitRateGradient(gradient: number): IParticleSystem;
  15281. /**
  15282. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15283. * @param gradient defines the gradient to use (between 0 and 1)
  15284. * @param factor defines the start size value to affect to the specified gradient
  15285. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15286. * @returns the current particle system
  15287. */
  15288. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15289. /**
  15290. * Remove a specific start size gradient
  15291. * @param gradient defines the gradient to remove
  15292. * @returns the current particle system
  15293. */
  15294. removeStartSizeGradient(gradient: number): IParticleSystem;
  15295. private _createRampGradientTexture;
  15296. /**
  15297. * Gets the current list of ramp gradients.
  15298. * You must use addRampGradient and removeRampGradient to udpate this list
  15299. * @returns the list of ramp gradients
  15300. */
  15301. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15302. /** Force the system to rebuild all gradients that need to be resync */
  15303. forceRefreshGradients(): void;
  15304. private _syncRampGradientTexture;
  15305. /**
  15306. * Adds a new ramp gradient used to remap particle colors
  15307. * @param gradient defines the gradient to use (between 0 and 1)
  15308. * @param color defines the color to affect to the specified gradient
  15309. * @returns the current particle system
  15310. */
  15311. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15312. /**
  15313. * Remove a specific ramp gradient
  15314. * @param gradient defines the gradient to remove
  15315. * @returns the current particle system
  15316. */
  15317. removeRampGradient(gradient: number): ParticleSystem;
  15318. /**
  15319. * Adds a new color gradient
  15320. * @param gradient defines the gradient to use (between 0 and 1)
  15321. * @param color1 defines the color to affect to the specified gradient
  15322. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15323. * @returns this particle system
  15324. */
  15325. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15326. /**
  15327. * Remove a specific color gradient
  15328. * @param gradient defines the gradient to remove
  15329. * @returns this particle system
  15330. */
  15331. removeColorGradient(gradient: number): IParticleSystem;
  15332. private _fetchR;
  15333. protected _reset(): void;
  15334. private _resetEffect;
  15335. private _createVertexBuffers;
  15336. private _createIndexBuffer;
  15337. /**
  15338. * Gets the maximum number of particles active at the same time.
  15339. * @returns The max number of active particles.
  15340. */
  15341. getCapacity(): number;
  15342. /**
  15343. * Gets whether there are still active particles in the system.
  15344. * @returns True if it is alive, otherwise false.
  15345. */
  15346. isAlive(): boolean;
  15347. /**
  15348. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15349. * @returns True if it has been started, otherwise false.
  15350. */
  15351. isStarted(): boolean;
  15352. private _prepareSubEmitterInternalArray;
  15353. /**
  15354. * Starts the particle system and begins to emit
  15355. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15356. */
  15357. start(delay?: number): void;
  15358. /**
  15359. * Stops the particle system.
  15360. * @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.
  15361. */
  15362. stop(stopSubEmitters?: boolean): void;
  15363. /**
  15364. * Remove all active particles
  15365. */
  15366. reset(): void;
  15367. /**
  15368. * @hidden (for internal use only)
  15369. */
  15370. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15371. /**
  15372. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15373. * Its lifetime will start back at 0.
  15374. */
  15375. recycleParticle: (particle: Particle) => void;
  15376. private _stopSubEmitters;
  15377. private _createParticle;
  15378. private _removeFromRoot;
  15379. private _emitFromParticle;
  15380. private _update;
  15381. /** @hidden */
  15382. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15383. /** @hidden */
  15384. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15385. /**
  15386. * Fill the defines array according to the current settings of the particle system
  15387. * @param defines Array to be updated
  15388. * @param blendMode blend mode to take into account when updating the array
  15389. */
  15390. fillDefines(defines: Array<string>, blendMode: number): void;
  15391. /**
  15392. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  15393. * @param uniforms Uniforms array to fill
  15394. * @param attributes Attributes array to fill
  15395. * @param samplers Samplers array to fill
  15396. */
  15397. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  15398. /** @hidden */
  15399. private _getEffect;
  15400. /**
  15401. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15402. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15403. */
  15404. animate(preWarmOnly?: boolean): void;
  15405. private _appendParticleVertices;
  15406. /**
  15407. * Rebuilds the particle system.
  15408. */
  15409. rebuild(): void;
  15410. /**
  15411. * Is this system ready to be used/rendered
  15412. * @return true if the system is ready
  15413. */
  15414. isReady(): boolean;
  15415. private _render;
  15416. /**
  15417. * Renders the particle system in its current state.
  15418. * @returns the current number of particles
  15419. */
  15420. render(): number;
  15421. /**
  15422. * Disposes the particle system and free the associated resources
  15423. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15424. */
  15425. dispose(disposeTexture?: boolean): void;
  15426. /**
  15427. * Clones the particle system.
  15428. * @param name The name of the cloned object
  15429. * @param newEmitter The new emitter to use
  15430. * @returns the cloned particle system
  15431. */
  15432. clone(name: string, newEmitter: any): ParticleSystem;
  15433. /**
  15434. * Serializes the particle system to a JSON object
  15435. * @param serializeTexture defines if the texture must be serialized as well
  15436. * @returns the JSON object
  15437. */
  15438. serialize(serializeTexture?: boolean): any;
  15439. /** @hidden */
  15440. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  15441. /** @hidden */
  15442. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  15443. /**
  15444. * Parses a JSON object to create a particle system.
  15445. * @param parsedParticleSystem The JSON object to parse
  15446. * @param sceneOrEngine The scene or the engine to create the particle system in
  15447. * @param rootUrl The root url to use to load external dependencies like texture
  15448. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15449. * @returns the Parsed particle system
  15450. */
  15451. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15452. }
  15453. }
  15454. declare module BABYLON {
  15455. /**
  15456. * A particle represents one of the element emitted by a particle system.
  15457. * This is mainly define by its coordinates, direction, velocity and age.
  15458. */
  15459. export class Particle {
  15460. /**
  15461. * The particle system the particle belongs to.
  15462. */
  15463. particleSystem: ParticleSystem;
  15464. private static _Count;
  15465. /**
  15466. * Unique ID of the particle
  15467. */
  15468. id: number;
  15469. /**
  15470. * The world position of the particle in the scene.
  15471. */
  15472. position: Vector3;
  15473. /**
  15474. * The world direction of the particle in the scene.
  15475. */
  15476. direction: Vector3;
  15477. /**
  15478. * The color of the particle.
  15479. */
  15480. color: Color4;
  15481. /**
  15482. * The color change of the particle per step.
  15483. */
  15484. colorStep: Color4;
  15485. /**
  15486. * Defines how long will the life of the particle be.
  15487. */
  15488. lifeTime: number;
  15489. /**
  15490. * The current age of the particle.
  15491. */
  15492. age: number;
  15493. /**
  15494. * The current size of the particle.
  15495. */
  15496. size: number;
  15497. /**
  15498. * The current scale of the particle.
  15499. */
  15500. scale: Vector2;
  15501. /**
  15502. * The current angle of the particle.
  15503. */
  15504. angle: number;
  15505. /**
  15506. * Defines how fast is the angle changing.
  15507. */
  15508. angularSpeed: number;
  15509. /**
  15510. * Defines the cell index used by the particle to be rendered from a sprite.
  15511. */
  15512. cellIndex: number;
  15513. /**
  15514. * The information required to support color remapping
  15515. */
  15516. remapData: Vector4;
  15517. /** @hidden */
  15518. _randomCellOffset?: number;
  15519. /** @hidden */
  15520. _initialDirection: Nullable<Vector3>;
  15521. /** @hidden */
  15522. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15523. /** @hidden */
  15524. _initialStartSpriteCellID: number;
  15525. /** @hidden */
  15526. _initialEndSpriteCellID: number;
  15527. /** @hidden */
  15528. _currentColorGradient: Nullable<ColorGradient>;
  15529. /** @hidden */
  15530. _currentColor1: Color4;
  15531. /** @hidden */
  15532. _currentColor2: Color4;
  15533. /** @hidden */
  15534. _currentSizeGradient: Nullable<FactorGradient>;
  15535. /** @hidden */
  15536. _currentSize1: number;
  15537. /** @hidden */
  15538. _currentSize2: number;
  15539. /** @hidden */
  15540. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15541. /** @hidden */
  15542. _currentAngularSpeed1: number;
  15543. /** @hidden */
  15544. _currentAngularSpeed2: number;
  15545. /** @hidden */
  15546. _currentVelocityGradient: Nullable<FactorGradient>;
  15547. /** @hidden */
  15548. _currentVelocity1: number;
  15549. /** @hidden */
  15550. _currentVelocity2: number;
  15551. /** @hidden */
  15552. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15553. /** @hidden */
  15554. _currentLimitVelocity1: number;
  15555. /** @hidden */
  15556. _currentLimitVelocity2: number;
  15557. /** @hidden */
  15558. _currentDragGradient: Nullable<FactorGradient>;
  15559. /** @hidden */
  15560. _currentDrag1: number;
  15561. /** @hidden */
  15562. _currentDrag2: number;
  15563. /** @hidden */
  15564. _randomNoiseCoordinates1: Vector3;
  15565. /** @hidden */
  15566. _randomNoiseCoordinates2: Vector3;
  15567. /** @hidden */
  15568. _localPosition?: Vector3;
  15569. /**
  15570. * Creates a new instance Particle
  15571. * @param particleSystem the particle system the particle belongs to
  15572. */
  15573. constructor(
  15574. /**
  15575. * The particle system the particle belongs to.
  15576. */
  15577. particleSystem: ParticleSystem);
  15578. private updateCellInfoFromSystem;
  15579. /**
  15580. * Defines how the sprite cell index is updated for the particle
  15581. */
  15582. updateCellIndex(): void;
  15583. /** @hidden */
  15584. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15585. /** @hidden */
  15586. _inheritParticleInfoToSubEmitters(): void;
  15587. /** @hidden */
  15588. _reset(): void;
  15589. /**
  15590. * Copy the properties of particle to another one.
  15591. * @param other the particle to copy the information to.
  15592. */
  15593. copyTo(other: Particle): void;
  15594. }
  15595. }
  15596. declare module BABYLON {
  15597. /**
  15598. * Particle emitter represents a volume emitting particles.
  15599. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15600. */
  15601. export interface IParticleEmitterType {
  15602. /**
  15603. * Called by the particle System when the direction is computed for the created particle.
  15604. * @param worldMatrix is the world matrix of the particle system
  15605. * @param directionToUpdate is the direction vector to update with the result
  15606. * @param particle is the particle we are computed the direction for
  15607. * @param isLocal defines if the direction should be set in local space
  15608. */
  15609. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15610. /**
  15611. * Called by the particle System when the position is computed for the created particle.
  15612. * @param worldMatrix is the world matrix of the particle system
  15613. * @param positionToUpdate is the position vector to update with the result
  15614. * @param particle is the particle we are computed the position for
  15615. * @param isLocal defines if the position should be set in local space
  15616. */
  15617. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15618. /**
  15619. * Clones the current emitter and returns a copy of it
  15620. * @returns the new emitter
  15621. */
  15622. clone(): IParticleEmitterType;
  15623. /**
  15624. * Called by the GPUParticleSystem to setup the update shader
  15625. * @param effect defines the update shader
  15626. */
  15627. applyToShader(effect: Effect): void;
  15628. /**
  15629. * Returns a string to use to update the GPU particles update shader
  15630. * @returns the effect defines string
  15631. */
  15632. getEffectDefines(): string;
  15633. /**
  15634. * Returns a string representing the class name
  15635. * @returns a string containing the class name
  15636. */
  15637. getClassName(): string;
  15638. /**
  15639. * Serializes the particle system to a JSON object.
  15640. * @returns the JSON object
  15641. */
  15642. serialize(): any;
  15643. /**
  15644. * Parse properties from a JSON object
  15645. * @param serializationObject defines the JSON object
  15646. * @param scene defines the hosting scene
  15647. */
  15648. parse(serializationObject: any, scene: Nullable<Scene>): void;
  15649. }
  15650. }
  15651. declare module BABYLON {
  15652. /**
  15653. * Particle emitter emitting particles from the inside of a box.
  15654. * It emits the particles randomly between 2 given directions.
  15655. */
  15656. export class BoxParticleEmitter implements IParticleEmitterType {
  15657. /**
  15658. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15659. */
  15660. direction1: Vector3;
  15661. /**
  15662. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15663. */
  15664. direction2: Vector3;
  15665. /**
  15666. * 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.
  15667. */
  15668. minEmitBox: Vector3;
  15669. /**
  15670. * 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.
  15671. */
  15672. maxEmitBox: Vector3;
  15673. /**
  15674. * Creates a new instance BoxParticleEmitter
  15675. */
  15676. constructor();
  15677. /**
  15678. * Called by the particle System when the direction is computed for the created particle.
  15679. * @param worldMatrix is the world matrix of the particle system
  15680. * @param directionToUpdate is the direction vector to update with the result
  15681. * @param particle is the particle we are computed the direction for
  15682. * @param isLocal defines if the direction should be set in local space
  15683. */
  15684. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15685. /**
  15686. * Called by the particle System when the position is computed for the created particle.
  15687. * @param worldMatrix is the world matrix of the particle system
  15688. * @param positionToUpdate is the position vector to update with the result
  15689. * @param particle is the particle we are computed the position for
  15690. * @param isLocal defines if the position should be set in local space
  15691. */
  15692. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15693. /**
  15694. * Clones the current emitter and returns a copy of it
  15695. * @returns the new emitter
  15696. */
  15697. clone(): BoxParticleEmitter;
  15698. /**
  15699. * Called by the GPUParticleSystem to setup the update shader
  15700. * @param effect defines the update shader
  15701. */
  15702. applyToShader(effect: Effect): void;
  15703. /**
  15704. * Returns a string to use to update the GPU particles update shader
  15705. * @returns a string containng the defines string
  15706. */
  15707. getEffectDefines(): string;
  15708. /**
  15709. * Returns the string "BoxParticleEmitter"
  15710. * @returns a string containing the class name
  15711. */
  15712. getClassName(): string;
  15713. /**
  15714. * Serializes the particle system to a JSON object.
  15715. * @returns the JSON object
  15716. */
  15717. serialize(): any;
  15718. /**
  15719. * Parse properties from a JSON object
  15720. * @param serializationObject defines the JSON object
  15721. */
  15722. parse(serializationObject: any): void;
  15723. }
  15724. }
  15725. declare module BABYLON {
  15726. /**
  15727. * Particle emitter emitting particles from the inside of a cone.
  15728. * It emits the particles alongside the cone volume from the base to the particle.
  15729. * The emission direction might be randomized.
  15730. */
  15731. export class ConeParticleEmitter implements IParticleEmitterType {
  15732. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15733. directionRandomizer: number;
  15734. private _radius;
  15735. private _angle;
  15736. private _height;
  15737. /**
  15738. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15739. */
  15740. radiusRange: number;
  15741. /**
  15742. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15743. */
  15744. heightRange: number;
  15745. /**
  15746. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15747. */
  15748. emitFromSpawnPointOnly: boolean;
  15749. /**
  15750. * Gets or sets the radius of the emission cone
  15751. */
  15752. get radius(): number;
  15753. set radius(value: number);
  15754. /**
  15755. * Gets or sets the angle of the emission cone
  15756. */
  15757. get angle(): number;
  15758. set angle(value: number);
  15759. private _buildHeight;
  15760. /**
  15761. * Creates a new instance ConeParticleEmitter
  15762. * @param radius the radius of the emission cone (1 by default)
  15763. * @param angle the cone base angle (PI by default)
  15764. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15765. */
  15766. constructor(radius?: number, angle?: number,
  15767. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15768. directionRandomizer?: number);
  15769. /**
  15770. * Called by the particle System when the direction is computed for the created particle.
  15771. * @param worldMatrix is the world matrix of the particle system
  15772. * @param directionToUpdate is the direction vector to update with the result
  15773. * @param particle is the particle we are computed the direction for
  15774. * @param isLocal defines if the direction should be set in local space
  15775. */
  15776. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15777. /**
  15778. * Called by the particle System when the position is computed for the created particle.
  15779. * @param worldMatrix is the world matrix of the particle system
  15780. * @param positionToUpdate is the position vector to update with the result
  15781. * @param particle is the particle we are computed the position for
  15782. * @param isLocal defines if the position should be set in local space
  15783. */
  15784. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15785. /**
  15786. * Clones the current emitter and returns a copy of it
  15787. * @returns the new emitter
  15788. */
  15789. clone(): ConeParticleEmitter;
  15790. /**
  15791. * Called by the GPUParticleSystem to setup the update shader
  15792. * @param effect defines the update shader
  15793. */
  15794. applyToShader(effect: Effect): void;
  15795. /**
  15796. * Returns a string to use to update the GPU particles update shader
  15797. * @returns a string containng the defines string
  15798. */
  15799. getEffectDefines(): string;
  15800. /**
  15801. * Returns the string "ConeParticleEmitter"
  15802. * @returns a string containing the class name
  15803. */
  15804. getClassName(): string;
  15805. /**
  15806. * Serializes the particle system to a JSON object.
  15807. * @returns the JSON object
  15808. */
  15809. serialize(): any;
  15810. /**
  15811. * Parse properties from a JSON object
  15812. * @param serializationObject defines the JSON object
  15813. */
  15814. parse(serializationObject: any): void;
  15815. }
  15816. }
  15817. declare module BABYLON {
  15818. /**
  15819. * Particle emitter emitting particles from the inside of a cylinder.
  15820. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15821. */
  15822. export class CylinderParticleEmitter implements IParticleEmitterType {
  15823. /**
  15824. * The radius of the emission cylinder.
  15825. */
  15826. radius: number;
  15827. /**
  15828. * The height of the emission cylinder.
  15829. */
  15830. height: number;
  15831. /**
  15832. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15833. */
  15834. radiusRange: number;
  15835. /**
  15836. * How much to randomize the particle direction [0-1].
  15837. */
  15838. directionRandomizer: number;
  15839. /**
  15840. * Creates a new instance CylinderParticleEmitter
  15841. * @param radius the radius of the emission cylinder (1 by default)
  15842. * @param height the height of the emission cylinder (1 by default)
  15843. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15844. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15845. */
  15846. constructor(
  15847. /**
  15848. * The radius of the emission cylinder.
  15849. */
  15850. radius?: number,
  15851. /**
  15852. * The height of the emission cylinder.
  15853. */
  15854. height?: number,
  15855. /**
  15856. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15857. */
  15858. radiusRange?: number,
  15859. /**
  15860. * How much to randomize the particle direction [0-1].
  15861. */
  15862. directionRandomizer?: number);
  15863. /**
  15864. * Called by the particle System when the direction is computed for the created particle.
  15865. * @param worldMatrix is the world matrix of the particle system
  15866. * @param directionToUpdate is the direction vector to update with the result
  15867. * @param particle is the particle we are computed the direction for
  15868. * @param isLocal defines if the direction should be set in local space
  15869. */
  15870. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15871. /**
  15872. * Called by the particle System when the position is computed for the created particle.
  15873. * @param worldMatrix is the world matrix of the particle system
  15874. * @param positionToUpdate is the position vector to update with the result
  15875. * @param particle is the particle we are computed the position for
  15876. * @param isLocal defines if the position should be set in local space
  15877. */
  15878. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15879. /**
  15880. * Clones the current emitter and returns a copy of it
  15881. * @returns the new emitter
  15882. */
  15883. clone(): CylinderParticleEmitter;
  15884. /**
  15885. * Called by the GPUParticleSystem to setup the update shader
  15886. * @param effect defines the update shader
  15887. */
  15888. applyToShader(effect: Effect): void;
  15889. /**
  15890. * Returns a string to use to update the GPU particles update shader
  15891. * @returns a string containng the defines string
  15892. */
  15893. getEffectDefines(): string;
  15894. /**
  15895. * Returns the string "CylinderParticleEmitter"
  15896. * @returns a string containing the class name
  15897. */
  15898. getClassName(): string;
  15899. /**
  15900. * Serializes the particle system to a JSON object.
  15901. * @returns the JSON object
  15902. */
  15903. serialize(): any;
  15904. /**
  15905. * Parse properties from a JSON object
  15906. * @param serializationObject defines the JSON object
  15907. */
  15908. parse(serializationObject: any): void;
  15909. }
  15910. /**
  15911. * Particle emitter emitting particles from the inside of a cylinder.
  15912. * It emits the particles randomly between two vectors.
  15913. */
  15914. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15915. /**
  15916. * The min limit of the emission direction.
  15917. */
  15918. direction1: Vector3;
  15919. /**
  15920. * The max limit of the emission direction.
  15921. */
  15922. direction2: Vector3;
  15923. /**
  15924. * Creates a new instance CylinderDirectedParticleEmitter
  15925. * @param radius the radius of the emission cylinder (1 by default)
  15926. * @param height the height of the emission cylinder (1 by default)
  15927. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15928. * @param direction1 the min limit of the emission direction (up vector by default)
  15929. * @param direction2 the max limit of the emission direction (up vector by default)
  15930. */
  15931. constructor(radius?: number, height?: number, radiusRange?: number,
  15932. /**
  15933. * The min limit of the emission direction.
  15934. */
  15935. direction1?: Vector3,
  15936. /**
  15937. * The max limit of the emission direction.
  15938. */
  15939. direction2?: Vector3);
  15940. /**
  15941. * Called by the particle System when the direction is computed for the created particle.
  15942. * @param worldMatrix is the world matrix of the particle system
  15943. * @param directionToUpdate is the direction vector to update with the result
  15944. * @param particle is the particle we are computed the direction for
  15945. */
  15946. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15947. /**
  15948. * Clones the current emitter and returns a copy of it
  15949. * @returns the new emitter
  15950. */
  15951. clone(): CylinderDirectedParticleEmitter;
  15952. /**
  15953. * Called by the GPUParticleSystem to setup the update shader
  15954. * @param effect defines the update shader
  15955. */
  15956. applyToShader(effect: Effect): void;
  15957. /**
  15958. * Returns a string to use to update the GPU particles update shader
  15959. * @returns a string containng the defines string
  15960. */
  15961. getEffectDefines(): string;
  15962. /**
  15963. * Returns the string "CylinderDirectedParticleEmitter"
  15964. * @returns a string containing the class name
  15965. */
  15966. getClassName(): string;
  15967. /**
  15968. * Serializes the particle system to a JSON object.
  15969. * @returns the JSON object
  15970. */
  15971. serialize(): any;
  15972. /**
  15973. * Parse properties from a JSON object
  15974. * @param serializationObject defines the JSON object
  15975. */
  15976. parse(serializationObject: any): void;
  15977. }
  15978. }
  15979. declare module BABYLON {
  15980. /**
  15981. * Particle emitter emitting particles from the inside of a hemisphere.
  15982. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15983. */
  15984. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15985. /**
  15986. * The radius of the emission hemisphere.
  15987. */
  15988. radius: number;
  15989. /**
  15990. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15991. */
  15992. radiusRange: number;
  15993. /**
  15994. * How much to randomize the particle direction [0-1].
  15995. */
  15996. directionRandomizer: number;
  15997. /**
  15998. * Creates a new instance HemisphericParticleEmitter
  15999. * @param radius the radius of the emission hemisphere (1 by default)
  16000. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16001. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16002. */
  16003. constructor(
  16004. /**
  16005. * The radius of the emission hemisphere.
  16006. */
  16007. radius?: number,
  16008. /**
  16009. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16010. */
  16011. radiusRange?: number,
  16012. /**
  16013. * How much to randomize the particle direction [0-1].
  16014. */
  16015. directionRandomizer?: number);
  16016. /**
  16017. * Called by the particle System when the direction is computed for the created particle.
  16018. * @param worldMatrix is the world matrix of the particle system
  16019. * @param directionToUpdate is the direction vector to update with the result
  16020. * @param particle is the particle we are computed the direction for
  16021. * @param isLocal defines if the direction should be set in local space
  16022. */
  16023. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16024. /**
  16025. * Called by the particle System when the position is computed for the created particle.
  16026. * @param worldMatrix is the world matrix of the particle system
  16027. * @param positionToUpdate is the position vector to update with the result
  16028. * @param particle is the particle we are computed the position for
  16029. * @param isLocal defines if the position should be set in local space
  16030. */
  16031. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16032. /**
  16033. * Clones the current emitter and returns a copy of it
  16034. * @returns the new emitter
  16035. */
  16036. clone(): HemisphericParticleEmitter;
  16037. /**
  16038. * Called by the GPUParticleSystem to setup the update shader
  16039. * @param effect defines the update shader
  16040. */
  16041. applyToShader(effect: Effect): void;
  16042. /**
  16043. * Returns a string to use to update the GPU particles update shader
  16044. * @returns a string containng the defines string
  16045. */
  16046. getEffectDefines(): string;
  16047. /**
  16048. * Returns the string "HemisphericParticleEmitter"
  16049. * @returns a string containing the class name
  16050. */
  16051. getClassName(): string;
  16052. /**
  16053. * Serializes the particle system to a JSON object.
  16054. * @returns the JSON object
  16055. */
  16056. serialize(): any;
  16057. /**
  16058. * Parse properties from a JSON object
  16059. * @param serializationObject defines the JSON object
  16060. */
  16061. parse(serializationObject: any): void;
  16062. }
  16063. }
  16064. declare module BABYLON {
  16065. /**
  16066. * Particle emitter emitting particles from a point.
  16067. * It emits the particles randomly between 2 given directions.
  16068. */
  16069. export class PointParticleEmitter implements IParticleEmitterType {
  16070. /**
  16071. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16072. */
  16073. direction1: Vector3;
  16074. /**
  16075. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16076. */
  16077. direction2: Vector3;
  16078. /**
  16079. * Creates a new instance PointParticleEmitter
  16080. */
  16081. constructor();
  16082. /**
  16083. * Called by the particle System when the direction is computed for the created particle.
  16084. * @param worldMatrix is the world matrix of the particle system
  16085. * @param directionToUpdate is the direction vector to update with the result
  16086. * @param particle is the particle we are computed the direction for
  16087. * @param isLocal defines if the direction should be set in local space
  16088. */
  16089. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16090. /**
  16091. * Called by the particle System when the position is computed for the created particle.
  16092. * @param worldMatrix is the world matrix of the particle system
  16093. * @param positionToUpdate is the position vector to update with the result
  16094. * @param particle is the particle we are computed the position for
  16095. * @param isLocal defines if the position should be set in local space
  16096. */
  16097. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16098. /**
  16099. * Clones the current emitter and returns a copy of it
  16100. * @returns the new emitter
  16101. */
  16102. clone(): PointParticleEmitter;
  16103. /**
  16104. * Called by the GPUParticleSystem to setup the update shader
  16105. * @param effect defines the update shader
  16106. */
  16107. applyToShader(effect: Effect): void;
  16108. /**
  16109. * Returns a string to use to update the GPU particles update shader
  16110. * @returns a string containng the defines string
  16111. */
  16112. getEffectDefines(): string;
  16113. /**
  16114. * Returns the string "PointParticleEmitter"
  16115. * @returns a string containing the class name
  16116. */
  16117. getClassName(): string;
  16118. /**
  16119. * Serializes the particle system to a JSON object.
  16120. * @returns the JSON object
  16121. */
  16122. serialize(): any;
  16123. /**
  16124. * Parse properties from a JSON object
  16125. * @param serializationObject defines the JSON object
  16126. */
  16127. parse(serializationObject: any): void;
  16128. }
  16129. }
  16130. declare module BABYLON {
  16131. /**
  16132. * Particle emitter emitting particles from the inside of a sphere.
  16133. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16134. */
  16135. export class SphereParticleEmitter implements IParticleEmitterType {
  16136. /**
  16137. * The radius of the emission sphere.
  16138. */
  16139. radius: number;
  16140. /**
  16141. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16142. */
  16143. radiusRange: number;
  16144. /**
  16145. * How much to randomize the particle direction [0-1].
  16146. */
  16147. directionRandomizer: number;
  16148. /**
  16149. * Creates a new instance SphereParticleEmitter
  16150. * @param radius the radius of the emission sphere (1 by default)
  16151. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16152. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16153. */
  16154. constructor(
  16155. /**
  16156. * The radius of the emission sphere.
  16157. */
  16158. radius?: number,
  16159. /**
  16160. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16161. */
  16162. radiusRange?: number,
  16163. /**
  16164. * How much to randomize the particle direction [0-1].
  16165. */
  16166. directionRandomizer?: number);
  16167. /**
  16168. * Called by the particle System when the direction is computed for the created particle.
  16169. * @param worldMatrix is the world matrix of the particle system
  16170. * @param directionToUpdate is the direction vector to update with the result
  16171. * @param particle is the particle we are computed the direction for
  16172. * @param isLocal defines if the direction should be set in local space
  16173. */
  16174. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16175. /**
  16176. * Called by the particle System when the position is computed for the created particle.
  16177. * @param worldMatrix is the world matrix of the particle system
  16178. * @param positionToUpdate is the position vector to update with the result
  16179. * @param particle is the particle we are computed the position for
  16180. * @param isLocal defines if the position should be set in local space
  16181. */
  16182. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16183. /**
  16184. * Clones the current emitter and returns a copy of it
  16185. * @returns the new emitter
  16186. */
  16187. clone(): SphereParticleEmitter;
  16188. /**
  16189. * Called by the GPUParticleSystem to setup the update shader
  16190. * @param effect defines the update shader
  16191. */
  16192. applyToShader(effect: Effect): void;
  16193. /**
  16194. * Returns a string to use to update the GPU particles update shader
  16195. * @returns a string containng the defines string
  16196. */
  16197. getEffectDefines(): string;
  16198. /**
  16199. * Returns the string "SphereParticleEmitter"
  16200. * @returns a string containing the class name
  16201. */
  16202. getClassName(): string;
  16203. /**
  16204. * Serializes the particle system to a JSON object.
  16205. * @returns the JSON object
  16206. */
  16207. serialize(): any;
  16208. /**
  16209. * Parse properties from a JSON object
  16210. * @param serializationObject defines the JSON object
  16211. */
  16212. parse(serializationObject: any): void;
  16213. }
  16214. /**
  16215. * Particle emitter emitting particles from the inside of a sphere.
  16216. * It emits the particles randomly between two vectors.
  16217. */
  16218. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16219. /**
  16220. * The min limit of the emission direction.
  16221. */
  16222. direction1: Vector3;
  16223. /**
  16224. * The max limit of the emission direction.
  16225. */
  16226. direction2: Vector3;
  16227. /**
  16228. * Creates a new instance SphereDirectedParticleEmitter
  16229. * @param radius the radius of the emission sphere (1 by default)
  16230. * @param direction1 the min limit of the emission direction (up vector by default)
  16231. * @param direction2 the max limit of the emission direction (up vector by default)
  16232. */
  16233. constructor(radius?: number,
  16234. /**
  16235. * The min limit of the emission direction.
  16236. */
  16237. direction1?: Vector3,
  16238. /**
  16239. * The max limit of the emission direction.
  16240. */
  16241. direction2?: Vector3);
  16242. /**
  16243. * Called by the particle System when the direction is computed for the created particle.
  16244. * @param worldMatrix is the world matrix of the particle system
  16245. * @param directionToUpdate is the direction vector to update with the result
  16246. * @param particle is the particle we are computed the direction for
  16247. */
  16248. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16249. /**
  16250. * Clones the current emitter and returns a copy of it
  16251. * @returns the new emitter
  16252. */
  16253. clone(): SphereDirectedParticleEmitter;
  16254. /**
  16255. * Called by the GPUParticleSystem to setup the update shader
  16256. * @param effect defines the update shader
  16257. */
  16258. applyToShader(effect: Effect): void;
  16259. /**
  16260. * Returns a string to use to update the GPU particles update shader
  16261. * @returns a string containng the defines string
  16262. */
  16263. getEffectDefines(): string;
  16264. /**
  16265. * Returns the string "SphereDirectedParticleEmitter"
  16266. * @returns a string containing the class name
  16267. */
  16268. getClassName(): string;
  16269. /**
  16270. * Serializes the particle system to a JSON object.
  16271. * @returns the JSON object
  16272. */
  16273. serialize(): any;
  16274. /**
  16275. * Parse properties from a JSON object
  16276. * @param serializationObject defines the JSON object
  16277. */
  16278. parse(serializationObject: any): void;
  16279. }
  16280. }
  16281. declare module BABYLON {
  16282. /**
  16283. * Particle emitter emitting particles from a custom list of positions.
  16284. */
  16285. export class CustomParticleEmitter implements IParticleEmitterType {
  16286. /**
  16287. * Gets or sets the position generator that will create the inital position of each particle.
  16288. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16289. */
  16290. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  16291. /**
  16292. * Gets or sets the destination generator that will create the final destination of each particle.
  16293. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16294. */
  16295. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  16296. /**
  16297. * Creates a new instance CustomParticleEmitter
  16298. */
  16299. constructor();
  16300. /**
  16301. * Called by the particle System when the direction is computed for the created particle.
  16302. * @param worldMatrix is the world matrix of the particle system
  16303. * @param directionToUpdate is the direction vector to update with the result
  16304. * @param particle is the particle we are computed the direction for
  16305. * @param isLocal defines if the direction should be set in local space
  16306. */
  16307. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16308. /**
  16309. * Called by the particle System when the position is computed for the created particle.
  16310. * @param worldMatrix is the world matrix of the particle system
  16311. * @param positionToUpdate is the position vector to update with the result
  16312. * @param particle is the particle we are computed the position for
  16313. * @param isLocal defines if the position should be set in local space
  16314. */
  16315. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16316. /**
  16317. * Clones the current emitter and returns a copy of it
  16318. * @returns the new emitter
  16319. */
  16320. clone(): CustomParticleEmitter;
  16321. /**
  16322. * Called by the GPUParticleSystem to setup the update shader
  16323. * @param effect defines the update shader
  16324. */
  16325. applyToShader(effect: Effect): void;
  16326. /**
  16327. * Returns a string to use to update the GPU particles update shader
  16328. * @returns a string containng the defines string
  16329. */
  16330. getEffectDefines(): string;
  16331. /**
  16332. * Returns the string "PointParticleEmitter"
  16333. * @returns a string containing the class name
  16334. */
  16335. getClassName(): string;
  16336. /**
  16337. * Serializes the particle system to a JSON object.
  16338. * @returns the JSON object
  16339. */
  16340. serialize(): any;
  16341. /**
  16342. * Parse properties from a JSON object
  16343. * @param serializationObject defines the JSON object
  16344. */
  16345. parse(serializationObject: any): void;
  16346. }
  16347. }
  16348. declare module BABYLON {
  16349. /**
  16350. * Particle emitter emitting particles from the inside of a box.
  16351. * It emits the particles randomly between 2 given directions.
  16352. */
  16353. export class MeshParticleEmitter implements IParticleEmitterType {
  16354. private _indices;
  16355. private _positions;
  16356. private _normals;
  16357. private _storedNormal;
  16358. private _mesh;
  16359. /**
  16360. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16361. */
  16362. direction1: Vector3;
  16363. /**
  16364. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16365. */
  16366. direction2: Vector3;
  16367. /**
  16368. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  16369. */
  16370. useMeshNormalsForDirection: boolean;
  16371. /** Defines the mesh to use as source */
  16372. get mesh(): Nullable<AbstractMesh>;
  16373. set mesh(value: Nullable<AbstractMesh>);
  16374. /**
  16375. * Creates a new instance MeshParticleEmitter
  16376. * @param mesh defines the mesh to use as source
  16377. */
  16378. constructor(mesh?: Nullable<AbstractMesh>);
  16379. /**
  16380. * Called by the particle System when the direction is computed for the created particle.
  16381. * @param worldMatrix is the world matrix of the particle system
  16382. * @param directionToUpdate is the direction vector to update with the result
  16383. * @param particle is the particle we are computed the direction for
  16384. * @param isLocal defines if the direction should be set in local space
  16385. */
  16386. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16387. /**
  16388. * Called by the particle System when the position is computed for the created particle.
  16389. * @param worldMatrix is the world matrix of the particle system
  16390. * @param positionToUpdate is the position vector to update with the result
  16391. * @param particle is the particle we are computed the position for
  16392. * @param isLocal defines if the position should be set in local space
  16393. */
  16394. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16395. /**
  16396. * Clones the current emitter and returns a copy of it
  16397. * @returns the new emitter
  16398. */
  16399. clone(): MeshParticleEmitter;
  16400. /**
  16401. * Called by the GPUParticleSystem to setup the update shader
  16402. * @param effect defines the update shader
  16403. */
  16404. applyToShader(effect: Effect): void;
  16405. /**
  16406. * Returns a string to use to update the GPU particles update shader
  16407. * @returns a string containng the defines string
  16408. */
  16409. getEffectDefines(): string;
  16410. /**
  16411. * Returns the string "BoxParticleEmitter"
  16412. * @returns a string containing the class name
  16413. */
  16414. getClassName(): string;
  16415. /**
  16416. * Serializes the particle system to a JSON object.
  16417. * @returns the JSON object
  16418. */
  16419. serialize(): any;
  16420. /**
  16421. * Parse properties from a JSON object
  16422. * @param serializationObject defines the JSON object
  16423. * @param scene defines the hosting scene
  16424. */
  16425. parse(serializationObject: any, scene: Nullable<Scene>): void;
  16426. }
  16427. }
  16428. declare module BABYLON {
  16429. /**
  16430. * Interface representing a particle system in Babylon.js.
  16431. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16432. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16433. */
  16434. export interface IParticleSystem {
  16435. /**
  16436. * List of animations used by the particle system.
  16437. */
  16438. animations: Animation[];
  16439. /**
  16440. * The id of the Particle system.
  16441. */
  16442. id: string;
  16443. /**
  16444. * The name of the Particle system.
  16445. */
  16446. name: string;
  16447. /**
  16448. * The emitter represents the Mesh or position we are attaching the particle system to.
  16449. */
  16450. emitter: Nullable<AbstractMesh | Vector3>;
  16451. /**
  16452. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16453. */
  16454. isBillboardBased: boolean;
  16455. /**
  16456. * The rendering group used by the Particle system to chose when to render.
  16457. */
  16458. renderingGroupId: number;
  16459. /**
  16460. * The layer mask we are rendering the particles through.
  16461. */
  16462. layerMask: number;
  16463. /**
  16464. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16465. */
  16466. updateSpeed: number;
  16467. /**
  16468. * The amount of time the particle system is running (depends of the overall update speed).
  16469. */
  16470. targetStopDuration: number;
  16471. /**
  16472. * The texture used to render each particle. (this can be a spritesheet)
  16473. */
  16474. particleTexture: Nullable<BaseTexture>;
  16475. /**
  16476. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16477. */
  16478. blendMode: number;
  16479. /**
  16480. * Minimum life time of emitting particles.
  16481. */
  16482. minLifeTime: number;
  16483. /**
  16484. * Maximum life time of emitting particles.
  16485. */
  16486. maxLifeTime: number;
  16487. /**
  16488. * Minimum Size of emitting particles.
  16489. */
  16490. minSize: number;
  16491. /**
  16492. * Maximum Size of emitting particles.
  16493. */
  16494. maxSize: number;
  16495. /**
  16496. * Minimum scale of emitting particles on X axis.
  16497. */
  16498. minScaleX: number;
  16499. /**
  16500. * Maximum scale of emitting particles on X axis.
  16501. */
  16502. maxScaleX: number;
  16503. /**
  16504. * Minimum scale of emitting particles on Y axis.
  16505. */
  16506. minScaleY: number;
  16507. /**
  16508. * Maximum scale of emitting particles on Y axis.
  16509. */
  16510. maxScaleY: number;
  16511. /**
  16512. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16513. */
  16514. color1: Color4;
  16515. /**
  16516. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16517. */
  16518. color2: Color4;
  16519. /**
  16520. * Color the particle will have at the end of its lifetime.
  16521. */
  16522. colorDead: Color4;
  16523. /**
  16524. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16525. */
  16526. emitRate: number;
  16527. /**
  16528. * You can use gravity if you want to give an orientation to your particles.
  16529. */
  16530. gravity: Vector3;
  16531. /**
  16532. * Minimum power of emitting particles.
  16533. */
  16534. minEmitPower: number;
  16535. /**
  16536. * Maximum power of emitting particles.
  16537. */
  16538. maxEmitPower: number;
  16539. /**
  16540. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16541. */
  16542. minAngularSpeed: number;
  16543. /**
  16544. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16545. */
  16546. maxAngularSpeed: number;
  16547. /**
  16548. * Gets or sets the minimal initial rotation in radians.
  16549. */
  16550. minInitialRotation: number;
  16551. /**
  16552. * Gets or sets the maximal initial rotation in radians.
  16553. */
  16554. maxInitialRotation: number;
  16555. /**
  16556. * The particle emitter type defines the emitter used by the particle system.
  16557. * It can be for example box, sphere, or cone...
  16558. */
  16559. particleEmitterType: Nullable<IParticleEmitterType>;
  16560. /**
  16561. * Defines the delay in milliseconds before starting the system (0 by default)
  16562. */
  16563. startDelay: number;
  16564. /**
  16565. * 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
  16566. */
  16567. preWarmCycles: number;
  16568. /**
  16569. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16570. */
  16571. preWarmStepOffset: number;
  16572. /**
  16573. * 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)
  16574. */
  16575. spriteCellChangeSpeed: number;
  16576. /**
  16577. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16578. */
  16579. startSpriteCellID: number;
  16580. /**
  16581. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16582. */
  16583. endSpriteCellID: number;
  16584. /**
  16585. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16586. */
  16587. spriteCellWidth: number;
  16588. /**
  16589. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16590. */
  16591. spriteCellHeight: number;
  16592. /**
  16593. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16594. */
  16595. spriteRandomStartCell: boolean;
  16596. /**
  16597. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16598. */
  16599. isAnimationSheetEnabled: boolean;
  16600. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16601. translationPivot: Vector2;
  16602. /**
  16603. * Gets or sets a texture used to add random noise to particle positions
  16604. */
  16605. noiseTexture: Nullable<BaseTexture>;
  16606. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16607. noiseStrength: Vector3;
  16608. /**
  16609. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16610. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16611. */
  16612. billboardMode: number;
  16613. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16614. limitVelocityDamping: number;
  16615. /**
  16616. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16617. */
  16618. beginAnimationOnStart: boolean;
  16619. /**
  16620. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16621. */
  16622. beginAnimationFrom: number;
  16623. /**
  16624. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16625. */
  16626. beginAnimationTo: number;
  16627. /**
  16628. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16629. */
  16630. beginAnimationLoop: boolean;
  16631. /**
  16632. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16633. */
  16634. disposeOnStop: boolean;
  16635. /**
  16636. * Specifies if the particles are updated in emitter local space or world space
  16637. */
  16638. isLocal: boolean;
  16639. /** Snippet ID if the particle system was created from the snippet server */
  16640. snippetId: string;
  16641. /** Gets or sets a matrix to use to compute projection */
  16642. defaultProjectionMatrix: Matrix;
  16643. /**
  16644. * Gets the maximum number of particles active at the same time.
  16645. * @returns The max number of active particles.
  16646. */
  16647. getCapacity(): number;
  16648. /**
  16649. * Gets the number of particles active at the same time.
  16650. * @returns The number of active particles.
  16651. */
  16652. getActiveCount(): number;
  16653. /**
  16654. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16655. * @returns True if it has been started, otherwise false.
  16656. */
  16657. isStarted(): boolean;
  16658. /**
  16659. * Animates the particle system for this frame.
  16660. */
  16661. animate(): void;
  16662. /**
  16663. * Renders the particle system in its current state.
  16664. * @returns the current number of particles
  16665. */
  16666. render(): number;
  16667. /**
  16668. * Dispose the particle system and frees its associated resources.
  16669. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16670. */
  16671. dispose(disposeTexture?: boolean): void;
  16672. /**
  16673. * An event triggered when the system is disposed
  16674. */
  16675. onDisposeObservable: Observable<IParticleSystem>;
  16676. /**
  16677. * An event triggered when the system is stopped
  16678. */
  16679. onStoppedObservable: Observable<IParticleSystem>;
  16680. /**
  16681. * Clones the particle system.
  16682. * @param name The name of the cloned object
  16683. * @param newEmitter The new emitter to use
  16684. * @returns the cloned particle system
  16685. */
  16686. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16687. /**
  16688. * Serializes the particle system to a JSON object
  16689. * @param serializeTexture defines if the texture must be serialized as well
  16690. * @returns the JSON object
  16691. */
  16692. serialize(serializeTexture: boolean): any;
  16693. /**
  16694. * Rebuild the particle system
  16695. */
  16696. rebuild(): void;
  16697. /** Force the system to rebuild all gradients that need to be resync */
  16698. forceRefreshGradients(): void;
  16699. /**
  16700. * Starts the particle system and begins to emit
  16701. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16702. */
  16703. start(delay?: number): void;
  16704. /**
  16705. * Stops the particle system.
  16706. */
  16707. stop(): void;
  16708. /**
  16709. * Remove all active particles
  16710. */
  16711. reset(): void;
  16712. /**
  16713. * Gets a boolean indicating that the system is stopping
  16714. * @returns true if the system is currently stopping
  16715. */
  16716. isStopping(): boolean;
  16717. /**
  16718. * Is this system ready to be used/rendered
  16719. * @return true if the system is ready
  16720. */
  16721. isReady(): boolean;
  16722. /**
  16723. * Returns the string "ParticleSystem"
  16724. * @returns a string containing the class name
  16725. */
  16726. getClassName(): string;
  16727. /**
  16728. * Gets the custom effect used to render the particles
  16729. * @param blendMode Blend mode for which the effect should be retrieved
  16730. * @returns The effect
  16731. */
  16732. getCustomEffect(blendMode: number): Nullable<Effect>;
  16733. /**
  16734. * Sets the custom effect used to render the particles
  16735. * @param effect The effect to set
  16736. * @param blendMode Blend mode for which the effect should be set
  16737. */
  16738. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  16739. /**
  16740. * Fill the defines array according to the current settings of the particle system
  16741. * @param defines Array to be updated
  16742. * @param blendMode blend mode to take into account when updating the array
  16743. */
  16744. fillDefines(defines: Array<string>, blendMode: number): void;
  16745. /**
  16746. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  16747. * @param uniforms Uniforms array to fill
  16748. * @param attributes Attributes array to fill
  16749. * @param samplers Samplers array to fill
  16750. */
  16751. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  16752. /**
  16753. * Observable that will be called just before the particles are drawn
  16754. */
  16755. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  16756. /**
  16757. * Gets the name of the particle vertex shader
  16758. */
  16759. vertexShaderName: string;
  16760. /**
  16761. * Adds a new color gradient
  16762. * @param gradient defines the gradient to use (between 0 and 1)
  16763. * @param color1 defines the color to affect to the specified gradient
  16764. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16765. * @returns the current particle system
  16766. */
  16767. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16768. /**
  16769. * Remove a specific color gradient
  16770. * @param gradient defines the gradient to remove
  16771. * @returns the current particle system
  16772. */
  16773. removeColorGradient(gradient: number): IParticleSystem;
  16774. /**
  16775. * Adds a new size gradient
  16776. * @param gradient defines the gradient to use (between 0 and 1)
  16777. * @param factor defines the size factor to affect to the specified gradient
  16778. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16779. * @returns the current particle system
  16780. */
  16781. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16782. /**
  16783. * Remove a specific size gradient
  16784. * @param gradient defines the gradient to remove
  16785. * @returns the current particle system
  16786. */
  16787. removeSizeGradient(gradient: number): IParticleSystem;
  16788. /**
  16789. * Gets the current list of color gradients.
  16790. * You must use addColorGradient and removeColorGradient to udpate this list
  16791. * @returns the list of color gradients
  16792. */
  16793. getColorGradients(): Nullable<Array<ColorGradient>>;
  16794. /**
  16795. * Gets the current list of size gradients.
  16796. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16797. * @returns the list of size gradients
  16798. */
  16799. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16800. /**
  16801. * Gets the current list of angular speed gradients.
  16802. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16803. * @returns the list of angular speed gradients
  16804. */
  16805. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16806. /**
  16807. * Adds a new angular speed gradient
  16808. * @param gradient defines the gradient to use (between 0 and 1)
  16809. * @param factor defines the angular speed to affect to the specified gradient
  16810. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16811. * @returns the current particle system
  16812. */
  16813. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16814. /**
  16815. * Remove a specific angular speed gradient
  16816. * @param gradient defines the gradient to remove
  16817. * @returns the current particle system
  16818. */
  16819. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16820. /**
  16821. * Gets the current list of velocity gradients.
  16822. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16823. * @returns the list of velocity gradients
  16824. */
  16825. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16826. /**
  16827. * Adds a new velocity gradient
  16828. * @param gradient defines the gradient to use (between 0 and 1)
  16829. * @param factor defines the velocity to affect to the specified gradient
  16830. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16831. * @returns the current particle system
  16832. */
  16833. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16834. /**
  16835. * Remove a specific velocity gradient
  16836. * @param gradient defines the gradient to remove
  16837. * @returns the current particle system
  16838. */
  16839. removeVelocityGradient(gradient: number): IParticleSystem;
  16840. /**
  16841. * Gets the current list of limit velocity gradients.
  16842. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16843. * @returns the list of limit velocity gradients
  16844. */
  16845. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16846. /**
  16847. * Adds a new limit velocity gradient
  16848. * @param gradient defines the gradient to use (between 0 and 1)
  16849. * @param factor defines the limit velocity to affect to the specified gradient
  16850. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16851. * @returns the current particle system
  16852. */
  16853. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16854. /**
  16855. * Remove a specific limit velocity gradient
  16856. * @param gradient defines the gradient to remove
  16857. * @returns the current particle system
  16858. */
  16859. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16860. /**
  16861. * Adds a new drag gradient
  16862. * @param gradient defines the gradient to use (between 0 and 1)
  16863. * @param factor defines the drag to affect to the specified gradient
  16864. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16865. * @returns the current particle system
  16866. */
  16867. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16868. /**
  16869. * Remove a specific drag gradient
  16870. * @param gradient defines the gradient to remove
  16871. * @returns the current particle system
  16872. */
  16873. removeDragGradient(gradient: number): IParticleSystem;
  16874. /**
  16875. * Gets the current list of drag gradients.
  16876. * You must use addDragGradient and removeDragGradient to udpate this list
  16877. * @returns the list of drag gradients
  16878. */
  16879. getDragGradients(): Nullable<Array<FactorGradient>>;
  16880. /**
  16881. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16882. * @param gradient defines the gradient to use (between 0 and 1)
  16883. * @param factor defines the emit rate to affect to the specified gradient
  16884. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16885. * @returns the current particle system
  16886. */
  16887. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16888. /**
  16889. * Remove a specific emit rate gradient
  16890. * @param gradient defines the gradient to remove
  16891. * @returns the current particle system
  16892. */
  16893. removeEmitRateGradient(gradient: number): IParticleSystem;
  16894. /**
  16895. * Gets the current list of emit rate gradients.
  16896. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16897. * @returns the list of emit rate gradients
  16898. */
  16899. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16900. /**
  16901. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16902. * @param gradient defines the gradient to use (between 0 and 1)
  16903. * @param factor defines the start size to affect to the specified gradient
  16904. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16905. * @returns the current particle system
  16906. */
  16907. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16908. /**
  16909. * Remove a specific start size gradient
  16910. * @param gradient defines the gradient to remove
  16911. * @returns the current particle system
  16912. */
  16913. removeStartSizeGradient(gradient: number): IParticleSystem;
  16914. /**
  16915. * Gets the current list of start size gradients.
  16916. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16917. * @returns the list of start size gradients
  16918. */
  16919. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16920. /**
  16921. * Adds a new life time gradient
  16922. * @param gradient defines the gradient to use (between 0 and 1)
  16923. * @param factor defines the life time factor to affect to the specified gradient
  16924. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16925. * @returns the current particle system
  16926. */
  16927. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16928. /**
  16929. * Remove a specific life time gradient
  16930. * @param gradient defines the gradient to remove
  16931. * @returns the current particle system
  16932. */
  16933. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16934. /**
  16935. * Gets the current list of life time gradients.
  16936. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16937. * @returns the list of life time gradients
  16938. */
  16939. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16940. /**
  16941. * Gets the current list of color gradients.
  16942. * You must use addColorGradient and removeColorGradient to udpate this list
  16943. * @returns the list of color gradients
  16944. */
  16945. getColorGradients(): Nullable<Array<ColorGradient>>;
  16946. /**
  16947. * Adds a new ramp gradient used to remap particle colors
  16948. * @param gradient defines the gradient to use (between 0 and 1)
  16949. * @param color defines the color to affect to the specified gradient
  16950. * @returns the current particle system
  16951. */
  16952. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16953. /**
  16954. * Gets the current list of ramp gradients.
  16955. * You must use addRampGradient and removeRampGradient to udpate this list
  16956. * @returns the list of ramp gradients
  16957. */
  16958. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16959. /** Gets or sets a boolean indicating that ramp gradients must be used
  16960. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16961. */
  16962. useRampGradients: boolean;
  16963. /**
  16964. * Adds a new color remap gradient
  16965. * @param gradient defines the gradient to use (between 0 and 1)
  16966. * @param min defines the color remap minimal range
  16967. * @param max defines the color remap maximal range
  16968. * @returns the current particle system
  16969. */
  16970. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16971. /**
  16972. * Gets the current list of color remap gradients.
  16973. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16974. * @returns the list of color remap gradients
  16975. */
  16976. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16977. /**
  16978. * Adds a new alpha remap gradient
  16979. * @param gradient defines the gradient to use (between 0 and 1)
  16980. * @param min defines the alpha remap minimal range
  16981. * @param max defines the alpha remap maximal range
  16982. * @returns the current particle system
  16983. */
  16984. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16985. /**
  16986. * Gets the current list of alpha remap gradients.
  16987. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16988. * @returns the list of alpha remap gradients
  16989. */
  16990. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16991. /**
  16992. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16993. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16994. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16995. * @returns the emitter
  16996. */
  16997. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16998. /**
  16999. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17000. * @param radius The radius of the hemisphere to emit from
  17001. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17002. * @returns the emitter
  17003. */
  17004. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  17005. /**
  17006. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17007. * @param radius The radius of the sphere to emit from
  17008. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17009. * @returns the emitter
  17010. */
  17011. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  17012. /**
  17013. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17014. * @param radius The radius of the sphere to emit from
  17015. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17016. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17017. * @returns the emitter
  17018. */
  17019. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17020. /**
  17021. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17022. * @param radius The radius of the emission cylinder
  17023. * @param height The height of the emission cylinder
  17024. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17025. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17026. * @returns the emitter
  17027. */
  17028. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17029. /**
  17030. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17031. * @param radius The radius of the cylinder to emit from
  17032. * @param height The height of the emission cylinder
  17033. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17034. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17035. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17036. * @returns the emitter
  17037. */
  17038. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17039. /**
  17040. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17041. * @param radius The radius of the cone to emit from
  17042. * @param angle The base angle of the cone
  17043. * @returns the emitter
  17044. */
  17045. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17046. /**
  17047. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17048. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17049. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17050. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17051. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17052. * @returns the emitter
  17053. */
  17054. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17055. /**
  17056. * Get hosting scene
  17057. * @returns the scene
  17058. */
  17059. getScene(): Nullable<Scene>;
  17060. }
  17061. }
  17062. declare module BABYLON {
  17063. /**
  17064. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  17065. */
  17066. export class ColorSplitterBlock extends NodeMaterialBlock {
  17067. /**
  17068. * Create a new ColorSplitterBlock
  17069. * @param name defines the block name
  17070. */
  17071. constructor(name: string);
  17072. /**
  17073. * Gets the current class name
  17074. * @returns the class name
  17075. */
  17076. getClassName(): string;
  17077. /**
  17078. * Gets the rgba component (input)
  17079. */
  17080. get rgba(): NodeMaterialConnectionPoint;
  17081. /**
  17082. * Gets the rgb component (input)
  17083. */
  17084. get rgbIn(): NodeMaterialConnectionPoint;
  17085. /**
  17086. * Gets the rgb component (output)
  17087. */
  17088. get rgbOut(): NodeMaterialConnectionPoint;
  17089. /**
  17090. * Gets the r component (output)
  17091. */
  17092. get r(): NodeMaterialConnectionPoint;
  17093. /**
  17094. * Gets the g component (output)
  17095. */
  17096. get g(): NodeMaterialConnectionPoint;
  17097. /**
  17098. * Gets the b component (output)
  17099. */
  17100. get b(): NodeMaterialConnectionPoint;
  17101. /**
  17102. * Gets the a component (output)
  17103. */
  17104. get a(): NodeMaterialConnectionPoint;
  17105. protected _inputRename(name: string): string;
  17106. protected _outputRename(name: string): string;
  17107. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  17108. }
  17109. }
  17110. declare module BABYLON {
  17111. /**
  17112. * Operations supported by the Trigonometry block
  17113. */
  17114. export enum TrigonometryBlockOperations {
  17115. /** Cos */
  17116. Cos = 0,
  17117. /** Sin */
  17118. Sin = 1,
  17119. /** Abs */
  17120. Abs = 2,
  17121. /** Exp */
  17122. Exp = 3,
  17123. /** Exp2 */
  17124. Exp2 = 4,
  17125. /** Round */
  17126. Round = 5,
  17127. /** Floor */
  17128. Floor = 6,
  17129. /** Ceiling */
  17130. Ceiling = 7,
  17131. /** Square root */
  17132. Sqrt = 8,
  17133. /** Log */
  17134. Log = 9,
  17135. /** Tangent */
  17136. Tan = 10,
  17137. /** Arc tangent */
  17138. ArcTan = 11,
  17139. /** Arc cosinus */
  17140. ArcCos = 12,
  17141. /** Arc sinus */
  17142. ArcSin = 13,
  17143. /** Fraction */
  17144. Fract = 14,
  17145. /** Sign */
  17146. Sign = 15,
  17147. /** To radians (from degrees) */
  17148. Radians = 16,
  17149. /** To degrees (from radians) */
  17150. Degrees = 17
  17151. }
  17152. /**
  17153. * Block used to apply trigonometry operation to floats
  17154. */
  17155. export class TrigonometryBlock extends NodeMaterialBlock {
  17156. /**
  17157. * Gets or sets the operation applied by the block
  17158. */
  17159. operation: TrigonometryBlockOperations;
  17160. /**
  17161. * Creates a new TrigonometryBlock
  17162. * @param name defines the block name
  17163. */
  17164. constructor(name: string);
  17165. /**
  17166. * Gets the current class name
  17167. * @returns the class name
  17168. */
  17169. getClassName(): string;
  17170. /**
  17171. * Gets the input component
  17172. */
  17173. get input(): NodeMaterialConnectionPoint;
  17174. /**
  17175. * Gets the output component
  17176. */
  17177. get output(): NodeMaterialConnectionPoint;
  17178. protected _buildBlock(state: NodeMaterialBuildState): this;
  17179. serialize(): any;
  17180. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  17181. protected _dumpPropertiesCode(): string;
  17182. }
  17183. }
  17184. declare module BABYLON {
  17185. /**
  17186. * Interface used to configure the node material editor
  17187. */
  17188. export interface INodeMaterialEditorOptions {
  17189. /** Define the URl to load node editor script */
  17190. editorURL?: string;
  17191. }
  17192. /** @hidden */
  17193. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17194. NORMAL: boolean;
  17195. TANGENT: boolean;
  17196. UV1: boolean;
  17197. /** BONES */
  17198. NUM_BONE_INFLUENCERS: number;
  17199. BonesPerMesh: number;
  17200. BONETEXTURE: boolean;
  17201. /** MORPH TARGETS */
  17202. MORPHTARGETS: boolean;
  17203. MORPHTARGETS_NORMAL: boolean;
  17204. MORPHTARGETS_TANGENT: boolean;
  17205. MORPHTARGETS_UV: boolean;
  17206. NUM_MORPH_INFLUENCERS: number;
  17207. /** IMAGE PROCESSING */
  17208. IMAGEPROCESSING: boolean;
  17209. VIGNETTE: boolean;
  17210. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17211. VIGNETTEBLENDMODEOPAQUE: boolean;
  17212. TONEMAPPING: boolean;
  17213. TONEMAPPING_ACES: boolean;
  17214. CONTRAST: boolean;
  17215. EXPOSURE: boolean;
  17216. COLORCURVES: boolean;
  17217. COLORGRADING: boolean;
  17218. COLORGRADING3D: boolean;
  17219. SAMPLER3DGREENDEPTH: boolean;
  17220. SAMPLER3DBGRMAP: boolean;
  17221. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17222. /** MISC. */
  17223. BUMPDIRECTUV: number;
  17224. constructor();
  17225. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  17226. }
  17227. /**
  17228. * Class used to configure NodeMaterial
  17229. */
  17230. export interface INodeMaterialOptions {
  17231. /**
  17232. * Defines if blocks should emit comments
  17233. */
  17234. emitComments: boolean;
  17235. }
  17236. /**
  17237. * Class used to create a node based material built by assembling shader blocks
  17238. */
  17239. export class NodeMaterial extends PushMaterial {
  17240. private static _BuildIdGenerator;
  17241. private _options;
  17242. private _vertexCompilationState;
  17243. private _fragmentCompilationState;
  17244. private _sharedData;
  17245. private _buildId;
  17246. private _buildWasSuccessful;
  17247. private _cachedWorldViewMatrix;
  17248. private _cachedWorldViewProjectionMatrix;
  17249. private _optimizers;
  17250. private _animationFrame;
  17251. /** Define the Url to load node editor script */
  17252. static EditorURL: string;
  17253. /** Define the Url to load snippets */
  17254. static SnippetUrl: string;
  17255. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  17256. static IgnoreTexturesAtLoadTime: boolean;
  17257. private BJSNODEMATERIALEDITOR;
  17258. /** Get the inspector from bundle or global */
  17259. private _getGlobalNodeMaterialEditor;
  17260. /**
  17261. * Snippet ID if the material was created from the snippet server
  17262. */
  17263. snippetId: string;
  17264. /**
  17265. * Gets or sets data used by visual editor
  17266. * @see https://nme.babylonjs.com
  17267. */
  17268. editorData: any;
  17269. /**
  17270. * 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)
  17271. */
  17272. ignoreAlpha: boolean;
  17273. /**
  17274. * Defines the maximum number of lights that can be used in the material
  17275. */
  17276. maxSimultaneousLights: number;
  17277. /**
  17278. * Observable raised when the material is built
  17279. */
  17280. onBuildObservable: Observable<NodeMaterial>;
  17281. /**
  17282. * Gets or sets the root nodes of the material vertex shader
  17283. */
  17284. _vertexOutputNodes: NodeMaterialBlock[];
  17285. /**
  17286. * Gets or sets the root nodes of the material fragment (pixel) shader
  17287. */
  17288. _fragmentOutputNodes: NodeMaterialBlock[];
  17289. /** Gets or sets options to control the node material overall behavior */
  17290. get options(): INodeMaterialOptions;
  17291. set options(options: INodeMaterialOptions);
  17292. /**
  17293. * Default configuration related to image processing available in the standard Material.
  17294. */
  17295. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17296. /**
  17297. * Gets the image processing configuration used either in this material.
  17298. */
  17299. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17300. /**
  17301. * Sets the Default image processing configuration used either in the this material.
  17302. *
  17303. * If sets to null, the scene one is in use.
  17304. */
  17305. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17306. /**
  17307. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  17308. */
  17309. attachedBlocks: NodeMaterialBlock[];
  17310. /**
  17311. * Specifies the mode of the node material
  17312. * @hidden
  17313. */
  17314. _mode: NodeMaterialModes;
  17315. /**
  17316. * Gets the mode property
  17317. */
  17318. get mode(): NodeMaterialModes;
  17319. /**
  17320. * A free comment about the material
  17321. */
  17322. comment: string;
  17323. /**
  17324. * Create a new node based material
  17325. * @param name defines the material name
  17326. * @param scene defines the hosting scene
  17327. * @param options defines creation option
  17328. */
  17329. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  17330. /**
  17331. * Gets the current class name of the material e.g. "NodeMaterial"
  17332. * @returns the class name
  17333. */
  17334. getClassName(): string;
  17335. /**
  17336. * Keep track of the image processing observer to allow dispose and replace.
  17337. */
  17338. private _imageProcessingObserver;
  17339. /**
  17340. * Attaches a new image processing configuration to the Standard Material.
  17341. * @param configuration
  17342. */
  17343. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17344. /**
  17345. * Get a block by its name
  17346. * @param name defines the name of the block to retrieve
  17347. * @returns the required block or null if not found
  17348. */
  17349. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  17350. /**
  17351. * Get a block by its name
  17352. * @param predicate defines the predicate used to find the good candidate
  17353. * @returns the required block or null if not found
  17354. */
  17355. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  17356. /**
  17357. * Get an input block by its name
  17358. * @param predicate defines the predicate used to find the good candidate
  17359. * @returns the required input block or null if not found
  17360. */
  17361. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  17362. /**
  17363. * Gets the list of input blocks attached to this material
  17364. * @returns an array of InputBlocks
  17365. */
  17366. getInputBlocks(): InputBlock[];
  17367. /**
  17368. * Adds a new optimizer to the list of optimizers
  17369. * @param optimizer defines the optimizers to add
  17370. * @returns the current material
  17371. */
  17372. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  17373. /**
  17374. * Remove an optimizer from the list of optimizers
  17375. * @param optimizer defines the optimizers to remove
  17376. * @returns the current material
  17377. */
  17378. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  17379. /**
  17380. * Add a new block to the list of output nodes
  17381. * @param node defines the node to add
  17382. * @returns the current material
  17383. */
  17384. addOutputNode(node: NodeMaterialBlock): this;
  17385. /**
  17386. * Remove a block from the list of root nodes
  17387. * @param node defines the node to remove
  17388. * @returns the current material
  17389. */
  17390. removeOutputNode(node: NodeMaterialBlock): this;
  17391. private _addVertexOutputNode;
  17392. private _removeVertexOutputNode;
  17393. private _addFragmentOutputNode;
  17394. private _removeFragmentOutputNode;
  17395. /**
  17396. * Specifies if the material will require alpha blending
  17397. * @returns a boolean specifying if alpha blending is needed
  17398. */
  17399. needAlphaBlending(): boolean;
  17400. /**
  17401. * Specifies if this material should be rendered in alpha test mode
  17402. * @returns a boolean specifying if an alpha test is needed.
  17403. */
  17404. needAlphaTesting(): boolean;
  17405. private _initializeBlock;
  17406. private _resetDualBlocks;
  17407. /**
  17408. * Remove a block from the current node material
  17409. * @param block defines the block to remove
  17410. */
  17411. removeBlock(block: NodeMaterialBlock): void;
  17412. /**
  17413. * Build the material and generates the inner effect
  17414. * @param verbose defines if the build should log activity
  17415. */
  17416. build(verbose?: boolean): void;
  17417. /**
  17418. * Runs an otpimization phase to try to improve the shader code
  17419. */
  17420. optimize(): void;
  17421. private _prepareDefinesForAttributes;
  17422. /**
  17423. * Create a post process from the material
  17424. * @param camera The camera to apply the render pass to.
  17425. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  17426. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  17427. * @param engine The engine which the post process will be applied. (default: current engine)
  17428. * @param reusable If the post process can be reused on the same frame. (default: false)
  17429. * @param textureType Type of textures used when performing the post process. (default: 0)
  17430. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  17431. * @returns the post process created
  17432. */
  17433. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  17434. /**
  17435. * Create the post process effect from the material
  17436. * @param postProcess The post process to create the effect for
  17437. */
  17438. createEffectForPostProcess(postProcess: PostProcess): void;
  17439. private _createEffectForPostProcess;
  17440. /**
  17441. * Create a new procedural texture based on this node material
  17442. * @param size defines the size of the texture
  17443. * @param scene defines the hosting scene
  17444. * @returns the new procedural texture attached to this node material
  17445. */
  17446. createProceduralTexture(size: number | {
  17447. width: number;
  17448. height: number;
  17449. layers?: number;
  17450. }, scene: Scene): Nullable<ProceduralTexture>;
  17451. private _createEffectForParticles;
  17452. private _checkInternals;
  17453. /**
  17454. * Create the effect to be used as the custom effect for a particle system
  17455. * @param particleSystem Particle system to create the effect for
  17456. * @param onCompiled defines a function to call when the effect creation is successful
  17457. * @param onError defines a function to call when the effect creation has failed
  17458. */
  17459. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  17460. private _processDefines;
  17461. /**
  17462. * Get if the submesh is ready to be used and all its information available.
  17463. * Child classes can use it to update shaders
  17464. * @param mesh defines the mesh to check
  17465. * @param subMesh defines which submesh to check
  17466. * @param useInstances specifies that instances should be used
  17467. * @returns a boolean indicating that the submesh is ready or not
  17468. */
  17469. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17470. /**
  17471. * Get a string representing the shaders built by the current node graph
  17472. */
  17473. get compiledShaders(): string;
  17474. /**
  17475. * Binds the world matrix to the material
  17476. * @param world defines the world transformation matrix
  17477. */
  17478. bindOnlyWorldMatrix(world: Matrix): void;
  17479. /**
  17480. * Binds the submesh to this material by preparing the effect and shader to draw
  17481. * @param world defines the world transformation matrix
  17482. * @param mesh defines the mesh containing the submesh
  17483. * @param subMesh defines the submesh to bind the material to
  17484. */
  17485. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17486. /**
  17487. * Gets the active textures from the material
  17488. * @returns an array of textures
  17489. */
  17490. getActiveTextures(): BaseTexture[];
  17491. /**
  17492. * Gets the list of texture blocks
  17493. * @returns an array of texture blocks
  17494. */
  17495. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  17496. /**
  17497. * Specifies if the material uses a texture
  17498. * @param texture defines the texture to check against the material
  17499. * @returns a boolean specifying if the material uses the texture
  17500. */
  17501. hasTexture(texture: BaseTexture): boolean;
  17502. /**
  17503. * Disposes the material
  17504. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17505. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17506. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17507. */
  17508. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17509. /** Creates the node editor window. */
  17510. private _createNodeEditor;
  17511. /**
  17512. * Launch the node material editor
  17513. * @param config Define the configuration of the editor
  17514. * @return a promise fulfilled when the node editor is visible
  17515. */
  17516. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  17517. /**
  17518. * Clear the current material
  17519. */
  17520. clear(): void;
  17521. /**
  17522. * Clear the current material and set it to a default state
  17523. */
  17524. setToDefault(): void;
  17525. /**
  17526. * Clear the current material and set it to a default state for post process
  17527. */
  17528. setToDefaultPostProcess(): void;
  17529. /**
  17530. * Clear the current material and set it to a default state for procedural texture
  17531. */
  17532. setToDefaultProceduralTexture(): void;
  17533. /**
  17534. * Clear the current material and set it to a default state for particle
  17535. */
  17536. setToDefaultParticle(): void;
  17537. /**
  17538. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  17539. * @param url defines the url to load from
  17540. * @returns a promise that will fullfil when the material is fully loaded
  17541. */
  17542. loadAsync(url: string): Promise<void>;
  17543. private _gatherBlocks;
  17544. /**
  17545. * Generate a string containing the code declaration required to create an equivalent of this material
  17546. * @returns a string
  17547. */
  17548. generateCode(): string;
  17549. /**
  17550. * Serializes this material in a JSON representation
  17551. * @returns the serialized material object
  17552. */
  17553. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  17554. private _restoreConnections;
  17555. /**
  17556. * Clear the current graph and load a new one from a serialization object
  17557. * @param source defines the JSON representation of the material
  17558. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17559. * @param merge defines whether or not the source must be merged or replace the current content
  17560. */
  17561. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  17562. /**
  17563. * Makes a duplicate of the current material.
  17564. * @param name - name to use for the new material.
  17565. */
  17566. clone(name: string): NodeMaterial;
  17567. /**
  17568. * Creates a node material from parsed material data
  17569. * @param source defines the JSON representation of the material
  17570. * @param scene defines the hosting scene
  17571. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17572. * @returns a new node material
  17573. */
  17574. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  17575. /**
  17576. * Creates a node material from a snippet saved in a remote file
  17577. * @param name defines the name of the material to create
  17578. * @param url defines the url to load from
  17579. * @param scene defines the hosting scene
  17580. * @returns a promise that will resolve to the new node material
  17581. */
  17582. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  17583. /**
  17584. * Creates a node material from a snippet saved by the node material editor
  17585. * @param snippetId defines the snippet to load
  17586. * @param scene defines the hosting scene
  17587. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17588. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  17589. * @returns a promise that will resolve to the new node material
  17590. */
  17591. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  17592. /**
  17593. * Creates a new node material set to default basic configuration
  17594. * @param name defines the name of the material
  17595. * @param scene defines the hosting scene
  17596. * @returns a new NodeMaterial
  17597. */
  17598. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  17599. }
  17600. }
  17601. declare module BABYLON {
  17602. interface ThinEngine {
  17603. /**
  17604. * Unbind a list of render target textures from the webGL context
  17605. * This is used only when drawBuffer extension or webGL2 are active
  17606. * @param textures defines the render target textures to unbind
  17607. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  17608. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  17609. */
  17610. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  17611. /**
  17612. * Create a multi render target texture
  17613. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  17614. * @param size defines the size of the texture
  17615. * @param options defines the creation options
  17616. * @returns the cube texture as an InternalTexture
  17617. */
  17618. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  17619. /**
  17620. * Update the sample count for a given multiple render target texture
  17621. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  17622. * @param textures defines the textures to update
  17623. * @param samples defines the sample count to set
  17624. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  17625. */
  17626. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  17627. /**
  17628. * Select a subsets of attachments to draw to.
  17629. * @param attachments gl attachments
  17630. */
  17631. bindAttachments(attachments: number[]): void;
  17632. /**
  17633. * Creates a layout object to draw/clear on specific textures in a MRT
  17634. * @param textureStatus textureStatus[i] indicates if the i-th is active
  17635. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  17636. */
  17637. buildTextureLayout(textureStatus: boolean[]): number[];
  17638. /**
  17639. * Restores the webgl state to only draw on the main color attachment
  17640. */
  17641. restoreSingleAttachment(): void;
  17642. }
  17643. }
  17644. declare module BABYLON {
  17645. /**
  17646. * Creation options of the multi render target texture.
  17647. */
  17648. export interface IMultiRenderTargetOptions {
  17649. /**
  17650. * Define if the texture needs to create mip maps after render.
  17651. */
  17652. generateMipMaps?: boolean;
  17653. /**
  17654. * Define the types of all the draw buffers we want to create
  17655. */
  17656. types?: number[];
  17657. /**
  17658. * Define the sampling modes of all the draw buffers we want to create
  17659. */
  17660. samplingModes?: number[];
  17661. /**
  17662. * Define if a depth buffer is required
  17663. */
  17664. generateDepthBuffer?: boolean;
  17665. /**
  17666. * Define if a stencil buffer is required
  17667. */
  17668. generateStencilBuffer?: boolean;
  17669. /**
  17670. * Define if a depth texture is required instead of a depth buffer
  17671. */
  17672. generateDepthTexture?: boolean;
  17673. /**
  17674. * Define the number of desired draw buffers
  17675. */
  17676. textureCount?: number;
  17677. /**
  17678. * Define if aspect ratio should be adapted to the texture or stay the scene one
  17679. */
  17680. doNotChangeAspectRatio?: boolean;
  17681. /**
  17682. * Define the default type of the buffers we are creating
  17683. */
  17684. defaultType?: number;
  17685. }
  17686. /**
  17687. * A multi render target, like a render target provides the ability to render to a texture.
  17688. * Unlike the render target, it can render to several draw buffers in one draw.
  17689. * This is specially interesting in deferred rendering or for any effects requiring more than
  17690. * just one color from a single pass.
  17691. */
  17692. export class MultiRenderTarget extends RenderTargetTexture {
  17693. private _internalTextures;
  17694. private _textures;
  17695. private _multiRenderTargetOptions;
  17696. private _count;
  17697. /**
  17698. * Get if draw buffers are currently supported by the used hardware and browser.
  17699. */
  17700. get isSupported(): boolean;
  17701. /**
  17702. * Get the list of textures generated by the multi render target.
  17703. */
  17704. get textures(): Texture[];
  17705. /**
  17706. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  17707. */
  17708. get count(): number;
  17709. /**
  17710. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  17711. */
  17712. get depthTexture(): Texture;
  17713. /**
  17714. * Set the wrapping mode on U of all the textures we are rendering to.
  17715. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  17716. */
  17717. set wrapU(wrap: number);
  17718. /**
  17719. * Set the wrapping mode on V of all the textures we are rendering to.
  17720. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  17721. */
  17722. set wrapV(wrap: number);
  17723. /**
  17724. * Instantiate a new multi render target texture.
  17725. * A multi render target, like a render target provides the ability to render to a texture.
  17726. * Unlike the render target, it can render to several draw buffers in one draw.
  17727. * This is specially interesting in deferred rendering or for any effects requiring more than
  17728. * just one color from a single pass.
  17729. * @param name Define the name of the texture
  17730. * @param size Define the size of the buffers to render to
  17731. * @param count Define the number of target we are rendering into
  17732. * @param scene Define the scene the texture belongs to
  17733. * @param options Define the options used to create the multi render target
  17734. */
  17735. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  17736. private _initTypes;
  17737. /** @hidden */
  17738. _rebuild(forceFullRebuild?: boolean): void;
  17739. private _createInternalTextures;
  17740. private _createTextures;
  17741. /**
  17742. * Replaces a texture within the MRT.
  17743. * @param texture The new texture to insert in the MRT
  17744. * @param index The index of the texture to replace
  17745. */
  17746. replaceTexture(texture: Texture, index: number): void;
  17747. /**
  17748. * Define the number of samples used if MSAA is enabled.
  17749. */
  17750. get samples(): number;
  17751. set samples(value: number);
  17752. /**
  17753. * Resize all the textures in the multi render target.
  17754. * Be careful as it will recreate all the data in the new texture.
  17755. * @param size Define the new size
  17756. */
  17757. resize(size: any): void;
  17758. /**
  17759. * Changes the number of render targets in this MRT
  17760. * Be careful as it will recreate all the data in the new texture.
  17761. * @param count new texture count
  17762. * @param options Specifies texture types and sampling modes for new textures
  17763. */
  17764. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  17765. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17766. /**
  17767. * Dispose the render targets and their associated resources
  17768. */
  17769. dispose(): void;
  17770. /**
  17771. * Release all the underlying texture used as draw buffers.
  17772. */
  17773. releaseInternalTextures(): void;
  17774. }
  17775. }
  17776. declare module BABYLON {
  17777. /** @hidden */
  17778. export var imageProcessingPixelShader: {
  17779. name: string;
  17780. shader: string;
  17781. };
  17782. }
  17783. declare module BABYLON {
  17784. /**
  17785. * ImageProcessingPostProcess
  17786. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  17787. */
  17788. export class ImageProcessingPostProcess extends PostProcess {
  17789. /**
  17790. * Default configuration related to image processing available in the PBR Material.
  17791. */
  17792. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17793. /**
  17794. * Gets the image processing configuration used either in this material.
  17795. */
  17796. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17797. /**
  17798. * Sets the Default image processing configuration used either in the this material.
  17799. *
  17800. * If sets to null, the scene one is in use.
  17801. */
  17802. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17803. /**
  17804. * Keep track of the image processing observer to allow dispose and replace.
  17805. */
  17806. private _imageProcessingObserver;
  17807. /**
  17808. * Attaches a new image processing configuration to the PBR Material.
  17809. * @param configuration
  17810. */
  17811. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  17812. /**
  17813. * If the post process is supported.
  17814. */
  17815. get isSupported(): boolean;
  17816. /**
  17817. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  17818. */
  17819. get colorCurves(): Nullable<ColorCurves>;
  17820. /**
  17821. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  17822. */
  17823. set colorCurves(value: Nullable<ColorCurves>);
  17824. /**
  17825. * Gets wether the color curves effect is enabled.
  17826. */
  17827. get colorCurvesEnabled(): boolean;
  17828. /**
  17829. * Sets wether the color curves effect is enabled.
  17830. */
  17831. set colorCurvesEnabled(value: boolean);
  17832. /**
  17833. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  17834. */
  17835. get colorGradingTexture(): Nullable<BaseTexture>;
  17836. /**
  17837. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  17838. */
  17839. set colorGradingTexture(value: Nullable<BaseTexture>);
  17840. /**
  17841. * Gets wether the color grading effect is enabled.
  17842. */
  17843. get colorGradingEnabled(): boolean;
  17844. /**
  17845. * Gets wether the color grading effect is enabled.
  17846. */
  17847. set colorGradingEnabled(value: boolean);
  17848. /**
  17849. * Gets exposure used in the effect.
  17850. */
  17851. get exposure(): number;
  17852. /**
  17853. * Sets exposure used in the effect.
  17854. */
  17855. set exposure(value: number);
  17856. /**
  17857. * Gets wether tonemapping is enabled or not.
  17858. */
  17859. get toneMappingEnabled(): boolean;
  17860. /**
  17861. * Sets wether tonemapping is enabled or not
  17862. */
  17863. set toneMappingEnabled(value: boolean);
  17864. /**
  17865. * Gets the type of tone mapping effect.
  17866. */
  17867. get toneMappingType(): number;
  17868. /**
  17869. * Sets the type of tone mapping effect.
  17870. */
  17871. set toneMappingType(value: number);
  17872. /**
  17873. * Gets contrast used in the effect.
  17874. */
  17875. get contrast(): number;
  17876. /**
  17877. * Sets contrast used in the effect.
  17878. */
  17879. set contrast(value: number);
  17880. /**
  17881. * Gets Vignette stretch size.
  17882. */
  17883. get vignetteStretch(): number;
  17884. /**
  17885. * Sets Vignette stretch size.
  17886. */
  17887. set vignetteStretch(value: number);
  17888. /**
  17889. * Gets Vignette centre X Offset.
  17890. */
  17891. get vignetteCentreX(): number;
  17892. /**
  17893. * Sets Vignette centre X Offset.
  17894. */
  17895. set vignetteCentreX(value: number);
  17896. /**
  17897. * Gets Vignette centre Y Offset.
  17898. */
  17899. get vignetteCentreY(): number;
  17900. /**
  17901. * Sets Vignette centre Y Offset.
  17902. */
  17903. set vignetteCentreY(value: number);
  17904. /**
  17905. * Gets Vignette weight or intensity of the vignette effect.
  17906. */
  17907. get vignetteWeight(): number;
  17908. /**
  17909. * Sets Vignette weight or intensity of the vignette effect.
  17910. */
  17911. set vignetteWeight(value: number);
  17912. /**
  17913. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  17914. * if vignetteEnabled is set to true.
  17915. */
  17916. get vignetteColor(): Color4;
  17917. /**
  17918. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  17919. * if vignetteEnabled is set to true.
  17920. */
  17921. set vignetteColor(value: Color4);
  17922. /**
  17923. * Gets Camera field of view used by the Vignette effect.
  17924. */
  17925. get vignetteCameraFov(): number;
  17926. /**
  17927. * Sets Camera field of view used by the Vignette effect.
  17928. */
  17929. set vignetteCameraFov(value: number);
  17930. /**
  17931. * Gets the vignette blend mode allowing different kind of effect.
  17932. */
  17933. get vignetteBlendMode(): number;
  17934. /**
  17935. * Sets the vignette blend mode allowing different kind of effect.
  17936. */
  17937. set vignetteBlendMode(value: number);
  17938. /**
  17939. * Gets wether the vignette effect is enabled.
  17940. */
  17941. get vignetteEnabled(): boolean;
  17942. /**
  17943. * Sets wether the vignette effect is enabled.
  17944. */
  17945. set vignetteEnabled(value: boolean);
  17946. private _fromLinearSpace;
  17947. /**
  17948. * Gets wether the input of the processing is in Gamma or Linear Space.
  17949. */
  17950. get fromLinearSpace(): boolean;
  17951. /**
  17952. * Sets wether the input of the processing is in Gamma or Linear Space.
  17953. */
  17954. set fromLinearSpace(value: boolean);
  17955. /**
  17956. * Defines cache preventing GC.
  17957. */
  17958. private _defines;
  17959. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  17960. /**
  17961. * "ImageProcessingPostProcess"
  17962. * @returns "ImageProcessingPostProcess"
  17963. */
  17964. getClassName(): string;
  17965. /**
  17966. * @hidden
  17967. */
  17968. _updateParameters(): void;
  17969. dispose(camera?: Camera): void;
  17970. }
  17971. }
  17972. declare module BABYLON {
  17973. /**
  17974. * Interface for defining prepass effects in the prepass post-process pipeline
  17975. */
  17976. export interface PrePassEffectConfiguration {
  17977. /**
  17978. * Name of the effect
  17979. */
  17980. name: string;
  17981. /**
  17982. * Post process to attach for this effect
  17983. */
  17984. postProcess?: PostProcess;
  17985. /**
  17986. * Textures required in the MRT
  17987. */
  17988. texturesRequired: number[];
  17989. /**
  17990. * Is the effect enabled
  17991. */
  17992. enabled: boolean;
  17993. /**
  17994. * Disposes the effect configuration
  17995. */
  17996. dispose?: () => void;
  17997. /**
  17998. * Creates the associated post process
  17999. */
  18000. createPostProcess?: () => PostProcess;
  18001. }
  18002. }
  18003. declare module BABYLON {
  18004. /**
  18005. * Options to be used when creating a FresnelParameters.
  18006. */
  18007. export type IFresnelParametersCreationOptions = {
  18008. /**
  18009. * Define the color used on edges (grazing angle)
  18010. */
  18011. leftColor?: Color3;
  18012. /**
  18013. * Define the color used on center
  18014. */
  18015. rightColor?: Color3;
  18016. /**
  18017. * Define bias applied to computed fresnel term
  18018. */
  18019. bias?: number;
  18020. /**
  18021. * Defined the power exponent applied to fresnel term
  18022. */
  18023. power?: number;
  18024. /**
  18025. * Define if the fresnel effect is enable or not.
  18026. */
  18027. isEnabled?: boolean;
  18028. };
  18029. /**
  18030. * Serialized format for FresnelParameters.
  18031. */
  18032. export type IFresnelParametersSerialized = {
  18033. /**
  18034. * Define the color used on edges (grazing angle) [as an array]
  18035. */
  18036. leftColor: number[];
  18037. /**
  18038. * Define the color used on center [as an array]
  18039. */
  18040. rightColor: number[];
  18041. /**
  18042. * Define bias applied to computed fresnel term
  18043. */
  18044. bias: number;
  18045. /**
  18046. * Defined the power exponent applied to fresnel term
  18047. */
  18048. power?: number;
  18049. /**
  18050. * Define if the fresnel effect is enable or not.
  18051. */
  18052. isEnabled: boolean;
  18053. };
  18054. /**
  18055. * This represents all the required information to add a fresnel effect on a material:
  18056. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18057. */
  18058. export class FresnelParameters {
  18059. private _isEnabled;
  18060. /**
  18061. * Define if the fresnel effect is enable or not.
  18062. */
  18063. get isEnabled(): boolean;
  18064. set isEnabled(value: boolean);
  18065. /**
  18066. * Define the color used on edges (grazing angle)
  18067. */
  18068. leftColor: Color3;
  18069. /**
  18070. * Define the color used on center
  18071. */
  18072. rightColor: Color3;
  18073. /**
  18074. * Define bias applied to computed fresnel term
  18075. */
  18076. bias: number;
  18077. /**
  18078. * Defined the power exponent applied to fresnel term
  18079. */
  18080. power: number;
  18081. /**
  18082. * Creates a new FresnelParameters object.
  18083. *
  18084. * @param options provide your own settings to optionally to override defaults
  18085. */
  18086. constructor(options?: IFresnelParametersCreationOptions);
  18087. /**
  18088. * Clones the current fresnel and its valuues
  18089. * @returns a clone fresnel configuration
  18090. */
  18091. clone(): FresnelParameters;
  18092. /**
  18093. * Determines equality between FresnelParameters objects
  18094. * @param otherFresnelParameters defines the second operand
  18095. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  18096. */
  18097. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  18098. /**
  18099. * Serializes the current fresnel parameters to a JSON representation.
  18100. * @return the JSON serialization
  18101. */
  18102. serialize(): IFresnelParametersSerialized;
  18103. /**
  18104. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  18105. * @param parsedFresnelParameters Define the JSON representation
  18106. * @returns the parsed parameters
  18107. */
  18108. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  18109. }
  18110. }
  18111. declare module BABYLON {
  18112. /**
  18113. * This groups all the flags used to control the materials channel.
  18114. */
  18115. export class MaterialFlags {
  18116. private static _DiffuseTextureEnabled;
  18117. /**
  18118. * Are diffuse textures enabled in the application.
  18119. */
  18120. static get DiffuseTextureEnabled(): boolean;
  18121. static set DiffuseTextureEnabled(value: boolean);
  18122. private static _DetailTextureEnabled;
  18123. /**
  18124. * Are detail textures enabled in the application.
  18125. */
  18126. static get DetailTextureEnabled(): boolean;
  18127. static set DetailTextureEnabled(value: boolean);
  18128. private static _AmbientTextureEnabled;
  18129. /**
  18130. * Are ambient textures enabled in the application.
  18131. */
  18132. static get AmbientTextureEnabled(): boolean;
  18133. static set AmbientTextureEnabled(value: boolean);
  18134. private static _OpacityTextureEnabled;
  18135. /**
  18136. * Are opacity textures enabled in the application.
  18137. */
  18138. static get OpacityTextureEnabled(): boolean;
  18139. static set OpacityTextureEnabled(value: boolean);
  18140. private static _ReflectionTextureEnabled;
  18141. /**
  18142. * Are reflection textures enabled in the application.
  18143. */
  18144. static get ReflectionTextureEnabled(): boolean;
  18145. static set ReflectionTextureEnabled(value: boolean);
  18146. private static _EmissiveTextureEnabled;
  18147. /**
  18148. * Are emissive textures enabled in the application.
  18149. */
  18150. static get EmissiveTextureEnabled(): boolean;
  18151. static set EmissiveTextureEnabled(value: boolean);
  18152. private static _SpecularTextureEnabled;
  18153. /**
  18154. * Are specular textures enabled in the application.
  18155. */
  18156. static get SpecularTextureEnabled(): boolean;
  18157. static set SpecularTextureEnabled(value: boolean);
  18158. private static _BumpTextureEnabled;
  18159. /**
  18160. * Are bump textures enabled in the application.
  18161. */
  18162. static get BumpTextureEnabled(): boolean;
  18163. static set BumpTextureEnabled(value: boolean);
  18164. private static _LightmapTextureEnabled;
  18165. /**
  18166. * Are lightmap textures enabled in the application.
  18167. */
  18168. static get LightmapTextureEnabled(): boolean;
  18169. static set LightmapTextureEnabled(value: boolean);
  18170. private static _RefractionTextureEnabled;
  18171. /**
  18172. * Are refraction textures enabled in the application.
  18173. */
  18174. static get RefractionTextureEnabled(): boolean;
  18175. static set RefractionTextureEnabled(value: boolean);
  18176. private static _ColorGradingTextureEnabled;
  18177. /**
  18178. * Are color grading textures enabled in the application.
  18179. */
  18180. static get ColorGradingTextureEnabled(): boolean;
  18181. static set ColorGradingTextureEnabled(value: boolean);
  18182. private static _FresnelEnabled;
  18183. /**
  18184. * Are fresnels enabled in the application.
  18185. */
  18186. static get FresnelEnabled(): boolean;
  18187. static set FresnelEnabled(value: boolean);
  18188. private static _ClearCoatTextureEnabled;
  18189. /**
  18190. * Are clear coat textures enabled in the application.
  18191. */
  18192. static get ClearCoatTextureEnabled(): boolean;
  18193. static set ClearCoatTextureEnabled(value: boolean);
  18194. private static _ClearCoatBumpTextureEnabled;
  18195. /**
  18196. * Are clear coat bump textures enabled in the application.
  18197. */
  18198. static get ClearCoatBumpTextureEnabled(): boolean;
  18199. static set ClearCoatBumpTextureEnabled(value: boolean);
  18200. private static _ClearCoatTintTextureEnabled;
  18201. /**
  18202. * Are clear coat tint textures enabled in the application.
  18203. */
  18204. static get ClearCoatTintTextureEnabled(): boolean;
  18205. static set ClearCoatTintTextureEnabled(value: boolean);
  18206. private static _SheenTextureEnabled;
  18207. /**
  18208. * Are sheen textures enabled in the application.
  18209. */
  18210. static get SheenTextureEnabled(): boolean;
  18211. static set SheenTextureEnabled(value: boolean);
  18212. private static _AnisotropicTextureEnabled;
  18213. /**
  18214. * Are anisotropic textures enabled in the application.
  18215. */
  18216. static get AnisotropicTextureEnabled(): boolean;
  18217. static set AnisotropicTextureEnabled(value: boolean);
  18218. private static _ThicknessTextureEnabled;
  18219. /**
  18220. * Are thickness textures enabled in the application.
  18221. */
  18222. static get ThicknessTextureEnabled(): boolean;
  18223. static set ThicknessTextureEnabled(value: boolean);
  18224. }
  18225. }
  18226. declare module BABYLON {
  18227. /** @hidden */
  18228. export var defaultFragmentDeclaration: {
  18229. name: string;
  18230. shader: string;
  18231. };
  18232. }
  18233. declare module BABYLON {
  18234. /** @hidden */
  18235. export var defaultUboDeclaration: {
  18236. name: string;
  18237. shader: string;
  18238. };
  18239. }
  18240. declare module BABYLON {
  18241. /** @hidden */
  18242. export var prePassDeclaration: {
  18243. name: string;
  18244. shader: string;
  18245. };
  18246. }
  18247. declare module BABYLON {
  18248. /** @hidden */
  18249. export var lightFragmentDeclaration: {
  18250. name: string;
  18251. shader: string;
  18252. };
  18253. }
  18254. declare module BABYLON {
  18255. /** @hidden */
  18256. export var lightUboDeclaration: {
  18257. name: string;
  18258. shader: string;
  18259. };
  18260. }
  18261. declare module BABYLON {
  18262. /** @hidden */
  18263. export var lightsFragmentFunctions: {
  18264. name: string;
  18265. shader: string;
  18266. };
  18267. }
  18268. declare module BABYLON {
  18269. /** @hidden */
  18270. export var shadowsFragmentFunctions: {
  18271. name: string;
  18272. shader: string;
  18273. };
  18274. }
  18275. declare module BABYLON {
  18276. /** @hidden */
  18277. export var fresnelFunction: {
  18278. name: string;
  18279. shader: string;
  18280. };
  18281. }
  18282. declare module BABYLON {
  18283. /** @hidden */
  18284. export var bumpFragmentMainFunctions: {
  18285. name: string;
  18286. shader: string;
  18287. };
  18288. }
  18289. declare module BABYLON {
  18290. /** @hidden */
  18291. export var bumpFragmentFunctions: {
  18292. name: string;
  18293. shader: string;
  18294. };
  18295. }
  18296. declare module BABYLON {
  18297. /** @hidden */
  18298. export var logDepthDeclaration: {
  18299. name: string;
  18300. shader: string;
  18301. };
  18302. }
  18303. declare module BABYLON {
  18304. /** @hidden */
  18305. export var fogFragmentDeclaration: {
  18306. name: string;
  18307. shader: string;
  18308. };
  18309. }
  18310. declare module BABYLON {
  18311. /** @hidden */
  18312. export var bumpFragment: {
  18313. name: string;
  18314. shader: string;
  18315. };
  18316. }
  18317. declare module BABYLON {
  18318. /** @hidden */
  18319. export var depthPrePass: {
  18320. name: string;
  18321. shader: string;
  18322. };
  18323. }
  18324. declare module BABYLON {
  18325. /** @hidden */
  18326. export var lightFragment: {
  18327. name: string;
  18328. shader: string;
  18329. };
  18330. }
  18331. declare module BABYLON {
  18332. /** @hidden */
  18333. export var logDepthFragment: {
  18334. name: string;
  18335. shader: string;
  18336. };
  18337. }
  18338. declare module BABYLON {
  18339. /** @hidden */
  18340. export var fogFragment: {
  18341. name: string;
  18342. shader: string;
  18343. };
  18344. }
  18345. declare module BABYLON {
  18346. /** @hidden */
  18347. export var defaultPixelShader: {
  18348. name: string;
  18349. shader: string;
  18350. };
  18351. }
  18352. declare module BABYLON {
  18353. /** @hidden */
  18354. export var defaultVertexDeclaration: {
  18355. name: string;
  18356. shader: string;
  18357. };
  18358. }
  18359. declare module BABYLON {
  18360. /** @hidden */
  18361. export var bonesDeclaration: {
  18362. name: string;
  18363. shader: string;
  18364. };
  18365. }
  18366. declare module BABYLON {
  18367. /** @hidden */
  18368. export var instancesDeclaration: {
  18369. name: string;
  18370. shader: string;
  18371. };
  18372. }
  18373. declare module BABYLON {
  18374. /** @hidden */
  18375. export var prePassVertexDeclaration: {
  18376. name: string;
  18377. shader: string;
  18378. };
  18379. }
  18380. declare module BABYLON {
  18381. /** @hidden */
  18382. export var bumpVertexDeclaration: {
  18383. name: string;
  18384. shader: string;
  18385. };
  18386. }
  18387. declare module BABYLON {
  18388. /** @hidden */
  18389. export var fogVertexDeclaration: {
  18390. name: string;
  18391. shader: string;
  18392. };
  18393. }
  18394. declare module BABYLON {
  18395. /** @hidden */
  18396. export var morphTargetsVertexGlobalDeclaration: {
  18397. name: string;
  18398. shader: string;
  18399. };
  18400. }
  18401. declare module BABYLON {
  18402. /** @hidden */
  18403. export var morphTargetsVertexDeclaration: {
  18404. name: string;
  18405. shader: string;
  18406. };
  18407. }
  18408. declare module BABYLON {
  18409. /** @hidden */
  18410. export var morphTargetsVertex: {
  18411. name: string;
  18412. shader: string;
  18413. };
  18414. }
  18415. declare module BABYLON {
  18416. /** @hidden */
  18417. export var instancesVertex: {
  18418. name: string;
  18419. shader: string;
  18420. };
  18421. }
  18422. declare module BABYLON {
  18423. /** @hidden */
  18424. export var bonesVertex: {
  18425. name: string;
  18426. shader: string;
  18427. };
  18428. }
  18429. declare module BABYLON {
  18430. /** @hidden */
  18431. export var prePassVertex: {
  18432. name: string;
  18433. shader: string;
  18434. };
  18435. }
  18436. declare module BABYLON {
  18437. /** @hidden */
  18438. export var bumpVertex: {
  18439. name: string;
  18440. shader: string;
  18441. };
  18442. }
  18443. declare module BABYLON {
  18444. /** @hidden */
  18445. export var fogVertex: {
  18446. name: string;
  18447. shader: string;
  18448. };
  18449. }
  18450. declare module BABYLON {
  18451. /** @hidden */
  18452. export var shadowsVertex: {
  18453. name: string;
  18454. shader: string;
  18455. };
  18456. }
  18457. declare module BABYLON {
  18458. /** @hidden */
  18459. export var pointCloudVertex: {
  18460. name: string;
  18461. shader: string;
  18462. };
  18463. }
  18464. declare module BABYLON {
  18465. /** @hidden */
  18466. export var logDepthVertex: {
  18467. name: string;
  18468. shader: string;
  18469. };
  18470. }
  18471. declare module BABYLON {
  18472. /** @hidden */
  18473. export var defaultVertexShader: {
  18474. name: string;
  18475. shader: string;
  18476. };
  18477. }
  18478. declare module BABYLON {
  18479. /**
  18480. * @hidden
  18481. */
  18482. export interface IMaterialDetailMapDefines {
  18483. DETAIL: boolean;
  18484. DETAILDIRECTUV: number;
  18485. DETAIL_NORMALBLENDMETHOD: number;
  18486. /** @hidden */
  18487. _areTexturesDirty: boolean;
  18488. }
  18489. /**
  18490. * Define the code related to the detail map parameters of a material
  18491. *
  18492. * Inspired from:
  18493. * Unity: https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@9.0/manual/Mask-Map-and-Detail-Map.html and https://docs.unity3d.com/Manual/StandardShaderMaterialParameterDetail.html
  18494. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  18495. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  18496. */
  18497. export class DetailMapConfiguration {
  18498. private _texture;
  18499. /**
  18500. * The detail texture of the material.
  18501. */
  18502. texture: Nullable<BaseTexture>;
  18503. /**
  18504. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  18505. * Bigger values mean stronger blending
  18506. */
  18507. diffuseBlendLevel: number;
  18508. /**
  18509. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  18510. * Bigger values mean stronger blending. Only used with PBR materials
  18511. */
  18512. roughnessBlendLevel: number;
  18513. /**
  18514. * Defines how strong the bump effect from the detail map is
  18515. * Bigger values mean stronger effect
  18516. */
  18517. bumpLevel: number;
  18518. private _normalBlendMethod;
  18519. /**
  18520. * The method used to blend the bump and detail normals together
  18521. */
  18522. normalBlendMethod: number;
  18523. private _isEnabled;
  18524. /**
  18525. * Enable or disable the detail map on this material
  18526. */
  18527. isEnabled: boolean;
  18528. /** @hidden */
  18529. private _internalMarkAllSubMeshesAsTexturesDirty;
  18530. /** @hidden */
  18531. _markAllSubMeshesAsTexturesDirty(): void;
  18532. /**
  18533. * Instantiate a new detail map
  18534. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  18535. */
  18536. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  18537. /**
  18538. * Gets whether the submesh is ready to be used or not.
  18539. * @param defines the list of "defines" to update.
  18540. * @param scene defines the scene the material belongs to.
  18541. * @returns - boolean indicating that the submesh is ready or not.
  18542. */
  18543. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  18544. /**
  18545. * Update the defines for detail map usage
  18546. * @param defines the list of "defines" to update.
  18547. * @param scene defines the scene the material belongs to.
  18548. */
  18549. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  18550. /**
  18551. * Binds the material data.
  18552. * @param uniformBuffer defines the Uniform buffer to fill in.
  18553. * @param scene defines the scene the material belongs to.
  18554. * @param isFrozen defines whether the material is frozen or not.
  18555. */
  18556. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  18557. /**
  18558. * Checks to see if a texture is used in the material.
  18559. * @param texture - Base texture to use.
  18560. * @returns - Boolean specifying if a texture is used in the material.
  18561. */
  18562. hasTexture(texture: BaseTexture): boolean;
  18563. /**
  18564. * Returns an array of the actively used textures.
  18565. * @param activeTextures Array of BaseTextures
  18566. */
  18567. getActiveTextures(activeTextures: BaseTexture[]): void;
  18568. /**
  18569. * Returns the animatable textures.
  18570. * @param animatables Array of animatable textures.
  18571. */
  18572. getAnimatables(animatables: IAnimatable[]): void;
  18573. /**
  18574. * Disposes the resources of the material.
  18575. * @param forceDisposeTextures - Forces the disposal of all textures.
  18576. */
  18577. dispose(forceDisposeTextures?: boolean): void;
  18578. /**
  18579. * Get the current class name useful for serialization or dynamic coding.
  18580. * @returns "DetailMap"
  18581. */
  18582. getClassName(): string;
  18583. /**
  18584. * Add the required uniforms to the current list.
  18585. * @param uniforms defines the current uniform list.
  18586. */
  18587. static AddUniforms(uniforms: string[]): void;
  18588. /**
  18589. * Add the required samplers to the current list.
  18590. * @param samplers defines the current sampler list.
  18591. */
  18592. static AddSamplers(samplers: string[]): void;
  18593. /**
  18594. * Add the required uniforms to the current buffer.
  18595. * @param uniformBuffer defines the current uniform buffer.
  18596. */
  18597. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  18598. /**
  18599. * Makes a duplicate of the current instance into another one.
  18600. * @param detailMap define the instance where to copy the info
  18601. */
  18602. copyTo(detailMap: DetailMapConfiguration): void;
  18603. /**
  18604. * Serializes this detail map instance
  18605. * @returns - An object with the serialized instance.
  18606. */
  18607. serialize(): any;
  18608. /**
  18609. * Parses a detail map setting from a serialized object.
  18610. * @param source - Serialized object.
  18611. * @param scene Defines the scene we are parsing for
  18612. * @param rootUrl Defines the rootUrl to load from
  18613. */
  18614. parse(source: any, scene: Scene, rootUrl: string): void;
  18615. }
  18616. }
  18617. declare module BABYLON {
  18618. /** @hidden */
  18619. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  18620. MAINUV1: boolean;
  18621. MAINUV2: boolean;
  18622. DIFFUSE: boolean;
  18623. DIFFUSEDIRECTUV: number;
  18624. DETAIL: boolean;
  18625. DETAILDIRECTUV: number;
  18626. DETAIL_NORMALBLENDMETHOD: number;
  18627. AMBIENT: boolean;
  18628. AMBIENTDIRECTUV: number;
  18629. OPACITY: boolean;
  18630. OPACITYDIRECTUV: number;
  18631. OPACITYRGB: boolean;
  18632. REFLECTION: boolean;
  18633. EMISSIVE: boolean;
  18634. EMISSIVEDIRECTUV: number;
  18635. SPECULAR: boolean;
  18636. SPECULARDIRECTUV: number;
  18637. BUMP: boolean;
  18638. BUMPDIRECTUV: number;
  18639. PARALLAX: boolean;
  18640. PARALLAXOCCLUSION: boolean;
  18641. SPECULAROVERALPHA: boolean;
  18642. CLIPPLANE: boolean;
  18643. CLIPPLANE2: boolean;
  18644. CLIPPLANE3: boolean;
  18645. CLIPPLANE4: boolean;
  18646. CLIPPLANE5: boolean;
  18647. CLIPPLANE6: boolean;
  18648. ALPHATEST: boolean;
  18649. DEPTHPREPASS: boolean;
  18650. ALPHAFROMDIFFUSE: boolean;
  18651. POINTSIZE: boolean;
  18652. FOG: boolean;
  18653. SPECULARTERM: boolean;
  18654. DIFFUSEFRESNEL: boolean;
  18655. OPACITYFRESNEL: boolean;
  18656. REFLECTIONFRESNEL: boolean;
  18657. REFRACTIONFRESNEL: boolean;
  18658. EMISSIVEFRESNEL: boolean;
  18659. FRESNEL: boolean;
  18660. NORMAL: boolean;
  18661. UV1: boolean;
  18662. UV2: boolean;
  18663. VERTEXCOLOR: boolean;
  18664. VERTEXALPHA: boolean;
  18665. NUM_BONE_INFLUENCERS: number;
  18666. BonesPerMesh: number;
  18667. BONETEXTURE: boolean;
  18668. BONES_VELOCITY_ENABLED: boolean;
  18669. INSTANCES: boolean;
  18670. THIN_INSTANCES: boolean;
  18671. GLOSSINESS: boolean;
  18672. ROUGHNESS: boolean;
  18673. EMISSIVEASILLUMINATION: boolean;
  18674. LINKEMISSIVEWITHDIFFUSE: boolean;
  18675. REFLECTIONFRESNELFROMSPECULAR: boolean;
  18676. LIGHTMAP: boolean;
  18677. LIGHTMAPDIRECTUV: number;
  18678. OBJECTSPACE_NORMALMAP: boolean;
  18679. USELIGHTMAPASSHADOWMAP: boolean;
  18680. REFLECTIONMAP_3D: boolean;
  18681. REFLECTIONMAP_SPHERICAL: boolean;
  18682. REFLECTIONMAP_PLANAR: boolean;
  18683. REFLECTIONMAP_CUBIC: boolean;
  18684. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  18685. REFLECTIONMAP_PROJECTION: boolean;
  18686. REFLECTIONMAP_SKYBOX: boolean;
  18687. REFLECTIONMAP_EXPLICIT: boolean;
  18688. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  18689. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  18690. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  18691. INVERTCUBICMAP: boolean;
  18692. LOGARITHMICDEPTH: boolean;
  18693. REFRACTION: boolean;
  18694. REFRACTIONMAP_3D: boolean;
  18695. REFLECTIONOVERALPHA: boolean;
  18696. TWOSIDEDLIGHTING: boolean;
  18697. SHADOWFLOAT: boolean;
  18698. MORPHTARGETS: boolean;
  18699. MORPHTARGETS_NORMAL: boolean;
  18700. MORPHTARGETS_TANGENT: boolean;
  18701. MORPHTARGETS_UV: boolean;
  18702. NUM_MORPH_INFLUENCERS: number;
  18703. NONUNIFORMSCALING: boolean;
  18704. PREMULTIPLYALPHA: boolean;
  18705. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  18706. ALPHABLEND: boolean;
  18707. PREPASS: boolean;
  18708. PREPASS_IRRADIANCE: boolean;
  18709. PREPASS_IRRADIANCE_INDEX: number;
  18710. PREPASS_ALBEDO: boolean;
  18711. PREPASS_ALBEDO_INDEX: number;
  18712. PREPASS_DEPTHNORMAL: boolean;
  18713. PREPASS_DEPTHNORMAL_INDEX: number;
  18714. PREPASS_POSITION: boolean;
  18715. PREPASS_POSITION_INDEX: number;
  18716. PREPASS_VELOCITY: boolean;
  18717. PREPASS_VELOCITY_INDEX: number;
  18718. PREPASS_REFLECTIVITY: boolean;
  18719. PREPASS_REFLECTIVITY_INDEX: number;
  18720. SCENE_MRT_COUNT: number;
  18721. RGBDLIGHTMAP: boolean;
  18722. RGBDREFLECTION: boolean;
  18723. RGBDREFRACTION: boolean;
  18724. IMAGEPROCESSING: boolean;
  18725. VIGNETTE: boolean;
  18726. VIGNETTEBLENDMODEMULTIPLY: boolean;
  18727. VIGNETTEBLENDMODEOPAQUE: boolean;
  18728. TONEMAPPING: boolean;
  18729. TONEMAPPING_ACES: boolean;
  18730. CONTRAST: boolean;
  18731. COLORCURVES: boolean;
  18732. COLORGRADING: boolean;
  18733. COLORGRADING3D: boolean;
  18734. SAMPLER3DGREENDEPTH: boolean;
  18735. SAMPLER3DBGRMAP: boolean;
  18736. IMAGEPROCESSINGPOSTPROCESS: boolean;
  18737. MULTIVIEW: boolean;
  18738. /**
  18739. * If the reflection texture on this material is in linear color space
  18740. * @hidden
  18741. */
  18742. IS_REFLECTION_LINEAR: boolean;
  18743. /**
  18744. * If the refraction texture on this material is in linear color space
  18745. * @hidden
  18746. */
  18747. IS_REFRACTION_LINEAR: boolean;
  18748. EXPOSURE: boolean;
  18749. constructor();
  18750. setReflectionMode(modeToEnable: string): void;
  18751. }
  18752. /**
  18753. * This is the default material used in Babylon. It is the best trade off between quality
  18754. * and performances.
  18755. * @see https://doc.babylonjs.com/babylon101/materials
  18756. */
  18757. export class StandardMaterial extends PushMaterial {
  18758. private _diffuseTexture;
  18759. /**
  18760. * The basic texture of the material as viewed under a light.
  18761. */
  18762. diffuseTexture: Nullable<BaseTexture>;
  18763. private _ambientTexture;
  18764. /**
  18765. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  18766. */
  18767. ambientTexture: Nullable<BaseTexture>;
  18768. private _opacityTexture;
  18769. /**
  18770. * Define the transparency of the material from a texture.
  18771. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  18772. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  18773. */
  18774. opacityTexture: Nullable<BaseTexture>;
  18775. private _reflectionTexture;
  18776. /**
  18777. * Define the texture used to display the reflection.
  18778. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18779. */
  18780. reflectionTexture: Nullable<BaseTexture>;
  18781. private _emissiveTexture;
  18782. /**
  18783. * Define texture of the material as if self lit.
  18784. * This will be mixed in the final result even in the absence of light.
  18785. */
  18786. emissiveTexture: Nullable<BaseTexture>;
  18787. private _specularTexture;
  18788. /**
  18789. * Define how the color and intensity of the highlight given by the light in the material.
  18790. */
  18791. specularTexture: Nullable<BaseTexture>;
  18792. private _bumpTexture;
  18793. /**
  18794. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  18795. * 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.
  18796. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  18797. */
  18798. bumpTexture: Nullable<BaseTexture>;
  18799. private _lightmapTexture;
  18800. /**
  18801. * Complex lighting can be computationally expensive to compute at runtime.
  18802. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  18803. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  18804. */
  18805. lightmapTexture: Nullable<BaseTexture>;
  18806. private _refractionTexture;
  18807. /**
  18808. * Define the texture used to display the refraction.
  18809. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18810. */
  18811. refractionTexture: Nullable<BaseTexture>;
  18812. /**
  18813. * The color of the material lit by the environmental background lighting.
  18814. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  18815. */
  18816. ambientColor: Color3;
  18817. /**
  18818. * The basic color of the material as viewed under a light.
  18819. */
  18820. diffuseColor: Color3;
  18821. /**
  18822. * Define how the color and intensity of the highlight given by the light in the material.
  18823. */
  18824. specularColor: Color3;
  18825. /**
  18826. * Define the color of the material as if self lit.
  18827. * This will be mixed in the final result even in the absence of light.
  18828. */
  18829. emissiveColor: Color3;
  18830. /**
  18831. * Defines how sharp are the highlights in the material.
  18832. * The bigger the value the sharper giving a more glossy feeling to the result.
  18833. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  18834. */
  18835. specularPower: number;
  18836. private _useAlphaFromDiffuseTexture;
  18837. /**
  18838. * Does the transparency come from the diffuse texture alpha channel.
  18839. */
  18840. useAlphaFromDiffuseTexture: boolean;
  18841. private _useEmissiveAsIllumination;
  18842. /**
  18843. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  18844. */
  18845. useEmissiveAsIllumination: boolean;
  18846. private _linkEmissiveWithDiffuse;
  18847. /**
  18848. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  18849. * the emissive level when the final color is close to one.
  18850. */
  18851. linkEmissiveWithDiffuse: boolean;
  18852. private _useSpecularOverAlpha;
  18853. /**
  18854. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  18855. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  18856. */
  18857. useSpecularOverAlpha: boolean;
  18858. private _useReflectionOverAlpha;
  18859. /**
  18860. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  18861. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  18862. */
  18863. useReflectionOverAlpha: boolean;
  18864. private _disableLighting;
  18865. /**
  18866. * Does lights from the scene impacts this material.
  18867. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  18868. */
  18869. disableLighting: boolean;
  18870. private _useObjectSpaceNormalMap;
  18871. /**
  18872. * Allows using an object space normal map (instead of tangent space).
  18873. */
  18874. useObjectSpaceNormalMap: boolean;
  18875. private _useParallax;
  18876. /**
  18877. * Is parallax enabled or not.
  18878. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  18879. */
  18880. useParallax: boolean;
  18881. private _useParallaxOcclusion;
  18882. /**
  18883. * Is parallax occlusion enabled or not.
  18884. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  18885. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  18886. */
  18887. useParallaxOcclusion: boolean;
  18888. /**
  18889. * 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.
  18890. */
  18891. parallaxScaleBias: number;
  18892. private _roughness;
  18893. /**
  18894. * Helps to define how blurry the reflections should appears in the material.
  18895. */
  18896. roughness: number;
  18897. /**
  18898. * In case of refraction, define the value of the index of refraction.
  18899. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18900. */
  18901. indexOfRefraction: number;
  18902. /**
  18903. * Invert the refraction texture alongside the y axis.
  18904. * It can be useful with procedural textures or probe for instance.
  18905. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18906. */
  18907. invertRefractionY: boolean;
  18908. /**
  18909. * Defines the alpha limits in alpha test mode.
  18910. */
  18911. alphaCutOff: number;
  18912. private _useLightmapAsShadowmap;
  18913. /**
  18914. * In case of light mapping, define whether the map contains light or shadow informations.
  18915. */
  18916. useLightmapAsShadowmap: boolean;
  18917. private _diffuseFresnelParameters;
  18918. /**
  18919. * Define the diffuse fresnel parameters of the material.
  18920. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18921. */
  18922. diffuseFresnelParameters: FresnelParameters;
  18923. private _opacityFresnelParameters;
  18924. /**
  18925. * Define the opacity fresnel parameters of the material.
  18926. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18927. */
  18928. opacityFresnelParameters: FresnelParameters;
  18929. private _reflectionFresnelParameters;
  18930. /**
  18931. * Define the reflection fresnel parameters of the material.
  18932. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18933. */
  18934. reflectionFresnelParameters: FresnelParameters;
  18935. private _refractionFresnelParameters;
  18936. /**
  18937. * Define the refraction fresnel parameters of the material.
  18938. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18939. */
  18940. refractionFresnelParameters: FresnelParameters;
  18941. private _emissiveFresnelParameters;
  18942. /**
  18943. * Define the emissive fresnel parameters of the material.
  18944. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18945. */
  18946. emissiveFresnelParameters: FresnelParameters;
  18947. private _useReflectionFresnelFromSpecular;
  18948. /**
  18949. * If true automatically deducts the fresnels values from the material specularity.
  18950. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18951. */
  18952. useReflectionFresnelFromSpecular: boolean;
  18953. private _useGlossinessFromSpecularMapAlpha;
  18954. /**
  18955. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  18956. */
  18957. useGlossinessFromSpecularMapAlpha: boolean;
  18958. private _maxSimultaneousLights;
  18959. /**
  18960. * Defines the maximum number of lights that can be used in the material
  18961. */
  18962. maxSimultaneousLights: number;
  18963. private _invertNormalMapX;
  18964. /**
  18965. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  18966. */
  18967. invertNormalMapX: boolean;
  18968. private _invertNormalMapY;
  18969. /**
  18970. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  18971. */
  18972. invertNormalMapY: boolean;
  18973. private _twoSidedLighting;
  18974. /**
  18975. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  18976. */
  18977. twoSidedLighting: boolean;
  18978. /**
  18979. * Default configuration related to image processing available in the standard Material.
  18980. */
  18981. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  18982. /**
  18983. * Gets the image processing configuration used either in this material.
  18984. */
  18985. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  18986. /**
  18987. * Sets the Default image processing configuration used either in the this material.
  18988. *
  18989. * If sets to null, the scene one is in use.
  18990. */
  18991. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  18992. /**
  18993. * Keep track of the image processing observer to allow dispose and replace.
  18994. */
  18995. private _imageProcessingObserver;
  18996. /**
  18997. * Attaches a new image processing configuration to the Standard Material.
  18998. * @param configuration
  18999. */
  19000. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19001. /**
  19002. * Defines additionnal PrePass parameters for the material.
  19003. */
  19004. readonly prePassConfiguration: PrePassConfiguration;
  19005. /**
  19006. * Gets wether the color curves effect is enabled.
  19007. */
  19008. get cameraColorCurvesEnabled(): boolean;
  19009. /**
  19010. * Sets wether the color curves effect is enabled.
  19011. */
  19012. set cameraColorCurvesEnabled(value: boolean);
  19013. /**
  19014. * Gets wether the color grading effect is enabled.
  19015. */
  19016. get cameraColorGradingEnabled(): boolean;
  19017. /**
  19018. * Gets wether the color grading effect is enabled.
  19019. */
  19020. set cameraColorGradingEnabled(value: boolean);
  19021. /**
  19022. * Gets wether tonemapping is enabled or not.
  19023. */
  19024. get cameraToneMappingEnabled(): boolean;
  19025. /**
  19026. * Sets wether tonemapping is enabled or not
  19027. */
  19028. set cameraToneMappingEnabled(value: boolean);
  19029. /**
  19030. * The camera exposure used on this material.
  19031. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19032. * This corresponds to a photographic exposure.
  19033. */
  19034. get cameraExposure(): number;
  19035. /**
  19036. * The camera exposure used on this material.
  19037. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19038. * This corresponds to a photographic exposure.
  19039. */
  19040. set cameraExposure(value: number);
  19041. /**
  19042. * Gets The camera contrast used on this material.
  19043. */
  19044. get cameraContrast(): number;
  19045. /**
  19046. * Sets The camera contrast used on this material.
  19047. */
  19048. set cameraContrast(value: number);
  19049. /**
  19050. * Gets the Color Grading 2D Lookup Texture.
  19051. */
  19052. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  19053. /**
  19054. * Sets the Color Grading 2D Lookup Texture.
  19055. */
  19056. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  19057. /**
  19058. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19059. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19060. * 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;
  19061. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19062. */
  19063. get cameraColorCurves(): Nullable<ColorCurves>;
  19064. /**
  19065. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19066. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19067. * 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;
  19068. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19069. */
  19070. set cameraColorCurves(value: Nullable<ColorCurves>);
  19071. /**
  19072. * Can this material render to several textures at once
  19073. */
  19074. get canRenderToMRT(): boolean;
  19075. /**
  19076. * Defines the detail map parameters for the material.
  19077. */
  19078. readonly detailMap: DetailMapConfiguration;
  19079. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19080. protected _worldViewProjectionMatrix: Matrix;
  19081. protected _globalAmbientColor: Color3;
  19082. protected _useLogarithmicDepth: boolean;
  19083. protected _rebuildInParallel: boolean;
  19084. /**
  19085. * Instantiates a new standard material.
  19086. * This is the default material used in Babylon. It is the best trade off between quality
  19087. * and performances.
  19088. * @see https://doc.babylonjs.com/babylon101/materials
  19089. * @param name Define the name of the material in the scene
  19090. * @param scene Define the scene the material belong to
  19091. */
  19092. constructor(name: string, scene: Scene);
  19093. /**
  19094. * Gets a boolean indicating that current material needs to register RTT
  19095. */
  19096. get hasRenderTargetTextures(): boolean;
  19097. /**
  19098. * Gets the current class name of the material e.g. "StandardMaterial"
  19099. * Mainly use in serialization.
  19100. * @returns the class name
  19101. */
  19102. getClassName(): string;
  19103. /**
  19104. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19105. * You can try switching to logarithmic depth.
  19106. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19107. */
  19108. get useLogarithmicDepth(): boolean;
  19109. set useLogarithmicDepth(value: boolean);
  19110. /**
  19111. * Specifies if the material will require alpha blending
  19112. * @returns a boolean specifying if alpha blending is needed
  19113. */
  19114. needAlphaBlending(): boolean;
  19115. /**
  19116. * Specifies if this material should be rendered in alpha test mode
  19117. * @returns a boolean specifying if an alpha test is needed.
  19118. */
  19119. needAlphaTesting(): boolean;
  19120. /**
  19121. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  19122. */
  19123. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19124. /**
  19125. * Specifies whether or not there is a usable alpha channel for transparency.
  19126. */
  19127. protected _hasAlphaChannel(): boolean;
  19128. /**
  19129. * Get the texture used for alpha test purpose.
  19130. * @returns the diffuse texture in case of the standard material.
  19131. */
  19132. getAlphaTestTexture(): Nullable<BaseTexture>;
  19133. /**
  19134. * Get if the submesh is ready to be used and all its information available.
  19135. * Child classes can use it to update shaders
  19136. * @param mesh defines the mesh to check
  19137. * @param subMesh defines which submesh to check
  19138. * @param useInstances specifies that instances should be used
  19139. * @returns a boolean indicating that the submesh is ready or not
  19140. */
  19141. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19142. /**
  19143. * Builds the material UBO layouts.
  19144. * Used internally during the effect preparation.
  19145. */
  19146. buildUniformLayout(): void;
  19147. /**
  19148. * Unbinds the material from the mesh
  19149. */
  19150. unbind(): void;
  19151. /**
  19152. * Binds the submesh to this material by preparing the effect and shader to draw
  19153. * @param world defines the world transformation matrix
  19154. * @param mesh defines the mesh containing the submesh
  19155. * @param subMesh defines the submesh to bind the material to
  19156. */
  19157. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19158. /**
  19159. * Get the list of animatables in the material.
  19160. * @returns the list of animatables object used in the material
  19161. */
  19162. getAnimatables(): IAnimatable[];
  19163. /**
  19164. * Gets the active textures from the material
  19165. * @returns an array of textures
  19166. */
  19167. getActiveTextures(): BaseTexture[];
  19168. /**
  19169. * Specifies if the material uses a texture
  19170. * @param texture defines the texture to check against the material
  19171. * @returns a boolean specifying if the material uses the texture
  19172. */
  19173. hasTexture(texture: BaseTexture): boolean;
  19174. /**
  19175. * Disposes the material
  19176. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19177. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19178. */
  19179. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19180. /**
  19181. * Makes a duplicate of the material, and gives it a new name
  19182. * @param name defines the new name for the duplicated material
  19183. * @returns the cloned material
  19184. */
  19185. clone(name: string): StandardMaterial;
  19186. /**
  19187. * Serializes this material in a JSON representation
  19188. * @returns the serialized material object
  19189. */
  19190. serialize(): any;
  19191. /**
  19192. * Creates a standard material from parsed material data
  19193. * @param source defines the JSON representation of the material
  19194. * @param scene defines the hosting scene
  19195. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19196. * @returns a new standard material
  19197. */
  19198. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  19199. /**
  19200. * Are diffuse textures enabled in the application.
  19201. */
  19202. static get DiffuseTextureEnabled(): boolean;
  19203. static set DiffuseTextureEnabled(value: boolean);
  19204. /**
  19205. * Are detail textures enabled in the application.
  19206. */
  19207. static get DetailTextureEnabled(): boolean;
  19208. static set DetailTextureEnabled(value: boolean);
  19209. /**
  19210. * Are ambient textures enabled in the application.
  19211. */
  19212. static get AmbientTextureEnabled(): boolean;
  19213. static set AmbientTextureEnabled(value: boolean);
  19214. /**
  19215. * Are opacity textures enabled in the application.
  19216. */
  19217. static get OpacityTextureEnabled(): boolean;
  19218. static set OpacityTextureEnabled(value: boolean);
  19219. /**
  19220. * Are reflection textures enabled in the application.
  19221. */
  19222. static get ReflectionTextureEnabled(): boolean;
  19223. static set ReflectionTextureEnabled(value: boolean);
  19224. /**
  19225. * Are emissive textures enabled in the application.
  19226. */
  19227. static get EmissiveTextureEnabled(): boolean;
  19228. static set EmissiveTextureEnabled(value: boolean);
  19229. /**
  19230. * Are specular textures enabled in the application.
  19231. */
  19232. static get SpecularTextureEnabled(): boolean;
  19233. static set SpecularTextureEnabled(value: boolean);
  19234. /**
  19235. * Are bump textures enabled in the application.
  19236. */
  19237. static get BumpTextureEnabled(): boolean;
  19238. static set BumpTextureEnabled(value: boolean);
  19239. /**
  19240. * Are lightmap textures enabled in the application.
  19241. */
  19242. static get LightmapTextureEnabled(): boolean;
  19243. static set LightmapTextureEnabled(value: boolean);
  19244. /**
  19245. * Are refraction textures enabled in the application.
  19246. */
  19247. static get RefractionTextureEnabled(): boolean;
  19248. static set RefractionTextureEnabled(value: boolean);
  19249. /**
  19250. * Are color grading textures enabled in the application.
  19251. */
  19252. static get ColorGradingTextureEnabled(): boolean;
  19253. static set ColorGradingTextureEnabled(value: boolean);
  19254. /**
  19255. * Are fresnels enabled in the application.
  19256. */
  19257. static get FresnelEnabled(): boolean;
  19258. static set FresnelEnabled(value: boolean);
  19259. }
  19260. }
  19261. declare module BABYLON {
  19262. /** @hidden */
  19263. export var rgbdDecodePixelShader: {
  19264. name: string;
  19265. shader: string;
  19266. };
  19267. }
  19268. declare module BABYLON {
  19269. /**
  19270. * Class used to host RGBD texture specific utilities
  19271. */
  19272. export class RGBDTextureTools {
  19273. /**
  19274. * Expand the RGBD Texture from RGBD to Half Float if possible.
  19275. * @param texture the texture to expand.
  19276. */
  19277. static ExpandRGBDTexture(texture: Texture): void;
  19278. }
  19279. }
  19280. declare module BABYLON {
  19281. /**
  19282. * Class used to host texture specific utilities
  19283. */
  19284. export class BRDFTextureTools {
  19285. /**
  19286. * Prevents texture cache collision
  19287. */
  19288. private static _instanceNumber;
  19289. /**
  19290. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  19291. * @param scene defines the hosting scene
  19292. * @returns the environment BRDF texture
  19293. */
  19294. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  19295. private static _environmentBRDFBase64Texture;
  19296. }
  19297. }
  19298. declare module BABYLON {
  19299. /**
  19300. * @hidden
  19301. */
  19302. export interface IMaterialClearCoatDefines {
  19303. CLEARCOAT: boolean;
  19304. CLEARCOAT_DEFAULTIOR: boolean;
  19305. CLEARCOAT_TEXTURE: boolean;
  19306. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  19307. CLEARCOAT_TEXTUREDIRECTUV: number;
  19308. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  19309. CLEARCOAT_BUMP: boolean;
  19310. CLEARCOAT_BUMPDIRECTUV: number;
  19311. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  19312. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  19313. CLEARCOAT_REMAP_F0: boolean;
  19314. CLEARCOAT_TINT: boolean;
  19315. CLEARCOAT_TINT_TEXTURE: boolean;
  19316. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  19317. /** @hidden */
  19318. _areTexturesDirty: boolean;
  19319. }
  19320. /**
  19321. * Define the code related to the clear coat parameters of the pbr material.
  19322. */
  19323. export class PBRClearCoatConfiguration {
  19324. /**
  19325. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  19326. * The default fits with a polyurethane material.
  19327. * @hidden
  19328. */
  19329. static readonly _DefaultIndexOfRefraction: number;
  19330. private _isEnabled;
  19331. /**
  19332. * Defines if the clear coat is enabled in the material.
  19333. */
  19334. isEnabled: boolean;
  19335. /**
  19336. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  19337. */
  19338. intensity: number;
  19339. /**
  19340. * Defines the clear coat layer roughness.
  19341. */
  19342. roughness: number;
  19343. private _indexOfRefraction;
  19344. /**
  19345. * Defines the index of refraction of the clear coat.
  19346. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  19347. * The default fits with a polyurethane material.
  19348. * Changing the default value is more performance intensive.
  19349. */
  19350. indexOfRefraction: number;
  19351. private _texture;
  19352. /**
  19353. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  19354. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  19355. * if textureRoughness is not empty, else no texture roughness is used
  19356. */
  19357. texture: Nullable<BaseTexture>;
  19358. private _useRoughnessFromMainTexture;
  19359. /**
  19360. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  19361. * If false, the green channel from textureRoughness is used for roughness
  19362. */
  19363. useRoughnessFromMainTexture: boolean;
  19364. private _textureRoughness;
  19365. /**
  19366. * Stores the clear coat roughness in a texture (green channel)
  19367. * Not used if useRoughnessFromMainTexture is true
  19368. */
  19369. textureRoughness: Nullable<BaseTexture>;
  19370. private _remapF0OnInterfaceChange;
  19371. /**
  19372. * Defines if the F0 value should be remapped to account for the interface change in the material.
  19373. */
  19374. remapF0OnInterfaceChange: boolean;
  19375. private _bumpTexture;
  19376. /**
  19377. * Define the clear coat specific bump texture.
  19378. */
  19379. bumpTexture: Nullable<BaseTexture>;
  19380. private _isTintEnabled;
  19381. /**
  19382. * Defines if the clear coat tint is enabled in the material.
  19383. */
  19384. isTintEnabled: boolean;
  19385. /**
  19386. * Defines the clear coat tint of the material.
  19387. * This is only use if tint is enabled
  19388. */
  19389. tintColor: Color3;
  19390. /**
  19391. * Defines the distance at which the tint color should be found in the
  19392. * clear coat media.
  19393. * This is only use if tint is enabled
  19394. */
  19395. tintColorAtDistance: number;
  19396. /**
  19397. * Defines the clear coat layer thickness.
  19398. * This is only use if tint is enabled
  19399. */
  19400. tintThickness: number;
  19401. private _tintTexture;
  19402. /**
  19403. * Stores the clear tint values in a texture.
  19404. * rgb is tint
  19405. * a is a thickness factor
  19406. */
  19407. tintTexture: Nullable<BaseTexture>;
  19408. /** @hidden */
  19409. private _internalMarkAllSubMeshesAsTexturesDirty;
  19410. /** @hidden */
  19411. _markAllSubMeshesAsTexturesDirty(): void;
  19412. /**
  19413. * Instantiate a new istance of clear coat configuration.
  19414. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19415. */
  19416. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19417. /**
  19418. * Gets wehter the submesh is ready to be used or not.
  19419. * @param defines the list of "defines" to update.
  19420. * @param scene defines the scene the material belongs to.
  19421. * @param engine defines the engine the material belongs to.
  19422. * @param disableBumpMap defines wether the material disables bump or not.
  19423. * @returns - boolean indicating that the submesh is ready or not.
  19424. */
  19425. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  19426. /**
  19427. * Checks to see if a texture is used in the material.
  19428. * @param defines the list of "defines" to update.
  19429. * @param scene defines the scene to the material belongs to.
  19430. */
  19431. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  19432. /**
  19433. * Binds the material data.
  19434. * @param uniformBuffer defines the Uniform buffer to fill in.
  19435. * @param scene defines the scene the material belongs to.
  19436. * @param engine defines the engine the material belongs to.
  19437. * @param disableBumpMap defines wether the material disables bump or not.
  19438. * @param isFrozen defines wether the material is frozen or not.
  19439. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  19440. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  19441. * @param subMesh the submesh to bind data for
  19442. */
  19443. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  19444. /**
  19445. * Checks to see if a texture is used in the material.
  19446. * @param texture - Base texture to use.
  19447. * @returns - Boolean specifying if a texture is used in the material.
  19448. */
  19449. hasTexture(texture: BaseTexture): boolean;
  19450. /**
  19451. * Returns an array of the actively used textures.
  19452. * @param activeTextures Array of BaseTextures
  19453. */
  19454. getActiveTextures(activeTextures: BaseTexture[]): void;
  19455. /**
  19456. * Returns the animatable textures.
  19457. * @param animatables Array of animatable textures.
  19458. */
  19459. getAnimatables(animatables: IAnimatable[]): void;
  19460. /**
  19461. * Disposes the resources of the material.
  19462. * @param forceDisposeTextures - Forces the disposal of all textures.
  19463. */
  19464. dispose(forceDisposeTextures?: boolean): void;
  19465. /**
  19466. * Get the current class name of the texture useful for serialization or dynamic coding.
  19467. * @returns "PBRClearCoatConfiguration"
  19468. */
  19469. getClassName(): string;
  19470. /**
  19471. * Add fallbacks to the effect fallbacks list.
  19472. * @param defines defines the Base texture to use.
  19473. * @param fallbacks defines the current fallback list.
  19474. * @param currentRank defines the current fallback rank.
  19475. * @returns the new fallback rank.
  19476. */
  19477. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  19478. /**
  19479. * Add the required uniforms to the current list.
  19480. * @param uniforms defines the current uniform list.
  19481. */
  19482. static AddUniforms(uniforms: string[]): void;
  19483. /**
  19484. * Add the required samplers to the current list.
  19485. * @param samplers defines the current sampler list.
  19486. */
  19487. static AddSamplers(samplers: string[]): void;
  19488. /**
  19489. * Add the required uniforms to the current buffer.
  19490. * @param uniformBuffer defines the current uniform buffer.
  19491. */
  19492. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19493. /**
  19494. * Makes a duplicate of the current configuration into another one.
  19495. * @param clearCoatConfiguration define the config where to copy the info
  19496. */
  19497. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  19498. /**
  19499. * Serializes this clear coat configuration.
  19500. * @returns - An object with the serialized config.
  19501. */
  19502. serialize(): any;
  19503. /**
  19504. * Parses a anisotropy Configuration from a serialized object.
  19505. * @param source - Serialized object.
  19506. * @param scene Defines the scene we are parsing for
  19507. * @param rootUrl Defines the rootUrl to load from
  19508. */
  19509. parse(source: any, scene: Scene, rootUrl: string): void;
  19510. }
  19511. }
  19512. declare module BABYLON {
  19513. /**
  19514. * @hidden
  19515. */
  19516. export interface IMaterialAnisotropicDefines {
  19517. ANISOTROPIC: boolean;
  19518. ANISOTROPIC_TEXTURE: boolean;
  19519. ANISOTROPIC_TEXTUREDIRECTUV: number;
  19520. MAINUV1: boolean;
  19521. _areTexturesDirty: boolean;
  19522. _needUVs: boolean;
  19523. }
  19524. /**
  19525. * Define the code related to the anisotropic parameters of the pbr material.
  19526. */
  19527. export class PBRAnisotropicConfiguration {
  19528. private _isEnabled;
  19529. /**
  19530. * Defines if the anisotropy is enabled in the material.
  19531. */
  19532. isEnabled: boolean;
  19533. /**
  19534. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  19535. */
  19536. intensity: number;
  19537. /**
  19538. * Defines if the effect is along the tangents, bitangents or in between.
  19539. * By default, the effect is "strectching" the highlights along the tangents.
  19540. */
  19541. direction: Vector2;
  19542. private _texture;
  19543. /**
  19544. * Stores the anisotropy values in a texture.
  19545. * rg is direction (like normal from -1 to 1)
  19546. * b is a intensity
  19547. */
  19548. texture: Nullable<BaseTexture>;
  19549. /** @hidden */
  19550. private _internalMarkAllSubMeshesAsTexturesDirty;
  19551. /** @hidden */
  19552. _markAllSubMeshesAsTexturesDirty(): void;
  19553. /**
  19554. * Instantiate a new istance of anisotropy configuration.
  19555. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19556. */
  19557. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19558. /**
  19559. * Specifies that the submesh is ready to be used.
  19560. * @param defines the list of "defines" to update.
  19561. * @param scene defines the scene the material belongs to.
  19562. * @returns - boolean indicating that the submesh is ready or not.
  19563. */
  19564. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  19565. /**
  19566. * Checks to see if a texture is used in the material.
  19567. * @param defines the list of "defines" to update.
  19568. * @param mesh the mesh we are preparing the defines for.
  19569. * @param scene defines the scene the material belongs to.
  19570. */
  19571. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  19572. /**
  19573. * Binds the material data.
  19574. * @param uniformBuffer defines the Uniform buffer to fill in.
  19575. * @param scene defines the scene the material belongs to.
  19576. * @param isFrozen defines wether the material is frozen or not.
  19577. */
  19578. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  19579. /**
  19580. * Checks to see if a texture is used in the material.
  19581. * @param texture - Base texture to use.
  19582. * @returns - Boolean specifying if a texture is used in the material.
  19583. */
  19584. hasTexture(texture: BaseTexture): boolean;
  19585. /**
  19586. * Returns an array of the actively used textures.
  19587. * @param activeTextures Array of BaseTextures
  19588. */
  19589. getActiveTextures(activeTextures: BaseTexture[]): void;
  19590. /**
  19591. * Returns the animatable textures.
  19592. * @param animatables Array of animatable textures.
  19593. */
  19594. getAnimatables(animatables: IAnimatable[]): void;
  19595. /**
  19596. * Disposes the resources of the material.
  19597. * @param forceDisposeTextures - Forces the disposal of all textures.
  19598. */
  19599. dispose(forceDisposeTextures?: boolean): void;
  19600. /**
  19601. * Get the current class name of the texture useful for serialization or dynamic coding.
  19602. * @returns "PBRAnisotropicConfiguration"
  19603. */
  19604. getClassName(): string;
  19605. /**
  19606. * Add fallbacks to the effect fallbacks list.
  19607. * @param defines defines the Base texture to use.
  19608. * @param fallbacks defines the current fallback list.
  19609. * @param currentRank defines the current fallback rank.
  19610. * @returns the new fallback rank.
  19611. */
  19612. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  19613. /**
  19614. * Add the required uniforms to the current list.
  19615. * @param uniforms defines the current uniform list.
  19616. */
  19617. static AddUniforms(uniforms: string[]): void;
  19618. /**
  19619. * Add the required uniforms to the current buffer.
  19620. * @param uniformBuffer defines the current uniform buffer.
  19621. */
  19622. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19623. /**
  19624. * Add the required samplers to the current list.
  19625. * @param samplers defines the current sampler list.
  19626. */
  19627. static AddSamplers(samplers: string[]): void;
  19628. /**
  19629. * Makes a duplicate of the current configuration into another one.
  19630. * @param anisotropicConfiguration define the config where to copy the info
  19631. */
  19632. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  19633. /**
  19634. * Serializes this anisotropy configuration.
  19635. * @returns - An object with the serialized config.
  19636. */
  19637. serialize(): any;
  19638. /**
  19639. * Parses a anisotropy Configuration from a serialized object.
  19640. * @param source - Serialized object.
  19641. * @param scene Defines the scene we are parsing for
  19642. * @param rootUrl Defines the rootUrl to load from
  19643. */
  19644. parse(source: any, scene: Scene, rootUrl: string): void;
  19645. }
  19646. }
  19647. declare module BABYLON {
  19648. /**
  19649. * @hidden
  19650. */
  19651. export interface IMaterialBRDFDefines {
  19652. BRDF_V_HEIGHT_CORRELATED: boolean;
  19653. MS_BRDF_ENERGY_CONSERVATION: boolean;
  19654. SPHERICAL_HARMONICS: boolean;
  19655. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  19656. /** @hidden */
  19657. _areMiscDirty: boolean;
  19658. }
  19659. /**
  19660. * Define the code related to the BRDF parameters of the pbr material.
  19661. */
  19662. export class PBRBRDFConfiguration {
  19663. /**
  19664. * Default value used for the energy conservation.
  19665. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  19666. */
  19667. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  19668. /**
  19669. * Default value used for the Smith Visibility Height Correlated mode.
  19670. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  19671. */
  19672. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  19673. /**
  19674. * Default value used for the IBL diffuse part.
  19675. * This can help switching back to the polynomials mode globally which is a tiny bit
  19676. * less GPU intensive at the drawback of a lower quality.
  19677. */
  19678. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  19679. /**
  19680. * Default value used for activating energy conservation for the specular workflow.
  19681. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  19682. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  19683. */
  19684. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  19685. private _useEnergyConservation;
  19686. /**
  19687. * Defines if the material uses energy conservation.
  19688. */
  19689. useEnergyConservation: boolean;
  19690. private _useSmithVisibilityHeightCorrelated;
  19691. /**
  19692. * LEGACY Mode set to false
  19693. * Defines if the material uses height smith correlated visibility term.
  19694. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  19695. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  19696. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  19697. * Not relying on height correlated will also disable energy conservation.
  19698. */
  19699. useSmithVisibilityHeightCorrelated: boolean;
  19700. private _useSphericalHarmonics;
  19701. /**
  19702. * LEGACY Mode set to false
  19703. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  19704. * diffuse part of the IBL.
  19705. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  19706. * to the ground truth.
  19707. */
  19708. useSphericalHarmonics: boolean;
  19709. private _useSpecularGlossinessInputEnergyConservation;
  19710. /**
  19711. * Defines if the material uses energy conservation, when the specular workflow is active.
  19712. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  19713. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  19714. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  19715. */
  19716. useSpecularGlossinessInputEnergyConservation: boolean;
  19717. /** @hidden */
  19718. private _internalMarkAllSubMeshesAsMiscDirty;
  19719. /** @hidden */
  19720. _markAllSubMeshesAsMiscDirty(): void;
  19721. /**
  19722. * Instantiate a new istance of clear coat configuration.
  19723. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  19724. */
  19725. constructor(markAllSubMeshesAsMiscDirty: () => void);
  19726. /**
  19727. * Checks to see if a texture is used in the material.
  19728. * @param defines the list of "defines" to update.
  19729. */
  19730. prepareDefines(defines: IMaterialBRDFDefines): void;
  19731. /**
  19732. * Get the current class name of the texture useful for serialization or dynamic coding.
  19733. * @returns "PBRClearCoatConfiguration"
  19734. */
  19735. getClassName(): string;
  19736. /**
  19737. * Makes a duplicate of the current configuration into another one.
  19738. * @param brdfConfiguration define the config where to copy the info
  19739. */
  19740. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  19741. /**
  19742. * Serializes this BRDF configuration.
  19743. * @returns - An object with the serialized config.
  19744. */
  19745. serialize(): any;
  19746. /**
  19747. * Parses a anisotropy Configuration from a serialized object.
  19748. * @param source - Serialized object.
  19749. * @param scene Defines the scene we are parsing for
  19750. * @param rootUrl Defines the rootUrl to load from
  19751. */
  19752. parse(source: any, scene: Scene, rootUrl: string): void;
  19753. }
  19754. }
  19755. declare module BABYLON {
  19756. /**
  19757. * @hidden
  19758. */
  19759. export interface IMaterialSheenDefines {
  19760. SHEEN: boolean;
  19761. SHEEN_TEXTURE: boolean;
  19762. SHEEN_TEXTURE_ROUGHNESS: boolean;
  19763. SHEEN_TEXTUREDIRECTUV: number;
  19764. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  19765. SHEEN_LINKWITHALBEDO: boolean;
  19766. SHEEN_ROUGHNESS: boolean;
  19767. SHEEN_ALBEDOSCALING: boolean;
  19768. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  19769. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  19770. /** @hidden */
  19771. _areTexturesDirty: boolean;
  19772. }
  19773. /**
  19774. * Define the code related to the Sheen parameters of the pbr material.
  19775. */
  19776. export class PBRSheenConfiguration {
  19777. private _isEnabled;
  19778. /**
  19779. * Defines if the material uses sheen.
  19780. */
  19781. isEnabled: boolean;
  19782. private _linkSheenWithAlbedo;
  19783. /**
  19784. * Defines if the sheen is linked to the sheen color.
  19785. */
  19786. linkSheenWithAlbedo: boolean;
  19787. /**
  19788. * Defines the sheen intensity.
  19789. */
  19790. intensity: number;
  19791. /**
  19792. * Defines the sheen color.
  19793. */
  19794. color: Color3;
  19795. private _texture;
  19796. /**
  19797. * Stores the sheen tint values in a texture.
  19798. * rgb is tint
  19799. * a is a intensity or roughness if the roughness property has been defined and useRoughnessFromTexture is true (in that case, textureRoughness won't be used)
  19800. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  19801. */
  19802. texture: Nullable<BaseTexture>;
  19803. private _useRoughnessFromMainTexture;
  19804. /**
  19805. * Indicates that the alpha channel of the texture property will be used for roughness.
  19806. * Has no effect if the roughness (and texture!) property is not defined
  19807. */
  19808. useRoughnessFromMainTexture: boolean;
  19809. private _roughness;
  19810. /**
  19811. * Defines the sheen roughness.
  19812. * It is not taken into account if linkSheenWithAlbedo is true.
  19813. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  19814. */
  19815. roughness: Nullable<number>;
  19816. private _textureRoughness;
  19817. /**
  19818. * Stores the sheen roughness in a texture.
  19819. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  19820. */
  19821. textureRoughness: Nullable<BaseTexture>;
  19822. private _albedoScaling;
  19823. /**
  19824. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  19825. * It allows the strength of the sheen effect to not depend on the base color of the material,
  19826. * making it easier to setup and tweak the effect
  19827. */
  19828. albedoScaling: boolean;
  19829. /** @hidden */
  19830. private _internalMarkAllSubMeshesAsTexturesDirty;
  19831. /** @hidden */
  19832. _markAllSubMeshesAsTexturesDirty(): void;
  19833. /**
  19834. * Instantiate a new istance of clear coat configuration.
  19835. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19836. */
  19837. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19838. /**
  19839. * Specifies that the submesh is ready to be used.
  19840. * @param defines the list of "defines" to update.
  19841. * @param scene defines the scene the material belongs to.
  19842. * @returns - boolean indicating that the submesh is ready or not.
  19843. */
  19844. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  19845. /**
  19846. * Checks to see if a texture is used in the material.
  19847. * @param defines the list of "defines" to update.
  19848. * @param scene defines the scene the material belongs to.
  19849. */
  19850. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  19851. /**
  19852. * Binds the material data.
  19853. * @param uniformBuffer defines the Uniform buffer to fill in.
  19854. * @param scene defines the scene the material belongs to.
  19855. * @param isFrozen defines wether the material is frozen or not.
  19856. * @param subMesh the submesh to bind data for
  19857. */
  19858. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  19859. /**
  19860. * Checks to see if a texture is used in the material.
  19861. * @param texture - Base texture to use.
  19862. * @returns - Boolean specifying if a texture is used in the material.
  19863. */
  19864. hasTexture(texture: BaseTexture): boolean;
  19865. /**
  19866. * Returns an array of the actively used textures.
  19867. * @param activeTextures Array of BaseTextures
  19868. */
  19869. getActiveTextures(activeTextures: BaseTexture[]): void;
  19870. /**
  19871. * Returns the animatable textures.
  19872. * @param animatables Array of animatable textures.
  19873. */
  19874. getAnimatables(animatables: IAnimatable[]): void;
  19875. /**
  19876. * Disposes the resources of the material.
  19877. * @param forceDisposeTextures - Forces the disposal of all textures.
  19878. */
  19879. dispose(forceDisposeTextures?: boolean): void;
  19880. /**
  19881. * Get the current class name of the texture useful for serialization or dynamic coding.
  19882. * @returns "PBRSheenConfiguration"
  19883. */
  19884. getClassName(): string;
  19885. /**
  19886. * Add fallbacks to the effect fallbacks list.
  19887. * @param defines defines the Base texture to use.
  19888. * @param fallbacks defines the current fallback list.
  19889. * @param currentRank defines the current fallback rank.
  19890. * @returns the new fallback rank.
  19891. */
  19892. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  19893. /**
  19894. * Add the required uniforms to the current list.
  19895. * @param uniforms defines the current uniform list.
  19896. */
  19897. static AddUniforms(uniforms: string[]): void;
  19898. /**
  19899. * Add the required uniforms to the current buffer.
  19900. * @param uniformBuffer defines the current uniform buffer.
  19901. */
  19902. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19903. /**
  19904. * Add the required samplers to the current list.
  19905. * @param samplers defines the current sampler list.
  19906. */
  19907. static AddSamplers(samplers: string[]): void;
  19908. /**
  19909. * Makes a duplicate of the current configuration into another one.
  19910. * @param sheenConfiguration define the config where to copy the info
  19911. */
  19912. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  19913. /**
  19914. * Serializes this BRDF configuration.
  19915. * @returns - An object with the serialized config.
  19916. */
  19917. serialize(): any;
  19918. /**
  19919. * Parses a anisotropy Configuration from a serialized object.
  19920. * @param source - Serialized object.
  19921. * @param scene Defines the scene we are parsing for
  19922. * @param rootUrl Defines the rootUrl to load from
  19923. */
  19924. parse(source: any, scene: Scene, rootUrl: string): void;
  19925. }
  19926. }
  19927. declare module BABYLON {
  19928. /**
  19929. * @hidden
  19930. */
  19931. export interface IMaterialSubSurfaceDefines {
  19932. SUBSURFACE: boolean;
  19933. SS_REFRACTION: boolean;
  19934. SS_TRANSLUCENCY: boolean;
  19935. SS_SCATTERING: boolean;
  19936. SS_THICKNESSANDMASK_TEXTURE: boolean;
  19937. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  19938. SS_REFRACTIONMAP_3D: boolean;
  19939. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  19940. SS_LODINREFRACTIONALPHA: boolean;
  19941. SS_GAMMAREFRACTION: boolean;
  19942. SS_RGBDREFRACTION: boolean;
  19943. SS_LINEARSPECULARREFRACTION: boolean;
  19944. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  19945. SS_ALBEDOFORREFRACTIONTINT: boolean;
  19946. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  19947. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  19948. /** @hidden */
  19949. _areTexturesDirty: boolean;
  19950. }
  19951. /**
  19952. * Define the code related to the sub surface parameters of the pbr material.
  19953. */
  19954. export class PBRSubSurfaceConfiguration {
  19955. private _isRefractionEnabled;
  19956. /**
  19957. * Defines if the refraction is enabled in the material.
  19958. */
  19959. isRefractionEnabled: boolean;
  19960. private _isTranslucencyEnabled;
  19961. /**
  19962. * Defines if the translucency is enabled in the material.
  19963. */
  19964. isTranslucencyEnabled: boolean;
  19965. private _isScatteringEnabled;
  19966. /**
  19967. * Defines if the sub surface scattering is enabled in the material.
  19968. */
  19969. isScatteringEnabled: boolean;
  19970. private _scatteringDiffusionProfileIndex;
  19971. /**
  19972. * Diffusion profile for subsurface scattering.
  19973. * Useful for better scattering in the skins or foliages.
  19974. */
  19975. get scatteringDiffusionProfile(): Nullable<Color3>;
  19976. set scatteringDiffusionProfile(c: Nullable<Color3>);
  19977. /**
  19978. * Defines the refraction intensity of the material.
  19979. * The refraction when enabled replaces the Diffuse part of the material.
  19980. * The intensity helps transitionning between diffuse and refraction.
  19981. */
  19982. refractionIntensity: number;
  19983. /**
  19984. * Defines the translucency intensity of the material.
  19985. * When translucency has been enabled, this defines how much of the "translucency"
  19986. * is addded to the diffuse part of the material.
  19987. */
  19988. translucencyIntensity: number;
  19989. /**
  19990. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  19991. */
  19992. useAlbedoToTintRefraction: boolean;
  19993. private _thicknessTexture;
  19994. /**
  19995. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  19996. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  19997. * 0 would mean minimumThickness
  19998. * 1 would mean maximumThickness
  19999. * The other channels might be use as a mask to vary the different effects intensity.
  20000. */
  20001. thicknessTexture: Nullable<BaseTexture>;
  20002. private _refractionTexture;
  20003. /**
  20004. * Defines the texture to use for refraction.
  20005. */
  20006. refractionTexture: Nullable<BaseTexture>;
  20007. private _indexOfRefraction;
  20008. /**
  20009. * Index of refraction of the material base layer.
  20010. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20011. *
  20012. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  20013. *
  20014. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  20015. */
  20016. indexOfRefraction: number;
  20017. private _volumeIndexOfRefraction;
  20018. /**
  20019. * Index of refraction of the material's volume.
  20020. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20021. *
  20022. * This ONLY impacts refraction. If not provided or given a non-valid value,
  20023. * the volume will use the same IOR as the surface.
  20024. */
  20025. get volumeIndexOfRefraction(): number;
  20026. set volumeIndexOfRefraction(value: number);
  20027. private _invertRefractionY;
  20028. /**
  20029. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20030. */
  20031. invertRefractionY: boolean;
  20032. private _linkRefractionWithTransparency;
  20033. /**
  20034. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20035. * Materials half opaque for instance using refraction could benefit from this control.
  20036. */
  20037. linkRefractionWithTransparency: boolean;
  20038. /**
  20039. * Defines the minimum thickness stored in the thickness map.
  20040. * If no thickness map is defined, this value will be used to simulate thickness.
  20041. */
  20042. minimumThickness: number;
  20043. /**
  20044. * Defines the maximum thickness stored in the thickness map.
  20045. */
  20046. maximumThickness: number;
  20047. /**
  20048. * Defines the volume tint of the material.
  20049. * This is used for both translucency and scattering.
  20050. */
  20051. tintColor: Color3;
  20052. /**
  20053. * Defines the distance at which the tint color should be found in the media.
  20054. * This is used for refraction only.
  20055. */
  20056. tintColorAtDistance: number;
  20057. /**
  20058. * Defines how far each channel transmit through the media.
  20059. * It is defined as a color to simplify it selection.
  20060. */
  20061. diffusionDistance: Color3;
  20062. private _useMaskFromThicknessTexture;
  20063. /**
  20064. * Stores the intensity of the different subsurface effects in the thickness texture.
  20065. * * the green channel is the translucency intensity.
  20066. * * the blue channel is the scattering intensity.
  20067. * * the alpha channel is the refraction intensity.
  20068. */
  20069. useMaskFromThicknessTexture: boolean;
  20070. private _scene;
  20071. private _useMaskFromThicknessTextureGltf;
  20072. /**
  20073. * Stores the intensity of the different subsurface effects in the thickness texture. This variation
  20074. * matches the channel-packing that is used by glTF.
  20075. * * the red channel is the transmission/translucency intensity.
  20076. * * the green channel is the thickness.
  20077. */
  20078. useMaskFromThicknessTextureGltf: boolean;
  20079. /** @hidden */
  20080. private _internalMarkAllSubMeshesAsTexturesDirty;
  20081. private _internalMarkScenePrePassDirty;
  20082. /** @hidden */
  20083. _markAllSubMeshesAsTexturesDirty(): void;
  20084. /** @hidden */
  20085. _markScenePrePassDirty(): void;
  20086. /**
  20087. * Instantiate a new istance of sub surface configuration.
  20088. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20089. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  20090. * @param scene The scene
  20091. */
  20092. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  20093. /**
  20094. * Gets wehter the submesh is ready to be used or not.
  20095. * @param defines the list of "defines" to update.
  20096. * @param scene defines the scene the material belongs to.
  20097. * @returns - boolean indicating that the submesh is ready or not.
  20098. */
  20099. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  20100. /**
  20101. * Checks to see if a texture is used in the material.
  20102. * @param defines the list of "defines" to update.
  20103. * @param scene defines the scene to the material belongs to.
  20104. */
  20105. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  20106. /**
  20107. * Binds the material data.
  20108. * @param uniformBuffer defines the Uniform buffer to fill in.
  20109. * @param scene defines the scene the material belongs to.
  20110. * @param engine defines the engine the material belongs to.
  20111. * @param isFrozen defines whether the material is frozen or not.
  20112. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  20113. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  20114. */
  20115. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  20116. /**
  20117. * Unbinds the material from the mesh.
  20118. * @param activeEffect defines the effect that should be unbound from.
  20119. * @returns true if unbound, otherwise false
  20120. */
  20121. unbind(activeEffect: Effect): boolean;
  20122. /**
  20123. * Returns the texture used for refraction or null if none is used.
  20124. * @param scene defines the scene the material belongs to.
  20125. * @returns - Refraction texture if present. If no refraction texture and refraction
  20126. * is linked with transparency, returns environment texture. Otherwise, returns null.
  20127. */
  20128. private _getRefractionTexture;
  20129. /**
  20130. * Returns true if alpha blending should be disabled.
  20131. */
  20132. get disableAlphaBlending(): boolean;
  20133. /**
  20134. * Fills the list of render target textures.
  20135. * @param renderTargets the list of render targets to update
  20136. */
  20137. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  20138. /**
  20139. * Checks to see if a texture is used in the material.
  20140. * @param texture - Base texture to use.
  20141. * @returns - Boolean specifying if a texture is used in the material.
  20142. */
  20143. hasTexture(texture: BaseTexture): boolean;
  20144. /**
  20145. * Gets a boolean indicating that current material needs to register RTT
  20146. * @returns true if this uses a render target otherwise false.
  20147. */
  20148. hasRenderTargetTextures(): boolean;
  20149. /**
  20150. * Returns an array of the actively used textures.
  20151. * @param activeTextures Array of BaseTextures
  20152. */
  20153. getActiveTextures(activeTextures: BaseTexture[]): void;
  20154. /**
  20155. * Returns the animatable textures.
  20156. * @param animatables Array of animatable textures.
  20157. */
  20158. getAnimatables(animatables: IAnimatable[]): void;
  20159. /**
  20160. * Disposes the resources of the material.
  20161. * @param forceDisposeTextures - Forces the disposal of all textures.
  20162. */
  20163. dispose(forceDisposeTextures?: boolean): void;
  20164. /**
  20165. * Get the current class name of the texture useful for serialization or dynamic coding.
  20166. * @returns "PBRSubSurfaceConfiguration"
  20167. */
  20168. getClassName(): string;
  20169. /**
  20170. * Add fallbacks to the effect fallbacks list.
  20171. * @param defines defines the Base texture to use.
  20172. * @param fallbacks defines the current fallback list.
  20173. * @param currentRank defines the current fallback rank.
  20174. * @returns the new fallback rank.
  20175. */
  20176. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20177. /**
  20178. * Add the required uniforms to the current list.
  20179. * @param uniforms defines the current uniform list.
  20180. */
  20181. static AddUniforms(uniforms: string[]): void;
  20182. /**
  20183. * Add the required samplers to the current list.
  20184. * @param samplers defines the current sampler list.
  20185. */
  20186. static AddSamplers(samplers: string[]): void;
  20187. /**
  20188. * Add the required uniforms to the current buffer.
  20189. * @param uniformBuffer defines the current uniform buffer.
  20190. */
  20191. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20192. /**
  20193. * Makes a duplicate of the current configuration into another one.
  20194. * @param configuration define the config where to copy the info
  20195. */
  20196. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  20197. /**
  20198. * Serializes this Sub Surface configuration.
  20199. * @returns - An object with the serialized config.
  20200. */
  20201. serialize(): any;
  20202. /**
  20203. * Parses a anisotropy Configuration from a serialized object.
  20204. * @param source - Serialized object.
  20205. * @param scene Defines the scene we are parsing for
  20206. * @param rootUrl Defines the rootUrl to load from
  20207. */
  20208. parse(source: any, scene: Scene, rootUrl: string): void;
  20209. }
  20210. }
  20211. declare module BABYLON {
  20212. /**
  20213. * Class representing spherical harmonics coefficients to the 3rd degree
  20214. */
  20215. export class SphericalHarmonics {
  20216. /**
  20217. * Defines whether or not the harmonics have been prescaled for rendering.
  20218. */
  20219. preScaled: boolean;
  20220. /**
  20221. * The l0,0 coefficients of the spherical harmonics
  20222. */
  20223. l00: Vector3;
  20224. /**
  20225. * The l1,-1 coefficients of the spherical harmonics
  20226. */
  20227. l1_1: Vector3;
  20228. /**
  20229. * The l1,0 coefficients of the spherical harmonics
  20230. */
  20231. l10: Vector3;
  20232. /**
  20233. * The l1,1 coefficients of the spherical harmonics
  20234. */
  20235. l11: Vector3;
  20236. /**
  20237. * The l2,-2 coefficients of the spherical harmonics
  20238. */
  20239. l2_2: Vector3;
  20240. /**
  20241. * The l2,-1 coefficients of the spherical harmonics
  20242. */
  20243. l2_1: Vector3;
  20244. /**
  20245. * The l2,0 coefficients of the spherical harmonics
  20246. */
  20247. l20: Vector3;
  20248. /**
  20249. * The l2,1 coefficients of the spherical harmonics
  20250. */
  20251. l21: Vector3;
  20252. /**
  20253. * The l2,2 coefficients of the spherical harmonics
  20254. */
  20255. l22: Vector3;
  20256. /**
  20257. * Adds a light to the spherical harmonics
  20258. * @param direction the direction of the light
  20259. * @param color the color of the light
  20260. * @param deltaSolidAngle the delta solid angle of the light
  20261. */
  20262. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  20263. /**
  20264. * Scales the spherical harmonics by the given amount
  20265. * @param scale the amount to scale
  20266. */
  20267. scaleInPlace(scale: number): void;
  20268. /**
  20269. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  20270. *
  20271. * ```
  20272. * E_lm = A_l * L_lm
  20273. * ```
  20274. *
  20275. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  20276. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  20277. * the scaling factors are given in equation 9.
  20278. */
  20279. convertIncidentRadianceToIrradiance(): void;
  20280. /**
  20281. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  20282. *
  20283. * ```
  20284. * L = (1/pi) * E * rho
  20285. * ```
  20286. *
  20287. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  20288. */
  20289. convertIrradianceToLambertianRadiance(): void;
  20290. /**
  20291. * Integrates the reconstruction coefficients directly in to the SH preventing further
  20292. * required operations at run time.
  20293. *
  20294. * This is simply done by scaling back the SH with Ylm constants parameter.
  20295. * The trigonometric part being applied by the shader at run time.
  20296. */
  20297. preScaleForRendering(): void;
  20298. /**
  20299. * Constructs a spherical harmonics from an array.
  20300. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  20301. * @returns the spherical harmonics
  20302. */
  20303. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  20304. /**
  20305. * Gets the spherical harmonics from polynomial
  20306. * @param polynomial the spherical polynomial
  20307. * @returns the spherical harmonics
  20308. */
  20309. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  20310. }
  20311. /**
  20312. * Class representing spherical polynomial coefficients to the 3rd degree
  20313. */
  20314. export class SphericalPolynomial {
  20315. private _harmonics;
  20316. /**
  20317. * The spherical harmonics used to create the polynomials.
  20318. */
  20319. get preScaledHarmonics(): SphericalHarmonics;
  20320. /**
  20321. * The x coefficients of the spherical polynomial
  20322. */
  20323. x: Vector3;
  20324. /**
  20325. * The y coefficients of the spherical polynomial
  20326. */
  20327. y: Vector3;
  20328. /**
  20329. * The z coefficients of the spherical polynomial
  20330. */
  20331. z: Vector3;
  20332. /**
  20333. * The xx coefficients of the spherical polynomial
  20334. */
  20335. xx: Vector3;
  20336. /**
  20337. * The yy coefficients of the spherical polynomial
  20338. */
  20339. yy: Vector3;
  20340. /**
  20341. * The zz coefficients of the spherical polynomial
  20342. */
  20343. zz: Vector3;
  20344. /**
  20345. * The xy coefficients of the spherical polynomial
  20346. */
  20347. xy: Vector3;
  20348. /**
  20349. * The yz coefficients of the spherical polynomial
  20350. */
  20351. yz: Vector3;
  20352. /**
  20353. * The zx coefficients of the spherical polynomial
  20354. */
  20355. zx: Vector3;
  20356. /**
  20357. * Adds an ambient color to the spherical polynomial
  20358. * @param color the color to add
  20359. */
  20360. addAmbient(color: Color3): void;
  20361. /**
  20362. * Scales the spherical polynomial by the given amount
  20363. * @param scale the amount to scale
  20364. */
  20365. scaleInPlace(scale: number): void;
  20366. /**
  20367. * Gets the spherical polynomial from harmonics
  20368. * @param harmonics the spherical harmonics
  20369. * @returns the spherical polynomial
  20370. */
  20371. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  20372. /**
  20373. * Constructs a spherical polynomial from an array.
  20374. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  20375. * @returns the spherical polynomial
  20376. */
  20377. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  20378. }
  20379. }
  20380. declare module BABYLON {
  20381. /**
  20382. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  20383. */
  20384. export interface CubeMapInfo {
  20385. /**
  20386. * The pixel array for the front face.
  20387. * This is stored in format, left to right, up to down format.
  20388. */
  20389. front: Nullable<ArrayBufferView>;
  20390. /**
  20391. * The pixel array for the back face.
  20392. * This is stored in format, left to right, up to down format.
  20393. */
  20394. back: Nullable<ArrayBufferView>;
  20395. /**
  20396. * The pixel array for the left face.
  20397. * This is stored in format, left to right, up to down format.
  20398. */
  20399. left: Nullable<ArrayBufferView>;
  20400. /**
  20401. * The pixel array for the right face.
  20402. * This is stored in format, left to right, up to down format.
  20403. */
  20404. right: Nullable<ArrayBufferView>;
  20405. /**
  20406. * The pixel array for the up face.
  20407. * This is stored in format, left to right, up to down format.
  20408. */
  20409. up: Nullable<ArrayBufferView>;
  20410. /**
  20411. * The pixel array for the down face.
  20412. * This is stored in format, left to right, up to down format.
  20413. */
  20414. down: Nullable<ArrayBufferView>;
  20415. /**
  20416. * The size of the cubemap stored.
  20417. *
  20418. * Each faces will be size * size pixels.
  20419. */
  20420. size: number;
  20421. /**
  20422. * The format of the texture.
  20423. *
  20424. * RGBA, RGB.
  20425. */
  20426. format: number;
  20427. /**
  20428. * The type of the texture data.
  20429. *
  20430. * UNSIGNED_INT, FLOAT.
  20431. */
  20432. type: number;
  20433. /**
  20434. * Specifies whether the texture is in gamma space.
  20435. */
  20436. gammaSpace: boolean;
  20437. }
  20438. /**
  20439. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  20440. */
  20441. export class PanoramaToCubeMapTools {
  20442. private static FACE_LEFT;
  20443. private static FACE_RIGHT;
  20444. private static FACE_FRONT;
  20445. private static FACE_BACK;
  20446. private static FACE_DOWN;
  20447. private static FACE_UP;
  20448. /**
  20449. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  20450. *
  20451. * @param float32Array The source data.
  20452. * @param inputWidth The width of the input panorama.
  20453. * @param inputHeight The height of the input panorama.
  20454. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  20455. * @return The cubemap data
  20456. */
  20457. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  20458. private static CreateCubemapTexture;
  20459. private static CalcProjectionSpherical;
  20460. }
  20461. }
  20462. declare module BABYLON {
  20463. /**
  20464. * Helper class dealing with the extraction of spherical polynomial dataArray
  20465. * from a cube map.
  20466. */
  20467. export class CubeMapToSphericalPolynomialTools {
  20468. private static FileFaces;
  20469. /**
  20470. * Converts a texture to the according Spherical Polynomial data.
  20471. * This extracts the first 3 orders only as they are the only one used in the lighting.
  20472. *
  20473. * @param texture The texture to extract the information from.
  20474. * @return The Spherical Polynomial data.
  20475. */
  20476. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  20477. /**
  20478. * Converts a cubemap to the according Spherical Polynomial data.
  20479. * This extracts the first 3 orders only as they are the only one used in the lighting.
  20480. *
  20481. * @param cubeInfo The Cube map to extract the information from.
  20482. * @return The Spherical Polynomial data.
  20483. */
  20484. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  20485. }
  20486. }
  20487. declare module BABYLON {
  20488. interface BaseTexture {
  20489. /**
  20490. * Get the polynomial representation of the texture data.
  20491. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  20492. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  20493. */
  20494. sphericalPolynomial: Nullable<SphericalPolynomial>;
  20495. }
  20496. }
  20497. declare module BABYLON {
  20498. /** @hidden */
  20499. export var pbrFragmentDeclaration: {
  20500. name: string;
  20501. shader: string;
  20502. };
  20503. }
  20504. declare module BABYLON {
  20505. /** @hidden */
  20506. export var pbrUboDeclaration: {
  20507. name: string;
  20508. shader: string;
  20509. };
  20510. }
  20511. declare module BABYLON {
  20512. /** @hidden */
  20513. export var pbrFragmentExtraDeclaration: {
  20514. name: string;
  20515. shader: string;
  20516. };
  20517. }
  20518. declare module BABYLON {
  20519. /** @hidden */
  20520. export var pbrFragmentSamplersDeclaration: {
  20521. name: string;
  20522. shader: string;
  20523. };
  20524. }
  20525. declare module BABYLON {
  20526. /** @hidden */
  20527. export var subSurfaceScatteringFunctions: {
  20528. name: string;
  20529. shader: string;
  20530. };
  20531. }
  20532. declare module BABYLON {
  20533. /** @hidden */
  20534. export var importanceSampling: {
  20535. name: string;
  20536. shader: string;
  20537. };
  20538. }
  20539. declare module BABYLON {
  20540. /** @hidden */
  20541. export var pbrHelperFunctions: {
  20542. name: string;
  20543. shader: string;
  20544. };
  20545. }
  20546. declare module BABYLON {
  20547. /** @hidden */
  20548. export var harmonicsFunctions: {
  20549. name: string;
  20550. shader: string;
  20551. };
  20552. }
  20553. declare module BABYLON {
  20554. /** @hidden */
  20555. export var pbrDirectLightingSetupFunctions: {
  20556. name: string;
  20557. shader: string;
  20558. };
  20559. }
  20560. declare module BABYLON {
  20561. /** @hidden */
  20562. export var pbrDirectLightingFalloffFunctions: {
  20563. name: string;
  20564. shader: string;
  20565. };
  20566. }
  20567. declare module BABYLON {
  20568. /** @hidden */
  20569. export var pbrBRDFFunctions: {
  20570. name: string;
  20571. shader: string;
  20572. };
  20573. }
  20574. declare module BABYLON {
  20575. /** @hidden */
  20576. export var hdrFilteringFunctions: {
  20577. name: string;
  20578. shader: string;
  20579. };
  20580. }
  20581. declare module BABYLON {
  20582. /** @hidden */
  20583. export var pbrDirectLightingFunctions: {
  20584. name: string;
  20585. shader: string;
  20586. };
  20587. }
  20588. declare module BABYLON {
  20589. /** @hidden */
  20590. export var pbrIBLFunctions: {
  20591. name: string;
  20592. shader: string;
  20593. };
  20594. }
  20595. declare module BABYLON {
  20596. /** @hidden */
  20597. export var pbrBlockAlbedoOpacity: {
  20598. name: string;
  20599. shader: string;
  20600. };
  20601. }
  20602. declare module BABYLON {
  20603. /** @hidden */
  20604. export var pbrBlockReflectivity: {
  20605. name: string;
  20606. shader: string;
  20607. };
  20608. }
  20609. declare module BABYLON {
  20610. /** @hidden */
  20611. export var pbrBlockAmbientOcclusion: {
  20612. name: string;
  20613. shader: string;
  20614. };
  20615. }
  20616. declare module BABYLON {
  20617. /** @hidden */
  20618. export var pbrBlockAlphaFresnel: {
  20619. name: string;
  20620. shader: string;
  20621. };
  20622. }
  20623. declare module BABYLON {
  20624. /** @hidden */
  20625. export var pbrBlockAnisotropic: {
  20626. name: string;
  20627. shader: string;
  20628. };
  20629. }
  20630. declare module BABYLON {
  20631. /** @hidden */
  20632. export var pbrBlockReflection: {
  20633. name: string;
  20634. shader: string;
  20635. };
  20636. }
  20637. declare module BABYLON {
  20638. /** @hidden */
  20639. export var pbrBlockSheen: {
  20640. name: string;
  20641. shader: string;
  20642. };
  20643. }
  20644. declare module BABYLON {
  20645. /** @hidden */
  20646. export var pbrBlockClearcoat: {
  20647. name: string;
  20648. shader: string;
  20649. };
  20650. }
  20651. declare module BABYLON {
  20652. /** @hidden */
  20653. export var pbrBlockSubSurface: {
  20654. name: string;
  20655. shader: string;
  20656. };
  20657. }
  20658. declare module BABYLON {
  20659. /** @hidden */
  20660. export var pbrBlockNormalGeometric: {
  20661. name: string;
  20662. shader: string;
  20663. };
  20664. }
  20665. declare module BABYLON {
  20666. /** @hidden */
  20667. export var pbrBlockNormalFinal: {
  20668. name: string;
  20669. shader: string;
  20670. };
  20671. }
  20672. declare module BABYLON {
  20673. /** @hidden */
  20674. export var pbrBlockLightmapInit: {
  20675. name: string;
  20676. shader: string;
  20677. };
  20678. }
  20679. declare module BABYLON {
  20680. /** @hidden */
  20681. export var pbrBlockGeometryInfo: {
  20682. name: string;
  20683. shader: string;
  20684. };
  20685. }
  20686. declare module BABYLON {
  20687. /** @hidden */
  20688. export var pbrBlockReflectance0: {
  20689. name: string;
  20690. shader: string;
  20691. };
  20692. }
  20693. declare module BABYLON {
  20694. /** @hidden */
  20695. export var pbrBlockReflectance: {
  20696. name: string;
  20697. shader: string;
  20698. };
  20699. }
  20700. declare module BABYLON {
  20701. /** @hidden */
  20702. export var pbrBlockDirectLighting: {
  20703. name: string;
  20704. shader: string;
  20705. };
  20706. }
  20707. declare module BABYLON {
  20708. /** @hidden */
  20709. export var pbrBlockFinalLitComponents: {
  20710. name: string;
  20711. shader: string;
  20712. };
  20713. }
  20714. declare module BABYLON {
  20715. /** @hidden */
  20716. export var pbrBlockFinalUnlitComponents: {
  20717. name: string;
  20718. shader: string;
  20719. };
  20720. }
  20721. declare module BABYLON {
  20722. /** @hidden */
  20723. export var pbrBlockFinalColorComposition: {
  20724. name: string;
  20725. shader: string;
  20726. };
  20727. }
  20728. declare module BABYLON {
  20729. /** @hidden */
  20730. export var pbrBlockImageProcessing: {
  20731. name: string;
  20732. shader: string;
  20733. };
  20734. }
  20735. declare module BABYLON {
  20736. /** @hidden */
  20737. export var pbrDebug: {
  20738. name: string;
  20739. shader: string;
  20740. };
  20741. }
  20742. declare module BABYLON {
  20743. /** @hidden */
  20744. export var pbrPixelShader: {
  20745. name: string;
  20746. shader: string;
  20747. };
  20748. }
  20749. declare module BABYLON {
  20750. /** @hidden */
  20751. export var pbrVertexDeclaration: {
  20752. name: string;
  20753. shader: string;
  20754. };
  20755. }
  20756. declare module BABYLON {
  20757. /** @hidden */
  20758. export var pbrVertexShader: {
  20759. name: string;
  20760. shader: string;
  20761. };
  20762. }
  20763. declare module BABYLON {
  20764. /**
  20765. * Manages the defines for the PBR Material.
  20766. * @hidden
  20767. */
  20768. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  20769. PBR: boolean;
  20770. NUM_SAMPLES: string;
  20771. REALTIME_FILTERING: boolean;
  20772. MAINUV1: boolean;
  20773. MAINUV2: boolean;
  20774. UV1: boolean;
  20775. UV2: boolean;
  20776. ALBEDO: boolean;
  20777. GAMMAALBEDO: boolean;
  20778. ALBEDODIRECTUV: number;
  20779. VERTEXCOLOR: boolean;
  20780. DETAIL: boolean;
  20781. DETAILDIRECTUV: number;
  20782. DETAIL_NORMALBLENDMETHOD: number;
  20783. AMBIENT: boolean;
  20784. AMBIENTDIRECTUV: number;
  20785. AMBIENTINGRAYSCALE: boolean;
  20786. OPACITY: boolean;
  20787. VERTEXALPHA: boolean;
  20788. OPACITYDIRECTUV: number;
  20789. OPACITYRGB: boolean;
  20790. ALPHATEST: boolean;
  20791. DEPTHPREPASS: boolean;
  20792. ALPHABLEND: boolean;
  20793. ALPHAFROMALBEDO: boolean;
  20794. ALPHATESTVALUE: string;
  20795. SPECULAROVERALPHA: boolean;
  20796. RADIANCEOVERALPHA: boolean;
  20797. ALPHAFRESNEL: boolean;
  20798. LINEARALPHAFRESNEL: boolean;
  20799. PREMULTIPLYALPHA: boolean;
  20800. EMISSIVE: boolean;
  20801. EMISSIVEDIRECTUV: number;
  20802. REFLECTIVITY: boolean;
  20803. REFLECTIVITYDIRECTUV: number;
  20804. SPECULARTERM: boolean;
  20805. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  20806. MICROSURFACEAUTOMATIC: boolean;
  20807. LODBASEDMICROSFURACE: boolean;
  20808. MICROSURFACEMAP: boolean;
  20809. MICROSURFACEMAPDIRECTUV: number;
  20810. METALLICWORKFLOW: boolean;
  20811. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  20812. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  20813. METALLNESSSTOREINMETALMAPBLUE: boolean;
  20814. AOSTOREINMETALMAPRED: boolean;
  20815. METALLIC_REFLECTANCE: boolean;
  20816. METALLIC_REFLECTANCEDIRECTUV: number;
  20817. ENVIRONMENTBRDF: boolean;
  20818. ENVIRONMENTBRDF_RGBD: boolean;
  20819. NORMAL: boolean;
  20820. TANGENT: boolean;
  20821. BUMP: boolean;
  20822. BUMPDIRECTUV: number;
  20823. OBJECTSPACE_NORMALMAP: boolean;
  20824. PARALLAX: boolean;
  20825. PARALLAXOCCLUSION: boolean;
  20826. NORMALXYSCALE: boolean;
  20827. LIGHTMAP: boolean;
  20828. LIGHTMAPDIRECTUV: number;
  20829. USELIGHTMAPASSHADOWMAP: boolean;
  20830. GAMMALIGHTMAP: boolean;
  20831. RGBDLIGHTMAP: boolean;
  20832. REFLECTION: boolean;
  20833. REFLECTIONMAP_3D: boolean;
  20834. REFLECTIONMAP_SPHERICAL: boolean;
  20835. REFLECTIONMAP_PLANAR: boolean;
  20836. REFLECTIONMAP_CUBIC: boolean;
  20837. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  20838. REFLECTIONMAP_PROJECTION: boolean;
  20839. REFLECTIONMAP_SKYBOX: boolean;
  20840. REFLECTIONMAP_EXPLICIT: boolean;
  20841. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  20842. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  20843. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  20844. INVERTCUBICMAP: boolean;
  20845. USESPHERICALFROMREFLECTIONMAP: boolean;
  20846. USEIRRADIANCEMAP: boolean;
  20847. SPHERICAL_HARMONICS: boolean;
  20848. USESPHERICALINVERTEX: boolean;
  20849. REFLECTIONMAP_OPPOSITEZ: boolean;
  20850. LODINREFLECTIONALPHA: boolean;
  20851. GAMMAREFLECTION: boolean;
  20852. RGBDREFLECTION: boolean;
  20853. LINEARSPECULARREFLECTION: boolean;
  20854. RADIANCEOCCLUSION: boolean;
  20855. HORIZONOCCLUSION: boolean;
  20856. INSTANCES: boolean;
  20857. THIN_INSTANCES: boolean;
  20858. PREPASS: boolean;
  20859. PREPASS_IRRADIANCE: boolean;
  20860. PREPASS_IRRADIANCE_INDEX: number;
  20861. PREPASS_ALBEDO: boolean;
  20862. PREPASS_ALBEDO_INDEX: number;
  20863. PREPASS_DEPTHNORMAL: boolean;
  20864. PREPASS_DEPTHNORMAL_INDEX: number;
  20865. PREPASS_POSITION: boolean;
  20866. PREPASS_POSITION_INDEX: number;
  20867. PREPASS_VELOCITY: boolean;
  20868. PREPASS_VELOCITY_INDEX: number;
  20869. PREPASS_REFLECTIVITY: boolean;
  20870. PREPASS_REFLECTIVITY_INDEX: number;
  20871. SCENE_MRT_COUNT: number;
  20872. NUM_BONE_INFLUENCERS: number;
  20873. BonesPerMesh: number;
  20874. BONETEXTURE: boolean;
  20875. BONES_VELOCITY_ENABLED: boolean;
  20876. NONUNIFORMSCALING: boolean;
  20877. MORPHTARGETS: boolean;
  20878. MORPHTARGETS_NORMAL: boolean;
  20879. MORPHTARGETS_TANGENT: boolean;
  20880. MORPHTARGETS_UV: boolean;
  20881. NUM_MORPH_INFLUENCERS: number;
  20882. IMAGEPROCESSING: boolean;
  20883. VIGNETTE: boolean;
  20884. VIGNETTEBLENDMODEMULTIPLY: boolean;
  20885. VIGNETTEBLENDMODEOPAQUE: boolean;
  20886. TONEMAPPING: boolean;
  20887. TONEMAPPING_ACES: boolean;
  20888. CONTRAST: boolean;
  20889. COLORCURVES: boolean;
  20890. COLORGRADING: boolean;
  20891. COLORGRADING3D: boolean;
  20892. SAMPLER3DGREENDEPTH: boolean;
  20893. SAMPLER3DBGRMAP: boolean;
  20894. IMAGEPROCESSINGPOSTPROCESS: boolean;
  20895. EXPOSURE: boolean;
  20896. MULTIVIEW: boolean;
  20897. USEPHYSICALLIGHTFALLOFF: boolean;
  20898. USEGLTFLIGHTFALLOFF: boolean;
  20899. TWOSIDEDLIGHTING: boolean;
  20900. SHADOWFLOAT: boolean;
  20901. CLIPPLANE: boolean;
  20902. CLIPPLANE2: boolean;
  20903. CLIPPLANE3: boolean;
  20904. CLIPPLANE4: boolean;
  20905. CLIPPLANE5: boolean;
  20906. CLIPPLANE6: boolean;
  20907. POINTSIZE: boolean;
  20908. FOG: boolean;
  20909. LOGARITHMICDEPTH: boolean;
  20910. FORCENORMALFORWARD: boolean;
  20911. SPECULARAA: boolean;
  20912. CLEARCOAT: boolean;
  20913. CLEARCOAT_DEFAULTIOR: boolean;
  20914. CLEARCOAT_TEXTURE: boolean;
  20915. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  20916. CLEARCOAT_TEXTUREDIRECTUV: number;
  20917. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  20918. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20919. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20920. CLEARCOAT_BUMP: boolean;
  20921. CLEARCOAT_BUMPDIRECTUV: number;
  20922. CLEARCOAT_REMAP_F0: boolean;
  20923. CLEARCOAT_TINT: boolean;
  20924. CLEARCOAT_TINT_TEXTURE: boolean;
  20925. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  20926. ANISOTROPIC: boolean;
  20927. ANISOTROPIC_TEXTURE: boolean;
  20928. ANISOTROPIC_TEXTUREDIRECTUV: number;
  20929. BRDF_V_HEIGHT_CORRELATED: boolean;
  20930. MS_BRDF_ENERGY_CONSERVATION: boolean;
  20931. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  20932. SHEEN: boolean;
  20933. SHEEN_TEXTURE: boolean;
  20934. SHEEN_TEXTURE_ROUGHNESS: boolean;
  20935. SHEEN_TEXTUREDIRECTUV: number;
  20936. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  20937. SHEEN_LINKWITHALBEDO: boolean;
  20938. SHEEN_ROUGHNESS: boolean;
  20939. SHEEN_ALBEDOSCALING: boolean;
  20940. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20941. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20942. SUBSURFACE: boolean;
  20943. SS_REFRACTION: boolean;
  20944. SS_TRANSLUCENCY: boolean;
  20945. SS_SCATTERING: boolean;
  20946. SS_THICKNESSANDMASK_TEXTURE: boolean;
  20947. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  20948. SS_REFRACTIONMAP_3D: boolean;
  20949. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  20950. SS_LODINREFRACTIONALPHA: boolean;
  20951. SS_GAMMAREFRACTION: boolean;
  20952. SS_RGBDREFRACTION: boolean;
  20953. SS_LINEARSPECULARREFRACTION: boolean;
  20954. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  20955. SS_ALBEDOFORREFRACTIONTINT: boolean;
  20956. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  20957. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  20958. UNLIT: boolean;
  20959. DEBUGMODE: number;
  20960. /**
  20961. * Initializes the PBR Material defines.
  20962. */
  20963. constructor();
  20964. /**
  20965. * Resets the PBR Material defines.
  20966. */
  20967. reset(): void;
  20968. }
  20969. /**
  20970. * The Physically based material base class of BJS.
  20971. *
  20972. * This offers the main features of a standard PBR material.
  20973. * For more information, please refer to the documentation :
  20974. * https://doc.babylonjs.com/how_to/physically_based_rendering
  20975. */
  20976. export abstract class PBRBaseMaterial extends PushMaterial {
  20977. /**
  20978. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  20979. */
  20980. static readonly PBRMATERIAL_OPAQUE: number;
  20981. /**
  20982. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  20983. */
  20984. static readonly PBRMATERIAL_ALPHATEST: number;
  20985. /**
  20986. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  20987. */
  20988. static readonly PBRMATERIAL_ALPHABLEND: number;
  20989. /**
  20990. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  20991. * They are also discarded below the alpha cutoff threshold to improve performances.
  20992. */
  20993. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  20994. /**
  20995. * Defines the default value of how much AO map is occluding the analytical lights
  20996. * (point spot...).
  20997. */
  20998. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  20999. /**
  21000. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  21001. */
  21002. static readonly LIGHTFALLOFF_PHYSICAL: number;
  21003. /**
  21004. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  21005. * to enhance interoperability with other engines.
  21006. */
  21007. static readonly LIGHTFALLOFF_GLTF: number;
  21008. /**
  21009. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  21010. * to enhance interoperability with other materials.
  21011. */
  21012. static readonly LIGHTFALLOFF_STANDARD: number;
  21013. /**
  21014. * Intensity of the direct lights e.g. the four lights available in your scene.
  21015. * This impacts both the direct diffuse and specular highlights.
  21016. */
  21017. protected _directIntensity: number;
  21018. /**
  21019. * Intensity of the emissive part of the material.
  21020. * This helps controlling the emissive effect without modifying the emissive color.
  21021. */
  21022. protected _emissiveIntensity: number;
  21023. /**
  21024. * Intensity of the environment e.g. how much the environment will light the object
  21025. * either through harmonics for rough material or through the refelction for shiny ones.
  21026. */
  21027. protected _environmentIntensity: number;
  21028. /**
  21029. * This is a special control allowing the reduction of the specular highlights coming from the
  21030. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  21031. */
  21032. protected _specularIntensity: number;
  21033. /**
  21034. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  21035. */
  21036. private _lightingInfos;
  21037. /**
  21038. * Debug Control allowing disabling the bump map on this material.
  21039. */
  21040. protected _disableBumpMap: boolean;
  21041. /**
  21042. * AKA Diffuse Texture in standard nomenclature.
  21043. */
  21044. protected _albedoTexture: Nullable<BaseTexture>;
  21045. /**
  21046. * AKA Occlusion Texture in other nomenclature.
  21047. */
  21048. protected _ambientTexture: Nullable<BaseTexture>;
  21049. /**
  21050. * AKA Occlusion Texture Intensity in other nomenclature.
  21051. */
  21052. protected _ambientTextureStrength: number;
  21053. /**
  21054. * Defines how much the AO map is occluding the analytical lights (point spot...).
  21055. * 1 means it completely occludes it
  21056. * 0 mean it has no impact
  21057. */
  21058. protected _ambientTextureImpactOnAnalyticalLights: number;
  21059. /**
  21060. * Stores the alpha values in a texture.
  21061. */
  21062. protected _opacityTexture: Nullable<BaseTexture>;
  21063. /**
  21064. * Stores the reflection values in a texture.
  21065. */
  21066. protected _reflectionTexture: Nullable<BaseTexture>;
  21067. /**
  21068. * Stores the emissive values in a texture.
  21069. */
  21070. protected _emissiveTexture: Nullable<BaseTexture>;
  21071. /**
  21072. * AKA Specular texture in other nomenclature.
  21073. */
  21074. protected _reflectivityTexture: Nullable<BaseTexture>;
  21075. /**
  21076. * Used to switch from specular/glossiness to metallic/roughness workflow.
  21077. */
  21078. protected _metallicTexture: Nullable<BaseTexture>;
  21079. /**
  21080. * Specifies the metallic scalar of the metallic/roughness workflow.
  21081. * Can also be used to scale the metalness values of the metallic texture.
  21082. */
  21083. protected _metallic: Nullable<number>;
  21084. /**
  21085. * Specifies the roughness scalar of the metallic/roughness workflow.
  21086. * Can also be used to scale the roughness values of the metallic texture.
  21087. */
  21088. protected _roughness: Nullable<number>;
  21089. /**
  21090. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  21091. * By default the indexOfrefraction is used to compute F0;
  21092. *
  21093. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  21094. *
  21095. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  21096. * F90 = metallicReflectanceColor;
  21097. */
  21098. protected _metallicF0Factor: number;
  21099. /**
  21100. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  21101. * By default the F90 is always 1;
  21102. *
  21103. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  21104. *
  21105. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  21106. * F90 = metallicReflectanceColor;
  21107. */
  21108. protected _metallicReflectanceColor: Color3;
  21109. /**
  21110. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  21111. * This is multiply against the scalar values defined in the material.
  21112. */
  21113. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  21114. /**
  21115. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  21116. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  21117. */
  21118. protected _microSurfaceTexture: Nullable<BaseTexture>;
  21119. /**
  21120. * Stores surface normal data used to displace a mesh in a texture.
  21121. */
  21122. protected _bumpTexture: Nullable<BaseTexture>;
  21123. /**
  21124. * Stores the pre-calculated light information of a mesh in a texture.
  21125. */
  21126. protected _lightmapTexture: Nullable<BaseTexture>;
  21127. /**
  21128. * The color of a material in ambient lighting.
  21129. */
  21130. protected _ambientColor: Color3;
  21131. /**
  21132. * AKA Diffuse Color in other nomenclature.
  21133. */
  21134. protected _albedoColor: Color3;
  21135. /**
  21136. * AKA Specular Color in other nomenclature.
  21137. */
  21138. protected _reflectivityColor: Color3;
  21139. /**
  21140. * The color applied when light is reflected from a material.
  21141. */
  21142. protected _reflectionColor: Color3;
  21143. /**
  21144. * The color applied when light is emitted from a material.
  21145. */
  21146. protected _emissiveColor: Color3;
  21147. /**
  21148. * AKA Glossiness in other nomenclature.
  21149. */
  21150. protected _microSurface: number;
  21151. /**
  21152. * Specifies that the material will use the light map as a show map.
  21153. */
  21154. protected _useLightmapAsShadowmap: boolean;
  21155. /**
  21156. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  21157. * makes the reflect vector face the model (under horizon).
  21158. */
  21159. protected _useHorizonOcclusion: boolean;
  21160. /**
  21161. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  21162. * too much the area relying on ambient texture to define their ambient occlusion.
  21163. */
  21164. protected _useRadianceOcclusion: boolean;
  21165. /**
  21166. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  21167. */
  21168. protected _useAlphaFromAlbedoTexture: boolean;
  21169. /**
  21170. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  21171. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  21172. */
  21173. protected _useSpecularOverAlpha: boolean;
  21174. /**
  21175. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  21176. */
  21177. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  21178. /**
  21179. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  21180. */
  21181. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  21182. /**
  21183. * Specifies if the metallic texture contains the roughness information in its green channel.
  21184. */
  21185. protected _useRoughnessFromMetallicTextureGreen: boolean;
  21186. /**
  21187. * Specifies if the metallic texture contains the metallness information in its blue channel.
  21188. */
  21189. protected _useMetallnessFromMetallicTextureBlue: boolean;
  21190. /**
  21191. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  21192. */
  21193. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  21194. /**
  21195. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  21196. */
  21197. protected _useAmbientInGrayScale: boolean;
  21198. /**
  21199. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  21200. * The material will try to infer what glossiness each pixel should be.
  21201. */
  21202. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  21203. /**
  21204. * Defines the falloff type used in this material.
  21205. * It by default is Physical.
  21206. */
  21207. protected _lightFalloff: number;
  21208. /**
  21209. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  21210. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  21211. */
  21212. protected _useRadianceOverAlpha: boolean;
  21213. /**
  21214. * Allows using an object space normal map (instead of tangent space).
  21215. */
  21216. protected _useObjectSpaceNormalMap: boolean;
  21217. /**
  21218. * Allows using the bump map in parallax mode.
  21219. */
  21220. protected _useParallax: boolean;
  21221. /**
  21222. * Allows using the bump map in parallax occlusion mode.
  21223. */
  21224. protected _useParallaxOcclusion: boolean;
  21225. /**
  21226. * Controls the scale bias of the parallax mode.
  21227. */
  21228. protected _parallaxScaleBias: number;
  21229. /**
  21230. * If sets to true, disables all the lights affecting the material.
  21231. */
  21232. protected _disableLighting: boolean;
  21233. /**
  21234. * Number of Simultaneous lights allowed on the material.
  21235. */
  21236. protected _maxSimultaneousLights: number;
  21237. /**
  21238. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  21239. */
  21240. protected _invertNormalMapX: boolean;
  21241. /**
  21242. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  21243. */
  21244. protected _invertNormalMapY: boolean;
  21245. /**
  21246. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  21247. */
  21248. protected _twoSidedLighting: boolean;
  21249. /**
  21250. * Defines the alpha limits in alpha test mode.
  21251. */
  21252. protected _alphaCutOff: number;
  21253. /**
  21254. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21255. */
  21256. protected _forceAlphaTest: boolean;
  21257. /**
  21258. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  21259. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  21260. */
  21261. protected _useAlphaFresnel: boolean;
  21262. /**
  21263. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  21264. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  21265. */
  21266. protected _useLinearAlphaFresnel: boolean;
  21267. /**
  21268. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  21269. * from cos thetav and roughness:
  21270. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  21271. */
  21272. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  21273. /**
  21274. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  21275. */
  21276. protected _forceIrradianceInFragment: boolean;
  21277. private _realTimeFiltering;
  21278. /**
  21279. * Enables realtime filtering on the texture.
  21280. */
  21281. get realTimeFiltering(): boolean;
  21282. set realTimeFiltering(b: boolean);
  21283. private _realTimeFilteringQuality;
  21284. /**
  21285. * Quality switch for realtime filtering
  21286. */
  21287. get realTimeFilteringQuality(): number;
  21288. set realTimeFilteringQuality(n: number);
  21289. /**
  21290. * Can this material render to several textures at once
  21291. */
  21292. get canRenderToMRT(): boolean;
  21293. /**
  21294. * Force normal to face away from face.
  21295. */
  21296. protected _forceNormalForward: boolean;
  21297. /**
  21298. * Enables specular anti aliasing in the PBR shader.
  21299. * It will both interacts on the Geometry for analytical and IBL lighting.
  21300. * It also prefilter the roughness map based on the bump values.
  21301. */
  21302. protected _enableSpecularAntiAliasing: boolean;
  21303. /**
  21304. * Default configuration related to image processing available in the PBR Material.
  21305. */
  21306. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  21307. /**
  21308. * Keep track of the image processing observer to allow dispose and replace.
  21309. */
  21310. private _imageProcessingObserver;
  21311. /**
  21312. * Attaches a new image processing configuration to the PBR Material.
  21313. * @param configuration
  21314. */
  21315. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  21316. /**
  21317. * Stores the available render targets.
  21318. */
  21319. private _renderTargets;
  21320. /**
  21321. * Sets the global ambient color for the material used in lighting calculations.
  21322. */
  21323. private _globalAmbientColor;
  21324. /**
  21325. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  21326. */
  21327. private _useLogarithmicDepth;
  21328. /**
  21329. * If set to true, no lighting calculations will be applied.
  21330. */
  21331. private _unlit;
  21332. private _debugMode;
  21333. /**
  21334. * @hidden
  21335. * This is reserved for the inspector.
  21336. * Defines the material debug mode.
  21337. * It helps seeing only some components of the material while troubleshooting.
  21338. */
  21339. debugMode: number;
  21340. /**
  21341. * @hidden
  21342. * This is reserved for the inspector.
  21343. * Specify from where on screen the debug mode should start.
  21344. * The value goes from -1 (full screen) to 1 (not visible)
  21345. * It helps with side by side comparison against the final render
  21346. * This defaults to -1
  21347. */
  21348. private debugLimit;
  21349. /**
  21350. * @hidden
  21351. * This is reserved for the inspector.
  21352. * As the default viewing range might not be enough (if the ambient is really small for instance)
  21353. * You can use the factor to better multiply the final value.
  21354. */
  21355. private debugFactor;
  21356. /**
  21357. * Defines the clear coat layer parameters for the material.
  21358. */
  21359. readonly clearCoat: PBRClearCoatConfiguration;
  21360. /**
  21361. * Defines the anisotropic parameters for the material.
  21362. */
  21363. readonly anisotropy: PBRAnisotropicConfiguration;
  21364. /**
  21365. * Defines the BRDF parameters for the material.
  21366. */
  21367. readonly brdf: PBRBRDFConfiguration;
  21368. /**
  21369. * Defines the Sheen parameters for the material.
  21370. */
  21371. readonly sheen: PBRSheenConfiguration;
  21372. /**
  21373. * Defines the SubSurface parameters for the material.
  21374. */
  21375. readonly subSurface: PBRSubSurfaceConfiguration;
  21376. /**
  21377. * Defines additionnal PrePass parameters for the material.
  21378. */
  21379. readonly prePassConfiguration: PrePassConfiguration;
  21380. /**
  21381. * Defines the detail map parameters for the material.
  21382. */
  21383. readonly detailMap: DetailMapConfiguration;
  21384. protected _rebuildInParallel: boolean;
  21385. /**
  21386. * Instantiates a new PBRMaterial instance.
  21387. *
  21388. * @param name The material name
  21389. * @param scene The scene the material will be use in.
  21390. */
  21391. constructor(name: string, scene: Scene);
  21392. /**
  21393. * Gets a boolean indicating that current material needs to register RTT
  21394. */
  21395. get hasRenderTargetTextures(): boolean;
  21396. /**
  21397. * Gets the name of the material class.
  21398. */
  21399. getClassName(): string;
  21400. /**
  21401. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  21402. */
  21403. get useLogarithmicDepth(): boolean;
  21404. /**
  21405. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  21406. */
  21407. set useLogarithmicDepth(value: boolean);
  21408. /**
  21409. * Returns true if alpha blending should be disabled.
  21410. */
  21411. protected get _disableAlphaBlending(): boolean;
  21412. /**
  21413. * Specifies whether or not this material should be rendered in alpha blend mode.
  21414. */
  21415. needAlphaBlending(): boolean;
  21416. /**
  21417. * Specifies whether or not this material should be rendered in alpha test mode.
  21418. */
  21419. needAlphaTesting(): boolean;
  21420. /**
  21421. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  21422. */
  21423. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  21424. /**
  21425. * Specifies whether or not there is a usable alpha channel for transparency.
  21426. */
  21427. protected _hasAlphaChannel(): boolean;
  21428. /**
  21429. * Gets the texture used for the alpha test.
  21430. */
  21431. getAlphaTestTexture(): Nullable<BaseTexture>;
  21432. /**
  21433. * Specifies that the submesh is ready to be used.
  21434. * @param mesh - BJS mesh.
  21435. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  21436. * @param useInstances - Specifies that instances should be used.
  21437. * @returns - boolean indicating that the submesh is ready or not.
  21438. */
  21439. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  21440. /**
  21441. * Specifies if the material uses metallic roughness workflow.
  21442. * @returns boolean specifiying if the material uses metallic roughness workflow.
  21443. */
  21444. isMetallicWorkflow(): boolean;
  21445. private _prepareEffect;
  21446. private _prepareDefines;
  21447. /**
  21448. * Force shader compilation
  21449. */
  21450. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  21451. /**
  21452. * Initializes the uniform buffer layout for the shader.
  21453. */
  21454. buildUniformLayout(): void;
  21455. /**
  21456. * Unbinds the material from the mesh
  21457. */
  21458. unbind(): void;
  21459. /**
  21460. * Binds the submesh data.
  21461. * @param world - The world matrix.
  21462. * @param mesh - The BJS mesh.
  21463. * @param subMesh - A submesh of the BJS mesh.
  21464. */
  21465. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21466. /**
  21467. * Returns the animatable textures.
  21468. * @returns - Array of animatable textures.
  21469. */
  21470. getAnimatables(): IAnimatable[];
  21471. /**
  21472. * Returns the texture used for reflections.
  21473. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  21474. */
  21475. private _getReflectionTexture;
  21476. /**
  21477. * Returns an array of the actively used textures.
  21478. * @returns - Array of BaseTextures
  21479. */
  21480. getActiveTextures(): BaseTexture[];
  21481. /**
  21482. * Checks to see if a texture is used in the material.
  21483. * @param texture - Base texture to use.
  21484. * @returns - Boolean specifying if a texture is used in the material.
  21485. */
  21486. hasTexture(texture: BaseTexture): boolean;
  21487. /**
  21488. * Sets the required values to the prepass renderer.
  21489. * @param prePassRenderer defines the prepass renderer to setup
  21490. */
  21491. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  21492. /**
  21493. * Disposes the resources of the material.
  21494. * @param forceDisposeEffect - Forces the disposal of effects.
  21495. * @param forceDisposeTextures - Forces the disposal of all textures.
  21496. */
  21497. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  21498. }
  21499. }
  21500. declare module BABYLON {
  21501. /**
  21502. * The Physically based material of BJS.
  21503. *
  21504. * This offers the main features of a standard PBR material.
  21505. * For more information, please refer to the documentation :
  21506. * https://doc.babylonjs.com/how_to/physically_based_rendering
  21507. */
  21508. export class PBRMaterial extends PBRBaseMaterial {
  21509. /**
  21510. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21511. */
  21512. static readonly PBRMATERIAL_OPAQUE: number;
  21513. /**
  21514. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21515. */
  21516. static readonly PBRMATERIAL_ALPHATEST: number;
  21517. /**
  21518. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21519. */
  21520. static readonly PBRMATERIAL_ALPHABLEND: number;
  21521. /**
  21522. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21523. * They are also discarded below the alpha cutoff threshold to improve performances.
  21524. */
  21525. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  21526. /**
  21527. * Defines the default value of how much AO map is occluding the analytical lights
  21528. * (point spot...).
  21529. */
  21530. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  21531. /**
  21532. * Intensity of the direct lights e.g. the four lights available in your scene.
  21533. * This impacts both the direct diffuse and specular highlights.
  21534. */
  21535. directIntensity: number;
  21536. /**
  21537. * Intensity of the emissive part of the material.
  21538. * This helps controlling the emissive effect without modifying the emissive color.
  21539. */
  21540. emissiveIntensity: number;
  21541. /**
  21542. * Intensity of the environment e.g. how much the environment will light the object
  21543. * either through harmonics for rough material or through the refelction for shiny ones.
  21544. */
  21545. environmentIntensity: number;
  21546. /**
  21547. * This is a special control allowing the reduction of the specular highlights coming from the
  21548. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  21549. */
  21550. specularIntensity: number;
  21551. /**
  21552. * Debug Control allowing disabling the bump map on this material.
  21553. */
  21554. disableBumpMap: boolean;
  21555. /**
  21556. * AKA Diffuse Texture in standard nomenclature.
  21557. */
  21558. albedoTexture: BaseTexture;
  21559. /**
  21560. * AKA Occlusion Texture in other nomenclature.
  21561. */
  21562. ambientTexture: BaseTexture;
  21563. /**
  21564. * AKA Occlusion Texture Intensity in other nomenclature.
  21565. */
  21566. ambientTextureStrength: number;
  21567. /**
  21568. * Defines how much the AO map is occluding the analytical lights (point spot...).
  21569. * 1 means it completely occludes it
  21570. * 0 mean it has no impact
  21571. */
  21572. ambientTextureImpactOnAnalyticalLights: number;
  21573. /**
  21574. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  21575. */
  21576. opacityTexture: BaseTexture;
  21577. /**
  21578. * Stores the reflection values in a texture.
  21579. */
  21580. reflectionTexture: Nullable<BaseTexture>;
  21581. /**
  21582. * Stores the emissive values in a texture.
  21583. */
  21584. emissiveTexture: BaseTexture;
  21585. /**
  21586. * AKA Specular texture in other nomenclature.
  21587. */
  21588. reflectivityTexture: BaseTexture;
  21589. /**
  21590. * Used to switch from specular/glossiness to metallic/roughness workflow.
  21591. */
  21592. metallicTexture: BaseTexture;
  21593. /**
  21594. * Specifies the metallic scalar of the metallic/roughness workflow.
  21595. * Can also be used to scale the metalness values of the metallic texture.
  21596. */
  21597. metallic: Nullable<number>;
  21598. /**
  21599. * Specifies the roughness scalar of the metallic/roughness workflow.
  21600. * Can also be used to scale the roughness values of the metallic texture.
  21601. */
  21602. roughness: Nullable<number>;
  21603. /**
  21604. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  21605. * By default the indexOfrefraction is used to compute F0;
  21606. *
  21607. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  21608. *
  21609. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  21610. * F90 = metallicReflectanceColor;
  21611. */
  21612. metallicF0Factor: number;
  21613. /**
  21614. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  21615. * By default the F90 is always 1;
  21616. *
  21617. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  21618. *
  21619. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  21620. * F90 = metallicReflectanceColor;
  21621. */
  21622. metallicReflectanceColor: Color3;
  21623. /**
  21624. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  21625. * This is multiply against the scalar values defined in the material.
  21626. */
  21627. metallicReflectanceTexture: Nullable<BaseTexture>;
  21628. /**
  21629. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  21630. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  21631. */
  21632. microSurfaceTexture: BaseTexture;
  21633. /**
  21634. * Stores surface normal data used to displace a mesh in a texture.
  21635. */
  21636. bumpTexture: BaseTexture;
  21637. /**
  21638. * Stores the pre-calculated light information of a mesh in a texture.
  21639. */
  21640. lightmapTexture: BaseTexture;
  21641. /**
  21642. * Stores the refracted light information in a texture.
  21643. */
  21644. get refractionTexture(): Nullable<BaseTexture>;
  21645. set refractionTexture(value: Nullable<BaseTexture>);
  21646. /**
  21647. * The color of a material in ambient lighting.
  21648. */
  21649. ambientColor: Color3;
  21650. /**
  21651. * AKA Diffuse Color in other nomenclature.
  21652. */
  21653. albedoColor: Color3;
  21654. /**
  21655. * AKA Specular Color in other nomenclature.
  21656. */
  21657. reflectivityColor: Color3;
  21658. /**
  21659. * The color reflected from the material.
  21660. */
  21661. reflectionColor: Color3;
  21662. /**
  21663. * The color emitted from the material.
  21664. */
  21665. emissiveColor: Color3;
  21666. /**
  21667. * AKA Glossiness in other nomenclature.
  21668. */
  21669. microSurface: number;
  21670. /**
  21671. * Index of refraction of the material base layer.
  21672. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  21673. *
  21674. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  21675. *
  21676. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  21677. */
  21678. get indexOfRefraction(): number;
  21679. set indexOfRefraction(value: number);
  21680. /**
  21681. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21682. */
  21683. get invertRefractionY(): boolean;
  21684. set invertRefractionY(value: boolean);
  21685. /**
  21686. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21687. * Materials half opaque for instance using refraction could benefit from this control.
  21688. */
  21689. get linkRefractionWithTransparency(): boolean;
  21690. set linkRefractionWithTransparency(value: boolean);
  21691. /**
  21692. * If true, the light map contains occlusion information instead of lighting info.
  21693. */
  21694. useLightmapAsShadowmap: boolean;
  21695. /**
  21696. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  21697. */
  21698. useAlphaFromAlbedoTexture: boolean;
  21699. /**
  21700. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21701. */
  21702. forceAlphaTest: boolean;
  21703. /**
  21704. * Defines the alpha limits in alpha test mode.
  21705. */
  21706. alphaCutOff: number;
  21707. /**
  21708. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  21709. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  21710. */
  21711. useSpecularOverAlpha: boolean;
  21712. /**
  21713. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  21714. */
  21715. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  21716. /**
  21717. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  21718. */
  21719. useRoughnessFromMetallicTextureAlpha: boolean;
  21720. /**
  21721. * Specifies if the metallic texture contains the roughness information in its green channel.
  21722. */
  21723. useRoughnessFromMetallicTextureGreen: boolean;
  21724. /**
  21725. * Specifies if the metallic texture contains the metallness information in its blue channel.
  21726. */
  21727. useMetallnessFromMetallicTextureBlue: boolean;
  21728. /**
  21729. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  21730. */
  21731. useAmbientOcclusionFromMetallicTextureRed: boolean;
  21732. /**
  21733. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  21734. */
  21735. useAmbientInGrayScale: boolean;
  21736. /**
  21737. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  21738. * The material will try to infer what glossiness each pixel should be.
  21739. */
  21740. useAutoMicroSurfaceFromReflectivityMap: boolean;
  21741. /**
  21742. * BJS is using an harcoded light falloff based on a manually sets up range.
  21743. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  21744. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  21745. */
  21746. get usePhysicalLightFalloff(): boolean;
  21747. /**
  21748. * BJS is using an harcoded light falloff based on a manually sets up range.
  21749. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  21750. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  21751. */
  21752. set usePhysicalLightFalloff(value: boolean);
  21753. /**
  21754. * In order to support the falloff compatibility with gltf, a special mode has been added
  21755. * to reproduce the gltf light falloff.
  21756. */
  21757. get useGLTFLightFalloff(): boolean;
  21758. /**
  21759. * In order to support the falloff compatibility with gltf, a special mode has been added
  21760. * to reproduce the gltf light falloff.
  21761. */
  21762. set useGLTFLightFalloff(value: boolean);
  21763. /**
  21764. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  21765. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  21766. */
  21767. useRadianceOverAlpha: boolean;
  21768. /**
  21769. * Allows using an object space normal map (instead of tangent space).
  21770. */
  21771. useObjectSpaceNormalMap: boolean;
  21772. /**
  21773. * Allows using the bump map in parallax mode.
  21774. */
  21775. useParallax: boolean;
  21776. /**
  21777. * Allows using the bump map in parallax occlusion mode.
  21778. */
  21779. useParallaxOcclusion: boolean;
  21780. /**
  21781. * Controls the scale bias of the parallax mode.
  21782. */
  21783. parallaxScaleBias: number;
  21784. /**
  21785. * If sets to true, disables all the lights affecting the material.
  21786. */
  21787. disableLighting: boolean;
  21788. /**
  21789. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  21790. */
  21791. forceIrradianceInFragment: boolean;
  21792. /**
  21793. * Number of Simultaneous lights allowed on the material.
  21794. */
  21795. maxSimultaneousLights: number;
  21796. /**
  21797. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  21798. */
  21799. invertNormalMapX: boolean;
  21800. /**
  21801. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  21802. */
  21803. invertNormalMapY: boolean;
  21804. /**
  21805. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  21806. */
  21807. twoSidedLighting: boolean;
  21808. /**
  21809. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  21810. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  21811. */
  21812. useAlphaFresnel: boolean;
  21813. /**
  21814. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  21815. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  21816. */
  21817. useLinearAlphaFresnel: boolean;
  21818. /**
  21819. * Let user defines the brdf lookup texture used for IBL.
  21820. * A default 8bit version is embedded but you could point at :
  21821. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  21822. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  21823. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  21824. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  21825. */
  21826. environmentBRDFTexture: Nullable<BaseTexture>;
  21827. /**
  21828. * Force normal to face away from face.
  21829. */
  21830. forceNormalForward: boolean;
  21831. /**
  21832. * Enables specular anti aliasing in the PBR shader.
  21833. * It will both interacts on the Geometry for analytical and IBL lighting.
  21834. * It also prefilter the roughness map based on the bump values.
  21835. */
  21836. enableSpecularAntiAliasing: boolean;
  21837. /**
  21838. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  21839. * makes the reflect vector face the model (under horizon).
  21840. */
  21841. useHorizonOcclusion: boolean;
  21842. /**
  21843. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  21844. * too much the area relying on ambient texture to define their ambient occlusion.
  21845. */
  21846. useRadianceOcclusion: boolean;
  21847. /**
  21848. * If set to true, no lighting calculations will be applied.
  21849. */
  21850. unlit: boolean;
  21851. /**
  21852. * Gets the image processing configuration used either in this material.
  21853. */
  21854. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  21855. /**
  21856. * Sets the Default image processing configuration used either in the this material.
  21857. *
  21858. * If sets to null, the scene one is in use.
  21859. */
  21860. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  21861. /**
  21862. * Gets wether the color curves effect is enabled.
  21863. */
  21864. get cameraColorCurvesEnabled(): boolean;
  21865. /**
  21866. * Sets wether the color curves effect is enabled.
  21867. */
  21868. set cameraColorCurvesEnabled(value: boolean);
  21869. /**
  21870. * Gets wether the color grading effect is enabled.
  21871. */
  21872. get cameraColorGradingEnabled(): boolean;
  21873. /**
  21874. * Gets wether the color grading effect is enabled.
  21875. */
  21876. set cameraColorGradingEnabled(value: boolean);
  21877. /**
  21878. * Gets wether tonemapping is enabled or not.
  21879. */
  21880. get cameraToneMappingEnabled(): boolean;
  21881. /**
  21882. * Sets wether tonemapping is enabled or not
  21883. */
  21884. set cameraToneMappingEnabled(value: boolean);
  21885. /**
  21886. * The camera exposure used on this material.
  21887. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  21888. * This corresponds to a photographic exposure.
  21889. */
  21890. get cameraExposure(): number;
  21891. /**
  21892. * The camera exposure used on this material.
  21893. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  21894. * This corresponds to a photographic exposure.
  21895. */
  21896. set cameraExposure(value: number);
  21897. /**
  21898. * Gets The camera contrast used on this material.
  21899. */
  21900. get cameraContrast(): number;
  21901. /**
  21902. * Sets The camera contrast used on this material.
  21903. */
  21904. set cameraContrast(value: number);
  21905. /**
  21906. * Gets the Color Grading 2D Lookup Texture.
  21907. */
  21908. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  21909. /**
  21910. * Sets the Color Grading 2D Lookup Texture.
  21911. */
  21912. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  21913. /**
  21914. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  21915. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  21916. * 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;
  21917. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  21918. */
  21919. get cameraColorCurves(): Nullable<ColorCurves>;
  21920. /**
  21921. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  21922. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  21923. * 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;
  21924. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  21925. */
  21926. set cameraColorCurves(value: Nullable<ColorCurves>);
  21927. /**
  21928. * Instantiates a new PBRMaterial instance.
  21929. *
  21930. * @param name The material name
  21931. * @param scene The scene the material will be use in.
  21932. */
  21933. constructor(name: string, scene: Scene);
  21934. /**
  21935. * Returns the name of this material class.
  21936. */
  21937. getClassName(): string;
  21938. /**
  21939. * Makes a duplicate of the current material.
  21940. * @param name - name to use for the new material.
  21941. */
  21942. clone(name: string): PBRMaterial;
  21943. /**
  21944. * Serializes this PBR Material.
  21945. * @returns - An object with the serialized material.
  21946. */
  21947. serialize(): any;
  21948. /**
  21949. * Parses a PBR Material from a serialized object.
  21950. * @param source - Serialized object.
  21951. * @param scene - BJS scene instance.
  21952. * @param rootUrl - url for the scene object
  21953. * @returns - PBRMaterial
  21954. */
  21955. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  21956. }
  21957. }
  21958. declare module BABYLON {
  21959. /** @hidden */
  21960. export var mrtFragmentDeclaration: {
  21961. name: string;
  21962. shader: string;
  21963. };
  21964. }
  21965. declare module BABYLON {
  21966. /** @hidden */
  21967. export var geometryPixelShader: {
  21968. name: string;
  21969. shader: string;
  21970. };
  21971. }
  21972. declare module BABYLON {
  21973. /** @hidden */
  21974. export var geometryVertexShader: {
  21975. name: string;
  21976. shader: string;
  21977. };
  21978. }
  21979. declare module BABYLON {
  21980. /** @hidden */
  21981. interface ISavedTransformationMatrix {
  21982. world: Matrix;
  21983. viewProjection: Matrix;
  21984. }
  21985. /**
  21986. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  21987. */
  21988. export class GeometryBufferRenderer {
  21989. /**
  21990. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  21991. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  21992. */
  21993. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  21994. /**
  21995. * Constant used to retrieve the position texture index in the G-Buffer textures array
  21996. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  21997. */
  21998. static readonly POSITION_TEXTURE_TYPE: number;
  21999. /**
  22000. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  22001. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  22002. */
  22003. static readonly VELOCITY_TEXTURE_TYPE: number;
  22004. /**
  22005. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  22006. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  22007. */
  22008. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  22009. /**
  22010. * Dictionary used to store the previous transformation matrices of each rendered mesh
  22011. * in order to compute objects velocities when enableVelocity is set to "true"
  22012. * @hidden
  22013. */
  22014. _previousTransformationMatrices: {
  22015. [index: number]: ISavedTransformationMatrix;
  22016. };
  22017. /**
  22018. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  22019. * in order to compute objects velocities when enableVelocity is set to "true"
  22020. * @hidden
  22021. */
  22022. _previousBonesTransformationMatrices: {
  22023. [index: number]: Float32Array;
  22024. };
  22025. /**
  22026. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  22027. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  22028. */
  22029. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  22030. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  22031. renderTransparentMeshes: boolean;
  22032. private _scene;
  22033. private _resizeObserver;
  22034. private _multiRenderTarget;
  22035. private _ratio;
  22036. private _enablePosition;
  22037. private _enableVelocity;
  22038. private _enableReflectivity;
  22039. private _positionIndex;
  22040. private _velocityIndex;
  22041. private _reflectivityIndex;
  22042. private _depthNormalIndex;
  22043. private _linkedWithPrePass;
  22044. private _prePassRenderer;
  22045. private _attachments;
  22046. protected _effect: Effect;
  22047. protected _cachedDefines: string;
  22048. /**
  22049. * @hidden
  22050. * Sets up internal structures to share outputs with PrePassRenderer
  22051. * This method should only be called by the PrePassRenderer itself
  22052. */
  22053. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  22054. /**
  22055. * @hidden
  22056. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  22057. * This method should only be called by the PrePassRenderer itself
  22058. */
  22059. _unlinkPrePassRenderer(): void;
  22060. /**
  22061. * @hidden
  22062. * Resets the geometry buffer layout
  22063. */
  22064. _resetLayout(): void;
  22065. /**
  22066. * @hidden
  22067. * Replaces a texture in the geometry buffer renderer
  22068. * Useful when linking textures of the prepass renderer
  22069. */
  22070. _forceTextureType(geometryBufferType: number, index: number): void;
  22071. /**
  22072. * @hidden
  22073. * Sets texture attachments
  22074. * Useful when linking textures of the prepass renderer
  22075. */
  22076. _setAttachments(attachments: number[]): void;
  22077. /**
  22078. * @hidden
  22079. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  22080. * Useful when linking textures of the prepass renderer
  22081. */
  22082. _linkInternalTexture(internalTexture: InternalTexture): void;
  22083. /**
  22084. * Gets the render list (meshes to be rendered) used in the G buffer.
  22085. */
  22086. get renderList(): Nullable<AbstractMesh[]>;
  22087. /**
  22088. * Set the render list (meshes to be rendered) used in the G buffer.
  22089. */
  22090. set renderList(meshes: Nullable<AbstractMesh[]>);
  22091. /**
  22092. * Gets wether or not G buffer are supported by the running hardware.
  22093. * This requires draw buffer supports
  22094. */
  22095. get isSupported(): boolean;
  22096. /**
  22097. * Returns the index of the given texture type in the G-Buffer textures array
  22098. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  22099. * @returns the index of the given texture type in the G-Buffer textures array
  22100. */
  22101. getTextureIndex(textureType: number): number;
  22102. /**
  22103. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  22104. */
  22105. get enablePosition(): boolean;
  22106. /**
  22107. * Sets whether or not objects positions are enabled for the G buffer.
  22108. */
  22109. set enablePosition(enable: boolean);
  22110. /**
  22111. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  22112. */
  22113. get enableVelocity(): boolean;
  22114. /**
  22115. * Sets wether or not objects velocities are enabled for the G buffer.
  22116. */
  22117. set enableVelocity(enable: boolean);
  22118. /**
  22119. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  22120. */
  22121. get enableReflectivity(): boolean;
  22122. /**
  22123. * Sets wether or not objects roughness are enabled for the G buffer.
  22124. */
  22125. set enableReflectivity(enable: boolean);
  22126. /**
  22127. * Gets the scene associated with the buffer.
  22128. */
  22129. get scene(): Scene;
  22130. /**
  22131. * Gets the ratio used by the buffer during its creation.
  22132. * How big is the buffer related to the main canvas.
  22133. */
  22134. get ratio(): number;
  22135. /** @hidden */
  22136. static _SceneComponentInitialization: (scene: Scene) => void;
  22137. /**
  22138. * Creates a new G Buffer for the scene
  22139. * @param scene The scene the buffer belongs to
  22140. * @param ratio How big is the buffer related to the main canvas.
  22141. */
  22142. constructor(scene: Scene, ratio?: number);
  22143. /**
  22144. * Checks wether everything is ready to render a submesh to the G buffer.
  22145. * @param subMesh the submesh to check readiness for
  22146. * @param useInstances is the mesh drawn using instance or not
  22147. * @returns true if ready otherwise false
  22148. */
  22149. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  22150. /**
  22151. * Gets the current underlying G Buffer.
  22152. * @returns the buffer
  22153. */
  22154. getGBuffer(): MultiRenderTarget;
  22155. /**
  22156. * Gets the number of samples used to render the buffer (anti aliasing).
  22157. */
  22158. get samples(): number;
  22159. /**
  22160. * Sets the number of samples used to render the buffer (anti aliasing).
  22161. */
  22162. set samples(value: number);
  22163. /**
  22164. * Disposes the renderer and frees up associated resources.
  22165. */
  22166. dispose(): void;
  22167. private _assignRenderTargetIndices;
  22168. protected _createRenderTargets(): void;
  22169. private _copyBonesTransformationMatrices;
  22170. }
  22171. }
  22172. declare module BABYLON {
  22173. /**
  22174. * Renders a pre pass of the scene
  22175. * This means every mesh in the scene will be rendered to a render target texture
  22176. * And then this texture will be composited to the rendering canvas with post processes
  22177. * It is necessary for effects like subsurface scattering or deferred shading
  22178. */
  22179. export class PrePassRenderer {
  22180. /** @hidden */
  22181. static _SceneComponentInitialization: (scene: Scene) => void;
  22182. private _textureFormats;
  22183. /**
  22184. * To save performance, we can excluded skinned meshes from the prepass
  22185. */
  22186. excludedSkinnedMesh: AbstractMesh[];
  22187. /**
  22188. * Force material to be excluded from the prepass
  22189. * Can be useful when `useGeometryBufferFallback` is set to `true`
  22190. * and you don't want a material to show in the effect.
  22191. */
  22192. excludedMaterials: Material[];
  22193. private _textureIndices;
  22194. private _scene;
  22195. private _engine;
  22196. private _isDirty;
  22197. /**
  22198. * Number of textures in the multi render target texture where the scene is directly rendered
  22199. */
  22200. mrtCount: number;
  22201. /**
  22202. * The render target where the scene is directly rendered
  22203. */
  22204. prePassRT: MultiRenderTarget;
  22205. private _multiRenderAttachments;
  22206. private _defaultAttachments;
  22207. private _clearAttachments;
  22208. private _postProcesses;
  22209. private readonly _clearColor;
  22210. /**
  22211. * Image processing post process for composition
  22212. */
  22213. imageProcessingPostProcess: ImageProcessingPostProcess;
  22214. /**
  22215. * Configuration for prepass effects
  22216. */
  22217. private _effectConfigurations;
  22218. private _mrtFormats;
  22219. private _mrtLayout;
  22220. private _enabled;
  22221. /**
  22222. * Indicates if the prepass is enabled
  22223. */
  22224. get enabled(): boolean;
  22225. /**
  22226. * How many samples are used for MSAA of the scene render target
  22227. */
  22228. get samples(): number;
  22229. set samples(n: number);
  22230. private _geometryBuffer;
  22231. private _useGeometryBufferFallback;
  22232. /**
  22233. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  22234. */
  22235. get useGeometryBufferFallback(): boolean;
  22236. set useGeometryBufferFallback(value: boolean);
  22237. /**
  22238. * Set to true to disable gamma transform in PrePass.
  22239. * Can be useful in case you already proceed to gamma transform on a material level
  22240. * and your post processes don't need to be in linear color space.
  22241. */
  22242. disableGammaTransform: boolean;
  22243. /**
  22244. * Instanciates a prepass renderer
  22245. * @param scene The scene
  22246. */
  22247. constructor(scene: Scene);
  22248. private _initializeAttachments;
  22249. private _createCompositionEffect;
  22250. /**
  22251. * Indicates if rendering a prepass is supported
  22252. */
  22253. get isSupported(): boolean;
  22254. /**
  22255. * Sets the proper output textures to draw in the engine.
  22256. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  22257. * @param subMesh Submesh on which the effect is applied
  22258. */
  22259. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  22260. /**
  22261. * Restores attachments for single texture draw.
  22262. */
  22263. restoreAttachments(): void;
  22264. /**
  22265. * @hidden
  22266. */
  22267. _beforeCameraDraw(): void;
  22268. /**
  22269. * @hidden
  22270. */
  22271. _afterCameraDraw(): void;
  22272. private _checkRTSize;
  22273. private _bindFrameBuffer;
  22274. /**
  22275. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  22276. */
  22277. clear(): void;
  22278. private _setState;
  22279. private _updateGeometryBufferLayout;
  22280. /**
  22281. * Adds an effect configuration to the prepass.
  22282. * If an effect has already been added, it won't add it twice and will return the configuration
  22283. * already present.
  22284. * @param cfg the effect configuration
  22285. * @return the effect configuration now used by the prepass
  22286. */
  22287. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  22288. /**
  22289. * Returns the index of a texture in the multi render target texture array.
  22290. * @param type Texture type
  22291. * @return The index
  22292. */
  22293. getIndex(type: number): number;
  22294. private _enable;
  22295. private _disable;
  22296. private _resetLayout;
  22297. private _resetPostProcessChain;
  22298. private _bindPostProcessChain;
  22299. /**
  22300. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  22301. */
  22302. markAsDirty(): void;
  22303. /**
  22304. * Enables a texture on the MultiRenderTarget for prepass
  22305. */
  22306. private _enableTextures;
  22307. private _update;
  22308. private _markAllMaterialsAsPrePassDirty;
  22309. /**
  22310. * Disposes the prepass renderer.
  22311. */
  22312. dispose(): void;
  22313. }
  22314. }
  22315. declare module BABYLON {
  22316. /**
  22317. * Size options for a post process
  22318. */
  22319. export type PostProcessOptions = {
  22320. width: number;
  22321. height: number;
  22322. };
  22323. /**
  22324. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22325. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22326. */
  22327. export class PostProcess {
  22328. /**
  22329. * Gets or sets the unique id of the post process
  22330. */
  22331. uniqueId: number;
  22332. /** Name of the PostProcess. */
  22333. name: string;
  22334. /**
  22335. * Width of the texture to apply the post process on
  22336. */
  22337. width: number;
  22338. /**
  22339. * Height of the texture to apply the post process on
  22340. */
  22341. height: number;
  22342. /**
  22343. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22344. */
  22345. nodeMaterialSource: Nullable<NodeMaterial>;
  22346. /**
  22347. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22348. * @hidden
  22349. */
  22350. _outputTexture: Nullable<InternalTexture>;
  22351. /**
  22352. * Sampling mode used by the shader
  22353. * See https://doc.babylonjs.com/classes/3.1/texture
  22354. */
  22355. renderTargetSamplingMode: number;
  22356. /**
  22357. * Clear color to use when screen clearing
  22358. */
  22359. clearColor: Color4;
  22360. /**
  22361. * If the buffer needs to be cleared before applying the post process. (default: true)
  22362. * Should be set to false if shader will overwrite all previous pixels.
  22363. */
  22364. autoClear: boolean;
  22365. /**
  22366. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22367. */
  22368. alphaMode: number;
  22369. /**
  22370. * Sets the setAlphaBlendConstants of the babylon engine
  22371. */
  22372. alphaConstants: Color4;
  22373. /**
  22374. * Animations to be used for the post processing
  22375. */
  22376. animations: Animation[];
  22377. /**
  22378. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22379. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22380. */
  22381. enablePixelPerfectMode: boolean;
  22382. /**
  22383. * Force the postprocess to be applied without taking in account viewport
  22384. */
  22385. forceFullscreenViewport: boolean;
  22386. /**
  22387. * List of inspectable custom properties (used by the Inspector)
  22388. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22389. */
  22390. inspectableCustomProperties: IInspectable[];
  22391. /**
  22392. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22393. *
  22394. * | Value | Type | Description |
  22395. * | ----- | ----------------------------------- | ----------- |
  22396. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22397. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22398. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22399. *
  22400. */
  22401. scaleMode: number;
  22402. /**
  22403. * Force textures to be a power of two (default: false)
  22404. */
  22405. alwaysForcePOT: boolean;
  22406. private _samples;
  22407. /**
  22408. * Number of sample textures (default: 1)
  22409. */
  22410. get samples(): number;
  22411. set samples(n: number);
  22412. /**
  22413. * Modify the scale of the post process to be the same as the viewport (default: false)
  22414. */
  22415. adaptScaleToCurrentViewport: boolean;
  22416. private _camera;
  22417. protected _scene: Scene;
  22418. private _engine;
  22419. private _options;
  22420. private _reusable;
  22421. private _textureType;
  22422. private _textureFormat;
  22423. /**
  22424. * Smart array of input and output textures for the post process.
  22425. * @hidden
  22426. */
  22427. _textures: SmartArray<InternalTexture>;
  22428. /**
  22429. * The index in _textures that corresponds to the output texture.
  22430. * @hidden
  22431. */
  22432. _currentRenderTextureInd: number;
  22433. private _effect;
  22434. private _samplers;
  22435. private _fragmentUrl;
  22436. private _vertexUrl;
  22437. private _parameters;
  22438. private _scaleRatio;
  22439. protected _indexParameters: any;
  22440. private _shareOutputWithPostProcess;
  22441. private _texelSize;
  22442. private _forcedOutputTexture;
  22443. /**
  22444. * Prepass configuration in case this post process needs a texture from prepass
  22445. * @hidden
  22446. */
  22447. _prePassEffectConfiguration: PrePassEffectConfiguration;
  22448. /**
  22449. * Returns the fragment url or shader name used in the post process.
  22450. * @returns the fragment url or name in the shader store.
  22451. */
  22452. getEffectName(): string;
  22453. /**
  22454. * An event triggered when the postprocess is activated.
  22455. */
  22456. onActivateObservable: Observable<Camera>;
  22457. private _onActivateObserver;
  22458. /**
  22459. * A function that is added to the onActivateObservable
  22460. */
  22461. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22462. /**
  22463. * An event triggered when the postprocess changes its size.
  22464. */
  22465. onSizeChangedObservable: Observable<PostProcess>;
  22466. private _onSizeChangedObserver;
  22467. /**
  22468. * A function that is added to the onSizeChangedObservable
  22469. */
  22470. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22471. /**
  22472. * An event triggered when the postprocess applies its effect.
  22473. */
  22474. onApplyObservable: Observable<Effect>;
  22475. private _onApplyObserver;
  22476. /**
  22477. * A function that is added to the onApplyObservable
  22478. */
  22479. set onApply(callback: (effect: Effect) => void);
  22480. /**
  22481. * An event triggered before rendering the postprocess
  22482. */
  22483. onBeforeRenderObservable: Observable<Effect>;
  22484. private _onBeforeRenderObserver;
  22485. /**
  22486. * A function that is added to the onBeforeRenderObservable
  22487. */
  22488. set onBeforeRender(callback: (effect: Effect) => void);
  22489. /**
  22490. * An event triggered after rendering the postprocess
  22491. */
  22492. onAfterRenderObservable: Observable<Effect>;
  22493. private _onAfterRenderObserver;
  22494. /**
  22495. * A function that is added to the onAfterRenderObservable
  22496. */
  22497. set onAfterRender(callback: (efect: Effect) => void);
  22498. /**
  22499. * 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
  22500. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22501. */
  22502. get inputTexture(): InternalTexture;
  22503. set inputTexture(value: InternalTexture);
  22504. /**
  22505. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  22506. * the only way to unset it is to use this function to restore its internal state
  22507. */
  22508. restoreDefaultInputTexture(): void;
  22509. /**
  22510. * Gets the camera which post process is applied to.
  22511. * @returns The camera the post process is applied to.
  22512. */
  22513. getCamera(): Camera;
  22514. /**
  22515. * Gets the texel size of the postprocess.
  22516. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22517. */
  22518. get texelSize(): Vector2;
  22519. /**
  22520. * Creates a new instance PostProcess
  22521. * @param name The name of the PostProcess.
  22522. * @param fragmentUrl The url of the fragment shader to be used.
  22523. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22524. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22525. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22526. * @param camera The camera to apply the render pass to.
  22527. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22528. * @param engine The engine which the post process will be applied. (default: current engine)
  22529. * @param reusable If the post process can be reused on the same frame. (default: false)
  22530. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22531. * @param textureType Type of textures used when performing the post process. (default: 0)
  22532. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22533. * @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
  22534. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  22535. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22536. */
  22537. constructor(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, textureFormat?: number);
  22538. /**
  22539. * Gets a string identifying the name of the class
  22540. * @returns "PostProcess" string
  22541. */
  22542. getClassName(): string;
  22543. /**
  22544. * Gets the engine which this post process belongs to.
  22545. * @returns The engine the post process was enabled with.
  22546. */
  22547. getEngine(): Engine;
  22548. /**
  22549. * The effect that is created when initializing the post process.
  22550. * @returns The created effect corresponding the the postprocess.
  22551. */
  22552. getEffect(): Effect;
  22553. /**
  22554. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22555. * @param postProcess The post process to share the output with.
  22556. * @returns This post process.
  22557. */
  22558. shareOutputWith(postProcess: PostProcess): PostProcess;
  22559. /**
  22560. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22561. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22562. */
  22563. useOwnOutput(): void;
  22564. /**
  22565. * Updates the effect with the current post process compile time values and recompiles the shader.
  22566. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22567. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22568. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22569. * @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
  22570. * @param onCompiled Called when the shader has been compiled.
  22571. * @param onError Called if there is an error when compiling a shader.
  22572. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22573. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22574. */
  22575. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, vertexUrl?: string, fragmentUrl?: string): void;
  22576. /**
  22577. * The post process is reusable if it can be used multiple times within one frame.
  22578. * @returns If the post process is reusable
  22579. */
  22580. isReusable(): boolean;
  22581. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22582. markTextureDirty(): void;
  22583. /**
  22584. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22585. * 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.
  22586. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22587. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22588. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22589. * @returns The target texture that was bound to be written to.
  22590. */
  22591. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22592. /**
  22593. * If the post process is supported.
  22594. */
  22595. get isSupported(): boolean;
  22596. /**
  22597. * The aspect ratio of the output texture.
  22598. */
  22599. get aspectRatio(): number;
  22600. /**
  22601. * Get a value indicating if the post-process is ready to be used
  22602. * @returns true if the post-process is ready (shader is compiled)
  22603. */
  22604. isReady(): boolean;
  22605. /**
  22606. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22607. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22608. */
  22609. apply(): Nullable<Effect>;
  22610. private _disposeTextures;
  22611. /**
  22612. * Sets the required values to the prepass renderer.
  22613. * @param prePassRenderer defines the prepass renderer to setup.
  22614. * @returns true if the pre pass is needed.
  22615. */
  22616. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  22617. /**
  22618. * Disposes the post process.
  22619. * @param camera The camera to dispose the post process on.
  22620. */
  22621. dispose(camera?: Camera): void;
  22622. /**
  22623. * Serializes the particle system to a JSON object
  22624. * @returns the JSON object
  22625. */
  22626. serialize(): any;
  22627. /**
  22628. * Creates a material from parsed material data
  22629. * @param parsedPostProcess defines parsed post process data
  22630. * @param scene defines the hosting scene
  22631. * @param rootUrl defines the root URL to use to load textures
  22632. * @returns a new post process
  22633. */
  22634. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  22635. }
  22636. }
  22637. declare module BABYLON {
  22638. /** @hidden */
  22639. export var kernelBlurVaryingDeclaration: {
  22640. name: string;
  22641. shader: string;
  22642. };
  22643. }
  22644. declare module BABYLON {
  22645. /** @hidden */
  22646. export var packingFunctions: {
  22647. name: string;
  22648. shader: string;
  22649. };
  22650. }
  22651. declare module BABYLON {
  22652. /** @hidden */
  22653. export var kernelBlurFragment: {
  22654. name: string;
  22655. shader: string;
  22656. };
  22657. }
  22658. declare module BABYLON {
  22659. /** @hidden */
  22660. export var kernelBlurFragment2: {
  22661. name: string;
  22662. shader: string;
  22663. };
  22664. }
  22665. declare module BABYLON {
  22666. /** @hidden */
  22667. export var kernelBlurPixelShader: {
  22668. name: string;
  22669. shader: string;
  22670. };
  22671. }
  22672. declare module BABYLON {
  22673. /** @hidden */
  22674. export var kernelBlurVertex: {
  22675. name: string;
  22676. shader: string;
  22677. };
  22678. }
  22679. declare module BABYLON {
  22680. /** @hidden */
  22681. export var kernelBlurVertexShader: {
  22682. name: string;
  22683. shader: string;
  22684. };
  22685. }
  22686. declare module BABYLON {
  22687. /**
  22688. * The Blur Post Process which blurs an image based on a kernel and direction.
  22689. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22690. */
  22691. export class BlurPostProcess extends PostProcess {
  22692. private blockCompilation;
  22693. protected _kernel: number;
  22694. protected _idealKernel: number;
  22695. protected _packedFloat: boolean;
  22696. private _staticDefines;
  22697. /** The direction in which to blur the image. */
  22698. direction: Vector2;
  22699. /**
  22700. * Sets the length in pixels of the blur sample region
  22701. */
  22702. set kernel(v: number);
  22703. /**
  22704. * Gets the length in pixels of the blur sample region
  22705. */
  22706. get kernel(): number;
  22707. /**
  22708. * Sets wether or not the blur needs to unpack/repack floats
  22709. */
  22710. set packedFloat(v: boolean);
  22711. /**
  22712. * Gets wether or not the blur is unpacking/repacking floats
  22713. */
  22714. get packedFloat(): boolean;
  22715. /**
  22716. * Gets a string identifying the name of the class
  22717. * @returns "BlurPostProcess" string
  22718. */
  22719. getClassName(): string;
  22720. /**
  22721. * Creates a new instance BlurPostProcess
  22722. * @param name The name of the effect.
  22723. * @param direction The direction in which to blur the image.
  22724. * @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.
  22725. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22726. * @param camera The camera to apply the render pass to.
  22727. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22728. * @param engine The engine which the post process will be applied. (default: current engine)
  22729. * @param reusable If the post process can be reused on the same frame. (default: false)
  22730. * @param textureType Type of textures used when performing the post process. (default: 0)
  22731. * @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)
  22732. */
  22733. constructor(name: string, direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  22734. /**
  22735. * Updates the effect with the current post process compile time values and recompiles the shader.
  22736. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22737. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22738. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22739. * @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
  22740. * @param onCompiled Called when the shader has been compiled.
  22741. * @param onError Called if there is an error when compiling a shader.
  22742. */
  22743. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22744. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22745. /**
  22746. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  22747. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  22748. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  22749. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  22750. * The gaps between physical kernels are compensated for in the weighting of the samples
  22751. * @param idealKernel Ideal blur kernel.
  22752. * @return Nearest best kernel.
  22753. */
  22754. protected _nearestBestKernel(idealKernel: number): number;
  22755. /**
  22756. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  22757. * @param x The point on the Gaussian distribution to sample.
  22758. * @return the value of the Gaussian function at x.
  22759. */
  22760. protected _gaussianWeight(x: number): number;
  22761. /**
  22762. * Generates a string that can be used as a floating point number in GLSL.
  22763. * @param x Value to print.
  22764. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  22765. * @return GLSL float string.
  22766. */
  22767. protected _glslFloat(x: number, decimalFigures?: number): string;
  22768. /** @hidden */
  22769. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  22770. }
  22771. }
  22772. declare module BABYLON {
  22773. /**
  22774. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22775. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22776. * You can then easily use it as a reflectionTexture on a flat surface.
  22777. * In case the surface is not a plane, please consider relying on reflection probes.
  22778. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22779. */
  22780. export class MirrorTexture extends RenderTargetTexture {
  22781. private scene;
  22782. /**
  22783. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  22784. * 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.
  22785. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22786. */
  22787. mirrorPlane: Plane;
  22788. /**
  22789. * Define the blur ratio used to blur the reflection if needed.
  22790. */
  22791. set blurRatio(value: number);
  22792. get blurRatio(): number;
  22793. /**
  22794. * Define the adaptive blur kernel used to blur the reflection if needed.
  22795. * This will autocompute the closest best match for the `blurKernel`
  22796. */
  22797. set adaptiveBlurKernel(value: number);
  22798. /**
  22799. * Define the blur kernel used to blur the reflection if needed.
  22800. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22801. */
  22802. set blurKernel(value: number);
  22803. /**
  22804. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  22805. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22806. */
  22807. set blurKernelX(value: number);
  22808. get blurKernelX(): number;
  22809. /**
  22810. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  22811. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22812. */
  22813. set blurKernelY(value: number);
  22814. get blurKernelY(): number;
  22815. private _autoComputeBlurKernel;
  22816. protected _onRatioRescale(): void;
  22817. private _updateGammaSpace;
  22818. private _imageProcessingConfigChangeObserver;
  22819. private _transformMatrix;
  22820. private _mirrorMatrix;
  22821. private _savedViewMatrix;
  22822. private _blurX;
  22823. private _blurY;
  22824. private _adaptiveBlurKernel;
  22825. private _blurKernelX;
  22826. private _blurKernelY;
  22827. private _blurRatio;
  22828. /**
  22829. * Instantiates a Mirror Texture.
  22830. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22831. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22832. * You can then easily use it as a reflectionTexture on a flat surface.
  22833. * In case the surface is not a plane, please consider relying on reflection probes.
  22834. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22835. * @param name
  22836. * @param size
  22837. * @param scene
  22838. * @param generateMipMaps
  22839. * @param type
  22840. * @param samplingMode
  22841. * @param generateDepthBuffer
  22842. */
  22843. constructor(name: string, size: number | {
  22844. width: number;
  22845. height: number;
  22846. } | {
  22847. ratio: number;
  22848. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  22849. private _preparePostProcesses;
  22850. /**
  22851. * Clone the mirror texture.
  22852. * @returns the cloned texture
  22853. */
  22854. clone(): MirrorTexture;
  22855. /**
  22856. * Serialize the texture to a JSON representation you could use in Parse later on
  22857. * @returns the serialized JSON representation
  22858. */
  22859. serialize(): any;
  22860. /**
  22861. * Dispose the texture and release its associated resources.
  22862. */
  22863. dispose(): void;
  22864. }
  22865. }
  22866. declare module BABYLON {
  22867. /**
  22868. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  22869. * @see https://doc.babylonjs.com/babylon101/materials#texture
  22870. */
  22871. export class Texture extends BaseTexture {
  22872. /**
  22873. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  22874. */
  22875. static SerializeBuffers: boolean;
  22876. /**
  22877. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  22878. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  22879. */
  22880. static ForceSerializeBuffers: boolean;
  22881. /** @hidden */
  22882. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  22883. /** @hidden */
  22884. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  22885. /** @hidden */
  22886. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  22887. /** nearest is mag = nearest and min = nearest and mip = linear */
  22888. static readonly NEAREST_SAMPLINGMODE: number;
  22889. /** nearest is mag = nearest and min = nearest and mip = linear */
  22890. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  22891. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22892. static readonly BILINEAR_SAMPLINGMODE: number;
  22893. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22894. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  22895. /** Trilinear is mag = linear and min = linear and mip = linear */
  22896. static readonly TRILINEAR_SAMPLINGMODE: number;
  22897. /** Trilinear is mag = linear and min = linear and mip = linear */
  22898. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  22899. /** mag = nearest and min = nearest and mip = nearest */
  22900. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  22901. /** mag = nearest and min = linear and mip = nearest */
  22902. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  22903. /** mag = nearest and min = linear and mip = linear */
  22904. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  22905. /** mag = nearest and min = linear and mip = none */
  22906. static readonly NEAREST_LINEAR: number;
  22907. /** mag = nearest and min = nearest and mip = none */
  22908. static readonly NEAREST_NEAREST: number;
  22909. /** mag = linear and min = nearest and mip = nearest */
  22910. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  22911. /** mag = linear and min = nearest and mip = linear */
  22912. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  22913. /** mag = linear and min = linear and mip = none */
  22914. static readonly LINEAR_LINEAR: number;
  22915. /** mag = linear and min = nearest and mip = none */
  22916. static readonly LINEAR_NEAREST: number;
  22917. /** Explicit coordinates mode */
  22918. static readonly EXPLICIT_MODE: number;
  22919. /** Spherical coordinates mode */
  22920. static readonly SPHERICAL_MODE: number;
  22921. /** Planar coordinates mode */
  22922. static readonly PLANAR_MODE: number;
  22923. /** Cubic coordinates mode */
  22924. static readonly CUBIC_MODE: number;
  22925. /** Projection coordinates mode */
  22926. static readonly PROJECTION_MODE: number;
  22927. /** Inverse Cubic coordinates mode */
  22928. static readonly SKYBOX_MODE: number;
  22929. /** Inverse Cubic coordinates mode */
  22930. static readonly INVCUBIC_MODE: number;
  22931. /** Equirectangular coordinates mode */
  22932. static readonly EQUIRECTANGULAR_MODE: number;
  22933. /** Equirectangular Fixed coordinates mode */
  22934. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  22935. /** Equirectangular Fixed Mirrored coordinates mode */
  22936. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  22937. /** Texture is not repeating outside of 0..1 UVs */
  22938. static readonly CLAMP_ADDRESSMODE: number;
  22939. /** Texture is repeating outside of 0..1 UVs */
  22940. static readonly WRAP_ADDRESSMODE: number;
  22941. /** Texture is repeating and mirrored */
  22942. static readonly MIRROR_ADDRESSMODE: number;
  22943. /**
  22944. * 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
  22945. */
  22946. static UseSerializedUrlIfAny: boolean;
  22947. /**
  22948. * Define the url of the texture.
  22949. */
  22950. url: Nullable<string>;
  22951. /**
  22952. * Define an offset on the texture to offset the u coordinates of the UVs
  22953. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  22954. */
  22955. uOffset: number;
  22956. /**
  22957. * Define an offset on the texture to offset the v coordinates of the UVs
  22958. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  22959. */
  22960. vOffset: number;
  22961. /**
  22962. * Define an offset on the texture to scale the u coordinates of the UVs
  22963. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  22964. */
  22965. uScale: number;
  22966. /**
  22967. * Define an offset on the texture to scale the v coordinates of the UVs
  22968. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  22969. */
  22970. vScale: number;
  22971. /**
  22972. * Define an offset on the texture to rotate around the u coordinates of the UVs
  22973. * @see https://doc.babylonjs.com/how_to/more_materials
  22974. */
  22975. uAng: number;
  22976. /**
  22977. * Define an offset on the texture to rotate around the v coordinates of the UVs
  22978. * @see https://doc.babylonjs.com/how_to/more_materials
  22979. */
  22980. vAng: number;
  22981. /**
  22982. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  22983. * @see https://doc.babylonjs.com/how_to/more_materials
  22984. */
  22985. wAng: number;
  22986. /**
  22987. * Defines the center of rotation (U)
  22988. */
  22989. uRotationCenter: number;
  22990. /**
  22991. * Defines the center of rotation (V)
  22992. */
  22993. vRotationCenter: number;
  22994. /**
  22995. * Defines the center of rotation (W)
  22996. */
  22997. wRotationCenter: number;
  22998. /**
  22999. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  23000. */
  23001. homogeneousRotationInUVTransform: boolean;
  23002. /**
  23003. * Are mip maps generated for this texture or not.
  23004. */
  23005. get noMipmap(): boolean;
  23006. /**
  23007. * List of inspectable custom properties (used by the Inspector)
  23008. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23009. */
  23010. inspectableCustomProperties: Nullable<IInspectable[]>;
  23011. private _noMipmap;
  23012. /** @hidden */
  23013. _invertY: boolean;
  23014. private _rowGenerationMatrix;
  23015. private _cachedTextureMatrix;
  23016. private _projectionModeMatrix;
  23017. private _t0;
  23018. private _t1;
  23019. private _t2;
  23020. private _cachedUOffset;
  23021. private _cachedVOffset;
  23022. private _cachedUScale;
  23023. private _cachedVScale;
  23024. private _cachedUAng;
  23025. private _cachedVAng;
  23026. private _cachedWAng;
  23027. private _cachedProjectionMatrixId;
  23028. private _cachedURotationCenter;
  23029. private _cachedVRotationCenter;
  23030. private _cachedWRotationCenter;
  23031. private _cachedHomogeneousRotationInUVTransform;
  23032. private _cachedCoordinatesMode;
  23033. /** @hidden */
  23034. protected _initialSamplingMode: number;
  23035. /** @hidden */
  23036. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23037. private _deleteBuffer;
  23038. protected _format: Nullable<number>;
  23039. private _delayedOnLoad;
  23040. private _delayedOnError;
  23041. private _mimeType?;
  23042. private _loaderOptions?;
  23043. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  23044. get mimeType(): string | undefined;
  23045. /**
  23046. * Observable triggered once the texture has been loaded.
  23047. */
  23048. onLoadObservable: Observable<Texture>;
  23049. protected _isBlocking: boolean;
  23050. /**
  23051. * Is the texture preventing material to render while loading.
  23052. * If false, a default texture will be used instead of the loading one during the preparation step.
  23053. */
  23054. set isBlocking(value: boolean);
  23055. get isBlocking(): boolean;
  23056. /**
  23057. * Get the current sampling mode associated with the texture.
  23058. */
  23059. get samplingMode(): number;
  23060. /**
  23061. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23062. */
  23063. get invertY(): boolean;
  23064. /**
  23065. * Instantiates a new texture.
  23066. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23067. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23068. * @param url defines the url of the picture to load as a texture
  23069. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23070. * @param noMipmap defines if the texture will require mip maps or not
  23071. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23072. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23073. * @param onLoad defines a callback triggered when the texture has been loaded
  23074. * @param onError defines a callback triggered when an error occurred during the loading session
  23075. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23076. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23077. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23078. * @param mimeType defines an optional mime type information
  23079. * @param loaderOptions options to be passed to the loader
  23080. */
  23081. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string, loaderOptions?: any);
  23082. /**
  23083. * Update the url (and optional buffer) of this texture if url was null during construction.
  23084. * @param url the url of the texture
  23085. * @param buffer the buffer of the texture (defaults to null)
  23086. * @param onLoad callback called when the texture is loaded (defaults to null)
  23087. */
  23088. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23089. /**
  23090. * Finish the loading sequence of a texture flagged as delayed load.
  23091. * @hidden
  23092. */
  23093. delayLoad(): void;
  23094. private _prepareRowForTextureGeneration;
  23095. /**
  23096. * Checks if the texture has the same transform matrix than another texture
  23097. * @param texture texture to check against
  23098. * @returns true if the transforms are the same, else false
  23099. */
  23100. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  23101. /**
  23102. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23103. * @returns the transform matrix of the texture.
  23104. */
  23105. getTextureMatrix(uBase?: number): Matrix;
  23106. /**
  23107. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23108. * @returns The reflection texture transform
  23109. */
  23110. getReflectionTextureMatrix(): Matrix;
  23111. /**
  23112. * Clones the texture.
  23113. * @returns the cloned texture
  23114. */
  23115. clone(): Texture;
  23116. /**
  23117. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23118. * @returns The JSON representation of the texture
  23119. */
  23120. serialize(): any;
  23121. /**
  23122. * Get the current class name of the texture useful for serialization or dynamic coding.
  23123. * @returns "Texture"
  23124. */
  23125. getClassName(): string;
  23126. /**
  23127. * Dispose the texture and release its associated resources.
  23128. */
  23129. dispose(): void;
  23130. /**
  23131. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23132. * @param parsedTexture Define the JSON representation of the texture
  23133. * @param scene Define the scene the parsed texture should be instantiated in
  23134. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23135. * @returns The parsed texture if successful
  23136. */
  23137. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23138. /**
  23139. * Creates a texture from its base 64 representation.
  23140. * @param data Define the base64 payload without the data: prefix
  23141. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23142. * @param scene Define the scene the texture should belong to
  23143. * @param noMipmap Forces the texture to not create mip map information if true
  23144. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23145. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23146. * @param onLoad define a callback triggered when the texture has been loaded
  23147. * @param onError define a callback triggered when an error occurred during the loading session
  23148. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23149. * @returns the created texture
  23150. */
  23151. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23152. /**
  23153. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23154. * @param data Define the base64 payload without the data: prefix
  23155. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23156. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23157. * @param scene Define the scene the texture should belong to
  23158. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23159. * @param noMipmap Forces the texture to not create mip map information if true
  23160. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23161. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23162. * @param onLoad define a callback triggered when the texture has been loaded
  23163. * @param onError define a callback triggered when an error occurred during the loading session
  23164. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23165. * @returns the created texture
  23166. */
  23167. 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;
  23168. }
  23169. }
  23170. declare module BABYLON {
  23171. /**
  23172. * ThinSprite Class used to represent a thin sprite
  23173. * This is the base class for sprites but can also directly be used with ThinEngine
  23174. * @see https://doc.babylonjs.com/babylon101/sprites
  23175. */
  23176. export class ThinSprite {
  23177. /** Gets or sets the cell index in the sprite sheet */
  23178. cellIndex: number;
  23179. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  23180. cellRef: string;
  23181. /** Gets or sets the current world position */
  23182. position: IVector3Like;
  23183. /** Gets or sets the main color */
  23184. color: IColor4Like;
  23185. /** Gets or sets the width */
  23186. width: number;
  23187. /** Gets or sets the height */
  23188. height: number;
  23189. /** Gets or sets rotation angle */
  23190. angle: number;
  23191. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  23192. invertU: boolean;
  23193. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  23194. invertV: boolean;
  23195. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  23196. isVisible: boolean;
  23197. /**
  23198. * Returns a boolean indicating if the animation is started
  23199. */
  23200. get animationStarted(): boolean;
  23201. /** Gets the initial key for the animation (setting it will restart the animation) */
  23202. get fromIndex(): number;
  23203. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  23204. get toIndex(): number;
  23205. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  23206. get loopAnimation(): boolean;
  23207. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  23208. get delay(): number;
  23209. /** @hidden */
  23210. _xOffset: number;
  23211. /** @hidden */
  23212. _yOffset: number;
  23213. /** @hidden */
  23214. _xSize: number;
  23215. /** @hidden */
  23216. _ySize: number;
  23217. private _animationStarted;
  23218. protected _loopAnimation: boolean;
  23219. protected _fromIndex: number;
  23220. protected _toIndex: number;
  23221. protected _delay: number;
  23222. private _direction;
  23223. private _time;
  23224. private _onBaseAnimationEnd;
  23225. /**
  23226. * Creates a new Thin Sprite
  23227. */
  23228. constructor();
  23229. /**
  23230. * Starts an animation
  23231. * @param from defines the initial key
  23232. * @param to defines the end key
  23233. * @param loop defines if the animation must loop
  23234. * @param delay defines the start delay (in ms)
  23235. * @param onAnimationEnd defines a callback for when the animation ends
  23236. */
  23237. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  23238. /** Stops current animation (if any) */
  23239. stopAnimation(): void;
  23240. /** @hidden */
  23241. _animate(deltaTime: number): void;
  23242. }
  23243. }
  23244. declare module BABYLON {
  23245. /** @hidden */
  23246. export var imageProcessingCompatibility: {
  23247. name: string;
  23248. shader: string;
  23249. };
  23250. }
  23251. declare module BABYLON {
  23252. /** @hidden */
  23253. export var spritesPixelShader: {
  23254. name: string;
  23255. shader: string;
  23256. };
  23257. }
  23258. declare module BABYLON {
  23259. /** @hidden */
  23260. export var spritesVertexShader: {
  23261. name: string;
  23262. shader: string;
  23263. };
  23264. }
  23265. declare module BABYLON {
  23266. /**
  23267. * Class used to render sprites.
  23268. *
  23269. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  23270. */
  23271. export class SpriteRenderer {
  23272. /**
  23273. * Defines the texture of the spritesheet
  23274. */
  23275. texture: Nullable<ThinTexture>;
  23276. /**
  23277. * Defines the default width of a cell in the spritesheet
  23278. */
  23279. cellWidth: number;
  23280. /**
  23281. * Defines the default height of a cell in the spritesheet
  23282. */
  23283. cellHeight: number;
  23284. /**
  23285. * Blend mode use to render the particle, it can be any of
  23286. * the static Constants.ALPHA_x properties provided in this class.
  23287. * Default value is Constants.ALPHA_COMBINE
  23288. */
  23289. blendMode: number;
  23290. /**
  23291. * Gets or sets a boolean indicating if alpha mode is automatically
  23292. * reset.
  23293. */
  23294. autoResetAlpha: boolean;
  23295. /**
  23296. * Disables writing to the depth buffer when rendering the sprites.
  23297. * It can be handy to disable depth writing when using textures without alpha channel
  23298. * and setting some specific blend modes.
  23299. */
  23300. disableDepthWrite: boolean;
  23301. /**
  23302. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  23303. */
  23304. fogEnabled: boolean;
  23305. /**
  23306. * Gets the capacity of the manager
  23307. */
  23308. get capacity(): number;
  23309. private readonly _engine;
  23310. private readonly _useVAO;
  23311. private readonly _useInstancing;
  23312. private readonly _scene;
  23313. private readonly _capacity;
  23314. private readonly _epsilon;
  23315. private _vertexBufferSize;
  23316. private _vertexData;
  23317. private _buffer;
  23318. private _vertexBuffers;
  23319. private _spriteBuffer;
  23320. private _indexBuffer;
  23321. private _effectBase;
  23322. private _effectFog;
  23323. private _vertexArrayObject;
  23324. /**
  23325. * Creates a new sprite Renderer
  23326. * @param engine defines the engine the renderer works with
  23327. * @param capacity defines the maximum allowed number of sprites
  23328. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  23329. * @param scene defines the hosting scene
  23330. */
  23331. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  23332. /**
  23333. * Render all child sprites
  23334. * @param sprites defines the list of sprites to render
  23335. * @param deltaTime defines the time since last frame
  23336. * @param viewMatrix defines the viewMatrix to use to render the sprites
  23337. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  23338. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  23339. */
  23340. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  23341. private _appendSpriteVertex;
  23342. /**
  23343. * Release associated resources
  23344. */
  23345. dispose(): void;
  23346. }
  23347. }
  23348. declare module BABYLON {
  23349. /**
  23350. * Defines the minimum interface to fullfil in order to be a sprite manager.
  23351. */
  23352. export interface ISpriteManager extends IDisposable {
  23353. /**
  23354. * Gets manager's name
  23355. */
  23356. name: string;
  23357. /**
  23358. * Restricts the camera to viewing objects with the same layerMask.
  23359. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  23360. */
  23361. layerMask: number;
  23362. /**
  23363. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23364. */
  23365. isPickable: boolean;
  23366. /**
  23367. * Gets the hosting scene
  23368. */
  23369. scene: Scene;
  23370. /**
  23371. * Specifies the rendering group id for this mesh (0 by default)
  23372. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  23373. */
  23374. renderingGroupId: number;
  23375. /**
  23376. * Defines the list of sprites managed by the manager.
  23377. */
  23378. sprites: Array<Sprite>;
  23379. /**
  23380. * Gets or sets the spritesheet texture
  23381. */
  23382. texture: Texture;
  23383. /** Defines the default width of a cell in the spritesheet */
  23384. cellWidth: number;
  23385. /** Defines the default height of a cell in the spritesheet */
  23386. cellHeight: number;
  23387. /**
  23388. * Tests the intersection of a sprite with a specific ray.
  23389. * @param ray The ray we are sending to test the collision
  23390. * @param camera The camera space we are sending rays in
  23391. * @param predicate A predicate allowing excluding sprites from the list of object to test
  23392. * @param fastCheck defines if the first intersection will be used (and not the closest)
  23393. * @returns picking info or null.
  23394. */
  23395. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  23396. /**
  23397. * Intersects the sprites with a ray
  23398. * @param ray defines the ray to intersect with
  23399. * @param camera defines the current active camera
  23400. * @param predicate defines a predicate used to select candidate sprites
  23401. * @returns null if no hit or a PickingInfo array
  23402. */
  23403. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  23404. /**
  23405. * Renders the list of sprites on screen.
  23406. */
  23407. render(): void;
  23408. }
  23409. /**
  23410. * Class used to manage multiple sprites on the same spritesheet
  23411. * @see https://doc.babylonjs.com/babylon101/sprites
  23412. */
  23413. export class SpriteManager implements ISpriteManager {
  23414. /** defines the manager's name */
  23415. name: string;
  23416. /** Define the Url to load snippets */
  23417. static SnippetUrl: string;
  23418. /** Snippet ID if the manager was created from the snippet server */
  23419. snippetId: string;
  23420. /** Gets the list of sprites */
  23421. sprites: Sprite[];
  23422. /** Gets or sets the rendering group id (0 by default) */
  23423. renderingGroupId: number;
  23424. /** Gets or sets camera layer mask */
  23425. layerMask: number;
  23426. /** Gets or sets a boolean indicating if the sprites are pickable */
  23427. isPickable: boolean;
  23428. /**
  23429. * An event triggered when the manager is disposed.
  23430. */
  23431. onDisposeObservable: Observable<SpriteManager>;
  23432. /**
  23433. * Callback called when the manager is disposed
  23434. */
  23435. set onDispose(callback: () => void);
  23436. /**
  23437. * Gets or sets the unique id of the sprite
  23438. */
  23439. uniqueId: number;
  23440. /**
  23441. * Gets the array of sprites
  23442. */
  23443. get children(): Sprite[];
  23444. /**
  23445. * Gets the hosting scene
  23446. */
  23447. get scene(): Scene;
  23448. /**
  23449. * Gets the capacity of the manager
  23450. */
  23451. get capacity(): number;
  23452. /**
  23453. * Gets or sets the spritesheet texture
  23454. */
  23455. get texture(): Texture;
  23456. set texture(value: Texture);
  23457. /** Defines the default width of a cell in the spritesheet */
  23458. get cellWidth(): number;
  23459. set cellWidth(value: number);
  23460. /** Defines the default height of a cell in the spritesheet */
  23461. get cellHeight(): number;
  23462. set cellHeight(value: number);
  23463. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  23464. get fogEnabled(): boolean;
  23465. set fogEnabled(value: boolean);
  23466. /**
  23467. * Blend mode use to render the particle, it can be any of
  23468. * the static Constants.ALPHA_x properties provided in this class.
  23469. * Default value is Constants.ALPHA_COMBINE
  23470. */
  23471. get blendMode(): number;
  23472. set blendMode(blendMode: number);
  23473. /** Disables writing to the depth buffer when rendering the sprites.
  23474. * It can be handy to disable depth writing when using textures without alpha channel
  23475. * and setting some specific blend modes.
  23476. */
  23477. disableDepthWrite: boolean;
  23478. private _spriteRenderer;
  23479. /** Associative array from JSON sprite data file */
  23480. private _cellData;
  23481. /** Array of sprite names from JSON sprite data file */
  23482. private _spriteMap;
  23483. /** True when packed cell data from JSON file is ready*/
  23484. private _packedAndReady;
  23485. private _textureContent;
  23486. private _onDisposeObserver;
  23487. private _fromPacked;
  23488. private _scene;
  23489. /**
  23490. * Creates a new sprite manager
  23491. * @param name defines the manager's name
  23492. * @param imgUrl defines the sprite sheet url
  23493. * @param capacity defines the maximum allowed number of sprites
  23494. * @param cellSize defines the size of a sprite cell
  23495. * @param scene defines the hosting scene
  23496. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  23497. * @param samplingMode defines the smapling mode to use with spritesheet
  23498. * @param fromPacked set to false; do not alter
  23499. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  23500. */
  23501. constructor(
  23502. /** defines the manager's name */
  23503. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  23504. /**
  23505. * Returns the string "SpriteManager"
  23506. * @returns "SpriteManager"
  23507. */
  23508. getClassName(): string;
  23509. private _makePacked;
  23510. private _checkTextureAlpha;
  23511. /**
  23512. * Intersects the sprites with a ray
  23513. * @param ray defines the ray to intersect with
  23514. * @param camera defines the current active camera
  23515. * @param predicate defines a predicate used to select candidate sprites
  23516. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  23517. * @returns null if no hit or a PickingInfo
  23518. */
  23519. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  23520. /**
  23521. * Intersects the sprites with a ray
  23522. * @param ray defines the ray to intersect with
  23523. * @param camera defines the current active camera
  23524. * @param predicate defines a predicate used to select candidate sprites
  23525. * @returns null if no hit or a PickingInfo array
  23526. */
  23527. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  23528. /**
  23529. * Render all child sprites
  23530. */
  23531. render(): void;
  23532. private _customUpdate;
  23533. /**
  23534. * Release associated resources
  23535. */
  23536. dispose(): void;
  23537. /**
  23538. * Serializes the sprite manager to a JSON object
  23539. * @param serializeTexture defines if the texture must be serialized as well
  23540. * @returns the JSON object
  23541. */
  23542. serialize(serializeTexture?: boolean): any;
  23543. /**
  23544. * Parses a JSON object to create a new sprite manager.
  23545. * @param parsedManager The JSON object to parse
  23546. * @param scene The scene to create the sprite managerin
  23547. * @param rootUrl The root url to use to load external dependencies like texture
  23548. * @returns the new sprite manager
  23549. */
  23550. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  23551. /**
  23552. * Creates a sprite manager from a snippet saved in a remote file
  23553. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  23554. * @param url defines the url to load from
  23555. * @param scene defines the hosting scene
  23556. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23557. * @returns a promise that will resolve to the new sprite manager
  23558. */
  23559. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  23560. /**
  23561. * Creates a sprite manager from a snippet saved by the sprite editor
  23562. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  23563. * @param scene defines the hosting scene
  23564. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23565. * @returns a promise that will resolve to the new sprite manager
  23566. */
  23567. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  23568. }
  23569. }
  23570. declare module BABYLON {
  23571. /**
  23572. * Class used to represent a sprite
  23573. * @see https://doc.babylonjs.com/babylon101/sprites
  23574. */
  23575. export class Sprite extends ThinSprite implements IAnimatable {
  23576. /** defines the name */
  23577. name: string;
  23578. /** Gets or sets the current world position */
  23579. position: Vector3;
  23580. /** Gets or sets the main color */
  23581. color: Color4;
  23582. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  23583. disposeWhenFinishedAnimating: boolean;
  23584. /** Gets the list of attached animations */
  23585. animations: Nullable<Array<Animation>>;
  23586. /** Gets or sets a boolean indicating if the sprite can be picked */
  23587. isPickable: boolean;
  23588. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  23589. useAlphaForPicking: boolean;
  23590. /**
  23591. * Gets or sets the associated action manager
  23592. */
  23593. actionManager: Nullable<ActionManager>;
  23594. /**
  23595. * An event triggered when the control has been disposed
  23596. */
  23597. onDisposeObservable: Observable<Sprite>;
  23598. private _manager;
  23599. private _onAnimationEnd;
  23600. /**
  23601. * Gets or sets the sprite size
  23602. */
  23603. get size(): number;
  23604. set size(value: number);
  23605. /**
  23606. * Gets or sets the unique id of the sprite
  23607. */
  23608. uniqueId: number;
  23609. /**
  23610. * Gets the manager of this sprite
  23611. */
  23612. get manager(): ISpriteManager;
  23613. /**
  23614. * Creates a new Sprite
  23615. * @param name defines the name
  23616. * @param manager defines the manager
  23617. */
  23618. constructor(
  23619. /** defines the name */
  23620. name: string, manager: ISpriteManager);
  23621. /**
  23622. * Returns the string "Sprite"
  23623. * @returns "Sprite"
  23624. */
  23625. getClassName(): string;
  23626. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  23627. get fromIndex(): number;
  23628. set fromIndex(value: number);
  23629. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  23630. get toIndex(): number;
  23631. set toIndex(value: number);
  23632. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  23633. get loopAnimation(): boolean;
  23634. set loopAnimation(value: boolean);
  23635. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  23636. get delay(): number;
  23637. set delay(value: number);
  23638. /**
  23639. * Starts an animation
  23640. * @param from defines the initial key
  23641. * @param to defines the end key
  23642. * @param loop defines if the animation must loop
  23643. * @param delay defines the start delay (in ms)
  23644. * @param onAnimationEnd defines a callback to call when animation ends
  23645. */
  23646. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  23647. private _endAnimation;
  23648. /** Release associated resources */
  23649. dispose(): void;
  23650. /**
  23651. * Serializes the sprite to a JSON object
  23652. * @returns the JSON object
  23653. */
  23654. serialize(): any;
  23655. /**
  23656. * Parses a JSON object to create a new sprite
  23657. * @param parsedSprite The JSON object to parse
  23658. * @param manager defines the hosting manager
  23659. * @returns the new sprite
  23660. */
  23661. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  23662. }
  23663. }
  23664. declare module BABYLON {
  23665. /**
  23666. * Information about the result of picking within a scene
  23667. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  23668. */
  23669. export class PickingInfo {
  23670. /** @hidden */
  23671. _pickingUnavailable: boolean;
  23672. /**
  23673. * If the pick collided with an object
  23674. */
  23675. hit: boolean;
  23676. /**
  23677. * Distance away where the pick collided
  23678. */
  23679. distance: number;
  23680. /**
  23681. * The location of pick collision
  23682. */
  23683. pickedPoint: Nullable<Vector3>;
  23684. /**
  23685. * The mesh corresponding the the pick collision
  23686. */
  23687. pickedMesh: Nullable<AbstractMesh>;
  23688. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  23689. bu: number;
  23690. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  23691. bv: number;
  23692. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  23693. faceId: number;
  23694. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  23695. subMeshFaceId: number;
  23696. /** Id of the the submesh that was picked */
  23697. subMeshId: number;
  23698. /** If a sprite was picked, this will be the sprite the pick collided with */
  23699. pickedSprite: Nullable<Sprite>;
  23700. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  23701. thinInstanceIndex: number;
  23702. /**
  23703. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  23704. */
  23705. originMesh: Nullable<AbstractMesh>;
  23706. /**
  23707. * The ray that was used to perform the picking.
  23708. */
  23709. ray: Nullable<Ray>;
  23710. /**
  23711. * Gets the normal correspodning to the face the pick collided with
  23712. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  23713. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  23714. * @returns The normal correspodning to the face the pick collided with
  23715. */
  23716. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  23717. /**
  23718. * Gets the texture coordinates of where the pick occured
  23719. * @returns the vector containing the coordnates of the texture
  23720. */
  23721. getTextureCoordinates(): Nullable<Vector2>;
  23722. }
  23723. }
  23724. declare module BABYLON {
  23725. /**
  23726. * Gather the list of pointer event types as constants.
  23727. */
  23728. export class PointerEventTypes {
  23729. /**
  23730. * 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.
  23731. */
  23732. static readonly POINTERDOWN: number;
  23733. /**
  23734. * The pointerup event is fired when a pointer is no longer active.
  23735. */
  23736. static readonly POINTERUP: number;
  23737. /**
  23738. * The pointermove event is fired when a pointer changes coordinates.
  23739. */
  23740. static readonly POINTERMOVE: number;
  23741. /**
  23742. * The pointerwheel event is fired when a mouse wheel has been rotated.
  23743. */
  23744. static readonly POINTERWHEEL: number;
  23745. /**
  23746. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  23747. */
  23748. static readonly POINTERPICK: number;
  23749. /**
  23750. * The pointertap event is fired when a the object has been touched and released without drag.
  23751. */
  23752. static readonly POINTERTAP: number;
  23753. /**
  23754. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  23755. */
  23756. static readonly POINTERDOUBLETAP: number;
  23757. }
  23758. /**
  23759. * Base class of pointer info types.
  23760. */
  23761. export class PointerInfoBase {
  23762. /**
  23763. * Defines the type of event (PointerEventTypes)
  23764. */
  23765. type: number;
  23766. /**
  23767. * Defines the related dom event
  23768. */
  23769. event: PointerEvent | MouseWheelEvent;
  23770. /**
  23771. * Instantiates the base class of pointers info.
  23772. * @param type Defines the type of event (PointerEventTypes)
  23773. * @param event Defines the related dom event
  23774. */
  23775. constructor(
  23776. /**
  23777. * Defines the type of event (PointerEventTypes)
  23778. */
  23779. type: number,
  23780. /**
  23781. * Defines the related dom event
  23782. */
  23783. event: PointerEvent | MouseWheelEvent);
  23784. }
  23785. /**
  23786. * This class is used to store pointer related info for the onPrePointerObservable event.
  23787. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  23788. */
  23789. export class PointerInfoPre extends PointerInfoBase {
  23790. /**
  23791. * Ray from a pointer if availible (eg. 6dof controller)
  23792. */
  23793. ray: Nullable<Ray>;
  23794. /**
  23795. * Defines the local position of the pointer on the canvas.
  23796. */
  23797. localPosition: Vector2;
  23798. /**
  23799. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  23800. */
  23801. skipOnPointerObservable: boolean;
  23802. /**
  23803. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  23804. * @param type Defines the type of event (PointerEventTypes)
  23805. * @param event Defines the related dom event
  23806. * @param localX Defines the local x coordinates of the pointer when the event occured
  23807. * @param localY Defines the local y coordinates of the pointer when the event occured
  23808. */
  23809. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  23810. }
  23811. /**
  23812. * This type contains all the data related to a pointer event in Babylon.js.
  23813. * 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.
  23814. */
  23815. export class PointerInfo extends PointerInfoBase {
  23816. /**
  23817. * Defines the picking info associated to the info (if any)\
  23818. */
  23819. pickInfo: Nullable<PickingInfo>;
  23820. /**
  23821. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  23822. * @param type Defines the type of event (PointerEventTypes)
  23823. * @param event Defines the related dom event
  23824. * @param pickInfo Defines the picking info associated to the info (if any)\
  23825. */
  23826. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  23827. /**
  23828. * Defines the picking info associated to the info (if any)\
  23829. */
  23830. pickInfo: Nullable<PickingInfo>);
  23831. }
  23832. /**
  23833. * Data relating to a touch event on the screen.
  23834. */
  23835. export interface PointerTouch {
  23836. /**
  23837. * X coordinate of touch.
  23838. */
  23839. x: number;
  23840. /**
  23841. * Y coordinate of touch.
  23842. */
  23843. y: number;
  23844. /**
  23845. * Id of touch. Unique for each finger.
  23846. */
  23847. pointerId: number;
  23848. /**
  23849. * Event type passed from DOM.
  23850. */
  23851. type: any;
  23852. }
  23853. }
  23854. declare module BABYLON {
  23855. /**
  23856. * Manage the mouse inputs to control the movement of a free camera.
  23857. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  23858. */
  23859. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  23860. /**
  23861. * Define if touch is enabled in the mouse input
  23862. */
  23863. touchEnabled: boolean;
  23864. /**
  23865. * Defines the camera the input is attached to.
  23866. */
  23867. camera: FreeCamera;
  23868. /**
  23869. * Defines the buttons associated with the input to handle camera move.
  23870. */
  23871. buttons: number[];
  23872. /**
  23873. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  23874. */
  23875. angularSensibility: number;
  23876. private _pointerInput;
  23877. private _onMouseMove;
  23878. private _observer;
  23879. private previousPosition;
  23880. /**
  23881. * Observable for when a pointer move event occurs containing the move offset
  23882. */
  23883. onPointerMovedObservable: Observable<{
  23884. offsetX: number;
  23885. offsetY: number;
  23886. }>;
  23887. /**
  23888. * @hidden
  23889. * If the camera should be rotated automatically based on pointer movement
  23890. */
  23891. _allowCameraRotation: boolean;
  23892. /**
  23893. * Manage the mouse inputs to control the movement of a free camera.
  23894. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  23895. * @param touchEnabled Defines if touch is enabled or not
  23896. */
  23897. constructor(
  23898. /**
  23899. * Define if touch is enabled in the mouse input
  23900. */
  23901. touchEnabled?: boolean);
  23902. /**
  23903. * Attach the input controls to a specific dom element to get the input from.
  23904. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  23905. */
  23906. attachControl(noPreventDefault?: boolean): void;
  23907. /**
  23908. * Called on JS contextmenu event.
  23909. * Override this method to provide functionality.
  23910. */
  23911. protected onContextMenu(evt: PointerEvent): void;
  23912. /**
  23913. * Detach the current controls from the specified dom element.
  23914. */
  23915. detachControl(): void;
  23916. /**
  23917. * Gets the class name of the current intput.
  23918. * @returns the class name
  23919. */
  23920. getClassName(): string;
  23921. /**
  23922. * Get the friendly name associated with the input class.
  23923. * @returns the input friendly name
  23924. */
  23925. getSimpleName(): string;
  23926. }
  23927. }
  23928. declare module BABYLON {
  23929. /**
  23930. * Base class for mouse wheel input..
  23931. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  23932. * for example usage.
  23933. */
  23934. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  23935. /**
  23936. * Defines the camera the input is attached to.
  23937. */
  23938. abstract camera: Camera;
  23939. /**
  23940. * How fast is the camera moves in relation to X axis mouseWheel events.
  23941. * Use negative value to reverse direction.
  23942. */
  23943. wheelPrecisionX: number;
  23944. /**
  23945. * How fast is the camera moves in relation to Y axis mouseWheel events.
  23946. * Use negative value to reverse direction.
  23947. */
  23948. wheelPrecisionY: number;
  23949. /**
  23950. * How fast is the camera moves in relation to Z axis mouseWheel events.
  23951. * Use negative value to reverse direction.
  23952. */
  23953. wheelPrecisionZ: number;
  23954. /**
  23955. * Observable for when a mouse wheel move event occurs.
  23956. */
  23957. onChangedObservable: Observable<{
  23958. wheelDeltaX: number;
  23959. wheelDeltaY: number;
  23960. wheelDeltaZ: number;
  23961. }>;
  23962. private _wheel;
  23963. private _observer;
  23964. /**
  23965. * Attach the input controls to a specific dom element to get the input from.
  23966. * @param noPreventDefault Defines whether event caught by the controls
  23967. * should call preventdefault().
  23968. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  23969. */
  23970. attachControl(noPreventDefault?: boolean): void;
  23971. /**
  23972. * Detach the current controls from the specified dom element.
  23973. */
  23974. detachControl(): void;
  23975. /**
  23976. * Called for each rendered frame.
  23977. */
  23978. checkInputs(): void;
  23979. /**
  23980. * Gets the class name of the current intput.
  23981. * @returns the class name
  23982. */
  23983. getClassName(): string;
  23984. /**
  23985. * Get the friendly name associated with the input class.
  23986. * @returns the input friendly name
  23987. */
  23988. getSimpleName(): string;
  23989. /**
  23990. * Incremental value of multiple mouse wheel movements of the X axis.
  23991. * Should be zero-ed when read.
  23992. */
  23993. protected _wheelDeltaX: number;
  23994. /**
  23995. * Incremental value of multiple mouse wheel movements of the Y axis.
  23996. * Should be zero-ed when read.
  23997. */
  23998. protected _wheelDeltaY: number;
  23999. /**
  24000. * Incremental value of multiple mouse wheel movements of the Z axis.
  24001. * Should be zero-ed when read.
  24002. */
  24003. protected _wheelDeltaZ: number;
  24004. /**
  24005. * Firefox uses a different scheme to report scroll distances to other
  24006. * browsers. Rather than use complicated methods to calculate the exact
  24007. * multiple we need to apply, let's just cheat and use a constant.
  24008. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  24009. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  24010. */
  24011. private readonly _ffMultiplier;
  24012. /**
  24013. * Different event attributes for wheel data fall into a few set ranges.
  24014. * Some relevant but dated date here:
  24015. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  24016. */
  24017. private readonly _normalize;
  24018. }
  24019. }
  24020. declare module BABYLON {
  24021. /**
  24022. * Manage the mouse wheel inputs to control a free camera.
  24023. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24024. */
  24025. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  24026. /**
  24027. * Defines the camera the input is attached to.
  24028. */
  24029. camera: FreeCamera;
  24030. /**
  24031. * Gets the class name of the current input.
  24032. * @returns the class name
  24033. */
  24034. getClassName(): string;
  24035. /**
  24036. * Set which movement axis (relative to camera's orientation) the mouse
  24037. * wheel's X axis controls.
  24038. * @param axis The axis to be moved. Set null to clear.
  24039. */
  24040. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  24041. /**
  24042. * Get the configured movement axis (relative to camera's orientation) the
  24043. * mouse wheel's X axis controls.
  24044. * @returns The configured axis or null if none.
  24045. */
  24046. get wheelXMoveRelative(): Nullable<Coordinate>;
  24047. /**
  24048. * Set which movement axis (relative to camera's orientation) the mouse
  24049. * wheel's Y axis controls.
  24050. * @param axis The axis to be moved. Set null to clear.
  24051. */
  24052. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  24053. /**
  24054. * Get the configured movement axis (relative to camera's orientation) the
  24055. * mouse wheel's Y axis controls.
  24056. * @returns The configured axis or null if none.
  24057. */
  24058. get wheelYMoveRelative(): Nullable<Coordinate>;
  24059. /**
  24060. * Set which movement axis (relative to camera's orientation) the mouse
  24061. * wheel's Z axis controls.
  24062. * @param axis The axis to be moved. Set null to clear.
  24063. */
  24064. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  24065. /**
  24066. * Get the configured movement axis (relative to camera's orientation) the
  24067. * mouse wheel's Z axis controls.
  24068. * @returns The configured axis or null if none.
  24069. */
  24070. get wheelZMoveRelative(): Nullable<Coordinate>;
  24071. /**
  24072. * Set which rotation axis (relative to camera's orientation) the mouse
  24073. * wheel's X axis controls.
  24074. * @param axis The axis to be moved. Set null to clear.
  24075. */
  24076. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  24077. /**
  24078. * Get the configured rotation axis (relative to camera's orientation) the
  24079. * mouse wheel's X axis controls.
  24080. * @returns The configured axis or null if none.
  24081. */
  24082. get wheelXRotateRelative(): Nullable<Coordinate>;
  24083. /**
  24084. * Set which rotation axis (relative to camera's orientation) the mouse
  24085. * wheel's Y axis controls.
  24086. * @param axis The axis to be moved. Set null to clear.
  24087. */
  24088. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  24089. /**
  24090. * Get the configured rotation axis (relative to camera's orientation) the
  24091. * mouse wheel's Y axis controls.
  24092. * @returns The configured axis or null if none.
  24093. */
  24094. get wheelYRotateRelative(): Nullable<Coordinate>;
  24095. /**
  24096. * Set which rotation axis (relative to camera's orientation) the mouse
  24097. * wheel's Z axis controls.
  24098. * @param axis The axis to be moved. Set null to clear.
  24099. */
  24100. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  24101. /**
  24102. * Get the configured rotation axis (relative to camera's orientation) the
  24103. * mouse wheel's Z axis controls.
  24104. * @returns The configured axis or null if none.
  24105. */
  24106. get wheelZRotateRelative(): Nullable<Coordinate>;
  24107. /**
  24108. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  24109. * controls.
  24110. * @param axis The axis to be moved. Set null to clear.
  24111. */
  24112. set wheelXMoveScene(axis: Nullable<Coordinate>);
  24113. /**
  24114. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24115. * X axis controls.
  24116. * @returns The configured axis or null if none.
  24117. */
  24118. get wheelXMoveScene(): Nullable<Coordinate>;
  24119. /**
  24120. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  24121. * controls.
  24122. * @param axis The axis to be moved. Set null to clear.
  24123. */
  24124. set wheelYMoveScene(axis: Nullable<Coordinate>);
  24125. /**
  24126. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24127. * Y axis controls.
  24128. * @returns The configured axis or null if none.
  24129. */
  24130. get wheelYMoveScene(): Nullable<Coordinate>;
  24131. /**
  24132. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  24133. * controls.
  24134. * @param axis The axis to be moved. Set null to clear.
  24135. */
  24136. set wheelZMoveScene(axis: Nullable<Coordinate>);
  24137. /**
  24138. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24139. * Z axis controls.
  24140. * @returns The configured axis or null if none.
  24141. */
  24142. get wheelZMoveScene(): Nullable<Coordinate>;
  24143. /**
  24144. * Called for each rendered frame.
  24145. */
  24146. checkInputs(): void;
  24147. private _moveRelative;
  24148. private _rotateRelative;
  24149. private _moveScene;
  24150. /**
  24151. * These are set to the desired default behaviour.
  24152. */
  24153. private _wheelXAction;
  24154. private _wheelXActionCoordinate;
  24155. private _wheelYAction;
  24156. private _wheelYActionCoordinate;
  24157. private _wheelZAction;
  24158. private _wheelZActionCoordinate;
  24159. /**
  24160. * Update the camera according to any configured properties for the 3
  24161. * mouse-wheel axis.
  24162. */
  24163. private _updateCamera;
  24164. }
  24165. }
  24166. declare module BABYLON {
  24167. /**
  24168. * Manage the touch inputs to control the movement of a free camera.
  24169. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24170. */
  24171. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  24172. /**
  24173. * Define if mouse events can be treated as touch events
  24174. */
  24175. allowMouse: boolean;
  24176. /**
  24177. * Defines the camera the input is attached to.
  24178. */
  24179. camera: FreeCamera;
  24180. /**
  24181. * Defines the touch sensibility for rotation.
  24182. * The higher the faster.
  24183. */
  24184. touchAngularSensibility: number;
  24185. /**
  24186. * Defines the touch sensibility for move.
  24187. * The higher the faster.
  24188. */
  24189. touchMoveSensibility: number;
  24190. private _offsetX;
  24191. private _offsetY;
  24192. private _pointerPressed;
  24193. private _pointerInput?;
  24194. private _observer;
  24195. private _onLostFocus;
  24196. /**
  24197. * Manage the touch inputs to control the movement of a free camera.
  24198. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24199. * @param allowMouse Defines if mouse events can be treated as touch events
  24200. */
  24201. constructor(
  24202. /**
  24203. * Define if mouse events can be treated as touch events
  24204. */
  24205. allowMouse?: boolean);
  24206. /**
  24207. * Attach the input controls to a specific dom element to get the input from.
  24208. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24209. */
  24210. attachControl(noPreventDefault?: boolean): void;
  24211. /**
  24212. * Detach the current controls from the specified dom element.
  24213. */
  24214. detachControl(): void;
  24215. /**
  24216. * Update the current camera state depending on the inputs that have been used this frame.
  24217. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  24218. */
  24219. checkInputs(): void;
  24220. /**
  24221. * Gets the class name of the current intput.
  24222. * @returns the class name
  24223. */
  24224. getClassName(): string;
  24225. /**
  24226. * Get the friendly name associated with the input class.
  24227. * @returns the input friendly name
  24228. */
  24229. getSimpleName(): string;
  24230. }
  24231. }
  24232. declare module BABYLON {
  24233. /**
  24234. * Default Inputs manager for the FreeCamera.
  24235. * It groups all the default supported inputs for ease of use.
  24236. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24237. */
  24238. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  24239. /**
  24240. * @hidden
  24241. */
  24242. _mouseInput: Nullable<FreeCameraMouseInput>;
  24243. /**
  24244. * @hidden
  24245. */
  24246. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  24247. /**
  24248. * Instantiates a new FreeCameraInputsManager.
  24249. * @param camera Defines the camera the inputs belong to
  24250. */
  24251. constructor(camera: FreeCamera);
  24252. /**
  24253. * Add keyboard input support to the input manager.
  24254. * @returns the current input manager
  24255. */
  24256. addKeyboard(): FreeCameraInputsManager;
  24257. /**
  24258. * Add mouse input support to the input manager.
  24259. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  24260. * @returns the current input manager
  24261. */
  24262. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  24263. /**
  24264. * Removes the mouse input support from the manager
  24265. * @returns the current input manager
  24266. */
  24267. removeMouse(): FreeCameraInputsManager;
  24268. /**
  24269. * Add mouse wheel input support to the input manager.
  24270. * @returns the current input manager
  24271. */
  24272. addMouseWheel(): FreeCameraInputsManager;
  24273. /**
  24274. * Removes the mouse wheel input support from the manager
  24275. * @returns the current input manager
  24276. */
  24277. removeMouseWheel(): FreeCameraInputsManager;
  24278. /**
  24279. * Add touch input support to the input manager.
  24280. * @returns the current input manager
  24281. */
  24282. addTouch(): FreeCameraInputsManager;
  24283. /**
  24284. * Remove all attached input methods from a camera
  24285. */
  24286. clear(): void;
  24287. }
  24288. }
  24289. declare module BABYLON {
  24290. /**
  24291. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  24292. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  24293. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  24294. */
  24295. export class FreeCamera extends TargetCamera {
  24296. /**
  24297. * Define the collision ellipsoid of the camera.
  24298. * This is helpful to simulate a camera body like the player body around the camera
  24299. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  24300. */
  24301. ellipsoid: Vector3;
  24302. /**
  24303. * Define an offset for the position of the ellipsoid around the camera.
  24304. * This can be helpful to determine the center of the body near the gravity center of the body
  24305. * instead of its head.
  24306. */
  24307. ellipsoidOffset: Vector3;
  24308. /**
  24309. * Enable or disable collisions of the camera with the rest of the scene objects.
  24310. */
  24311. checkCollisions: boolean;
  24312. /**
  24313. * Enable or disable gravity on the camera.
  24314. */
  24315. applyGravity: boolean;
  24316. /**
  24317. * Define the input manager associated to the camera.
  24318. */
  24319. inputs: FreeCameraInputsManager;
  24320. /**
  24321. * Gets the input sensibility for a mouse input. (default is 2000.0)
  24322. * Higher values reduce sensitivity.
  24323. */
  24324. get angularSensibility(): number;
  24325. /**
  24326. * Sets the input sensibility for a mouse input. (default is 2000.0)
  24327. * Higher values reduce sensitivity.
  24328. */
  24329. set angularSensibility(value: number);
  24330. /**
  24331. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  24332. */
  24333. get keysUp(): number[];
  24334. set keysUp(value: number[]);
  24335. /**
  24336. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  24337. */
  24338. get keysUpward(): number[];
  24339. set keysUpward(value: number[]);
  24340. /**
  24341. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  24342. */
  24343. get keysDown(): number[];
  24344. set keysDown(value: number[]);
  24345. /**
  24346. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  24347. */
  24348. get keysDownward(): number[];
  24349. set keysDownward(value: number[]);
  24350. /**
  24351. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  24352. */
  24353. get keysLeft(): number[];
  24354. set keysLeft(value: number[]);
  24355. /**
  24356. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  24357. */
  24358. get keysRight(): number[];
  24359. set keysRight(value: number[]);
  24360. /**
  24361. * Event raised when the camera collide with a mesh in the scene.
  24362. */
  24363. onCollide: (collidedMesh: AbstractMesh) => void;
  24364. private _collider;
  24365. private _needMoveForGravity;
  24366. private _oldPosition;
  24367. private _diffPosition;
  24368. private _newPosition;
  24369. /** @hidden */
  24370. _localDirection: Vector3;
  24371. /** @hidden */
  24372. _transformedDirection: Vector3;
  24373. /**
  24374. * Instantiates a Free Camera.
  24375. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  24376. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  24377. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  24378. * @param name Define the name of the camera in the scene
  24379. * @param position Define the start position of the camera in the scene
  24380. * @param scene Define the scene the camera belongs to
  24381. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  24382. */
  24383. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24384. /**
  24385. * Attach the input controls to a specific dom element to get the input from.
  24386. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24387. */
  24388. attachControl(noPreventDefault?: boolean): void;
  24389. /**
  24390. * Attach the input controls to a specific dom element to get the input from.
  24391. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  24392. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24393. * BACK COMPAT SIGNATURE ONLY.
  24394. */
  24395. attachControl(ignored: any, noPreventDefault?: boolean): void;
  24396. /**
  24397. * Detach the current controls from the specified dom element.
  24398. */
  24399. detachControl(): void;
  24400. /**
  24401. * Detach the current controls from the specified dom element.
  24402. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  24403. */
  24404. detachControl(ignored: any): void;
  24405. private _collisionMask;
  24406. /**
  24407. * Define a collision mask to limit the list of object the camera can collide with
  24408. */
  24409. get collisionMask(): number;
  24410. set collisionMask(mask: number);
  24411. /** @hidden */
  24412. _collideWithWorld(displacement: Vector3): void;
  24413. private _onCollisionPositionChange;
  24414. /** @hidden */
  24415. _checkInputs(): void;
  24416. /** @hidden */
  24417. _decideIfNeedsToMove(): boolean;
  24418. /** @hidden */
  24419. _updatePosition(): void;
  24420. /**
  24421. * Destroy the camera and release the current resources hold by it.
  24422. */
  24423. dispose(): void;
  24424. /**
  24425. * Gets the current object class name.
  24426. * @return the class name
  24427. */
  24428. getClassName(): string;
  24429. }
  24430. }
  24431. declare module BABYLON {
  24432. /**
  24433. * Represents a gamepad control stick position
  24434. */
  24435. export class StickValues {
  24436. /**
  24437. * The x component of the control stick
  24438. */
  24439. x: number;
  24440. /**
  24441. * The y component of the control stick
  24442. */
  24443. y: number;
  24444. /**
  24445. * Initializes the gamepad x and y control stick values
  24446. * @param x The x component of the gamepad control stick value
  24447. * @param y The y component of the gamepad control stick value
  24448. */
  24449. constructor(
  24450. /**
  24451. * The x component of the control stick
  24452. */
  24453. x: number,
  24454. /**
  24455. * The y component of the control stick
  24456. */
  24457. y: number);
  24458. }
  24459. /**
  24460. * An interface which manages callbacks for gamepad button changes
  24461. */
  24462. export interface GamepadButtonChanges {
  24463. /**
  24464. * Called when a gamepad has been changed
  24465. */
  24466. changed: boolean;
  24467. /**
  24468. * Called when a gamepad press event has been triggered
  24469. */
  24470. pressChanged: boolean;
  24471. /**
  24472. * Called when a touch event has been triggered
  24473. */
  24474. touchChanged: boolean;
  24475. /**
  24476. * Called when a value has changed
  24477. */
  24478. valueChanged: boolean;
  24479. }
  24480. /**
  24481. * Represents a gamepad
  24482. */
  24483. export class Gamepad {
  24484. /**
  24485. * The id of the gamepad
  24486. */
  24487. id: string;
  24488. /**
  24489. * The index of the gamepad
  24490. */
  24491. index: number;
  24492. /**
  24493. * The browser gamepad
  24494. */
  24495. browserGamepad: any;
  24496. /**
  24497. * Specifies what type of gamepad this represents
  24498. */
  24499. type: number;
  24500. private _leftStick;
  24501. private _rightStick;
  24502. /** @hidden */
  24503. _isConnected: boolean;
  24504. private _leftStickAxisX;
  24505. private _leftStickAxisY;
  24506. private _rightStickAxisX;
  24507. private _rightStickAxisY;
  24508. /**
  24509. * Triggered when the left control stick has been changed
  24510. */
  24511. private _onleftstickchanged;
  24512. /**
  24513. * Triggered when the right control stick has been changed
  24514. */
  24515. private _onrightstickchanged;
  24516. /**
  24517. * Represents a gamepad controller
  24518. */
  24519. static GAMEPAD: number;
  24520. /**
  24521. * Represents a generic controller
  24522. */
  24523. static GENERIC: number;
  24524. /**
  24525. * Represents an XBox controller
  24526. */
  24527. static XBOX: number;
  24528. /**
  24529. * Represents a pose-enabled controller
  24530. */
  24531. static POSE_ENABLED: number;
  24532. /**
  24533. * Represents an Dual Shock controller
  24534. */
  24535. static DUALSHOCK: number;
  24536. /**
  24537. * Specifies whether the left control stick should be Y-inverted
  24538. */
  24539. protected _invertLeftStickY: boolean;
  24540. /**
  24541. * Specifies if the gamepad has been connected
  24542. */
  24543. get isConnected(): boolean;
  24544. /**
  24545. * Initializes the gamepad
  24546. * @param id The id of the gamepad
  24547. * @param index The index of the gamepad
  24548. * @param browserGamepad The browser gamepad
  24549. * @param leftStickX The x component of the left joystick
  24550. * @param leftStickY The y component of the left joystick
  24551. * @param rightStickX The x component of the right joystick
  24552. * @param rightStickY The y component of the right joystick
  24553. */
  24554. constructor(
  24555. /**
  24556. * The id of the gamepad
  24557. */
  24558. id: string,
  24559. /**
  24560. * The index of the gamepad
  24561. */
  24562. index: number,
  24563. /**
  24564. * The browser gamepad
  24565. */
  24566. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  24567. /**
  24568. * Callback triggered when the left joystick has changed
  24569. * @param callback
  24570. */
  24571. onleftstickchanged(callback: (values: StickValues) => void): void;
  24572. /**
  24573. * Callback triggered when the right joystick has changed
  24574. * @param callback
  24575. */
  24576. onrightstickchanged(callback: (values: StickValues) => void): void;
  24577. /**
  24578. * Gets the left joystick
  24579. */
  24580. get leftStick(): StickValues;
  24581. /**
  24582. * Sets the left joystick values
  24583. */
  24584. set leftStick(newValues: StickValues);
  24585. /**
  24586. * Gets the right joystick
  24587. */
  24588. get rightStick(): StickValues;
  24589. /**
  24590. * Sets the right joystick value
  24591. */
  24592. set rightStick(newValues: StickValues);
  24593. /**
  24594. * Updates the gamepad joystick positions
  24595. */
  24596. update(): void;
  24597. /**
  24598. * Disposes the gamepad
  24599. */
  24600. dispose(): void;
  24601. }
  24602. /**
  24603. * Represents a generic gamepad
  24604. */
  24605. export class GenericPad extends Gamepad {
  24606. private _buttons;
  24607. private _onbuttondown;
  24608. private _onbuttonup;
  24609. /**
  24610. * Observable triggered when a button has been pressed
  24611. */
  24612. onButtonDownObservable: Observable<number>;
  24613. /**
  24614. * Observable triggered when a button has been released
  24615. */
  24616. onButtonUpObservable: Observable<number>;
  24617. /**
  24618. * Callback triggered when a button has been pressed
  24619. * @param callback Called when a button has been pressed
  24620. */
  24621. onbuttondown(callback: (buttonPressed: number) => void): void;
  24622. /**
  24623. * Callback triggered when a button has been released
  24624. * @param callback Called when a button has been released
  24625. */
  24626. onbuttonup(callback: (buttonReleased: number) => void): void;
  24627. /**
  24628. * Initializes the generic gamepad
  24629. * @param id The id of the generic gamepad
  24630. * @param index The index of the generic gamepad
  24631. * @param browserGamepad The browser gamepad
  24632. */
  24633. constructor(id: string, index: number, browserGamepad: any);
  24634. private _setButtonValue;
  24635. /**
  24636. * Updates the generic gamepad
  24637. */
  24638. update(): void;
  24639. /**
  24640. * Disposes the generic gamepad
  24641. */
  24642. dispose(): void;
  24643. }
  24644. }
  24645. declare module BABYLON {
  24646. /**
  24647. * Defines a runtime animation
  24648. */
  24649. export class RuntimeAnimation {
  24650. private _events;
  24651. /**
  24652. * The current frame of the runtime animation
  24653. */
  24654. private _currentFrame;
  24655. /**
  24656. * The animation used by the runtime animation
  24657. */
  24658. private _animation;
  24659. /**
  24660. * The target of the runtime animation
  24661. */
  24662. private _target;
  24663. /**
  24664. * The initiating animatable
  24665. */
  24666. private _host;
  24667. /**
  24668. * The original value of the runtime animation
  24669. */
  24670. private _originalValue;
  24671. /**
  24672. * The original blend value of the runtime animation
  24673. */
  24674. private _originalBlendValue;
  24675. /**
  24676. * The offsets cache of the runtime animation
  24677. */
  24678. private _offsetsCache;
  24679. /**
  24680. * The high limits cache of the runtime animation
  24681. */
  24682. private _highLimitsCache;
  24683. /**
  24684. * Specifies if the runtime animation has been stopped
  24685. */
  24686. private _stopped;
  24687. /**
  24688. * The blending factor of the runtime animation
  24689. */
  24690. private _blendingFactor;
  24691. /**
  24692. * The BabylonJS scene
  24693. */
  24694. private _scene;
  24695. /**
  24696. * The current value of the runtime animation
  24697. */
  24698. private _currentValue;
  24699. /** @hidden */
  24700. _animationState: _IAnimationState;
  24701. /**
  24702. * The active target of the runtime animation
  24703. */
  24704. private _activeTargets;
  24705. private _currentActiveTarget;
  24706. private _directTarget;
  24707. /**
  24708. * The target path of the runtime animation
  24709. */
  24710. private _targetPath;
  24711. /**
  24712. * The weight of the runtime animation
  24713. */
  24714. private _weight;
  24715. /**
  24716. * The ratio offset of the runtime animation
  24717. */
  24718. private _ratioOffset;
  24719. /**
  24720. * The previous delay of the runtime animation
  24721. */
  24722. private _previousDelay;
  24723. /**
  24724. * The previous ratio of the runtime animation
  24725. */
  24726. private _previousRatio;
  24727. private _enableBlending;
  24728. private _keys;
  24729. private _minFrame;
  24730. private _maxFrame;
  24731. private _minValue;
  24732. private _maxValue;
  24733. private _targetIsArray;
  24734. /**
  24735. * Gets the current frame of the runtime animation
  24736. */
  24737. get currentFrame(): number;
  24738. /**
  24739. * Gets the weight of the runtime animation
  24740. */
  24741. get weight(): number;
  24742. /**
  24743. * Gets the current value of the runtime animation
  24744. */
  24745. get currentValue(): any;
  24746. /**
  24747. * Gets the target path of the runtime animation
  24748. */
  24749. get targetPath(): string;
  24750. /**
  24751. * Gets the actual target of the runtime animation
  24752. */
  24753. get target(): any;
  24754. /**
  24755. * Gets the additive state of the runtime animation
  24756. */
  24757. get isAdditive(): boolean;
  24758. /** @hidden */
  24759. _onLoop: () => void;
  24760. /**
  24761. * Create a new RuntimeAnimation object
  24762. * @param target defines the target of the animation
  24763. * @param animation defines the source animation object
  24764. * @param scene defines the hosting scene
  24765. * @param host defines the initiating Animatable
  24766. */
  24767. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  24768. private _preparePath;
  24769. /**
  24770. * Gets the animation from the runtime animation
  24771. */
  24772. get animation(): Animation;
  24773. /**
  24774. * Resets the runtime animation to the beginning
  24775. * @param restoreOriginal defines whether to restore the target property to the original value
  24776. */
  24777. reset(restoreOriginal?: boolean): void;
  24778. /**
  24779. * Specifies if the runtime animation is stopped
  24780. * @returns Boolean specifying if the runtime animation is stopped
  24781. */
  24782. isStopped(): boolean;
  24783. /**
  24784. * Disposes of the runtime animation
  24785. */
  24786. dispose(): void;
  24787. /**
  24788. * Apply the interpolated value to the target
  24789. * @param currentValue defines the value computed by the animation
  24790. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  24791. */
  24792. setValue(currentValue: any, weight: number): void;
  24793. private _getOriginalValues;
  24794. private _setValue;
  24795. /**
  24796. * Gets the loop pmode of the runtime animation
  24797. * @returns Loop Mode
  24798. */
  24799. private _getCorrectLoopMode;
  24800. /**
  24801. * Move the current animation to a given frame
  24802. * @param frame defines the frame to move to
  24803. */
  24804. goToFrame(frame: number): void;
  24805. /**
  24806. * @hidden Internal use only
  24807. */
  24808. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  24809. /**
  24810. * Execute the current animation
  24811. * @param delay defines the delay to add to the current frame
  24812. * @param from defines the lower bound of the animation range
  24813. * @param to defines the upper bound of the animation range
  24814. * @param loop defines if the current animation must loop
  24815. * @param speedRatio defines the current speed ratio
  24816. * @param weight defines the weight of the animation (default is -1 so no weight)
  24817. * @param onLoop optional callback called when animation loops
  24818. * @returns a boolean indicating if the animation is running
  24819. */
  24820. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  24821. }
  24822. }
  24823. declare module BABYLON {
  24824. /**
  24825. * Class used to store an actual running animation
  24826. */
  24827. export class Animatable {
  24828. /** defines the target object */
  24829. target: any;
  24830. /** defines the starting frame number (default is 0) */
  24831. fromFrame: number;
  24832. /** defines the ending frame number (default is 100) */
  24833. toFrame: number;
  24834. /** defines if the animation must loop (default is false) */
  24835. loopAnimation: boolean;
  24836. /** defines a callback to call when animation ends if it is not looping */
  24837. onAnimationEnd?: (() => void) | null | undefined;
  24838. /** defines a callback to call when animation loops */
  24839. onAnimationLoop?: (() => void) | null | undefined;
  24840. /** defines whether the animation should be evaluated additively */
  24841. isAdditive: boolean;
  24842. private _localDelayOffset;
  24843. private _pausedDelay;
  24844. private _runtimeAnimations;
  24845. private _paused;
  24846. private _scene;
  24847. private _speedRatio;
  24848. private _weight;
  24849. private _syncRoot;
  24850. /**
  24851. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  24852. * This will only apply for non looping animation (default is true)
  24853. */
  24854. disposeOnEnd: boolean;
  24855. /**
  24856. * Gets a boolean indicating if the animation has started
  24857. */
  24858. animationStarted: boolean;
  24859. /**
  24860. * Observer raised when the animation ends
  24861. */
  24862. onAnimationEndObservable: Observable<Animatable>;
  24863. /**
  24864. * Observer raised when the animation loops
  24865. */
  24866. onAnimationLoopObservable: Observable<Animatable>;
  24867. /**
  24868. * Gets the root Animatable used to synchronize and normalize animations
  24869. */
  24870. get syncRoot(): Nullable<Animatable>;
  24871. /**
  24872. * Gets the current frame of the first RuntimeAnimation
  24873. * Used to synchronize Animatables
  24874. */
  24875. get masterFrame(): number;
  24876. /**
  24877. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  24878. */
  24879. get weight(): number;
  24880. set weight(value: number);
  24881. /**
  24882. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  24883. */
  24884. get speedRatio(): number;
  24885. set speedRatio(value: number);
  24886. /**
  24887. * Creates a new Animatable
  24888. * @param scene defines the hosting scene
  24889. * @param target defines the target object
  24890. * @param fromFrame defines the starting frame number (default is 0)
  24891. * @param toFrame defines the ending frame number (default is 100)
  24892. * @param loopAnimation defines if the animation must loop (default is false)
  24893. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  24894. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  24895. * @param animations defines a group of animation to add to the new Animatable
  24896. * @param onAnimationLoop defines a callback to call when animation loops
  24897. * @param isAdditive defines whether the animation should be evaluated additively
  24898. */
  24899. constructor(scene: Scene,
  24900. /** defines the target object */
  24901. target: any,
  24902. /** defines the starting frame number (default is 0) */
  24903. fromFrame?: number,
  24904. /** defines the ending frame number (default is 100) */
  24905. toFrame?: number,
  24906. /** defines if the animation must loop (default is false) */
  24907. loopAnimation?: boolean, speedRatio?: number,
  24908. /** defines a callback to call when animation ends if it is not looping */
  24909. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  24910. /** defines a callback to call when animation loops */
  24911. onAnimationLoop?: (() => void) | null | undefined,
  24912. /** defines whether the animation should be evaluated additively */
  24913. isAdditive?: boolean);
  24914. /**
  24915. * Synchronize and normalize current Animatable with a source Animatable
  24916. * This is useful when using animation weights and when animations are not of the same length
  24917. * @param root defines the root Animatable to synchronize with
  24918. * @returns the current Animatable
  24919. */
  24920. syncWith(root: Animatable): Animatable;
  24921. /**
  24922. * Gets the list of runtime animations
  24923. * @returns an array of RuntimeAnimation
  24924. */
  24925. getAnimations(): RuntimeAnimation[];
  24926. /**
  24927. * Adds more animations to the current animatable
  24928. * @param target defines the target of the animations
  24929. * @param animations defines the new animations to add
  24930. */
  24931. appendAnimations(target: any, animations: Animation[]): void;
  24932. /**
  24933. * Gets the source animation for a specific property
  24934. * @param property defines the propertyu to look for
  24935. * @returns null or the source animation for the given property
  24936. */
  24937. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  24938. /**
  24939. * Gets the runtime animation for a specific property
  24940. * @param property defines the propertyu to look for
  24941. * @returns null or the runtime animation for the given property
  24942. */
  24943. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  24944. /**
  24945. * Resets the animatable to its original state
  24946. */
  24947. reset(): void;
  24948. /**
  24949. * Allows the animatable to blend with current running animations
  24950. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  24951. * @param blendingSpeed defines the blending speed to use
  24952. */
  24953. enableBlending(blendingSpeed: number): void;
  24954. /**
  24955. * Disable animation blending
  24956. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  24957. */
  24958. disableBlending(): void;
  24959. /**
  24960. * Jump directly to a given frame
  24961. * @param frame defines the frame to jump to
  24962. */
  24963. goToFrame(frame: number): void;
  24964. /**
  24965. * Pause the animation
  24966. */
  24967. pause(): void;
  24968. /**
  24969. * Restart the animation
  24970. */
  24971. restart(): void;
  24972. private _raiseOnAnimationEnd;
  24973. /**
  24974. * Stop and delete the current animation
  24975. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  24976. * @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)
  24977. */
  24978. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  24979. /**
  24980. * Wait asynchronously for the animation to end
  24981. * @returns a promise which will be fullfilled when the animation ends
  24982. */
  24983. waitAsync(): Promise<Animatable>;
  24984. /** @hidden */
  24985. _animate(delay: number): boolean;
  24986. }
  24987. interface Scene {
  24988. /** @hidden */
  24989. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  24990. /** @hidden */
  24991. _processLateAnimationBindingsForMatrices(holder: {
  24992. totalWeight: number;
  24993. totalAdditiveWeight: number;
  24994. animations: RuntimeAnimation[];
  24995. additiveAnimations: RuntimeAnimation[];
  24996. originalValue: Matrix;
  24997. }): any;
  24998. /** @hidden */
  24999. _processLateAnimationBindingsForQuaternions(holder: {
  25000. totalWeight: number;
  25001. totalAdditiveWeight: number;
  25002. animations: RuntimeAnimation[];
  25003. additiveAnimations: RuntimeAnimation[];
  25004. originalValue: Quaternion;
  25005. }, refQuaternion: Quaternion): Quaternion;
  25006. /** @hidden */
  25007. _processLateAnimationBindings(): void;
  25008. /**
  25009. * Will start the animation sequence of a given target
  25010. * @param target defines the target
  25011. * @param from defines from which frame should animation start
  25012. * @param to defines until which frame should animation run.
  25013. * @param weight defines the weight to apply to the animation (1.0 by default)
  25014. * @param loop defines if the animation loops
  25015. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25016. * @param onAnimationEnd defines the function to be executed when the animation ends
  25017. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25018. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  25019. * @param onAnimationLoop defines the callback to call when an animation loops
  25020. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25021. * @returns the animatable object created for this animation
  25022. */
  25023. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  25024. /**
  25025. * Will start the animation sequence of a given target
  25026. * @param target defines the target
  25027. * @param from defines from which frame should animation start
  25028. * @param to defines until which frame should animation run.
  25029. * @param loop defines if the animation loops
  25030. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25031. * @param onAnimationEnd defines the function to be executed when the animation ends
  25032. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25033. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  25034. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  25035. * @param onAnimationLoop defines the callback to call when an animation loops
  25036. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25037. * @returns the animatable object created for this animation
  25038. */
  25039. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  25040. /**
  25041. * Will start the animation sequence of a given target and its hierarchy
  25042. * @param target defines the target
  25043. * @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.
  25044. * @param from defines from which frame should animation start
  25045. * @param to defines until which frame should animation run.
  25046. * @param loop defines if the animation loops
  25047. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25048. * @param onAnimationEnd defines the function to be executed when the animation ends
  25049. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25050. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  25051. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  25052. * @param onAnimationLoop defines the callback to call when an animation loops
  25053. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25054. * @returns the list of created animatables
  25055. */
  25056. 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, isAdditive?: boolean): Animatable[];
  25057. /**
  25058. * Begin a new animation on a given node
  25059. * @param target defines the target where the animation will take place
  25060. * @param animations defines the list of animations to start
  25061. * @param from defines the initial value
  25062. * @param to defines the final value
  25063. * @param loop defines if you want animation to loop (off by default)
  25064. * @param speedRatio defines the speed ratio to apply to all animations
  25065. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25066. * @param onAnimationLoop defines the callback to call when an animation loops
  25067. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25068. * @returns the list of created animatables
  25069. */
  25070. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  25071. /**
  25072. * Begin a new animation on a given node and its hierarchy
  25073. * @param target defines the root node where the animation will take place
  25074. * @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.
  25075. * @param animations defines the list of animations to start
  25076. * @param from defines the initial value
  25077. * @param to defines the final value
  25078. * @param loop defines if you want animation to loop (off by default)
  25079. * @param speedRatio defines the speed ratio to apply to all animations
  25080. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25081. * @param onAnimationLoop defines the callback to call when an animation loops
  25082. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25083. * @returns the list of animatables created for all nodes
  25084. */
  25085. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  25086. /**
  25087. * Gets the animatable associated with a specific target
  25088. * @param target defines the target of the animatable
  25089. * @returns the required animatable if found
  25090. */
  25091. getAnimatableByTarget(target: any): Nullable<Animatable>;
  25092. /**
  25093. * Gets all animatables associated with a given target
  25094. * @param target defines the target to look animatables for
  25095. * @returns an array of Animatables
  25096. */
  25097. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  25098. /**
  25099. * Stops and removes all animations that have been applied to the scene
  25100. */
  25101. stopAllAnimations(): void;
  25102. /**
  25103. * Gets the current delta time used by animation engine
  25104. */
  25105. deltaTime: number;
  25106. }
  25107. interface Bone {
  25108. /**
  25109. * Copy an animation range from another bone
  25110. * @param source defines the source bone
  25111. * @param rangeName defines the range name to copy
  25112. * @param frameOffset defines the frame offset
  25113. * @param rescaleAsRequired defines if rescaling must be applied if required
  25114. * @param skelDimensionsRatio defines the scaling ratio
  25115. * @returns true if operation was successful
  25116. */
  25117. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  25118. }
  25119. }
  25120. declare module BABYLON {
  25121. /**
  25122. * Class used to override all child animations of a given target
  25123. */
  25124. export class AnimationPropertiesOverride {
  25125. /**
  25126. * Gets or sets a value indicating if animation blending must be used
  25127. */
  25128. enableBlending: boolean;
  25129. /**
  25130. * Gets or sets the blending speed to use when enableBlending is true
  25131. */
  25132. blendingSpeed: number;
  25133. /**
  25134. * Gets or sets the default loop mode to use
  25135. */
  25136. loopMode: number;
  25137. }
  25138. }
  25139. declare module BABYLON {
  25140. /**
  25141. * Class used to handle skinning animations
  25142. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25143. */
  25144. export class Skeleton implements IAnimatable {
  25145. /** defines the skeleton name */
  25146. name: string;
  25147. /** defines the skeleton Id */
  25148. id: string;
  25149. /**
  25150. * Defines the list of child bones
  25151. */
  25152. bones: Bone[];
  25153. /**
  25154. * Defines an estimate of the dimension of the skeleton at rest
  25155. */
  25156. dimensionsAtRest: Vector3;
  25157. /**
  25158. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  25159. */
  25160. needInitialSkinMatrix: boolean;
  25161. /**
  25162. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  25163. */
  25164. overrideMesh: Nullable<AbstractMesh>;
  25165. /**
  25166. * Gets the list of animations attached to this skeleton
  25167. */
  25168. animations: Array<Animation>;
  25169. private _scene;
  25170. private _isDirty;
  25171. private _transformMatrices;
  25172. private _transformMatrixTexture;
  25173. private _meshesWithPoseMatrix;
  25174. private _animatables;
  25175. private _identity;
  25176. private _synchronizedWithMesh;
  25177. private _ranges;
  25178. private _lastAbsoluteTransformsUpdateId;
  25179. private _canUseTextureForBones;
  25180. private _uniqueId;
  25181. /** @hidden */
  25182. _numBonesWithLinkedTransformNode: number;
  25183. /** @hidden */
  25184. _hasWaitingData: Nullable<boolean>;
  25185. /** @hidden */
  25186. _waitingOverrideMeshId: Nullable<string>;
  25187. /**
  25188. * Specifies if the skeleton should be serialized
  25189. */
  25190. doNotSerialize: boolean;
  25191. private _useTextureToStoreBoneMatrices;
  25192. /**
  25193. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  25194. * Please note that this option is not available if the hardware does not support it
  25195. */
  25196. get useTextureToStoreBoneMatrices(): boolean;
  25197. set useTextureToStoreBoneMatrices(value: boolean);
  25198. private _animationPropertiesOverride;
  25199. /**
  25200. * Gets or sets the animation properties override
  25201. */
  25202. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25203. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  25204. /**
  25205. * List of inspectable custom properties (used by the Inspector)
  25206. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25207. */
  25208. inspectableCustomProperties: IInspectable[];
  25209. /**
  25210. * An observable triggered before computing the skeleton's matrices
  25211. */
  25212. onBeforeComputeObservable: Observable<Skeleton>;
  25213. /**
  25214. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  25215. */
  25216. get isUsingTextureForMatrices(): boolean;
  25217. /**
  25218. * Gets the unique ID of this skeleton
  25219. */
  25220. get uniqueId(): number;
  25221. /**
  25222. * Creates a new skeleton
  25223. * @param name defines the skeleton name
  25224. * @param id defines the skeleton Id
  25225. * @param scene defines the hosting scene
  25226. */
  25227. constructor(
  25228. /** defines the skeleton name */
  25229. name: string,
  25230. /** defines the skeleton Id */
  25231. id: string, scene: Scene);
  25232. /**
  25233. * Gets the current object class name.
  25234. * @return the class name
  25235. */
  25236. getClassName(): string;
  25237. /**
  25238. * Returns an array containing the root bones
  25239. * @returns an array containing the root bones
  25240. */
  25241. getChildren(): Array<Bone>;
  25242. /**
  25243. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  25244. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  25245. * @returns a Float32Array containing matrices data
  25246. */
  25247. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  25248. /**
  25249. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  25250. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  25251. * @returns a raw texture containing the data
  25252. */
  25253. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  25254. /**
  25255. * Gets the current hosting scene
  25256. * @returns a scene object
  25257. */
  25258. getScene(): Scene;
  25259. /**
  25260. * Gets a string representing the current skeleton data
  25261. * @param fullDetails defines a boolean indicating if we want a verbose version
  25262. * @returns a string representing the current skeleton data
  25263. */
  25264. toString(fullDetails?: boolean): string;
  25265. /**
  25266. * Get bone's index searching by name
  25267. * @param name defines bone's name to search for
  25268. * @return the indice of the bone. Returns -1 if not found
  25269. */
  25270. getBoneIndexByName(name: string): number;
  25271. /**
  25272. * Creater a new animation range
  25273. * @param name defines the name of the range
  25274. * @param from defines the start key
  25275. * @param to defines the end key
  25276. */
  25277. createAnimationRange(name: string, from: number, to: number): void;
  25278. /**
  25279. * Delete a specific animation range
  25280. * @param name defines the name of the range
  25281. * @param deleteFrames defines if frames must be removed as well
  25282. */
  25283. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25284. /**
  25285. * Gets a specific animation range
  25286. * @param name defines the name of the range to look for
  25287. * @returns the requested animation range or null if not found
  25288. */
  25289. getAnimationRange(name: string): Nullable<AnimationRange>;
  25290. /**
  25291. * Gets the list of all animation ranges defined on this skeleton
  25292. * @returns an array
  25293. */
  25294. getAnimationRanges(): Nullable<AnimationRange>[];
  25295. /**
  25296. * Copy animation range from a source skeleton.
  25297. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  25298. * @param source defines the source skeleton
  25299. * @param name defines the name of the range to copy
  25300. * @param rescaleAsRequired defines if rescaling must be applied if required
  25301. * @returns true if operation was successful
  25302. */
  25303. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  25304. /**
  25305. * Forces the skeleton to go to rest pose
  25306. */
  25307. returnToRest(): void;
  25308. private _getHighestAnimationFrame;
  25309. /**
  25310. * Begin a specific animation range
  25311. * @param name defines the name of the range to start
  25312. * @param loop defines if looping must be turned on (false by default)
  25313. * @param speedRatio defines the speed ratio to apply (1 by default)
  25314. * @param onAnimationEnd defines a callback which will be called when animation will end
  25315. * @returns a new animatable
  25316. */
  25317. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25318. /**
  25319. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  25320. * @param skeleton defines the Skeleton containing the animation range to convert
  25321. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  25322. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  25323. * @returns the original skeleton
  25324. */
  25325. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  25326. /** @hidden */
  25327. _markAsDirty(): void;
  25328. /** @hidden */
  25329. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  25330. /** @hidden */
  25331. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  25332. private _computeTransformMatrices;
  25333. /**
  25334. * Build all resources required to render a skeleton
  25335. */
  25336. prepare(): void;
  25337. /**
  25338. * Gets the list of animatables currently running for this skeleton
  25339. * @returns an array of animatables
  25340. */
  25341. getAnimatables(): IAnimatable[];
  25342. /**
  25343. * Clone the current skeleton
  25344. * @param name defines the name of the new skeleton
  25345. * @param id defines the id of the new skeleton
  25346. * @returns the new skeleton
  25347. */
  25348. clone(name: string, id?: string): Skeleton;
  25349. /**
  25350. * Enable animation blending for this skeleton
  25351. * @param blendingSpeed defines the blending speed to apply
  25352. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25353. */
  25354. enableBlending(blendingSpeed?: number): void;
  25355. /**
  25356. * Releases all resources associated with the current skeleton
  25357. */
  25358. dispose(): void;
  25359. /**
  25360. * Serialize the skeleton in a JSON object
  25361. * @returns a JSON object
  25362. */
  25363. serialize(): any;
  25364. /**
  25365. * Creates a new skeleton from serialized data
  25366. * @param parsedSkeleton defines the serialized data
  25367. * @param scene defines the hosting scene
  25368. * @returns a new skeleton
  25369. */
  25370. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  25371. /**
  25372. * Compute all node absolute transforms
  25373. * @param forceUpdate defines if computation must be done even if cache is up to date
  25374. */
  25375. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  25376. /**
  25377. * Gets the root pose matrix
  25378. * @returns a matrix
  25379. */
  25380. getPoseMatrix(): Nullable<Matrix>;
  25381. /**
  25382. * Sorts bones per internal index
  25383. */
  25384. sortBones(): void;
  25385. private _sortBones;
  25386. /**
  25387. * Set the current local matrix as the restPose for all bones in the skeleton.
  25388. */
  25389. setCurrentPoseAsRest(): void;
  25390. }
  25391. }
  25392. declare module BABYLON {
  25393. /**
  25394. * Class used to store bone information
  25395. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25396. */
  25397. export class Bone extends Node {
  25398. /**
  25399. * defines the bone name
  25400. */
  25401. name: string;
  25402. private static _tmpVecs;
  25403. private static _tmpQuat;
  25404. private static _tmpMats;
  25405. /**
  25406. * Gets the list of child bones
  25407. */
  25408. children: Bone[];
  25409. /** Gets the animations associated with this bone */
  25410. animations: Animation[];
  25411. /**
  25412. * Gets or sets bone length
  25413. */
  25414. length: number;
  25415. /**
  25416. * @hidden Internal only
  25417. * Set this value to map this bone to a different index in the transform matrices
  25418. * Set this value to -1 to exclude the bone from the transform matrices
  25419. */
  25420. _index: Nullable<number>;
  25421. private _skeleton;
  25422. private _localMatrix;
  25423. private _restPose;
  25424. private _bindPose;
  25425. private _baseMatrix;
  25426. private _absoluteTransform;
  25427. private _invertedAbsoluteTransform;
  25428. private _parent;
  25429. private _scalingDeterminant;
  25430. private _worldTransform;
  25431. private _localScaling;
  25432. private _localRotation;
  25433. private _localPosition;
  25434. private _needToDecompose;
  25435. private _needToCompose;
  25436. /** @hidden */
  25437. _linkedTransformNode: Nullable<TransformNode>;
  25438. /** @hidden */
  25439. _waitingTransformNodeId: Nullable<string>;
  25440. /** @hidden */
  25441. get _matrix(): Matrix;
  25442. /** @hidden */
  25443. set _matrix(value: Matrix);
  25444. /**
  25445. * Create a new bone
  25446. * @param name defines the bone name
  25447. * @param skeleton defines the parent skeleton
  25448. * @param parentBone defines the parent (can be null if the bone is the root)
  25449. * @param localMatrix defines the local matrix
  25450. * @param restPose defines the rest pose matrix
  25451. * @param baseMatrix defines the base matrix
  25452. * @param index defines index of the bone in the hiearchy
  25453. */
  25454. constructor(
  25455. /**
  25456. * defines the bone name
  25457. */
  25458. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  25459. /**
  25460. * Gets the current object class name.
  25461. * @return the class name
  25462. */
  25463. getClassName(): string;
  25464. /**
  25465. * Gets the parent skeleton
  25466. * @returns a skeleton
  25467. */
  25468. getSkeleton(): Skeleton;
  25469. /**
  25470. * Gets parent bone
  25471. * @returns a bone or null if the bone is the root of the bone hierarchy
  25472. */
  25473. getParent(): Nullable<Bone>;
  25474. /**
  25475. * Returns an array containing the root bones
  25476. * @returns an array containing the root bones
  25477. */
  25478. getChildren(): Array<Bone>;
  25479. /**
  25480. * Gets the node index in matrix array generated for rendering
  25481. * @returns the node index
  25482. */
  25483. getIndex(): number;
  25484. /**
  25485. * Sets the parent bone
  25486. * @param parent defines the parent (can be null if the bone is the root)
  25487. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  25488. */
  25489. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  25490. /**
  25491. * Gets the local matrix
  25492. * @returns a matrix
  25493. */
  25494. getLocalMatrix(): Matrix;
  25495. /**
  25496. * Gets the base matrix (initial matrix which remains unchanged)
  25497. * @returns a matrix
  25498. */
  25499. getBaseMatrix(): Matrix;
  25500. /**
  25501. * Gets the rest pose matrix
  25502. * @returns a matrix
  25503. */
  25504. getRestPose(): Matrix;
  25505. /**
  25506. * Sets the rest pose matrix
  25507. * @param matrix the local-space rest pose to set for this bone
  25508. */
  25509. setRestPose(matrix: Matrix): void;
  25510. /**
  25511. * Gets the bind pose matrix
  25512. * @returns the bind pose matrix
  25513. */
  25514. getBindPose(): Matrix;
  25515. /**
  25516. * Sets the bind pose matrix
  25517. * @param matrix the local-space bind pose to set for this bone
  25518. */
  25519. setBindPose(matrix: Matrix): void;
  25520. /**
  25521. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  25522. */
  25523. getWorldMatrix(): Matrix;
  25524. /**
  25525. * Sets the local matrix to rest pose matrix
  25526. */
  25527. returnToRest(): void;
  25528. /**
  25529. * Gets the inverse of the absolute transform matrix.
  25530. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  25531. * @returns a matrix
  25532. */
  25533. getInvertedAbsoluteTransform(): Matrix;
  25534. /**
  25535. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  25536. * @returns a matrix
  25537. */
  25538. getAbsoluteTransform(): Matrix;
  25539. /**
  25540. * Links with the given transform node.
  25541. * The local matrix of this bone is copied from the transform node every frame.
  25542. * @param transformNode defines the transform node to link to
  25543. */
  25544. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  25545. /**
  25546. * Gets the node used to drive the bone's transformation
  25547. * @returns a transform node or null
  25548. */
  25549. getTransformNode(): Nullable<TransformNode>;
  25550. /** Gets or sets current position (in local space) */
  25551. get position(): Vector3;
  25552. set position(newPosition: Vector3);
  25553. /** Gets or sets current rotation (in local space) */
  25554. get rotation(): Vector3;
  25555. set rotation(newRotation: Vector3);
  25556. /** Gets or sets current rotation quaternion (in local space) */
  25557. get rotationQuaternion(): Quaternion;
  25558. set rotationQuaternion(newRotation: Quaternion);
  25559. /** Gets or sets current scaling (in local space) */
  25560. get scaling(): Vector3;
  25561. set scaling(newScaling: Vector3);
  25562. /**
  25563. * Gets the animation properties override
  25564. */
  25565. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25566. private _decompose;
  25567. private _compose;
  25568. /**
  25569. * Update the base and local matrices
  25570. * @param matrix defines the new base or local matrix
  25571. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  25572. * @param updateLocalMatrix defines if the local matrix should be updated
  25573. */
  25574. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  25575. /** @hidden */
  25576. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  25577. /**
  25578. * Flag the bone as dirty (Forcing it to update everything)
  25579. */
  25580. markAsDirty(): void;
  25581. /** @hidden */
  25582. _markAsDirtyAndCompose(): void;
  25583. private _markAsDirtyAndDecompose;
  25584. /**
  25585. * Translate the bone in local or world space
  25586. * @param vec The amount to translate the bone
  25587. * @param space The space that the translation is in
  25588. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25589. */
  25590. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  25591. /**
  25592. * Set the postion of the bone in local or world space
  25593. * @param position The position to set the bone
  25594. * @param space The space that the position is in
  25595. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25596. */
  25597. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  25598. /**
  25599. * Set the absolute position of the bone (world space)
  25600. * @param position The position to set the bone
  25601. * @param mesh The mesh that this bone is attached to
  25602. */
  25603. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  25604. /**
  25605. * Scale the bone on the x, y and z axes (in local space)
  25606. * @param x The amount to scale the bone on the x axis
  25607. * @param y The amount to scale the bone on the y axis
  25608. * @param z The amount to scale the bone on the z axis
  25609. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  25610. */
  25611. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  25612. /**
  25613. * Set the bone scaling in local space
  25614. * @param scale defines the scaling vector
  25615. */
  25616. setScale(scale: Vector3): void;
  25617. /**
  25618. * Gets the current scaling in local space
  25619. * @returns the current scaling vector
  25620. */
  25621. getScale(): Vector3;
  25622. /**
  25623. * Gets the current scaling in local space and stores it in a target vector
  25624. * @param result defines the target vector
  25625. */
  25626. getScaleToRef(result: Vector3): void;
  25627. /**
  25628. * Set the yaw, pitch, and roll of the bone in local or world space
  25629. * @param yaw The rotation of the bone on the y axis
  25630. * @param pitch The rotation of the bone on the x axis
  25631. * @param roll The rotation of the bone on the z axis
  25632. * @param space The space that the axes of rotation are in
  25633. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25634. */
  25635. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  25636. /**
  25637. * Add a rotation to the bone on an axis in local or world space
  25638. * @param axis The axis to rotate the bone on
  25639. * @param amount The amount to rotate the bone
  25640. * @param space The space that the axis is in
  25641. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25642. */
  25643. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  25644. /**
  25645. * Set the rotation of the bone to a particular axis angle in local or world space
  25646. * @param axis The axis to rotate the bone on
  25647. * @param angle The angle that the bone should be rotated to
  25648. * @param space The space that the axis is in
  25649. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25650. */
  25651. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  25652. /**
  25653. * Set the euler rotation of the bone in local or world space
  25654. * @param rotation The euler rotation that the bone should be set to
  25655. * @param space The space that the rotation is in
  25656. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25657. */
  25658. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  25659. /**
  25660. * Set the quaternion rotation of the bone in local or world space
  25661. * @param quat The quaternion rotation that the bone should be set to
  25662. * @param space The space that the rotation is in
  25663. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25664. */
  25665. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  25666. /**
  25667. * Set the rotation matrix of the bone in local or world space
  25668. * @param rotMat The rotation matrix that the bone should be set to
  25669. * @param space The space that the rotation is in
  25670. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25671. */
  25672. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  25673. private _rotateWithMatrix;
  25674. private _getNegativeRotationToRef;
  25675. /**
  25676. * Get the position of the bone in local or world space
  25677. * @param space The space that the returned position is in
  25678. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25679. * @returns The position of the bone
  25680. */
  25681. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  25682. /**
  25683. * Copy the position of the bone to a vector3 in local or world space
  25684. * @param space The space that the returned position is in
  25685. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25686. * @param result The vector3 to copy the position to
  25687. */
  25688. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  25689. /**
  25690. * Get the absolute position of the bone (world space)
  25691. * @param mesh The mesh that this bone is attached to
  25692. * @returns The absolute position of the bone
  25693. */
  25694. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  25695. /**
  25696. * Copy the absolute position of the bone (world space) to the result param
  25697. * @param mesh The mesh that this bone is attached to
  25698. * @param result The vector3 to copy the absolute position to
  25699. */
  25700. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  25701. /**
  25702. * Compute the absolute transforms of this bone and its children
  25703. */
  25704. computeAbsoluteTransforms(): void;
  25705. /**
  25706. * Get the world direction from an axis that is in the local space of the bone
  25707. * @param localAxis The local direction that is used to compute the world direction
  25708. * @param mesh The mesh that this bone is attached to
  25709. * @returns The world direction
  25710. */
  25711. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  25712. /**
  25713. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  25714. * @param localAxis The local direction that is used to compute the world direction
  25715. * @param mesh The mesh that this bone is attached to
  25716. * @param result The vector3 that the world direction will be copied to
  25717. */
  25718. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  25719. /**
  25720. * Get the euler rotation of the bone in local or world space
  25721. * @param space The space that the rotation should be in
  25722. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25723. * @returns The euler rotation
  25724. */
  25725. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  25726. /**
  25727. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  25728. * @param space The space that the rotation should be in
  25729. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25730. * @param result The vector3 that the rotation should be copied to
  25731. */
  25732. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  25733. /**
  25734. * Get the quaternion rotation of the bone in either local or world space
  25735. * @param space The space that the rotation should be in
  25736. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25737. * @returns The quaternion rotation
  25738. */
  25739. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  25740. /**
  25741. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  25742. * @param space The space that the rotation should be in
  25743. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25744. * @param result The quaternion that the rotation should be copied to
  25745. */
  25746. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  25747. /**
  25748. * Get the rotation matrix of the bone in local or world space
  25749. * @param space The space that the rotation should be in
  25750. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25751. * @returns The rotation matrix
  25752. */
  25753. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  25754. /**
  25755. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  25756. * @param space The space that the rotation should be in
  25757. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25758. * @param result The quaternion that the rotation should be copied to
  25759. */
  25760. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  25761. /**
  25762. * Get the world position of a point that is in the local space of the bone
  25763. * @param position The local position
  25764. * @param mesh The mesh that this bone is attached to
  25765. * @returns The world position
  25766. */
  25767. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  25768. /**
  25769. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  25770. * @param position The local position
  25771. * @param mesh The mesh that this bone is attached to
  25772. * @param result The vector3 that the world position should be copied to
  25773. */
  25774. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  25775. /**
  25776. * Get the local position of a point that is in world space
  25777. * @param position The world position
  25778. * @param mesh The mesh that this bone is attached to
  25779. * @returns The local position
  25780. */
  25781. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  25782. /**
  25783. * Get the local position of a point that is in world space and copy it to the result param
  25784. * @param position The world position
  25785. * @param mesh The mesh that this bone is attached to
  25786. * @param result The vector3 that the local position should be copied to
  25787. */
  25788. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  25789. /**
  25790. * Set the current local matrix as the restPose for this bone.
  25791. */
  25792. setCurrentPoseAsRest(): void;
  25793. }
  25794. }
  25795. declare module BABYLON {
  25796. /**
  25797. * 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.
  25798. * @see https://doc.babylonjs.com/how_to/transformnode
  25799. */
  25800. export class TransformNode extends Node {
  25801. /**
  25802. * Object will not rotate to face the camera
  25803. */
  25804. static BILLBOARDMODE_NONE: number;
  25805. /**
  25806. * Object will rotate to face the camera but only on the x axis
  25807. */
  25808. static BILLBOARDMODE_X: number;
  25809. /**
  25810. * Object will rotate to face the camera but only on the y axis
  25811. */
  25812. static BILLBOARDMODE_Y: number;
  25813. /**
  25814. * Object will rotate to face the camera but only on the z axis
  25815. */
  25816. static BILLBOARDMODE_Z: number;
  25817. /**
  25818. * Object will rotate to face the camera
  25819. */
  25820. static BILLBOARDMODE_ALL: number;
  25821. /**
  25822. * Object will rotate to face the camera's position instead of orientation
  25823. */
  25824. static BILLBOARDMODE_USE_POSITION: number;
  25825. private static _TmpRotation;
  25826. private static _TmpScaling;
  25827. private static _TmpTranslation;
  25828. private _forward;
  25829. private _forwardInverted;
  25830. private _up;
  25831. private _right;
  25832. private _rightInverted;
  25833. private _position;
  25834. private _rotation;
  25835. private _rotationQuaternion;
  25836. protected _scaling: Vector3;
  25837. protected _isDirty: boolean;
  25838. private _transformToBoneReferal;
  25839. private _isAbsoluteSynced;
  25840. private _billboardMode;
  25841. /**
  25842. * Gets or sets the billboard mode. Default is 0.
  25843. *
  25844. * | Value | Type | Description |
  25845. * | --- | --- | --- |
  25846. * | 0 | BILLBOARDMODE_NONE | |
  25847. * | 1 | BILLBOARDMODE_X | |
  25848. * | 2 | BILLBOARDMODE_Y | |
  25849. * | 4 | BILLBOARDMODE_Z | |
  25850. * | 7 | BILLBOARDMODE_ALL | |
  25851. *
  25852. */
  25853. get billboardMode(): number;
  25854. set billboardMode(value: number);
  25855. private _preserveParentRotationForBillboard;
  25856. /**
  25857. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  25858. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  25859. */
  25860. get preserveParentRotationForBillboard(): boolean;
  25861. set preserveParentRotationForBillboard(value: boolean);
  25862. /**
  25863. * 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
  25864. */
  25865. scalingDeterminant: number;
  25866. private _infiniteDistance;
  25867. /**
  25868. * Gets or sets the distance of the object to max, often used by skybox
  25869. */
  25870. get infiniteDistance(): boolean;
  25871. set infiniteDistance(value: boolean);
  25872. /**
  25873. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  25874. * By default the system will update normals to compensate
  25875. */
  25876. ignoreNonUniformScaling: boolean;
  25877. /**
  25878. * 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
  25879. */
  25880. reIntegrateRotationIntoRotationQuaternion: boolean;
  25881. /** @hidden */
  25882. _poseMatrix: Nullable<Matrix>;
  25883. /** @hidden */
  25884. _localMatrix: Matrix;
  25885. private _usePivotMatrix;
  25886. private _absolutePosition;
  25887. private _absoluteScaling;
  25888. private _absoluteRotationQuaternion;
  25889. private _pivotMatrix;
  25890. private _pivotMatrixInverse;
  25891. /** @hidden */
  25892. _postMultiplyPivotMatrix: boolean;
  25893. protected _isWorldMatrixFrozen: boolean;
  25894. /** @hidden */
  25895. _indexInSceneTransformNodesArray: number;
  25896. /**
  25897. * An event triggered after the world matrix is updated
  25898. */
  25899. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  25900. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  25901. /**
  25902. * Gets a string identifying the name of the class
  25903. * @returns "TransformNode" string
  25904. */
  25905. getClassName(): string;
  25906. /**
  25907. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  25908. */
  25909. get position(): Vector3;
  25910. set position(newPosition: Vector3);
  25911. /**
  25912. * 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)).
  25913. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  25914. */
  25915. get rotation(): Vector3;
  25916. set rotation(newRotation: Vector3);
  25917. /**
  25918. * 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)).
  25919. */
  25920. get scaling(): Vector3;
  25921. set scaling(newScaling: Vector3);
  25922. /**
  25923. * 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).
  25924. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  25925. */
  25926. get rotationQuaternion(): Nullable<Quaternion>;
  25927. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  25928. /**
  25929. * The forward direction of that transform in world space.
  25930. */
  25931. get forward(): Vector3;
  25932. /**
  25933. * The up direction of that transform in world space.
  25934. */
  25935. get up(): Vector3;
  25936. /**
  25937. * The right direction of that transform in world space.
  25938. */
  25939. get right(): Vector3;
  25940. /**
  25941. * Copies the parameter passed Matrix into the mesh Pose matrix.
  25942. * @param matrix the matrix to copy the pose from
  25943. * @returns this TransformNode.
  25944. */
  25945. updatePoseMatrix(matrix: Matrix): TransformNode;
  25946. /**
  25947. * Returns the mesh Pose matrix.
  25948. * @returns the pose matrix
  25949. */
  25950. getPoseMatrix(): Matrix;
  25951. /** @hidden */
  25952. _isSynchronized(): boolean;
  25953. /** @hidden */
  25954. _initCache(): void;
  25955. /**
  25956. * Flag the transform node as dirty (Forcing it to update everything)
  25957. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  25958. * @returns this transform node
  25959. */
  25960. markAsDirty(property: string): TransformNode;
  25961. /**
  25962. * Returns the current mesh absolute position.
  25963. * Returns a Vector3.
  25964. */
  25965. get absolutePosition(): Vector3;
  25966. /**
  25967. * Returns the current mesh absolute scaling.
  25968. * Returns a Vector3.
  25969. */
  25970. get absoluteScaling(): Vector3;
  25971. /**
  25972. * Returns the current mesh absolute rotation.
  25973. * Returns a Quaternion.
  25974. */
  25975. get absoluteRotationQuaternion(): Quaternion;
  25976. /**
  25977. * Sets a new matrix to apply before all other transformation
  25978. * @param matrix defines the transform matrix
  25979. * @returns the current TransformNode
  25980. */
  25981. setPreTransformMatrix(matrix: Matrix): TransformNode;
  25982. /**
  25983. * Sets a new pivot matrix to the current node
  25984. * @param matrix defines the new pivot matrix to use
  25985. * @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
  25986. * @returns the current TransformNode
  25987. */
  25988. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  25989. /**
  25990. * Returns the mesh pivot matrix.
  25991. * Default : Identity.
  25992. * @returns the matrix
  25993. */
  25994. getPivotMatrix(): Matrix;
  25995. /**
  25996. * Instantiate (when possible) or clone that node with its hierarchy
  25997. * @param newParent defines the new parent to use for the instance (or clone)
  25998. * @param options defines options to configure how copy is done
  25999. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  26000. * @returns an instance (or a clone) of the current node with its hiearchy
  26001. */
  26002. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  26003. doNotInstantiate: boolean;
  26004. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  26005. /**
  26006. * Prevents the World matrix to be computed any longer
  26007. * @param newWorldMatrix defines an optional matrix to use as world matrix
  26008. * @returns the TransformNode.
  26009. */
  26010. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  26011. /**
  26012. * Allows back the World matrix computation.
  26013. * @returns the TransformNode.
  26014. */
  26015. unfreezeWorldMatrix(): this;
  26016. /**
  26017. * True if the World matrix has been frozen.
  26018. */
  26019. get isWorldMatrixFrozen(): boolean;
  26020. /**
  26021. * Retuns the mesh absolute position in the World.
  26022. * @returns a Vector3.
  26023. */
  26024. getAbsolutePosition(): Vector3;
  26025. /**
  26026. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  26027. * @param absolutePosition the absolute position to set
  26028. * @returns the TransformNode.
  26029. */
  26030. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26031. /**
  26032. * Sets the mesh position in its local space.
  26033. * @param vector3 the position to set in localspace
  26034. * @returns the TransformNode.
  26035. */
  26036. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  26037. /**
  26038. * Returns the mesh position in the local space from the current World matrix values.
  26039. * @returns a new Vector3.
  26040. */
  26041. getPositionExpressedInLocalSpace(): Vector3;
  26042. /**
  26043. * Translates the mesh along the passed Vector3 in its local space.
  26044. * @param vector3 the distance to translate in localspace
  26045. * @returns the TransformNode.
  26046. */
  26047. locallyTranslate(vector3: Vector3): TransformNode;
  26048. private static _lookAtVectorCache;
  26049. /**
  26050. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  26051. * @param targetPoint the position (must be in same space as current mesh) to look at
  26052. * @param yawCor optional yaw (y-axis) correction in radians
  26053. * @param pitchCor optional pitch (x-axis) correction in radians
  26054. * @param rollCor optional roll (z-axis) correction in radians
  26055. * @param space the choosen space of the target
  26056. * @returns the TransformNode.
  26057. */
  26058. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  26059. /**
  26060. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  26061. * This Vector3 is expressed in the World space.
  26062. * @param localAxis axis to rotate
  26063. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  26064. */
  26065. getDirection(localAxis: Vector3): Vector3;
  26066. /**
  26067. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  26068. * localAxis is expressed in the mesh local space.
  26069. * result is computed in the Wordl space from the mesh World matrix.
  26070. * @param localAxis axis to rotate
  26071. * @param result the resulting transformnode
  26072. * @returns this TransformNode.
  26073. */
  26074. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  26075. /**
  26076. * Sets this transform node rotation to the given local axis.
  26077. * @param localAxis the axis in local space
  26078. * @param yawCor optional yaw (y-axis) correction in radians
  26079. * @param pitchCor optional pitch (x-axis) correction in radians
  26080. * @param rollCor optional roll (z-axis) correction in radians
  26081. * @returns this TransformNode
  26082. */
  26083. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  26084. /**
  26085. * Sets a new pivot point to the current node
  26086. * @param point defines the new pivot point to use
  26087. * @param space defines if the point is in world or local space (local by default)
  26088. * @returns the current TransformNode
  26089. */
  26090. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  26091. /**
  26092. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  26093. * @returns the pivot point
  26094. */
  26095. getPivotPoint(): Vector3;
  26096. /**
  26097. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  26098. * @param result the vector3 to store the result
  26099. * @returns this TransformNode.
  26100. */
  26101. getPivotPointToRef(result: Vector3): TransformNode;
  26102. /**
  26103. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  26104. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  26105. */
  26106. getAbsolutePivotPoint(): Vector3;
  26107. /**
  26108. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  26109. * @param result vector3 to store the result
  26110. * @returns this TransformNode.
  26111. */
  26112. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  26113. /**
  26114. * Defines the passed node as the parent of the current node.
  26115. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  26116. * @see https://doc.babylonjs.com/how_to/parenting
  26117. * @param node the node ot set as the parent
  26118. * @returns this TransformNode.
  26119. */
  26120. setParent(node: Nullable<Node>): TransformNode;
  26121. private _nonUniformScaling;
  26122. /**
  26123. * True if the scaling property of this object is non uniform eg. (1,2,1)
  26124. */
  26125. get nonUniformScaling(): boolean;
  26126. /** @hidden */
  26127. _updateNonUniformScalingState(value: boolean): boolean;
  26128. /**
  26129. * Attach the current TransformNode to another TransformNode associated with a bone
  26130. * @param bone Bone affecting the TransformNode
  26131. * @param affectedTransformNode TransformNode associated with the bone
  26132. * @returns this object
  26133. */
  26134. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  26135. /**
  26136. * Detach the transform node if its associated with a bone
  26137. * @returns this object
  26138. */
  26139. detachFromBone(): TransformNode;
  26140. private static _rotationAxisCache;
  26141. /**
  26142. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  26143. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  26144. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  26145. * The passed axis is also normalized.
  26146. * @param axis the axis to rotate around
  26147. * @param amount the amount to rotate in radians
  26148. * @param space Space to rotate in (Default: local)
  26149. * @returns the TransformNode.
  26150. */
  26151. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26152. /**
  26153. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  26154. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  26155. * The passed axis is also normalized. .
  26156. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  26157. * @param point the point to rotate around
  26158. * @param axis the axis to rotate around
  26159. * @param amount the amount to rotate in radians
  26160. * @returns the TransformNode
  26161. */
  26162. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  26163. /**
  26164. * Translates the mesh along the axis vector for the passed distance in the given space.
  26165. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  26166. * @param axis the axis to translate in
  26167. * @param distance the distance to translate
  26168. * @param space Space to rotate in (Default: local)
  26169. * @returns the TransformNode.
  26170. */
  26171. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26172. /**
  26173. * Adds a rotation step to the mesh current rotation.
  26174. * x, y, z are Euler angles expressed in radians.
  26175. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  26176. * This means this rotation is made in the mesh local space only.
  26177. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  26178. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  26179. * ```javascript
  26180. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  26181. * ```
  26182. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  26183. * 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.
  26184. * @param x Rotation to add
  26185. * @param y Rotation to add
  26186. * @param z Rotation to add
  26187. * @returns the TransformNode.
  26188. */
  26189. addRotation(x: number, y: number, z: number): TransformNode;
  26190. /**
  26191. * @hidden
  26192. */
  26193. protected _getEffectiveParent(): Nullable<Node>;
  26194. /**
  26195. * Computes the world matrix of the node
  26196. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26197. * @returns the world matrix
  26198. */
  26199. computeWorldMatrix(force?: boolean): Matrix;
  26200. /**
  26201. * Resets this nodeTransform's local matrix to Matrix.Identity().
  26202. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  26203. */
  26204. resetLocalMatrix(independentOfChildren?: boolean): void;
  26205. protected _afterComputeWorldMatrix(): void;
  26206. /**
  26207. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  26208. * @param func callback function to add
  26209. *
  26210. * @returns the TransformNode.
  26211. */
  26212. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  26213. /**
  26214. * Removes a registered callback function.
  26215. * @param func callback function to remove
  26216. * @returns the TransformNode.
  26217. */
  26218. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  26219. /**
  26220. * Gets the position of the current mesh in camera space
  26221. * @param camera defines the camera to use
  26222. * @returns a position
  26223. */
  26224. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  26225. /**
  26226. * Returns the distance from the mesh to the active camera
  26227. * @param camera defines the camera to use
  26228. * @returns the distance
  26229. */
  26230. getDistanceToCamera(camera?: Nullable<Camera>): number;
  26231. /**
  26232. * Clone the current transform node
  26233. * @param name Name of the new clone
  26234. * @param newParent New parent for the clone
  26235. * @param doNotCloneChildren Do not clone children hierarchy
  26236. * @returns the new transform node
  26237. */
  26238. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  26239. /**
  26240. * Serializes the objects information.
  26241. * @param currentSerializationObject defines the object to serialize in
  26242. * @returns the serialized object
  26243. */
  26244. serialize(currentSerializationObject?: any): any;
  26245. /**
  26246. * Returns a new TransformNode object parsed from the source provided.
  26247. * @param parsedTransformNode is the source.
  26248. * @param scene the scne the object belongs to
  26249. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  26250. * @returns a new TransformNode object parsed from the source provided.
  26251. */
  26252. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  26253. /**
  26254. * Get all child-transformNodes of this node
  26255. * @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
  26256. * @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
  26257. * @returns an array of TransformNode
  26258. */
  26259. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  26260. /**
  26261. * Releases resources associated with this transform node.
  26262. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26263. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26264. */
  26265. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26266. /**
  26267. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26268. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26269. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26270. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26271. * @returns the current mesh
  26272. */
  26273. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  26274. private _syncAbsoluteScalingAndRotation;
  26275. }
  26276. }
  26277. declare module BABYLON {
  26278. /**
  26279. * Defines the types of pose enabled controllers that are supported
  26280. */
  26281. export enum PoseEnabledControllerType {
  26282. /**
  26283. * HTC Vive
  26284. */
  26285. VIVE = 0,
  26286. /**
  26287. * Oculus Rift
  26288. */
  26289. OCULUS = 1,
  26290. /**
  26291. * Windows mixed reality
  26292. */
  26293. WINDOWS = 2,
  26294. /**
  26295. * Samsung gear VR
  26296. */
  26297. GEAR_VR = 3,
  26298. /**
  26299. * Google Daydream
  26300. */
  26301. DAYDREAM = 4,
  26302. /**
  26303. * Generic
  26304. */
  26305. GENERIC = 5
  26306. }
  26307. /**
  26308. * Defines the MutableGamepadButton interface for the state of a gamepad button
  26309. */
  26310. export interface MutableGamepadButton {
  26311. /**
  26312. * Value of the button/trigger
  26313. */
  26314. value: number;
  26315. /**
  26316. * If the button/trigger is currently touched
  26317. */
  26318. touched: boolean;
  26319. /**
  26320. * If the button/trigger is currently pressed
  26321. */
  26322. pressed: boolean;
  26323. }
  26324. /**
  26325. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  26326. * @hidden
  26327. */
  26328. export interface ExtendedGamepadButton extends GamepadButton {
  26329. /**
  26330. * If the button/trigger is currently pressed
  26331. */
  26332. readonly pressed: boolean;
  26333. /**
  26334. * If the button/trigger is currently touched
  26335. */
  26336. readonly touched: boolean;
  26337. /**
  26338. * Value of the button/trigger
  26339. */
  26340. readonly value: number;
  26341. }
  26342. /** @hidden */
  26343. export interface _GamePadFactory {
  26344. /**
  26345. * Returns whether or not the current gamepad can be created for this type of controller.
  26346. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  26347. * @returns true if it can be created, otherwise false
  26348. */
  26349. canCreate(gamepadInfo: any): boolean;
  26350. /**
  26351. * Creates a new instance of the Gamepad.
  26352. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  26353. * @returns the new gamepad instance
  26354. */
  26355. create(gamepadInfo: any): Gamepad;
  26356. }
  26357. /**
  26358. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  26359. */
  26360. export class PoseEnabledControllerHelper {
  26361. /** @hidden */
  26362. static _ControllerFactories: _GamePadFactory[];
  26363. /** @hidden */
  26364. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  26365. /**
  26366. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  26367. * @param vrGamepad the gamepad to initialized
  26368. * @returns a vr controller of the type the gamepad identified as
  26369. */
  26370. static InitiateController(vrGamepad: any): Gamepad;
  26371. }
  26372. /**
  26373. * Defines the PoseEnabledController object that contains state of a vr capable controller
  26374. */
  26375. export class PoseEnabledController extends Gamepad implements PoseControlled {
  26376. /**
  26377. * If the controller is used in a webXR session
  26378. */
  26379. isXR: boolean;
  26380. private _deviceRoomPosition;
  26381. private _deviceRoomRotationQuaternion;
  26382. /**
  26383. * The device position in babylon space
  26384. */
  26385. devicePosition: Vector3;
  26386. /**
  26387. * The device rotation in babylon space
  26388. */
  26389. deviceRotationQuaternion: Quaternion;
  26390. /**
  26391. * The scale factor of the device in babylon space
  26392. */
  26393. deviceScaleFactor: number;
  26394. /**
  26395. * (Likely devicePosition should be used instead) The device position in its room space
  26396. */
  26397. position: Vector3;
  26398. /**
  26399. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  26400. */
  26401. rotationQuaternion: Quaternion;
  26402. /**
  26403. * The type of controller (Eg. Windows mixed reality)
  26404. */
  26405. controllerType: PoseEnabledControllerType;
  26406. protected _calculatedPosition: Vector3;
  26407. private _calculatedRotation;
  26408. /**
  26409. * The raw pose from the device
  26410. */
  26411. rawPose: DevicePose;
  26412. private _trackPosition;
  26413. private _maxRotationDistFromHeadset;
  26414. private _draggedRoomRotation;
  26415. /**
  26416. * @hidden
  26417. */
  26418. _disableTrackPosition(fixedPosition: Vector3): void;
  26419. /**
  26420. * Internal, the mesh attached to the controller
  26421. * @hidden
  26422. */
  26423. _mesh: Nullable<AbstractMesh>;
  26424. private _poseControlledCamera;
  26425. private _leftHandSystemQuaternion;
  26426. /**
  26427. * Internal, matrix used to convert room space to babylon space
  26428. * @hidden
  26429. */
  26430. _deviceToWorld: Matrix;
  26431. /**
  26432. * Node to be used when casting a ray from the controller
  26433. * @hidden
  26434. */
  26435. _pointingPoseNode: Nullable<TransformNode>;
  26436. /**
  26437. * Name of the child mesh that can be used to cast a ray from the controller
  26438. */
  26439. static readonly POINTING_POSE: string;
  26440. /**
  26441. * Creates a new PoseEnabledController from a gamepad
  26442. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  26443. */
  26444. constructor(browserGamepad: any);
  26445. private _workingMatrix;
  26446. /**
  26447. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  26448. */
  26449. update(): void;
  26450. /**
  26451. * Updates only the pose device and mesh without doing any button event checking
  26452. */
  26453. protected _updatePoseAndMesh(): void;
  26454. /**
  26455. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  26456. * @param poseData raw pose fromthe device
  26457. */
  26458. updateFromDevice(poseData: DevicePose): void;
  26459. /**
  26460. * @hidden
  26461. */
  26462. _meshAttachedObservable: Observable<AbstractMesh>;
  26463. /**
  26464. * Attaches a mesh to the controller
  26465. * @param mesh the mesh to be attached
  26466. */
  26467. attachToMesh(mesh: AbstractMesh): void;
  26468. /**
  26469. * Attaches the controllers mesh to a camera
  26470. * @param camera the camera the mesh should be attached to
  26471. */
  26472. attachToPoseControlledCamera(camera: TargetCamera): void;
  26473. /**
  26474. * Disposes of the controller
  26475. */
  26476. dispose(): void;
  26477. /**
  26478. * The mesh that is attached to the controller
  26479. */
  26480. get mesh(): Nullable<AbstractMesh>;
  26481. /**
  26482. * Gets the ray of the controller in the direction the controller is pointing
  26483. * @param length the length the resulting ray should be
  26484. * @returns a ray in the direction the controller is pointing
  26485. */
  26486. getForwardRay(length?: number): Ray;
  26487. }
  26488. }
  26489. declare module BABYLON {
  26490. /**
  26491. * Defines the WebVRController object that represents controllers tracked in 3D space
  26492. */
  26493. export abstract class WebVRController extends PoseEnabledController {
  26494. /**
  26495. * Internal, the default controller model for the controller
  26496. */
  26497. protected _defaultModel: Nullable<AbstractMesh>;
  26498. /**
  26499. * Fired when the trigger state has changed
  26500. */
  26501. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  26502. /**
  26503. * Fired when the main button state has changed
  26504. */
  26505. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  26506. /**
  26507. * Fired when the secondary button state has changed
  26508. */
  26509. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  26510. /**
  26511. * Fired when the pad state has changed
  26512. */
  26513. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  26514. /**
  26515. * Fired when controllers stick values have changed
  26516. */
  26517. onPadValuesChangedObservable: Observable<StickValues>;
  26518. /**
  26519. * Array of button availible on the controller
  26520. */
  26521. protected _buttons: Array<MutableGamepadButton>;
  26522. private _onButtonStateChange;
  26523. /**
  26524. * Fired when a controller button's state has changed
  26525. * @param callback the callback containing the button that was modified
  26526. */
  26527. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  26528. /**
  26529. * X and Y axis corresponding to the controllers joystick
  26530. */
  26531. pad: StickValues;
  26532. /**
  26533. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  26534. */
  26535. hand: string;
  26536. /**
  26537. * The default controller model for the controller
  26538. */
  26539. get defaultModel(): Nullable<AbstractMesh>;
  26540. /**
  26541. * Creates a new WebVRController from a gamepad
  26542. * @param vrGamepad the gamepad that the WebVRController should be created from
  26543. */
  26544. constructor(vrGamepad: any);
  26545. /**
  26546. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  26547. */
  26548. update(): void;
  26549. /**
  26550. * Function to be called when a button is modified
  26551. */
  26552. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  26553. /**
  26554. * Loads a mesh and attaches it to the controller
  26555. * @param scene the scene the mesh should be added to
  26556. * @param meshLoaded callback for when the mesh has been loaded
  26557. */
  26558. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  26559. private _setButtonValue;
  26560. private _changes;
  26561. private _checkChanges;
  26562. /**
  26563. * Disposes of th webVRCOntroller
  26564. */
  26565. dispose(): void;
  26566. }
  26567. }
  26568. declare module BABYLON {
  26569. /**
  26570. * The HemisphericLight simulates the ambient environment light,
  26571. * so the passed direction is the light reflection direction, not the incoming direction.
  26572. */
  26573. export class HemisphericLight extends Light {
  26574. /**
  26575. * The groundColor is the light in the opposite direction to the one specified during creation.
  26576. * 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.
  26577. */
  26578. groundColor: Color3;
  26579. /**
  26580. * The light reflection direction, not the incoming direction.
  26581. */
  26582. direction: Vector3;
  26583. /**
  26584. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  26585. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  26586. * The HemisphericLight can't cast shadows.
  26587. * Documentation : https://doc.babylonjs.com/babylon101/lights
  26588. * @param name The friendly name of the light
  26589. * @param direction The direction of the light reflection
  26590. * @param scene The scene the light belongs to
  26591. */
  26592. constructor(name: string, direction: Vector3, scene: Scene);
  26593. protected _buildUniformLayout(): void;
  26594. /**
  26595. * Returns the string "HemisphericLight".
  26596. * @return The class name
  26597. */
  26598. getClassName(): string;
  26599. /**
  26600. * Sets the HemisphericLight direction towards the passed target (Vector3).
  26601. * Returns the updated direction.
  26602. * @param target The target the direction should point to
  26603. * @return The computed direction
  26604. */
  26605. setDirectionToTarget(target: Vector3): Vector3;
  26606. /**
  26607. * Returns the shadow generator associated to the light.
  26608. * @returns Always null for hemispheric lights because it does not support shadows.
  26609. */
  26610. getShadowGenerator(): Nullable<IShadowGenerator>;
  26611. /**
  26612. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  26613. * @param effect The effect to update
  26614. * @param lightIndex The index of the light in the effect to update
  26615. * @returns The hemispheric light
  26616. */
  26617. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  26618. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  26619. /**
  26620. * Computes the world matrix of the node
  26621. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26622. * @param useWasUpdatedFlag defines a reserved property
  26623. * @returns the world matrix
  26624. */
  26625. computeWorldMatrix(): Matrix;
  26626. /**
  26627. * Returns the integer 3.
  26628. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  26629. */
  26630. getTypeID(): number;
  26631. /**
  26632. * Prepares the list of defines specific to the light type.
  26633. * @param defines the list of defines
  26634. * @param lightIndex defines the index of the light for the effect
  26635. */
  26636. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  26637. }
  26638. }
  26639. declare module BABYLON {
  26640. /** @hidden */
  26641. export var vrMultiviewToSingleviewPixelShader: {
  26642. name: string;
  26643. shader: string;
  26644. };
  26645. }
  26646. declare module BABYLON {
  26647. /**
  26648. * Renders to multiple views with a single draw call
  26649. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  26650. */
  26651. export class MultiviewRenderTarget extends RenderTargetTexture {
  26652. /**
  26653. * Creates a multiview render target
  26654. * @param scene scene used with the render target
  26655. * @param size the size of the render target (used for each view)
  26656. */
  26657. constructor(scene: Scene, size?: number | {
  26658. width: number;
  26659. height: number;
  26660. } | {
  26661. ratio: number;
  26662. });
  26663. /**
  26664. * @hidden
  26665. * @param faceIndex the face index, if its a cube texture
  26666. */
  26667. _bindFrameBuffer(faceIndex?: number): void;
  26668. /**
  26669. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  26670. * @returns the view count
  26671. */
  26672. getViewCount(): number;
  26673. }
  26674. }
  26675. declare module BABYLON {
  26676. interface Engine {
  26677. /**
  26678. * Creates a new multiview render target
  26679. * @param width defines the width of the texture
  26680. * @param height defines the height of the texture
  26681. * @returns the created multiview texture
  26682. */
  26683. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  26684. /**
  26685. * Binds a multiview framebuffer to be drawn to
  26686. * @param multiviewTexture texture to bind
  26687. */
  26688. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  26689. }
  26690. interface Camera {
  26691. /**
  26692. * @hidden
  26693. * 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)
  26694. */
  26695. _useMultiviewToSingleView: boolean;
  26696. /**
  26697. * @hidden
  26698. * 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)
  26699. */
  26700. _multiviewTexture: Nullable<RenderTargetTexture>;
  26701. /**
  26702. * @hidden
  26703. * ensures the multiview texture of the camera exists and has the specified width/height
  26704. * @param width height to set on the multiview texture
  26705. * @param height width to set on the multiview texture
  26706. */
  26707. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  26708. }
  26709. interface Scene {
  26710. /** @hidden */
  26711. _transformMatrixR: Matrix;
  26712. /** @hidden */
  26713. _multiviewSceneUbo: Nullable<UniformBuffer>;
  26714. /** @hidden */
  26715. _createMultiviewUbo(): void;
  26716. /** @hidden */
  26717. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  26718. /** @hidden */
  26719. _renderMultiviewToSingleView(camera: Camera): void;
  26720. }
  26721. }
  26722. declare module BABYLON {
  26723. /**
  26724. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  26725. * This will not be used for webXR as it supports displaying texture arrays directly
  26726. */
  26727. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  26728. /**
  26729. * Gets a string identifying the name of the class
  26730. * @returns "VRMultiviewToSingleviewPostProcess" string
  26731. */
  26732. getClassName(): string;
  26733. /**
  26734. * Initializes a VRMultiviewToSingleview
  26735. * @param name name of the post process
  26736. * @param camera camera to be applied to
  26737. * @param scaleFactor scaling factor to the size of the output texture
  26738. */
  26739. constructor(name: string, camera: Camera, scaleFactor: number);
  26740. }
  26741. }
  26742. declare module BABYLON {
  26743. /**
  26744. * Interface used to define additional presentation attributes
  26745. */
  26746. export interface IVRPresentationAttributes {
  26747. /**
  26748. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  26749. */
  26750. highRefreshRate: boolean;
  26751. /**
  26752. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  26753. */
  26754. foveationLevel: number;
  26755. }
  26756. interface Engine {
  26757. /** @hidden */
  26758. _vrDisplay: any;
  26759. /** @hidden */
  26760. _vrSupported: boolean;
  26761. /** @hidden */
  26762. _oldSize: Size;
  26763. /** @hidden */
  26764. _oldHardwareScaleFactor: number;
  26765. /** @hidden */
  26766. _vrExclusivePointerMode: boolean;
  26767. /** @hidden */
  26768. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  26769. /** @hidden */
  26770. _onVRDisplayPointerRestricted: () => void;
  26771. /** @hidden */
  26772. _onVRDisplayPointerUnrestricted: () => void;
  26773. /** @hidden */
  26774. _onVrDisplayConnect: Nullable<(display: any) => void>;
  26775. /** @hidden */
  26776. _onVrDisplayDisconnect: Nullable<() => void>;
  26777. /** @hidden */
  26778. _onVrDisplayPresentChange: Nullable<() => void>;
  26779. /**
  26780. * Observable signaled when VR display mode changes
  26781. */
  26782. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  26783. /**
  26784. * Observable signaled when VR request present is complete
  26785. */
  26786. onVRRequestPresentComplete: Observable<boolean>;
  26787. /**
  26788. * Observable signaled when VR request present starts
  26789. */
  26790. onVRRequestPresentStart: Observable<Engine>;
  26791. /**
  26792. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  26793. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  26794. */
  26795. isInVRExclusivePointerMode: boolean;
  26796. /**
  26797. * Gets a boolean indicating if a webVR device was detected
  26798. * @returns true if a webVR device was detected
  26799. */
  26800. isVRDevicePresent(): boolean;
  26801. /**
  26802. * Gets the current webVR device
  26803. * @returns the current webVR device (or null)
  26804. */
  26805. getVRDevice(): any;
  26806. /**
  26807. * Initializes a webVR display and starts listening to display change events
  26808. * The onVRDisplayChangedObservable will be notified upon these changes
  26809. * @returns A promise containing a VRDisplay and if vr is supported
  26810. */
  26811. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  26812. /** @hidden */
  26813. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  26814. /**
  26815. * Gets or sets the presentation attributes used to configure VR rendering
  26816. */
  26817. vrPresentationAttributes?: IVRPresentationAttributes;
  26818. /**
  26819. * Call this function to switch to webVR mode
  26820. * Will do nothing if webVR is not supported or if there is no webVR device
  26821. * @param options the webvr options provided to the camera. mainly used for multiview
  26822. * @see https://doc.babylonjs.com/how_to/webvr_camera
  26823. */
  26824. enableVR(options: WebVROptions): void;
  26825. /** @hidden */
  26826. _onVRFullScreenTriggered(): void;
  26827. }
  26828. }
  26829. declare module BABYLON {
  26830. /**
  26831. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  26832. * IMPORTANT!! The data is right-hand data.
  26833. * @export
  26834. * @interface DevicePose
  26835. */
  26836. export interface DevicePose {
  26837. /**
  26838. * The position of the device, values in array are [x,y,z].
  26839. */
  26840. readonly position: Nullable<Float32Array>;
  26841. /**
  26842. * The linearVelocity of the device, values in array are [x,y,z].
  26843. */
  26844. readonly linearVelocity: Nullable<Float32Array>;
  26845. /**
  26846. * The linearAcceleration of the device, values in array are [x,y,z].
  26847. */
  26848. readonly linearAcceleration: Nullable<Float32Array>;
  26849. /**
  26850. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  26851. */
  26852. readonly orientation: Nullable<Float32Array>;
  26853. /**
  26854. * The angularVelocity of the device, values in array are [x,y,z].
  26855. */
  26856. readonly angularVelocity: Nullable<Float32Array>;
  26857. /**
  26858. * The angularAcceleration of the device, values in array are [x,y,z].
  26859. */
  26860. readonly angularAcceleration: Nullable<Float32Array>;
  26861. }
  26862. /**
  26863. * Interface representing a pose controlled object in Babylon.
  26864. * A pose controlled object has both regular pose values as well as pose values
  26865. * from an external device such as a VR head mounted display
  26866. */
  26867. export interface PoseControlled {
  26868. /**
  26869. * The position of the object in babylon space.
  26870. */
  26871. position: Vector3;
  26872. /**
  26873. * The rotation quaternion of the object in babylon space.
  26874. */
  26875. rotationQuaternion: Quaternion;
  26876. /**
  26877. * The position of the device in babylon space.
  26878. */
  26879. devicePosition?: Vector3;
  26880. /**
  26881. * The rotation quaternion of the device in babylon space.
  26882. */
  26883. deviceRotationQuaternion: Quaternion;
  26884. /**
  26885. * The raw pose coming from the device.
  26886. */
  26887. rawPose: Nullable<DevicePose>;
  26888. /**
  26889. * The scale of the device to be used when translating from device space to babylon space.
  26890. */
  26891. deviceScaleFactor: number;
  26892. /**
  26893. * Updates the poseControlled values based on the input device pose.
  26894. * @param poseData the pose data to update the object with
  26895. */
  26896. updateFromDevice(poseData: DevicePose): void;
  26897. }
  26898. /**
  26899. * Set of options to customize the webVRCamera
  26900. */
  26901. export interface WebVROptions {
  26902. /**
  26903. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  26904. */
  26905. trackPosition?: boolean;
  26906. /**
  26907. * Sets the scale of the vrDevice in babylon space. (default: 1)
  26908. */
  26909. positionScale?: number;
  26910. /**
  26911. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  26912. */
  26913. displayName?: string;
  26914. /**
  26915. * Should the native controller meshes be initialized. (default: true)
  26916. */
  26917. controllerMeshes?: boolean;
  26918. /**
  26919. * Creating a default HemiLight only on controllers. (default: true)
  26920. */
  26921. defaultLightingOnControllers?: boolean;
  26922. /**
  26923. * If you don't want to use the default VR button of the helper. (default: false)
  26924. */
  26925. useCustomVRButton?: boolean;
  26926. /**
  26927. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  26928. */
  26929. customVRButton?: HTMLButtonElement;
  26930. /**
  26931. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  26932. */
  26933. rayLength?: number;
  26934. /**
  26935. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  26936. */
  26937. defaultHeight?: number;
  26938. /**
  26939. * If multiview should be used if availible (default: false)
  26940. */
  26941. useMultiview?: boolean;
  26942. }
  26943. /**
  26944. * This represents a WebVR camera.
  26945. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  26946. * @example https://doc.babylonjs.com/how_to/webvr_camera
  26947. */
  26948. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  26949. private webVROptions;
  26950. /**
  26951. * @hidden
  26952. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  26953. */
  26954. _vrDevice: any;
  26955. /**
  26956. * The rawPose of the vrDevice.
  26957. */
  26958. rawPose: Nullable<DevicePose>;
  26959. private _onVREnabled;
  26960. private _specsVersion;
  26961. private _attached;
  26962. private _frameData;
  26963. protected _descendants: Array<Node>;
  26964. private _deviceRoomPosition;
  26965. /** @hidden */
  26966. _deviceRoomRotationQuaternion: Quaternion;
  26967. private _standingMatrix;
  26968. /**
  26969. * Represents device position in babylon space.
  26970. */
  26971. devicePosition: Vector3;
  26972. /**
  26973. * Represents device rotation in babylon space.
  26974. */
  26975. deviceRotationQuaternion: Quaternion;
  26976. /**
  26977. * The scale of the device to be used when translating from device space to babylon space.
  26978. */
  26979. deviceScaleFactor: number;
  26980. private _deviceToWorld;
  26981. private _worldToDevice;
  26982. /**
  26983. * References to the webVR controllers for the vrDevice.
  26984. */
  26985. controllers: Array<WebVRController>;
  26986. /**
  26987. * Emits an event when a controller is attached.
  26988. */
  26989. onControllersAttachedObservable: Observable<WebVRController[]>;
  26990. /**
  26991. * Emits an event when a controller's mesh has been loaded;
  26992. */
  26993. onControllerMeshLoadedObservable: Observable<WebVRController>;
  26994. /**
  26995. * Emits an event when the HMD's pose has been updated.
  26996. */
  26997. onPoseUpdatedFromDeviceObservable: Observable<any>;
  26998. private _poseSet;
  26999. /**
  27000. * If the rig cameras be used as parent instead of this camera.
  27001. */
  27002. rigParenting: boolean;
  27003. private _lightOnControllers;
  27004. private _defaultHeight?;
  27005. /**
  27006. * Instantiates a WebVRFreeCamera.
  27007. * @param name The name of the WebVRFreeCamera
  27008. * @param position The starting anchor position for the camera
  27009. * @param scene The scene the camera belongs to
  27010. * @param webVROptions a set of customizable options for the webVRCamera
  27011. */
  27012. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  27013. /**
  27014. * Gets the device distance from the ground in meters.
  27015. * @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.
  27016. */
  27017. deviceDistanceToRoomGround(): number;
  27018. /**
  27019. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  27020. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  27021. */
  27022. useStandingMatrix(callback?: (bool: boolean) => void): void;
  27023. /**
  27024. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  27025. * @returns A promise with a boolean set to if the standing matrix is supported.
  27026. */
  27027. useStandingMatrixAsync(): Promise<boolean>;
  27028. /**
  27029. * Disposes the camera
  27030. */
  27031. dispose(): void;
  27032. /**
  27033. * Gets a vrController by name.
  27034. * @param name The name of the controller to retreive
  27035. * @returns the controller matching the name specified or null if not found
  27036. */
  27037. getControllerByName(name: string): Nullable<WebVRController>;
  27038. private _leftController;
  27039. /**
  27040. * The controller corresponding to the users left hand.
  27041. */
  27042. get leftController(): Nullable<WebVRController>;
  27043. private _rightController;
  27044. /**
  27045. * The controller corresponding to the users right hand.
  27046. */
  27047. get rightController(): Nullable<WebVRController>;
  27048. /**
  27049. * Casts a ray forward from the vrCamera's gaze.
  27050. * @param length Length of the ray (default: 100)
  27051. * @returns the ray corresponding to the gaze
  27052. */
  27053. getForwardRay(length?: number): Ray;
  27054. /**
  27055. * @hidden
  27056. * Updates the camera based on device's frame data
  27057. */
  27058. _checkInputs(): void;
  27059. /**
  27060. * Updates the poseControlled values based on the input device pose.
  27061. * @param poseData Pose coming from the device
  27062. */
  27063. updateFromDevice(poseData: DevicePose): void;
  27064. private _detachIfAttached;
  27065. /**
  27066. * WebVR's attach control will start broadcasting frames to the device.
  27067. * Note that in certain browsers (chrome for example) this function must be called
  27068. * within a user-interaction callback. Example:
  27069. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  27070. *
  27071. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  27072. */
  27073. attachControl(noPreventDefault?: boolean): void;
  27074. /**
  27075. * Detach the current controls from the specified dom element.
  27076. */
  27077. detachControl(): void;
  27078. /**
  27079. * @returns the name of this class
  27080. */
  27081. getClassName(): string;
  27082. /**
  27083. * Calls resetPose on the vrDisplay
  27084. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  27085. */
  27086. resetToCurrentRotation(): void;
  27087. /**
  27088. * @hidden
  27089. * Updates the rig cameras (left and right eye)
  27090. */
  27091. _updateRigCameras(): void;
  27092. private _workingVector;
  27093. private _oneVector;
  27094. private _workingMatrix;
  27095. private updateCacheCalled;
  27096. private _correctPositionIfNotTrackPosition;
  27097. /**
  27098. * @hidden
  27099. * Updates the cached values of the camera
  27100. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  27101. */
  27102. _updateCache(ignoreParentClass?: boolean): void;
  27103. /**
  27104. * @hidden
  27105. * Get current device position in babylon world
  27106. */
  27107. _computeDevicePosition(): void;
  27108. /**
  27109. * Updates the current device position and rotation in the babylon world
  27110. */
  27111. update(): void;
  27112. /**
  27113. * @hidden
  27114. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  27115. * @returns an identity matrix
  27116. */
  27117. _getViewMatrix(): Matrix;
  27118. private _tmpMatrix;
  27119. /**
  27120. * This function is called by the two RIG cameras.
  27121. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  27122. * @hidden
  27123. */
  27124. _getWebVRViewMatrix(): Matrix;
  27125. /** @hidden */
  27126. _getWebVRProjectionMatrix(): Matrix;
  27127. private _onGamepadConnectedObserver;
  27128. private _onGamepadDisconnectedObserver;
  27129. private _updateCacheWhenTrackingDisabledObserver;
  27130. /**
  27131. * Initializes the controllers and their meshes
  27132. */
  27133. initControllers(): void;
  27134. }
  27135. }
  27136. declare module BABYLON {
  27137. /**
  27138. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  27139. *
  27140. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  27141. *
  27142. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  27143. */
  27144. export class MaterialHelper {
  27145. /**
  27146. * Bind the current view position to an effect.
  27147. * @param effect The effect to be bound
  27148. * @param scene The scene the eyes position is used from
  27149. * @param variableName name of the shader variable that will hold the eye position
  27150. */
  27151. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  27152. /**
  27153. * Helps preparing the defines values about the UVs in used in the effect.
  27154. * UVs are shared as much as we can accross channels in the shaders.
  27155. * @param texture The texture we are preparing the UVs for
  27156. * @param defines The defines to update
  27157. * @param key The channel key "diffuse", "specular"... used in the shader
  27158. */
  27159. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  27160. /**
  27161. * Binds a texture matrix value to its corrsponding uniform
  27162. * @param texture The texture to bind the matrix for
  27163. * @param uniformBuffer The uniform buffer receivin the data
  27164. * @param key The channel key "diffuse", "specular"... used in the shader
  27165. */
  27166. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  27167. /**
  27168. * Gets the current status of the fog (should it be enabled?)
  27169. * @param mesh defines the mesh to evaluate for fog support
  27170. * @param scene defines the hosting scene
  27171. * @returns true if fog must be enabled
  27172. */
  27173. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  27174. /**
  27175. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  27176. * @param mesh defines the current mesh
  27177. * @param scene defines the current scene
  27178. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  27179. * @param pointsCloud defines if point cloud rendering has to be turned on
  27180. * @param fogEnabled defines if fog has to be turned on
  27181. * @param alphaTest defines if alpha testing has to be turned on
  27182. * @param defines defines the current list of defines
  27183. */
  27184. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  27185. /**
  27186. * Helper used to prepare the list of defines associated with frame values for shader compilation
  27187. * @param scene defines the current scene
  27188. * @param engine defines the current engine
  27189. * @param defines specifies the list of active defines
  27190. * @param useInstances defines if instances have to be turned on
  27191. * @param useClipPlane defines if clip plane have to be turned on
  27192. * @param useInstances defines if instances have to be turned on
  27193. * @param useThinInstances defines if thin instances have to be turned on
  27194. */
  27195. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  27196. /**
  27197. * Prepares the defines for bones
  27198. * @param mesh The mesh containing the geometry data we will draw
  27199. * @param defines The defines to update
  27200. */
  27201. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  27202. /**
  27203. * Prepares the defines for morph targets
  27204. * @param mesh The mesh containing the geometry data we will draw
  27205. * @param defines The defines to update
  27206. */
  27207. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  27208. /**
  27209. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  27210. * @param mesh The mesh containing the geometry data we will draw
  27211. * @param defines The defines to update
  27212. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  27213. * @param useBones Precise whether bones should be used or not (override mesh info)
  27214. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  27215. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  27216. * @returns false if defines are considered not dirty and have not been checked
  27217. */
  27218. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  27219. /**
  27220. * Prepares the defines related to multiview
  27221. * @param scene The scene we are intending to draw
  27222. * @param defines The defines to update
  27223. */
  27224. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  27225. /**
  27226. * Prepares the defines related to the prepass
  27227. * @param scene The scene we are intending to draw
  27228. * @param defines The defines to update
  27229. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  27230. */
  27231. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  27232. /**
  27233. * Prepares the defines related to the light information passed in parameter
  27234. * @param scene The scene we are intending to draw
  27235. * @param mesh The mesh the effect is compiling for
  27236. * @param light The light the effect is compiling for
  27237. * @param lightIndex The index of the light
  27238. * @param defines The defines to update
  27239. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  27240. * @param state Defines the current state regarding what is needed (normals, etc...)
  27241. */
  27242. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  27243. needNormals: boolean;
  27244. needRebuild: boolean;
  27245. shadowEnabled: boolean;
  27246. specularEnabled: boolean;
  27247. lightmapMode: boolean;
  27248. }): void;
  27249. /**
  27250. * Prepares the defines related to the light information passed in parameter
  27251. * @param scene The scene we are intending to draw
  27252. * @param mesh The mesh the effect is compiling for
  27253. * @param defines The defines to update
  27254. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  27255. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  27256. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  27257. * @returns true if normals will be required for the rest of the effect
  27258. */
  27259. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  27260. /**
  27261. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  27262. * @param lightIndex defines the light index
  27263. * @param uniformsList The uniform list
  27264. * @param samplersList The sampler list
  27265. * @param projectedLightTexture defines if projected texture must be used
  27266. * @param uniformBuffersList defines an optional list of uniform buffers
  27267. * @param updateOnlyBuffersList True to only update the uniformBuffersList array
  27268. */
  27269. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>, updateOnlyBuffersList?: boolean): void;
  27270. /**
  27271. * Prepares the uniforms and samplers list to be used in the effect
  27272. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  27273. * @param samplersList The sampler list
  27274. * @param defines The defines helping in the list generation
  27275. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  27276. */
  27277. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  27278. /**
  27279. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  27280. * @param defines The defines to update while falling back
  27281. * @param fallbacks The authorized effect fallbacks
  27282. * @param maxSimultaneousLights The maximum number of lights allowed
  27283. * @param rank the current rank of the Effect
  27284. * @returns The newly affected rank
  27285. */
  27286. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  27287. private static _TmpMorphInfluencers;
  27288. /**
  27289. * Prepares the list of attributes required for morph targets according to the effect defines.
  27290. * @param attribs The current list of supported attribs
  27291. * @param mesh The mesh to prepare the morph targets attributes for
  27292. * @param influencers The number of influencers
  27293. */
  27294. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  27295. /**
  27296. * Prepares the list of attributes required for morph targets according to the effect defines.
  27297. * @param attribs The current list of supported attribs
  27298. * @param mesh The mesh to prepare the morph targets attributes for
  27299. * @param defines The current Defines of the effect
  27300. */
  27301. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  27302. /**
  27303. * Prepares the list of attributes required for bones according to the effect defines.
  27304. * @param attribs The current list of supported attribs
  27305. * @param mesh The mesh to prepare the bones attributes for
  27306. * @param defines The current Defines of the effect
  27307. * @param fallbacks The current efffect fallback strategy
  27308. */
  27309. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  27310. /**
  27311. * Check and prepare the list of attributes required for instances according to the effect defines.
  27312. * @param attribs The current list of supported attribs
  27313. * @param defines The current MaterialDefines of the effect
  27314. */
  27315. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  27316. /**
  27317. * Add the list of attributes required for instances to the attribs array.
  27318. * @param attribs The current list of supported attribs
  27319. */
  27320. static PushAttributesForInstances(attribs: string[]): void;
  27321. /**
  27322. * Binds the light information to the effect.
  27323. * @param light The light containing the generator
  27324. * @param effect The effect we are binding the data to
  27325. * @param lightIndex The light index in the effect used to render
  27326. */
  27327. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  27328. /**
  27329. * Binds the lights information from the scene to the effect for the given mesh.
  27330. * @param light Light to bind
  27331. * @param lightIndex Light index
  27332. * @param scene The scene where the light belongs to
  27333. * @param effect The effect we are binding the data to
  27334. * @param useSpecular Defines if specular is supported
  27335. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  27336. */
  27337. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  27338. /**
  27339. * Binds the lights information from the scene to the effect for the given mesh.
  27340. * @param scene The scene the lights belongs to
  27341. * @param mesh The mesh we are binding the information to render
  27342. * @param effect The effect we are binding the data to
  27343. * @param defines The generated defines for the effect
  27344. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  27345. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  27346. */
  27347. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  27348. private static _tempFogColor;
  27349. /**
  27350. * Binds the fog information from the scene to the effect for the given mesh.
  27351. * @param scene The scene the lights belongs to
  27352. * @param mesh The mesh we are binding the information to render
  27353. * @param effect The effect we are binding the data to
  27354. * @param linearSpace Defines if the fog effect is applied in linear space
  27355. */
  27356. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  27357. /**
  27358. * Binds the bones information from the mesh to the effect.
  27359. * @param mesh The mesh we are binding the information to render
  27360. * @param effect The effect we are binding the data to
  27361. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  27362. */
  27363. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  27364. private static _CopyBonesTransformationMatrices;
  27365. /**
  27366. * Binds the morph targets information from the mesh to the effect.
  27367. * @param abstractMesh The mesh we are binding the information to render
  27368. * @param effect The effect we are binding the data to
  27369. */
  27370. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  27371. /**
  27372. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  27373. * @param defines The generated defines used in the effect
  27374. * @param effect The effect we are binding the data to
  27375. * @param scene The scene we are willing to render with logarithmic scale for
  27376. */
  27377. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  27378. /**
  27379. * Binds the clip plane information from the scene to the effect.
  27380. * @param scene The scene the clip plane information are extracted from
  27381. * @param effect The effect we are binding the data to
  27382. */
  27383. static BindClipPlane(effect: Effect, scene: Scene): void;
  27384. }
  27385. }
  27386. declare module BABYLON {
  27387. /** @hidden */
  27388. export var bayerDitherFunctions: {
  27389. name: string;
  27390. shader: string;
  27391. };
  27392. }
  27393. declare module BABYLON {
  27394. /** @hidden */
  27395. export var shadowMapFragmentDeclaration: {
  27396. name: string;
  27397. shader: string;
  27398. };
  27399. }
  27400. declare module BABYLON {
  27401. /** @hidden */
  27402. export var shadowMapFragment: {
  27403. name: string;
  27404. shader: string;
  27405. };
  27406. }
  27407. declare module BABYLON {
  27408. /** @hidden */
  27409. export var shadowMapPixelShader: {
  27410. name: string;
  27411. shader: string;
  27412. };
  27413. }
  27414. declare module BABYLON {
  27415. /** @hidden */
  27416. export var shadowMapVertexDeclaration: {
  27417. name: string;
  27418. shader: string;
  27419. };
  27420. }
  27421. declare module BABYLON {
  27422. /** @hidden */
  27423. export var shadowMapVertexNormalBias: {
  27424. name: string;
  27425. shader: string;
  27426. };
  27427. }
  27428. declare module BABYLON {
  27429. /** @hidden */
  27430. export var shadowMapVertexMetric: {
  27431. name: string;
  27432. shader: string;
  27433. };
  27434. }
  27435. declare module BABYLON {
  27436. /** @hidden */
  27437. export var shadowMapVertexShader: {
  27438. name: string;
  27439. shader: string;
  27440. };
  27441. }
  27442. declare module BABYLON {
  27443. /** @hidden */
  27444. export var depthBoxBlurPixelShader: {
  27445. name: string;
  27446. shader: string;
  27447. };
  27448. }
  27449. declare module BABYLON {
  27450. /** @hidden */
  27451. export var shadowMapFragmentSoftTransparentShadow: {
  27452. name: string;
  27453. shader: string;
  27454. };
  27455. }
  27456. declare module BABYLON {
  27457. /**
  27458. * Creates an instance based on a source mesh.
  27459. */
  27460. export class InstancedMesh extends AbstractMesh {
  27461. private _sourceMesh;
  27462. private _currentLOD;
  27463. /** @hidden */
  27464. _indexInSourceMeshInstanceArray: number;
  27465. constructor(name: string, source: Mesh);
  27466. /**
  27467. * Returns the string "InstancedMesh".
  27468. */
  27469. getClassName(): string;
  27470. /** Gets the list of lights affecting that mesh */
  27471. get lightSources(): Light[];
  27472. _resyncLightSources(): void;
  27473. _resyncLightSource(light: Light): void;
  27474. _removeLightSource(light: Light, dispose: boolean): void;
  27475. /**
  27476. * If the source mesh receives shadows
  27477. */
  27478. get receiveShadows(): boolean;
  27479. /**
  27480. * The material of the source mesh
  27481. */
  27482. get material(): Nullable<Material>;
  27483. /**
  27484. * Visibility of the source mesh
  27485. */
  27486. get visibility(): number;
  27487. /**
  27488. * Skeleton of the source mesh
  27489. */
  27490. get skeleton(): Nullable<Skeleton>;
  27491. /**
  27492. * Rendering ground id of the source mesh
  27493. */
  27494. get renderingGroupId(): number;
  27495. set renderingGroupId(value: number);
  27496. /**
  27497. * Returns the total number of vertices (integer).
  27498. */
  27499. getTotalVertices(): number;
  27500. /**
  27501. * Returns a positive integer : the total number of indices in this mesh geometry.
  27502. * @returns the numner of indices or zero if the mesh has no geometry.
  27503. */
  27504. getTotalIndices(): number;
  27505. /**
  27506. * The source mesh of the instance
  27507. */
  27508. get sourceMesh(): Mesh;
  27509. /**
  27510. * Creates a new InstancedMesh object from the mesh model.
  27511. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  27512. * @param name defines the name of the new instance
  27513. * @returns a new InstancedMesh
  27514. */
  27515. createInstance(name: string): InstancedMesh;
  27516. /**
  27517. * Is this node ready to be used/rendered
  27518. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27519. * @return {boolean} is it ready
  27520. */
  27521. isReady(completeCheck?: boolean): boolean;
  27522. /**
  27523. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27524. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  27525. * @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.
  27526. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  27527. */
  27528. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  27529. /**
  27530. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27531. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27532. * The `data` are either a numeric array either a Float32Array.
  27533. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  27534. * 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).
  27535. * Note that a new underlying VertexBuffer object is created each call.
  27536. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27537. *
  27538. * Possible `kind` values :
  27539. * - VertexBuffer.PositionKind
  27540. * - VertexBuffer.UVKind
  27541. * - VertexBuffer.UV2Kind
  27542. * - VertexBuffer.UV3Kind
  27543. * - VertexBuffer.UV4Kind
  27544. * - VertexBuffer.UV5Kind
  27545. * - VertexBuffer.UV6Kind
  27546. * - VertexBuffer.ColorKind
  27547. * - VertexBuffer.MatricesIndicesKind
  27548. * - VertexBuffer.MatricesIndicesExtraKind
  27549. * - VertexBuffer.MatricesWeightsKind
  27550. * - VertexBuffer.MatricesWeightsExtraKind
  27551. *
  27552. * Returns the Mesh.
  27553. */
  27554. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27555. /**
  27556. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27557. * If the mesh has no geometry, it is simply returned as it is.
  27558. * The `data` are either a numeric array either a Float32Array.
  27559. * No new underlying VertexBuffer object is created.
  27560. * 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.
  27561. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  27562. *
  27563. * Possible `kind` values :
  27564. * - VertexBuffer.PositionKind
  27565. * - VertexBuffer.UVKind
  27566. * - VertexBuffer.UV2Kind
  27567. * - VertexBuffer.UV3Kind
  27568. * - VertexBuffer.UV4Kind
  27569. * - VertexBuffer.UV5Kind
  27570. * - VertexBuffer.UV6Kind
  27571. * - VertexBuffer.ColorKind
  27572. * - VertexBuffer.MatricesIndicesKind
  27573. * - VertexBuffer.MatricesIndicesExtraKind
  27574. * - VertexBuffer.MatricesWeightsKind
  27575. * - VertexBuffer.MatricesWeightsExtraKind
  27576. *
  27577. * Returns the Mesh.
  27578. */
  27579. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  27580. /**
  27581. * Sets the mesh indices.
  27582. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  27583. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27584. * This method creates a new index buffer each call.
  27585. * Returns the Mesh.
  27586. */
  27587. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  27588. /**
  27589. * Boolean : True if the mesh owns the requested kind of data.
  27590. */
  27591. isVerticesDataPresent(kind: string): boolean;
  27592. /**
  27593. * Returns an array of indices (IndicesArray).
  27594. */
  27595. getIndices(): Nullable<IndicesArray>;
  27596. get _positions(): Nullable<Vector3[]>;
  27597. /**
  27598. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27599. * This means the mesh underlying bounding box and sphere are recomputed.
  27600. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27601. * @returns the current mesh
  27602. */
  27603. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  27604. /** @hidden */
  27605. _preActivate(): InstancedMesh;
  27606. /** @hidden */
  27607. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27608. /** @hidden */
  27609. _postActivate(): void;
  27610. getWorldMatrix(): Matrix;
  27611. get isAnInstance(): boolean;
  27612. /**
  27613. * Returns the current associated LOD AbstractMesh.
  27614. */
  27615. getLOD(camera: Camera): AbstractMesh;
  27616. /** @hidden */
  27617. _preActivateForIntermediateRendering(renderId: number): Mesh;
  27618. /** @hidden */
  27619. _syncSubMeshes(): InstancedMesh;
  27620. /** @hidden */
  27621. _generatePointsArray(): boolean;
  27622. /** @hidden */
  27623. _updateBoundingInfo(): AbstractMesh;
  27624. /**
  27625. * Creates a new InstancedMesh from the current mesh.
  27626. * - name (string) : the cloned mesh name
  27627. * - newParent (optional Node) : the optional Node to parent the clone to.
  27628. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  27629. *
  27630. * Returns the clone.
  27631. */
  27632. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  27633. /**
  27634. * Disposes the InstancedMesh.
  27635. * Returns nothing.
  27636. */
  27637. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27638. }
  27639. interface Mesh {
  27640. /**
  27641. * Register a custom buffer that will be instanced
  27642. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  27643. * @param kind defines the buffer kind
  27644. * @param stride defines the stride in floats
  27645. */
  27646. registerInstancedBuffer(kind: string, stride: number): void;
  27647. /**
  27648. * true to use the edge renderer for all instances of this mesh
  27649. */
  27650. edgesShareWithInstances: boolean;
  27651. /** @hidden */
  27652. _userInstancedBuffersStorage: {
  27653. data: {
  27654. [key: string]: Float32Array;
  27655. };
  27656. sizes: {
  27657. [key: string]: number;
  27658. };
  27659. vertexBuffers: {
  27660. [key: string]: Nullable<VertexBuffer>;
  27661. };
  27662. strides: {
  27663. [key: string]: number;
  27664. };
  27665. };
  27666. }
  27667. interface AbstractMesh {
  27668. /**
  27669. * Object used to store instanced buffers defined by user
  27670. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  27671. */
  27672. instancedBuffers: {
  27673. [key: string]: any;
  27674. };
  27675. }
  27676. }
  27677. declare module BABYLON {
  27678. /**
  27679. * Defines the options associated with the creation of a shader material.
  27680. */
  27681. export interface IShaderMaterialOptions {
  27682. /**
  27683. * Does the material work in alpha blend mode
  27684. */
  27685. needAlphaBlending: boolean;
  27686. /**
  27687. * Does the material work in alpha test mode
  27688. */
  27689. needAlphaTesting: boolean;
  27690. /**
  27691. * The list of attribute names used in the shader
  27692. */
  27693. attributes: string[];
  27694. /**
  27695. * The list of unifrom names used in the shader
  27696. */
  27697. uniforms: string[];
  27698. /**
  27699. * The list of UBO names used in the shader
  27700. */
  27701. uniformBuffers: string[];
  27702. /**
  27703. * The list of sampler names used in the shader
  27704. */
  27705. samplers: string[];
  27706. /**
  27707. * The list of defines used in the shader
  27708. */
  27709. defines: string[];
  27710. }
  27711. /**
  27712. * 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.
  27713. *
  27714. * This returned material effects how the mesh will look based on the code in the shaders.
  27715. *
  27716. * @see https://doc.babylonjs.com/how_to/shader_material
  27717. */
  27718. export class ShaderMaterial extends Material {
  27719. private _shaderPath;
  27720. private _options;
  27721. private _textures;
  27722. private _textureArrays;
  27723. private _floats;
  27724. private _ints;
  27725. private _floatsArrays;
  27726. private _colors3;
  27727. private _colors3Arrays;
  27728. private _colors4;
  27729. private _colors4Arrays;
  27730. private _vectors2;
  27731. private _vectors3;
  27732. private _vectors4;
  27733. private _matrices;
  27734. private _matrixArrays;
  27735. private _matrices3x3;
  27736. private _matrices2x2;
  27737. private _vectors2Arrays;
  27738. private _vectors3Arrays;
  27739. private _vectors4Arrays;
  27740. private _cachedWorldViewMatrix;
  27741. private _cachedWorldViewProjectionMatrix;
  27742. private _renderId;
  27743. private _multiview;
  27744. private _cachedDefines;
  27745. /** Define the Url to load snippets */
  27746. static SnippetUrl: string;
  27747. /** Snippet ID if the material was created from the snippet server */
  27748. snippetId: string;
  27749. /**
  27750. * Instantiate a new shader material.
  27751. * 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.
  27752. * This returned material effects how the mesh will look based on the code in the shaders.
  27753. * @see https://doc.babylonjs.com/how_to/shader_material
  27754. * @param name Define the name of the material in the scene
  27755. * @param scene Define the scene the material belongs to
  27756. * @param shaderPath Defines the route to the shader code in one of three ways:
  27757. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  27758. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  27759. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  27760. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  27761. * @param options Define the options used to create the shader
  27762. */
  27763. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  27764. /**
  27765. * Gets the shader path used to define the shader code
  27766. * It can be modified to trigger a new compilation
  27767. */
  27768. get shaderPath(): any;
  27769. /**
  27770. * Sets the shader path used to define the shader code
  27771. * It can be modified to trigger a new compilation
  27772. */
  27773. set shaderPath(shaderPath: any);
  27774. /**
  27775. * Gets the options used to compile the shader.
  27776. * They can be modified to trigger a new compilation
  27777. */
  27778. get options(): IShaderMaterialOptions;
  27779. /**
  27780. * Gets the current class name of the material e.g. "ShaderMaterial"
  27781. * Mainly use in serialization.
  27782. * @returns the class name
  27783. */
  27784. getClassName(): string;
  27785. /**
  27786. * Specifies if the material will require alpha blending
  27787. * @returns a boolean specifying if alpha blending is needed
  27788. */
  27789. needAlphaBlending(): boolean;
  27790. /**
  27791. * Specifies if this material should be rendered in alpha test mode
  27792. * @returns a boolean specifying if an alpha test is needed.
  27793. */
  27794. needAlphaTesting(): boolean;
  27795. private _checkUniform;
  27796. /**
  27797. * Set a texture in the shader.
  27798. * @param name Define the name of the uniform samplers as defined in the shader
  27799. * @param texture Define the texture to bind to this sampler
  27800. * @return the material itself allowing "fluent" like uniform updates
  27801. */
  27802. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  27803. /**
  27804. * Set a texture array in the shader.
  27805. * @param name Define the name of the uniform sampler array as defined in the shader
  27806. * @param textures Define the list of textures to bind to this sampler
  27807. * @return the material itself allowing "fluent" like uniform updates
  27808. */
  27809. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  27810. /**
  27811. * Set a float in the shader.
  27812. * @param name Define the name of the uniform as defined in the shader
  27813. * @param value Define the value to give to the uniform
  27814. * @return the material itself allowing "fluent" like uniform updates
  27815. */
  27816. setFloat(name: string, value: number): ShaderMaterial;
  27817. /**
  27818. * Set a int in the shader.
  27819. * @param name Define the name of the uniform as defined in the shader
  27820. * @param value Define the value to give to the uniform
  27821. * @return the material itself allowing "fluent" like uniform updates
  27822. */
  27823. setInt(name: string, value: number): ShaderMaterial;
  27824. /**
  27825. * Set an array of floats in the shader.
  27826. * @param name Define the name of the uniform as defined in the shader
  27827. * @param value Define the value to give to the uniform
  27828. * @return the material itself allowing "fluent" like uniform updates
  27829. */
  27830. setFloats(name: string, value: number[]): ShaderMaterial;
  27831. /**
  27832. * Set a vec3 in the shader from a Color3.
  27833. * @param name Define the name of the uniform as defined in the shader
  27834. * @param value Define the value to give to the uniform
  27835. * @return the material itself allowing "fluent" like uniform updates
  27836. */
  27837. setColor3(name: string, value: Color3): ShaderMaterial;
  27838. /**
  27839. * Set a vec3 array in the shader from a Color3 array.
  27840. * @param name Define the name of the uniform as defined in the shader
  27841. * @param value Define the value to give to the uniform
  27842. * @return the material itself allowing "fluent" like uniform updates
  27843. */
  27844. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  27845. /**
  27846. * Set a vec4 in the shader from a Color4.
  27847. * @param name Define the name of the uniform as defined in the shader
  27848. * @param value Define the value to give to the uniform
  27849. * @return the material itself allowing "fluent" like uniform updates
  27850. */
  27851. setColor4(name: string, value: Color4): ShaderMaterial;
  27852. /**
  27853. * Set a vec4 array in the shader from a Color4 array.
  27854. * @param name Define the name of the uniform as defined in the shader
  27855. * @param value Define the value to give to the uniform
  27856. * @return the material itself allowing "fluent" like uniform updates
  27857. */
  27858. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  27859. /**
  27860. * Set a vec2 in the shader from a Vector2.
  27861. * @param name Define the name of the uniform as defined in the shader
  27862. * @param value Define the value to give to the uniform
  27863. * @return the material itself allowing "fluent" like uniform updates
  27864. */
  27865. setVector2(name: string, value: Vector2): ShaderMaterial;
  27866. /**
  27867. * Set a vec3 in the shader from a Vector3.
  27868. * @param name Define the name of the uniform as defined in the shader
  27869. * @param value Define the value to give to the uniform
  27870. * @return the material itself allowing "fluent" like uniform updates
  27871. */
  27872. setVector3(name: string, value: Vector3): ShaderMaterial;
  27873. /**
  27874. * Set a vec4 in the shader from a Vector4.
  27875. * @param name Define the name of the uniform as defined in the shader
  27876. * @param value Define the value to give to the uniform
  27877. * @return the material itself allowing "fluent" like uniform updates
  27878. */
  27879. setVector4(name: string, value: Vector4): ShaderMaterial;
  27880. /**
  27881. * Set a mat4 in the shader from a Matrix.
  27882. * @param name Define the name of the uniform as defined in the shader
  27883. * @param value Define the value to give to the uniform
  27884. * @return the material itself allowing "fluent" like uniform updates
  27885. */
  27886. setMatrix(name: string, value: Matrix): ShaderMaterial;
  27887. /**
  27888. * Set a float32Array in the shader from a matrix array.
  27889. * @param name Define the name of the uniform as defined in the shader
  27890. * @param value Define the value to give to the uniform
  27891. * @return the material itself allowing "fluent" like uniform updates
  27892. */
  27893. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  27894. /**
  27895. * Set a mat3 in the shader from a Float32Array.
  27896. * @param name Define the name of the uniform as defined in the shader
  27897. * @param value Define the value to give to the uniform
  27898. * @return the material itself allowing "fluent" like uniform updates
  27899. */
  27900. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  27901. /**
  27902. * Set a mat2 in the shader from a Float32Array.
  27903. * @param name Define the name of the uniform as defined in the shader
  27904. * @param value Define the value to give to the uniform
  27905. * @return the material itself allowing "fluent" like uniform updates
  27906. */
  27907. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  27908. /**
  27909. * Set a vec2 array in the shader from a number array.
  27910. * @param name Define the name of the uniform as defined in the shader
  27911. * @param value Define the value to give to the uniform
  27912. * @return the material itself allowing "fluent" like uniform updates
  27913. */
  27914. setArray2(name: string, value: number[]): ShaderMaterial;
  27915. /**
  27916. * Set a vec3 array in the shader from a number array.
  27917. * @param name Define the name of the uniform as defined in the shader
  27918. * @param value Define the value to give to the uniform
  27919. * @return the material itself allowing "fluent" like uniform updates
  27920. */
  27921. setArray3(name: string, value: number[]): ShaderMaterial;
  27922. /**
  27923. * Set a vec4 array in the shader from a number array.
  27924. * @param name Define the name of the uniform as defined in the shader
  27925. * @param value Define the value to give to the uniform
  27926. * @return the material itself allowing "fluent" like uniform updates
  27927. */
  27928. setArray4(name: string, value: number[]): ShaderMaterial;
  27929. private _checkCache;
  27930. /**
  27931. * Specifies that the submesh is ready to be used
  27932. * @param mesh defines the mesh to check
  27933. * @param subMesh defines which submesh to check
  27934. * @param useInstances specifies that instances should be used
  27935. * @returns a boolean indicating that the submesh is ready or not
  27936. */
  27937. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27938. /**
  27939. * Checks if the material is ready to render the requested mesh
  27940. * @param mesh Define the mesh to render
  27941. * @param useInstances Define whether or not the material is used with instances
  27942. * @returns true if ready, otherwise false
  27943. */
  27944. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  27945. /**
  27946. * Binds the world matrix to the material
  27947. * @param world defines the world transformation matrix
  27948. * @param effectOverride - If provided, use this effect instead of internal effect
  27949. */
  27950. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  27951. /**
  27952. * Binds the submesh to this material by preparing the effect and shader to draw
  27953. * @param world defines the world transformation matrix
  27954. * @param mesh defines the mesh containing the submesh
  27955. * @param subMesh defines the submesh to bind the material to
  27956. */
  27957. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27958. /**
  27959. * Binds the material to the mesh
  27960. * @param world defines the world transformation matrix
  27961. * @param mesh defines the mesh to bind the material to
  27962. * @param effectOverride - If provided, use this effect instead of internal effect
  27963. */
  27964. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  27965. protected _afterBind(mesh?: Mesh): void;
  27966. /**
  27967. * Gets the active textures from the material
  27968. * @returns an array of textures
  27969. */
  27970. getActiveTextures(): BaseTexture[];
  27971. /**
  27972. * Specifies if the material uses a texture
  27973. * @param texture defines the texture to check against the material
  27974. * @returns a boolean specifying if the material uses the texture
  27975. */
  27976. hasTexture(texture: BaseTexture): boolean;
  27977. /**
  27978. * Makes a duplicate of the material, and gives it a new name
  27979. * @param name defines the new name for the duplicated material
  27980. * @returns the cloned material
  27981. */
  27982. clone(name: string): ShaderMaterial;
  27983. /**
  27984. * Disposes the material
  27985. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27986. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27987. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  27988. */
  27989. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  27990. /**
  27991. * Serializes this material in a JSON representation
  27992. * @returns the serialized material object
  27993. */
  27994. serialize(): any;
  27995. /**
  27996. * Creates a shader material from parsed shader material data
  27997. * @param source defines the JSON represnetation of the material
  27998. * @param scene defines the hosting scene
  27999. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28000. * @returns a new material
  28001. */
  28002. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  28003. /**
  28004. * Creates a new ShaderMaterial from a snippet saved in a remote file
  28005. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  28006. * @param url defines the url to load from
  28007. * @param scene defines the hosting scene
  28008. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28009. * @returns a promise that will resolve to the new ShaderMaterial
  28010. */
  28011. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  28012. /**
  28013. * Creates a ShaderMaterial from a snippet saved by the Inspector
  28014. * @param snippetId defines the snippet to load
  28015. * @param scene defines the hosting scene
  28016. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28017. * @returns a promise that will resolve to the new ShaderMaterial
  28018. */
  28019. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  28020. }
  28021. }
  28022. declare module BABYLON {
  28023. /** @hidden */
  28024. export var colorPixelShader: {
  28025. name: string;
  28026. shader: string;
  28027. };
  28028. }
  28029. declare module BABYLON {
  28030. /** @hidden */
  28031. export var colorVertexShader: {
  28032. name: string;
  28033. shader: string;
  28034. };
  28035. }
  28036. declare module BABYLON {
  28037. /**
  28038. * Line mesh
  28039. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  28040. */
  28041. export class LinesMesh extends Mesh {
  28042. /**
  28043. * If vertex color should be applied to the mesh
  28044. */
  28045. readonly useVertexColor?: boolean | undefined;
  28046. /**
  28047. * If vertex alpha should be applied to the mesh
  28048. */
  28049. readonly useVertexAlpha?: boolean | undefined;
  28050. /**
  28051. * Color of the line (Default: White)
  28052. */
  28053. color: Color3;
  28054. /**
  28055. * Alpha of the line (Default: 1)
  28056. */
  28057. alpha: number;
  28058. /**
  28059. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  28060. * This margin is expressed in world space coordinates, so its value may vary.
  28061. * Default value is 0.1
  28062. */
  28063. intersectionThreshold: number;
  28064. private _colorShader;
  28065. private color4;
  28066. /**
  28067. * Creates a new LinesMesh
  28068. * @param name defines the name
  28069. * @param scene defines the hosting scene
  28070. * @param parent defines the parent mesh if any
  28071. * @param source defines the optional source LinesMesh used to clone data from
  28072. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28073. * When false, achieved by calling a clone(), also passing False.
  28074. * This will make creation of children, recursive.
  28075. * @param useVertexColor defines if this LinesMesh supports vertex color
  28076. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  28077. */
  28078. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  28079. /**
  28080. * If vertex color should be applied to the mesh
  28081. */
  28082. useVertexColor?: boolean | undefined,
  28083. /**
  28084. * If vertex alpha should be applied to the mesh
  28085. */
  28086. useVertexAlpha?: boolean | undefined);
  28087. private _addClipPlaneDefine;
  28088. private _removeClipPlaneDefine;
  28089. isReady(): boolean;
  28090. /**
  28091. * Returns the string "LineMesh"
  28092. */
  28093. getClassName(): string;
  28094. /**
  28095. * @hidden
  28096. */
  28097. get material(): Material;
  28098. /**
  28099. * @hidden
  28100. */
  28101. set material(value: Material);
  28102. /**
  28103. * @hidden
  28104. */
  28105. get checkCollisions(): boolean;
  28106. /** @hidden */
  28107. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28108. /** @hidden */
  28109. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28110. /**
  28111. * Disposes of the line mesh
  28112. * @param doNotRecurse If children should be disposed
  28113. */
  28114. dispose(doNotRecurse?: boolean): void;
  28115. /**
  28116. * Returns a new LineMesh object cloned from the current one.
  28117. */
  28118. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  28119. /**
  28120. * Creates a new InstancedLinesMesh object from the mesh model.
  28121. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28122. * @param name defines the name of the new instance
  28123. * @returns a new InstancedLinesMesh
  28124. */
  28125. createInstance(name: string): InstancedLinesMesh;
  28126. }
  28127. /**
  28128. * Creates an instance based on a source LinesMesh
  28129. */
  28130. export class InstancedLinesMesh extends InstancedMesh {
  28131. /**
  28132. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  28133. * This margin is expressed in world space coordinates, so its value may vary.
  28134. * Initilized with the intersectionThreshold value of the source LinesMesh
  28135. */
  28136. intersectionThreshold: number;
  28137. constructor(name: string, source: LinesMesh);
  28138. /**
  28139. * Returns the string "InstancedLinesMesh".
  28140. */
  28141. getClassName(): string;
  28142. }
  28143. }
  28144. declare module BABYLON {
  28145. /** @hidden */
  28146. export var linePixelShader: {
  28147. name: string;
  28148. shader: string;
  28149. };
  28150. }
  28151. declare module BABYLON {
  28152. /** @hidden */
  28153. export var lineVertexShader: {
  28154. name: string;
  28155. shader: string;
  28156. };
  28157. }
  28158. declare module BABYLON {
  28159. interface Scene {
  28160. /** @hidden */
  28161. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  28162. }
  28163. interface AbstractMesh {
  28164. /**
  28165. * Gets the edgesRenderer associated with the mesh
  28166. */
  28167. edgesRenderer: Nullable<EdgesRenderer>;
  28168. }
  28169. interface LinesMesh {
  28170. /**
  28171. * Enables the edge rendering mode on the mesh.
  28172. * This mode makes the mesh edges visible
  28173. * @param epsilon defines the maximal distance between two angles to detect a face
  28174. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28175. * @returns the currentAbstractMesh
  28176. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28177. */
  28178. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28179. }
  28180. interface InstancedLinesMesh {
  28181. /**
  28182. * Enables the edge rendering mode on the mesh.
  28183. * This mode makes the mesh edges visible
  28184. * @param epsilon defines the maximal distance between two angles to detect a face
  28185. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28186. * @returns the current InstancedLinesMesh
  28187. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28188. */
  28189. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  28190. }
  28191. /**
  28192. * Defines the minimum contract an Edges renderer should follow.
  28193. */
  28194. export interface IEdgesRenderer extends IDisposable {
  28195. /**
  28196. * Gets or sets a boolean indicating if the edgesRenderer is active
  28197. */
  28198. isEnabled: boolean;
  28199. /**
  28200. * Renders the edges of the attached mesh,
  28201. */
  28202. render(): void;
  28203. /**
  28204. * Checks wether or not the edges renderer is ready to render.
  28205. * @return true if ready, otherwise false.
  28206. */
  28207. isReady(): boolean;
  28208. /**
  28209. * List of instances to render in case the source mesh has instances
  28210. */
  28211. customInstances: SmartArray<Matrix>;
  28212. }
  28213. /**
  28214. * Defines the additional options of the edges renderer
  28215. */
  28216. export interface IEdgesRendererOptions {
  28217. /**
  28218. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  28219. * If not defined, the default value is true
  28220. */
  28221. useAlternateEdgeFinder?: boolean;
  28222. /**
  28223. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  28224. * If not defined, the default value is true.
  28225. * You should normally leave it undefined (or set it to true), except if you see some artifacts in the edges rendering (can happen with complex geometries)
  28226. * This option is used only if useAlternateEdgeFinder = true
  28227. */
  28228. useFastVertexMerger?: boolean;
  28229. /**
  28230. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  28231. * The default value is 1e-6
  28232. * This option is used only if useAlternateEdgeFinder = true
  28233. */
  28234. epsilonVertexMerge?: number;
  28235. /**
  28236. * Gets or sets a boolean indicating that tessellation should be applied before finding the edges. You may need to activate this option if your geometry is a bit
  28237. * unusual, like having a vertex of a triangle in-between two vertices of an edge of another triangle. It happens often when using CSG to construct meshes.
  28238. * This option is used only if useAlternateEdgeFinder = true
  28239. */
  28240. applyTessellation?: boolean;
  28241. /**
  28242. * The limit under which 3 vertices are considered to be aligned. 3 vertices PQR are considered aligned if distance(PQ) + distance(QR) - distance(PR) < epsilonVertexAligned
  28243. * The default value is 1e-6
  28244. * This option is used only if useAlternateEdgeFinder = true
  28245. */
  28246. epsilonVertexAligned?: number;
  28247. }
  28248. /**
  28249. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  28250. */
  28251. export class EdgesRenderer implements IEdgesRenderer {
  28252. /**
  28253. * Define the size of the edges with an orthographic camera
  28254. */
  28255. edgesWidthScalerForOrthographic: number;
  28256. /**
  28257. * Define the size of the edges with a perspective camera
  28258. */
  28259. edgesWidthScalerForPerspective: number;
  28260. protected _source: AbstractMesh;
  28261. protected _linesPositions: number[];
  28262. protected _linesNormals: number[];
  28263. protected _linesIndices: number[];
  28264. protected _epsilon: number;
  28265. protected _indicesCount: number;
  28266. protected _lineShader: ShaderMaterial;
  28267. protected _ib: DataBuffer;
  28268. protected _buffers: {
  28269. [key: string]: Nullable<VertexBuffer>;
  28270. };
  28271. protected _buffersForInstances: {
  28272. [key: string]: Nullable<VertexBuffer>;
  28273. };
  28274. protected _checkVerticesInsteadOfIndices: boolean;
  28275. protected _options: Nullable<IEdgesRendererOptions>;
  28276. private _meshRebuildObserver;
  28277. private _meshDisposeObserver;
  28278. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  28279. isEnabled: boolean;
  28280. /** Gets the vertices generated by the edge renderer */
  28281. get linesPositions(): Immutable<Array<number>>;
  28282. /** Gets the normals generated by the edge renderer */
  28283. get linesNormals(): Immutable<Array<number>>;
  28284. /** Gets the indices generated by the edge renderer */
  28285. get linesIndices(): Immutable<Array<number>>;
  28286. /**
  28287. * List of instances to render in case the source mesh has instances
  28288. */
  28289. customInstances: SmartArray<Matrix>;
  28290. private static GetShader;
  28291. /**
  28292. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  28293. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  28294. * @param source Mesh used to create edges
  28295. * @param epsilon sum of angles in adjacency to check for edge
  28296. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  28297. * @param generateEdgesLines - should generate Lines or only prepare resources.
  28298. * @param options The options to apply when generating the edges
  28299. */
  28300. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  28301. protected _prepareRessources(): void;
  28302. /** @hidden */
  28303. _rebuild(): void;
  28304. /**
  28305. * Releases the required resources for the edges renderer
  28306. */
  28307. dispose(): void;
  28308. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  28309. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  28310. /**
  28311. * Checks if the pair of p0 and p1 is en edge
  28312. * @param faceIndex
  28313. * @param edge
  28314. * @param faceNormals
  28315. * @param p0
  28316. * @param p1
  28317. * @private
  28318. */
  28319. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  28320. /**
  28321. * push line into the position, normal and index buffer
  28322. * @protected
  28323. */
  28324. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  28325. /**
  28326. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  28327. */
  28328. private _tessellateTriangle;
  28329. private _generateEdgesLinesAlternate;
  28330. /**
  28331. * Generates lines edges from adjacencjes
  28332. * @private
  28333. */
  28334. _generateEdgesLines(): void;
  28335. /**
  28336. * Checks wether or not the edges renderer is ready to render.
  28337. * @return true if ready, otherwise false.
  28338. */
  28339. isReady(): boolean;
  28340. /**
  28341. * Renders the edges of the attached mesh,
  28342. */
  28343. render(): void;
  28344. }
  28345. /**
  28346. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  28347. */
  28348. export class LineEdgesRenderer extends EdgesRenderer {
  28349. /**
  28350. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  28351. * @param source LineMesh used to generate edges
  28352. * @param epsilon not important (specified angle for edge detection)
  28353. * @param checkVerticesInsteadOfIndices not important for LineMesh
  28354. */
  28355. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  28356. /**
  28357. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  28358. */
  28359. _generateEdgesLines(): void;
  28360. }
  28361. }
  28362. declare module BABYLON {
  28363. /**
  28364. * This represents the object necessary to create a rendering group.
  28365. * This is exclusively used and created by the rendering manager.
  28366. * To modify the behavior, you use the available helpers in your scene or meshes.
  28367. * @hidden
  28368. */
  28369. export class RenderingGroup {
  28370. index: number;
  28371. private static _zeroVector;
  28372. private _scene;
  28373. private _opaqueSubMeshes;
  28374. private _transparentSubMeshes;
  28375. private _alphaTestSubMeshes;
  28376. private _depthOnlySubMeshes;
  28377. private _particleSystems;
  28378. private _spriteManagers;
  28379. private _opaqueSortCompareFn;
  28380. private _alphaTestSortCompareFn;
  28381. private _transparentSortCompareFn;
  28382. private _renderOpaque;
  28383. private _renderAlphaTest;
  28384. private _renderTransparent;
  28385. /** @hidden */
  28386. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  28387. onBeforeTransparentRendering: () => void;
  28388. /**
  28389. * Set the opaque sort comparison function.
  28390. * If null the sub meshes will be render in the order they were created
  28391. */
  28392. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  28393. /**
  28394. * Set the alpha test sort comparison function.
  28395. * If null the sub meshes will be render in the order they were created
  28396. */
  28397. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  28398. /**
  28399. * Set the transparent sort comparison function.
  28400. * If null the sub meshes will be render in the order they were created
  28401. */
  28402. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  28403. /**
  28404. * Creates a new rendering group.
  28405. * @param index The rendering group index
  28406. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  28407. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  28408. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  28409. */
  28410. 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>);
  28411. /**
  28412. * Render all the sub meshes contained in the group.
  28413. * @param customRenderFunction Used to override the default render behaviour of the group.
  28414. * @returns true if rendered some submeshes.
  28415. */
  28416. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  28417. /**
  28418. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  28419. * @param subMeshes The submeshes to render
  28420. */
  28421. private renderOpaqueSorted;
  28422. /**
  28423. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  28424. * @param subMeshes The submeshes to render
  28425. */
  28426. private renderAlphaTestSorted;
  28427. /**
  28428. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  28429. * @param subMeshes The submeshes to render
  28430. */
  28431. private renderTransparentSorted;
  28432. /**
  28433. * Renders the submeshes in a specified order.
  28434. * @param subMeshes The submeshes to sort before render
  28435. * @param sortCompareFn The comparison function use to sort
  28436. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  28437. * @param transparent Specifies to activate blending if true
  28438. */
  28439. private static renderSorted;
  28440. /**
  28441. * Renders the submeshes in the order they were dispatched (no sort applied).
  28442. * @param subMeshes The submeshes to render
  28443. */
  28444. private static renderUnsorted;
  28445. /**
  28446. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  28447. * are rendered back to front if in the same alpha index.
  28448. *
  28449. * @param a The first submesh
  28450. * @param b The second submesh
  28451. * @returns The result of the comparison
  28452. */
  28453. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  28454. /**
  28455. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  28456. * are rendered back to front.
  28457. *
  28458. * @param a The first submesh
  28459. * @param b The second submesh
  28460. * @returns The result of the comparison
  28461. */
  28462. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  28463. /**
  28464. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  28465. * are rendered front to back (prevent overdraw).
  28466. *
  28467. * @param a The first submesh
  28468. * @param b The second submesh
  28469. * @returns The result of the comparison
  28470. */
  28471. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  28472. /**
  28473. * Resets the different lists of submeshes to prepare a new frame.
  28474. */
  28475. prepare(): void;
  28476. dispose(): void;
  28477. /**
  28478. * Inserts the submesh in its correct queue depending on its material.
  28479. * @param subMesh The submesh to dispatch
  28480. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  28481. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  28482. */
  28483. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  28484. dispatchSprites(spriteManager: ISpriteManager): void;
  28485. dispatchParticles(particleSystem: IParticleSystem): void;
  28486. private _renderParticles;
  28487. private _renderSprites;
  28488. }
  28489. }
  28490. declare module BABYLON {
  28491. /**
  28492. * Interface describing the different options available in the rendering manager
  28493. * regarding Auto Clear between groups.
  28494. */
  28495. export interface IRenderingManagerAutoClearSetup {
  28496. /**
  28497. * Defines whether or not autoclear is enable.
  28498. */
  28499. autoClear: boolean;
  28500. /**
  28501. * Defines whether or not to autoclear the depth buffer.
  28502. */
  28503. depth: boolean;
  28504. /**
  28505. * Defines whether or not to autoclear the stencil buffer.
  28506. */
  28507. stencil: boolean;
  28508. }
  28509. /**
  28510. * This class is used by the onRenderingGroupObservable
  28511. */
  28512. export class RenderingGroupInfo {
  28513. /**
  28514. * The Scene that being rendered
  28515. */
  28516. scene: Scene;
  28517. /**
  28518. * The camera currently used for the rendering pass
  28519. */
  28520. camera: Nullable<Camera>;
  28521. /**
  28522. * The ID of the renderingGroup being processed
  28523. */
  28524. renderingGroupId: number;
  28525. }
  28526. /**
  28527. * This is the manager responsible of all the rendering for meshes sprites and particles.
  28528. * It is enable to manage the different groups as well as the different necessary sort functions.
  28529. * This should not be used directly aside of the few static configurations
  28530. */
  28531. export class RenderingManager {
  28532. /**
  28533. * The max id used for rendering groups (not included)
  28534. */
  28535. static MAX_RENDERINGGROUPS: number;
  28536. /**
  28537. * The min id used for rendering groups (included)
  28538. */
  28539. static MIN_RENDERINGGROUPS: number;
  28540. /**
  28541. * Used to globally prevent autoclearing scenes.
  28542. */
  28543. static AUTOCLEAR: boolean;
  28544. /**
  28545. * @hidden
  28546. */
  28547. _useSceneAutoClearSetup: boolean;
  28548. private _scene;
  28549. private _renderingGroups;
  28550. private _depthStencilBufferAlreadyCleaned;
  28551. private _autoClearDepthStencil;
  28552. private _customOpaqueSortCompareFn;
  28553. private _customAlphaTestSortCompareFn;
  28554. private _customTransparentSortCompareFn;
  28555. private _renderingGroupInfo;
  28556. /**
  28557. * Instantiates a new rendering group for a particular scene
  28558. * @param scene Defines the scene the groups belongs to
  28559. */
  28560. constructor(scene: Scene);
  28561. private _clearDepthStencilBuffer;
  28562. /**
  28563. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  28564. * @hidden
  28565. */
  28566. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  28567. /**
  28568. * Resets the different information of the group to prepare a new frame
  28569. * @hidden
  28570. */
  28571. reset(): void;
  28572. /**
  28573. * Dispose and release the group and its associated resources.
  28574. * @hidden
  28575. */
  28576. dispose(): void;
  28577. /**
  28578. * Clear the info related to rendering groups preventing retention points during dispose.
  28579. */
  28580. freeRenderingGroups(): void;
  28581. private _prepareRenderingGroup;
  28582. /**
  28583. * Add a sprite manager to the rendering manager in order to render it this frame.
  28584. * @param spriteManager Define the sprite manager to render
  28585. */
  28586. dispatchSprites(spriteManager: ISpriteManager): void;
  28587. /**
  28588. * Add a particle system to the rendering manager in order to render it this frame.
  28589. * @param particleSystem Define the particle system to render
  28590. */
  28591. dispatchParticles(particleSystem: IParticleSystem): void;
  28592. /**
  28593. * Add a submesh to the manager in order to render it this frame
  28594. * @param subMesh The submesh to dispatch
  28595. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  28596. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  28597. */
  28598. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  28599. /**
  28600. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  28601. * This allowed control for front to back rendering or reversly depending of the special needs.
  28602. *
  28603. * @param renderingGroupId The rendering group id corresponding to its index
  28604. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  28605. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  28606. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  28607. */
  28608. 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;
  28609. /**
  28610. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  28611. *
  28612. * @param renderingGroupId The rendering group id corresponding to its index
  28613. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  28614. * @param depth Automatically clears depth between groups if true and autoClear is true.
  28615. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  28616. */
  28617. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  28618. /**
  28619. * Gets the current auto clear configuration for one rendering group of the rendering
  28620. * manager.
  28621. * @param index the rendering group index to get the information for
  28622. * @returns The auto clear setup for the requested rendering group
  28623. */
  28624. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  28625. }
  28626. }
  28627. declare module BABYLON {
  28628. /**
  28629. * Defines the options associated with the creation of a custom shader for a shadow generator.
  28630. */
  28631. export interface ICustomShaderOptions {
  28632. /**
  28633. * Gets or sets the custom shader name to use
  28634. */
  28635. shaderName: string;
  28636. /**
  28637. * The list of attribute names used in the shader
  28638. */
  28639. attributes?: string[];
  28640. /**
  28641. * The list of unifrom names used in the shader
  28642. */
  28643. uniforms?: string[];
  28644. /**
  28645. * The list of sampler names used in the shader
  28646. */
  28647. samplers?: string[];
  28648. /**
  28649. * The list of defines used in the shader
  28650. */
  28651. defines?: string[];
  28652. }
  28653. /**
  28654. * Interface to implement to create a shadow generator compatible with BJS.
  28655. */
  28656. export interface IShadowGenerator {
  28657. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  28658. id: string;
  28659. /**
  28660. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  28661. * @returns The render target texture if present otherwise, null
  28662. */
  28663. getShadowMap(): Nullable<RenderTargetTexture>;
  28664. /**
  28665. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  28666. * @param subMesh The submesh we want to render in the shadow map
  28667. * @param useInstances Defines wether will draw in the map using instances
  28668. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  28669. * @returns true if ready otherwise, false
  28670. */
  28671. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  28672. /**
  28673. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  28674. * @param defines Defines of the material we want to update
  28675. * @param lightIndex Index of the light in the enabled light list of the material
  28676. */
  28677. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  28678. /**
  28679. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  28680. * defined in the generator but impacting the effect).
  28681. * It implies the unifroms available on the materials are the standard BJS ones.
  28682. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  28683. * @param effect The effect we are binfing the information for
  28684. */
  28685. bindShadowLight(lightIndex: string, effect: Effect): void;
  28686. /**
  28687. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  28688. * (eq to shadow prjection matrix * light transform matrix)
  28689. * @returns The transform matrix used to create the shadow map
  28690. */
  28691. getTransformMatrix(): Matrix;
  28692. /**
  28693. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  28694. * Cube and 2D textures for instance.
  28695. */
  28696. recreateShadowMap(): void;
  28697. /**
  28698. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  28699. * @param onCompiled Callback triggered at the and of the effects compilation
  28700. * @param options Sets of optional options forcing the compilation with different modes
  28701. */
  28702. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  28703. useInstances: boolean;
  28704. }>): void;
  28705. /**
  28706. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  28707. * @param options Sets of optional options forcing the compilation with different modes
  28708. * @returns A promise that resolves when the compilation completes
  28709. */
  28710. forceCompilationAsync(options?: Partial<{
  28711. useInstances: boolean;
  28712. }>): Promise<void>;
  28713. /**
  28714. * Serializes the shadow generator setup to a json object.
  28715. * @returns The serialized JSON object
  28716. */
  28717. serialize(): any;
  28718. /**
  28719. * Disposes the Shadow map and related Textures and effects.
  28720. */
  28721. dispose(): void;
  28722. }
  28723. /**
  28724. * Default implementation IShadowGenerator.
  28725. * This is the main object responsible of generating shadows in the framework.
  28726. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  28727. */
  28728. export class ShadowGenerator implements IShadowGenerator {
  28729. /**
  28730. * Name of the shadow generator class
  28731. */
  28732. static CLASSNAME: string;
  28733. /**
  28734. * Shadow generator mode None: no filtering applied.
  28735. */
  28736. static readonly FILTER_NONE: number;
  28737. /**
  28738. * Shadow generator mode ESM: Exponential Shadow Mapping.
  28739. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28740. */
  28741. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  28742. /**
  28743. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  28744. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  28745. */
  28746. static readonly FILTER_POISSONSAMPLING: number;
  28747. /**
  28748. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  28749. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28750. */
  28751. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  28752. /**
  28753. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  28754. * edge artifacts on steep falloff.
  28755. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28756. */
  28757. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  28758. /**
  28759. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  28760. * edge artifacts on steep falloff.
  28761. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28762. */
  28763. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  28764. /**
  28765. * Shadow generator mode PCF: Percentage Closer Filtering
  28766. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  28767. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  28768. */
  28769. static readonly FILTER_PCF: number;
  28770. /**
  28771. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  28772. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  28773. * Contact Hardening
  28774. */
  28775. static readonly FILTER_PCSS: number;
  28776. /**
  28777. * Reserved for PCF and PCSS
  28778. * Highest Quality.
  28779. *
  28780. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  28781. *
  28782. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  28783. */
  28784. static readonly QUALITY_HIGH: number;
  28785. /**
  28786. * Reserved for PCF and PCSS
  28787. * Good tradeoff for quality/perf cross devices
  28788. *
  28789. * Execute PCF on a 3*3 kernel.
  28790. *
  28791. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  28792. */
  28793. static readonly QUALITY_MEDIUM: number;
  28794. /**
  28795. * Reserved for PCF and PCSS
  28796. * The lowest quality but the fastest.
  28797. *
  28798. * Execute PCF on a 1*1 kernel.
  28799. *
  28800. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  28801. */
  28802. static readonly QUALITY_LOW: number;
  28803. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  28804. id: string;
  28805. /** Gets or sets the custom shader name to use */
  28806. customShaderOptions: ICustomShaderOptions;
  28807. /** Gets or sets a custom function to allow/disallow rendering a sub mesh in the shadow map */
  28808. customAllowRendering: (subMesh: SubMesh) => boolean;
  28809. /**
  28810. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  28811. */
  28812. onBeforeShadowMapRenderObservable: Observable<Effect>;
  28813. /**
  28814. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  28815. */
  28816. onAfterShadowMapRenderObservable: Observable<Effect>;
  28817. /**
  28818. * Observable triggered before a mesh is rendered in the shadow map.
  28819. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  28820. */
  28821. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  28822. /**
  28823. * Observable triggered after a mesh is rendered in the shadow map.
  28824. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  28825. */
  28826. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  28827. protected _bias: number;
  28828. /**
  28829. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  28830. */
  28831. get bias(): number;
  28832. /**
  28833. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  28834. */
  28835. set bias(bias: number);
  28836. protected _normalBias: number;
  28837. /**
  28838. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  28839. */
  28840. get normalBias(): number;
  28841. /**
  28842. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  28843. */
  28844. set normalBias(normalBias: number);
  28845. protected _blurBoxOffset: number;
  28846. /**
  28847. * Gets the blur box offset: offset applied during the blur pass.
  28848. * Only useful if useKernelBlur = false
  28849. */
  28850. get blurBoxOffset(): number;
  28851. /**
  28852. * Sets the blur box offset: offset applied during the blur pass.
  28853. * Only useful if useKernelBlur = false
  28854. */
  28855. set blurBoxOffset(value: number);
  28856. protected _blurScale: number;
  28857. /**
  28858. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  28859. * 2 means half of the size.
  28860. */
  28861. get blurScale(): number;
  28862. /**
  28863. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  28864. * 2 means half of the size.
  28865. */
  28866. set blurScale(value: number);
  28867. protected _blurKernel: number;
  28868. /**
  28869. * Gets the blur kernel: kernel size of the blur pass.
  28870. * Only useful if useKernelBlur = true
  28871. */
  28872. get blurKernel(): number;
  28873. /**
  28874. * Sets the blur kernel: kernel size of the blur pass.
  28875. * Only useful if useKernelBlur = true
  28876. */
  28877. set blurKernel(value: number);
  28878. protected _useKernelBlur: boolean;
  28879. /**
  28880. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  28881. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  28882. */
  28883. get useKernelBlur(): boolean;
  28884. /**
  28885. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  28886. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  28887. */
  28888. set useKernelBlur(value: boolean);
  28889. protected _depthScale: number;
  28890. /**
  28891. * Gets the depth scale used in ESM mode.
  28892. */
  28893. get depthScale(): number;
  28894. /**
  28895. * Sets the depth scale used in ESM mode.
  28896. * This can override the scale stored on the light.
  28897. */
  28898. set depthScale(value: number);
  28899. protected _validateFilter(filter: number): number;
  28900. protected _filter: number;
  28901. /**
  28902. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  28903. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  28904. */
  28905. get filter(): number;
  28906. /**
  28907. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  28908. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  28909. */
  28910. set filter(value: number);
  28911. /**
  28912. * Gets if the current filter is set to Poisson Sampling.
  28913. */
  28914. get usePoissonSampling(): boolean;
  28915. /**
  28916. * Sets the current filter to Poisson Sampling.
  28917. */
  28918. set usePoissonSampling(value: boolean);
  28919. /**
  28920. * Gets if the current filter is set to ESM.
  28921. */
  28922. get useExponentialShadowMap(): boolean;
  28923. /**
  28924. * Sets the current filter is to ESM.
  28925. */
  28926. set useExponentialShadowMap(value: boolean);
  28927. /**
  28928. * Gets if the current filter is set to filtered ESM.
  28929. */
  28930. get useBlurExponentialShadowMap(): boolean;
  28931. /**
  28932. * Gets if the current filter is set to filtered ESM.
  28933. */
  28934. set useBlurExponentialShadowMap(value: boolean);
  28935. /**
  28936. * Gets if the current filter is set to "close ESM" (using the inverse of the
  28937. * exponential to prevent steep falloff artifacts).
  28938. */
  28939. get useCloseExponentialShadowMap(): boolean;
  28940. /**
  28941. * Sets the current filter to "close ESM" (using the inverse of the
  28942. * exponential to prevent steep falloff artifacts).
  28943. */
  28944. set useCloseExponentialShadowMap(value: boolean);
  28945. /**
  28946. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  28947. * exponential to prevent steep falloff artifacts).
  28948. */
  28949. get useBlurCloseExponentialShadowMap(): boolean;
  28950. /**
  28951. * Sets the current filter to filtered "close ESM" (using the inverse of the
  28952. * exponential to prevent steep falloff artifacts).
  28953. */
  28954. set useBlurCloseExponentialShadowMap(value: boolean);
  28955. /**
  28956. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  28957. */
  28958. get usePercentageCloserFiltering(): boolean;
  28959. /**
  28960. * Sets the current filter to "PCF" (percentage closer filtering).
  28961. */
  28962. set usePercentageCloserFiltering(value: boolean);
  28963. protected _filteringQuality: number;
  28964. /**
  28965. * Gets the PCF or PCSS Quality.
  28966. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  28967. */
  28968. get filteringQuality(): number;
  28969. /**
  28970. * Sets the PCF or PCSS Quality.
  28971. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  28972. */
  28973. set filteringQuality(filteringQuality: number);
  28974. /**
  28975. * Gets if the current filter is set to "PCSS" (contact hardening).
  28976. */
  28977. get useContactHardeningShadow(): boolean;
  28978. /**
  28979. * Sets the current filter to "PCSS" (contact hardening).
  28980. */
  28981. set useContactHardeningShadow(value: boolean);
  28982. protected _contactHardeningLightSizeUVRatio: number;
  28983. /**
  28984. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  28985. * Using a ratio helps keeping shape stability independently of the map size.
  28986. *
  28987. * It does not account for the light projection as it was having too much
  28988. * instability during the light setup or during light position changes.
  28989. *
  28990. * Only valid if useContactHardeningShadow is true.
  28991. */
  28992. get contactHardeningLightSizeUVRatio(): number;
  28993. /**
  28994. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  28995. * Using a ratio helps keeping shape stability independently of the map size.
  28996. *
  28997. * It does not account for the light projection as it was having too much
  28998. * instability during the light setup or during light position changes.
  28999. *
  29000. * Only valid if useContactHardeningShadow is true.
  29001. */
  29002. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  29003. protected _darkness: number;
  29004. /** Gets or sets the actual darkness of a shadow */
  29005. get darkness(): number;
  29006. set darkness(value: number);
  29007. /**
  29008. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  29009. * 0 means strongest and 1 would means no shadow.
  29010. * @returns the darkness.
  29011. */
  29012. getDarkness(): number;
  29013. /**
  29014. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  29015. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  29016. * @returns the shadow generator allowing fluent coding.
  29017. */
  29018. setDarkness(darkness: number): ShadowGenerator;
  29019. protected _transparencyShadow: boolean;
  29020. /** Gets or sets the ability to have transparent shadow */
  29021. get transparencyShadow(): boolean;
  29022. set transparencyShadow(value: boolean);
  29023. /**
  29024. * Sets the ability to have transparent shadow (boolean).
  29025. * @param transparent True if transparent else False
  29026. * @returns the shadow generator allowing fluent coding
  29027. */
  29028. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  29029. /**
  29030. * Enables or disables shadows with varying strength based on the transparency
  29031. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  29032. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  29033. * mesh.visibility * alphaTexture.a
  29034. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  29035. */
  29036. enableSoftTransparentShadow: boolean;
  29037. protected _shadowMap: Nullable<RenderTargetTexture>;
  29038. protected _shadowMap2: Nullable<RenderTargetTexture>;
  29039. /**
  29040. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  29041. * @returns The render target texture if present otherwise, null
  29042. */
  29043. getShadowMap(): Nullable<RenderTargetTexture>;
  29044. /**
  29045. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  29046. * @returns The render target texture if the shadow map is present otherwise, null
  29047. */
  29048. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  29049. /**
  29050. * Gets the class name of that object
  29051. * @returns "ShadowGenerator"
  29052. */
  29053. getClassName(): string;
  29054. /**
  29055. * Helper function to add a mesh and its descendants to the list of shadow casters.
  29056. * @param mesh Mesh to add
  29057. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  29058. * @returns the Shadow Generator itself
  29059. */
  29060. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  29061. /**
  29062. * Helper function to remove a mesh and its descendants from the list of shadow casters
  29063. * @param mesh Mesh to remove
  29064. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  29065. * @returns the Shadow Generator itself
  29066. */
  29067. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  29068. /**
  29069. * Controls the extent to which the shadows fade out at the edge of the frustum
  29070. */
  29071. frustumEdgeFalloff: number;
  29072. protected _light: IShadowLight;
  29073. /**
  29074. * Returns the associated light object.
  29075. * @returns the light generating the shadow
  29076. */
  29077. getLight(): IShadowLight;
  29078. /**
  29079. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  29080. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  29081. * It might on the other hand introduce peter panning.
  29082. */
  29083. forceBackFacesOnly: boolean;
  29084. protected _scene: Scene;
  29085. protected _lightDirection: Vector3;
  29086. protected _effect: Effect;
  29087. protected _viewMatrix: Matrix;
  29088. protected _projectionMatrix: Matrix;
  29089. protected _transformMatrix: Matrix;
  29090. protected _cachedPosition: Vector3;
  29091. protected _cachedDirection: Vector3;
  29092. protected _cachedDefines: string;
  29093. protected _currentRenderID: number;
  29094. protected _boxBlurPostprocess: Nullable<PostProcess>;
  29095. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  29096. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  29097. protected _blurPostProcesses: PostProcess[];
  29098. protected _mapSize: number;
  29099. protected _currentFaceIndex: number;
  29100. protected _currentFaceIndexCache: number;
  29101. protected _textureType: number;
  29102. protected _defaultTextureMatrix: Matrix;
  29103. protected _storedUniqueId: Nullable<number>;
  29104. /** @hidden */
  29105. static _SceneComponentInitialization: (scene: Scene) => void;
  29106. /**
  29107. * Gets or sets the size of the texture what stores the shadows
  29108. */
  29109. get mapSize(): number;
  29110. set mapSize(size: number);
  29111. /**
  29112. * Creates a ShadowGenerator object.
  29113. * A ShadowGenerator is the required tool to use the shadows.
  29114. * Each light casting shadows needs to use its own ShadowGenerator.
  29115. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  29116. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  29117. * @param light The light object generating the shadows.
  29118. * @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.
  29119. */
  29120. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  29121. protected _initializeGenerator(): void;
  29122. protected _createTargetRenderTexture(): void;
  29123. protected _initializeShadowMap(): void;
  29124. protected _initializeBlurRTTAndPostProcesses(): void;
  29125. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  29126. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  29127. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  29128. protected _applyFilterValues(): void;
  29129. /**
  29130. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29131. * @param onCompiled Callback triggered at the and of the effects compilation
  29132. * @param options Sets of optional options forcing the compilation with different modes
  29133. */
  29134. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  29135. useInstances: boolean;
  29136. }>): void;
  29137. /**
  29138. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29139. * @param options Sets of optional options forcing the compilation with different modes
  29140. * @returns A promise that resolves when the compilation completes
  29141. */
  29142. forceCompilationAsync(options?: Partial<{
  29143. useInstances: boolean;
  29144. }>): Promise<void>;
  29145. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  29146. private _prepareShadowDefines;
  29147. /**
  29148. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29149. * @param subMesh The submesh we want to render in the shadow map
  29150. * @param useInstances Defines wether will draw in the map using instances
  29151. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  29152. * @returns true if ready otherwise, false
  29153. */
  29154. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  29155. /**
  29156. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29157. * @param defines Defines of the material we want to update
  29158. * @param lightIndex Index of the light in the enabled light list of the material
  29159. */
  29160. prepareDefines(defines: any, lightIndex: number): void;
  29161. /**
  29162. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  29163. * defined in the generator but impacting the effect).
  29164. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  29165. * @param effect The effect we are binfing the information for
  29166. */
  29167. bindShadowLight(lightIndex: string, effect: Effect): void;
  29168. /**
  29169. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  29170. * (eq to shadow prjection matrix * light transform matrix)
  29171. * @returns The transform matrix used to create the shadow map
  29172. */
  29173. getTransformMatrix(): Matrix;
  29174. /**
  29175. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  29176. * Cube and 2D textures for instance.
  29177. */
  29178. recreateShadowMap(): void;
  29179. protected _disposeBlurPostProcesses(): void;
  29180. protected _disposeRTTandPostProcesses(): void;
  29181. /**
  29182. * Disposes the ShadowGenerator.
  29183. * Returns nothing.
  29184. */
  29185. dispose(): void;
  29186. /**
  29187. * Serializes the shadow generator setup to a json object.
  29188. * @returns The serialized JSON object
  29189. */
  29190. serialize(): any;
  29191. /**
  29192. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  29193. * @param parsedShadowGenerator The JSON object to parse
  29194. * @param scene The scene to create the shadow map for
  29195. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  29196. * @returns The parsed shadow generator
  29197. */
  29198. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  29199. }
  29200. }
  29201. declare module BABYLON {
  29202. /**
  29203. * Options to be used when creating a shadow depth material
  29204. */
  29205. export interface IIOptionShadowDepthMaterial {
  29206. /** Variables in the vertex shader code that need to have their names remapped.
  29207. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  29208. * "var_name" should be either: worldPos or vNormalW
  29209. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  29210. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  29211. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  29212. */
  29213. remappedVariables?: string[];
  29214. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  29215. standalone?: boolean;
  29216. }
  29217. /**
  29218. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  29219. */
  29220. export class ShadowDepthWrapper {
  29221. private _scene;
  29222. private _options?;
  29223. private _baseMaterial;
  29224. private _onEffectCreatedObserver;
  29225. private _subMeshToEffect;
  29226. private _subMeshToDepthEffect;
  29227. private _meshes;
  29228. /** @hidden */
  29229. _matriceNames: any;
  29230. /** Gets the standalone status of the wrapper */
  29231. get standalone(): boolean;
  29232. /** Gets the base material the wrapper is built upon */
  29233. get baseMaterial(): Material;
  29234. /**
  29235. * Instantiate a new shadow depth wrapper.
  29236. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  29237. * generate the shadow depth map. For more information, please refer to the documentation:
  29238. * https://doc.babylonjs.com/babylon101/shadows
  29239. * @param baseMaterial Material to wrap
  29240. * @param scene Define the scene the material belongs to
  29241. * @param options Options used to create the wrapper
  29242. */
  29243. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  29244. /**
  29245. * Gets the effect to use to generate the depth map
  29246. * @param subMesh subMesh to get the effect for
  29247. * @param shadowGenerator shadow generator to get the effect for
  29248. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  29249. */
  29250. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  29251. /**
  29252. * Specifies that the submesh is ready to be used for depth rendering
  29253. * @param subMesh submesh to check
  29254. * @param defines the list of defines to take into account when checking the effect
  29255. * @param shadowGenerator combined with subMesh, it defines the effect to check
  29256. * @param useInstances specifies that instances should be used
  29257. * @returns a boolean indicating that the submesh is ready or not
  29258. */
  29259. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  29260. /**
  29261. * Disposes the resources
  29262. */
  29263. dispose(): void;
  29264. private _makeEffect;
  29265. }
  29266. }
  29267. declare module BABYLON {
  29268. /**
  29269. * Options for compiling materials.
  29270. */
  29271. export interface IMaterialCompilationOptions {
  29272. /**
  29273. * Defines whether clip planes are enabled.
  29274. */
  29275. clipPlane: boolean;
  29276. /**
  29277. * Defines whether instances are enabled.
  29278. */
  29279. useInstances: boolean;
  29280. }
  29281. /**
  29282. * Options passed when calling customShaderNameResolve
  29283. */
  29284. export interface ICustomShaderNameResolveOptions {
  29285. /**
  29286. * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU
  29287. */
  29288. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  29289. }
  29290. /**
  29291. * Base class for the main features of a material in Babylon.js
  29292. */
  29293. export class Material implements IAnimatable {
  29294. /**
  29295. * Returns the triangle fill mode
  29296. */
  29297. static readonly TriangleFillMode: number;
  29298. /**
  29299. * Returns the wireframe mode
  29300. */
  29301. static readonly WireFrameFillMode: number;
  29302. /**
  29303. * Returns the point fill mode
  29304. */
  29305. static readonly PointFillMode: number;
  29306. /**
  29307. * Returns the point list draw mode
  29308. */
  29309. static readonly PointListDrawMode: number;
  29310. /**
  29311. * Returns the line list draw mode
  29312. */
  29313. static readonly LineListDrawMode: number;
  29314. /**
  29315. * Returns the line loop draw mode
  29316. */
  29317. static readonly LineLoopDrawMode: number;
  29318. /**
  29319. * Returns the line strip draw mode
  29320. */
  29321. static readonly LineStripDrawMode: number;
  29322. /**
  29323. * Returns the triangle strip draw mode
  29324. */
  29325. static readonly TriangleStripDrawMode: number;
  29326. /**
  29327. * Returns the triangle fan draw mode
  29328. */
  29329. static readonly TriangleFanDrawMode: number;
  29330. /**
  29331. * Stores the clock-wise side orientation
  29332. */
  29333. static readonly ClockWiseSideOrientation: number;
  29334. /**
  29335. * Stores the counter clock-wise side orientation
  29336. */
  29337. static readonly CounterClockWiseSideOrientation: number;
  29338. /**
  29339. * The dirty texture flag value
  29340. */
  29341. static readonly TextureDirtyFlag: number;
  29342. /**
  29343. * The dirty light flag value
  29344. */
  29345. static readonly LightDirtyFlag: number;
  29346. /**
  29347. * The dirty fresnel flag value
  29348. */
  29349. static readonly FresnelDirtyFlag: number;
  29350. /**
  29351. * The dirty attribute flag value
  29352. */
  29353. static readonly AttributesDirtyFlag: number;
  29354. /**
  29355. * The dirty misc flag value
  29356. */
  29357. static readonly MiscDirtyFlag: number;
  29358. /**
  29359. * The dirty prepass flag value
  29360. */
  29361. static readonly PrePassDirtyFlag: number;
  29362. /**
  29363. * The all dirty flag value
  29364. */
  29365. static readonly AllDirtyFlag: number;
  29366. /**
  29367. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  29368. */
  29369. static readonly MATERIAL_OPAQUE: number;
  29370. /**
  29371. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  29372. */
  29373. static readonly MATERIAL_ALPHATEST: number;
  29374. /**
  29375. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  29376. */
  29377. static readonly MATERIAL_ALPHABLEND: number;
  29378. /**
  29379. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  29380. * They are also discarded below the alpha cutoff threshold to improve performances.
  29381. */
  29382. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  29383. /**
  29384. * The Whiteout method is used to blend normals.
  29385. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  29386. */
  29387. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  29388. /**
  29389. * The Reoriented Normal Mapping method is used to blend normals.
  29390. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  29391. */
  29392. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  29393. /**
  29394. * Custom callback helping to override the default shader used in the material.
  29395. */
  29396. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  29397. /**
  29398. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  29399. */
  29400. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  29401. /**
  29402. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  29403. * This means that the material can keep using a previous shader while a new one is being compiled.
  29404. * This is mostly used when shader parallel compilation is supported (true by default)
  29405. */
  29406. allowShaderHotSwapping: boolean;
  29407. /**
  29408. * The ID of the material
  29409. */
  29410. id: string;
  29411. /**
  29412. * Gets or sets the unique id of the material
  29413. */
  29414. uniqueId: number;
  29415. /**
  29416. * The name of the material
  29417. */
  29418. name: string;
  29419. /**
  29420. * Gets or sets user defined metadata
  29421. */
  29422. metadata: any;
  29423. /**
  29424. * For internal use only. Please do not use.
  29425. */
  29426. reservedDataStore: any;
  29427. /**
  29428. * Specifies if the ready state should be checked on each call
  29429. */
  29430. checkReadyOnEveryCall: boolean;
  29431. /**
  29432. * Specifies if the ready state should be checked once
  29433. */
  29434. checkReadyOnlyOnce: boolean;
  29435. /**
  29436. * The state of the material
  29437. */
  29438. state: string;
  29439. /**
  29440. * If the material can be rendered to several textures with MRT extension
  29441. */
  29442. get canRenderToMRT(): boolean;
  29443. /**
  29444. * The alpha value of the material
  29445. */
  29446. protected _alpha: number;
  29447. /**
  29448. * List of inspectable custom properties (used by the Inspector)
  29449. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29450. */
  29451. inspectableCustomProperties: IInspectable[];
  29452. /**
  29453. * Sets the alpha value of the material
  29454. */
  29455. set alpha(value: number);
  29456. /**
  29457. * Gets the alpha value of the material
  29458. */
  29459. get alpha(): number;
  29460. /**
  29461. * Specifies if back face culling is enabled
  29462. */
  29463. protected _backFaceCulling: boolean;
  29464. /**
  29465. * Sets the back-face culling state
  29466. */
  29467. set backFaceCulling(value: boolean);
  29468. /**
  29469. * Gets the back-face culling state
  29470. */
  29471. get backFaceCulling(): boolean;
  29472. /**
  29473. * Stores the value for side orientation
  29474. */
  29475. sideOrientation: number;
  29476. /**
  29477. * Callback triggered when the material is compiled
  29478. */
  29479. onCompiled: Nullable<(effect: Effect) => void>;
  29480. /**
  29481. * Callback triggered when an error occurs
  29482. */
  29483. onError: Nullable<(effect: Effect, errors: string) => void>;
  29484. /**
  29485. * Callback triggered to get the render target textures
  29486. */
  29487. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  29488. /**
  29489. * Gets a boolean indicating that current material needs to register RTT
  29490. */
  29491. get hasRenderTargetTextures(): boolean;
  29492. /**
  29493. * Specifies if the material should be serialized
  29494. */
  29495. doNotSerialize: boolean;
  29496. /**
  29497. * @hidden
  29498. */
  29499. _storeEffectOnSubMeshes: boolean;
  29500. /**
  29501. * Stores the animations for the material
  29502. */
  29503. animations: Nullable<Array<Animation>>;
  29504. /**
  29505. * An event triggered when the material is disposed
  29506. */
  29507. onDisposeObservable: Observable<Material>;
  29508. /**
  29509. * An observer which watches for dispose events
  29510. */
  29511. private _onDisposeObserver;
  29512. private _onUnBindObservable;
  29513. /**
  29514. * Called during a dispose event
  29515. */
  29516. set onDispose(callback: () => void);
  29517. private _onBindObservable;
  29518. /**
  29519. * An event triggered when the material is bound
  29520. */
  29521. get onBindObservable(): Observable<AbstractMesh>;
  29522. /**
  29523. * An observer which watches for bind events
  29524. */
  29525. private _onBindObserver;
  29526. /**
  29527. * Called during a bind event
  29528. */
  29529. set onBind(callback: (Mesh: AbstractMesh) => void);
  29530. /**
  29531. * An event triggered when the material is unbound
  29532. */
  29533. get onUnBindObservable(): Observable<Material>;
  29534. protected _onEffectCreatedObservable: Nullable<Observable<{
  29535. effect: Effect;
  29536. subMesh: Nullable<SubMesh>;
  29537. }>>;
  29538. /**
  29539. * An event triggered when the effect is (re)created
  29540. */
  29541. get onEffectCreatedObservable(): Observable<{
  29542. effect: Effect;
  29543. subMesh: Nullable<SubMesh>;
  29544. }>;
  29545. /**
  29546. * Stores the value of the alpha mode
  29547. */
  29548. private _alphaMode;
  29549. /**
  29550. * Sets the value of the alpha mode.
  29551. *
  29552. * | Value | Type | Description |
  29553. * | --- | --- | --- |
  29554. * | 0 | ALPHA_DISABLE | |
  29555. * | 1 | ALPHA_ADD | |
  29556. * | 2 | ALPHA_COMBINE | |
  29557. * | 3 | ALPHA_SUBTRACT | |
  29558. * | 4 | ALPHA_MULTIPLY | |
  29559. * | 5 | ALPHA_MAXIMIZED | |
  29560. * | 6 | ALPHA_ONEONE | |
  29561. * | 7 | ALPHA_PREMULTIPLIED | |
  29562. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  29563. * | 9 | ALPHA_INTERPOLATE | |
  29564. * | 10 | ALPHA_SCREENMODE | |
  29565. *
  29566. */
  29567. set alphaMode(value: number);
  29568. /**
  29569. * Gets the value of the alpha mode
  29570. */
  29571. get alphaMode(): number;
  29572. /**
  29573. * Stores the state of the need depth pre-pass value
  29574. */
  29575. private _needDepthPrePass;
  29576. /**
  29577. * Sets the need depth pre-pass value
  29578. */
  29579. set needDepthPrePass(value: boolean);
  29580. /**
  29581. * Gets the depth pre-pass value
  29582. */
  29583. get needDepthPrePass(): boolean;
  29584. /**
  29585. * Specifies if depth writing should be disabled
  29586. */
  29587. disableDepthWrite: boolean;
  29588. /**
  29589. * Specifies if color writing should be disabled
  29590. */
  29591. disableColorWrite: boolean;
  29592. /**
  29593. * Specifies if depth writing should be forced
  29594. */
  29595. forceDepthWrite: boolean;
  29596. /**
  29597. * Specifies the depth function that should be used. 0 means the default engine function
  29598. */
  29599. depthFunction: number;
  29600. /**
  29601. * Specifies if there should be a separate pass for culling
  29602. */
  29603. separateCullingPass: boolean;
  29604. /**
  29605. * Stores the state specifing if fog should be enabled
  29606. */
  29607. private _fogEnabled;
  29608. /**
  29609. * Sets the state for enabling fog
  29610. */
  29611. set fogEnabled(value: boolean);
  29612. /**
  29613. * Gets the value of the fog enabled state
  29614. */
  29615. get fogEnabled(): boolean;
  29616. /**
  29617. * Stores the size of points
  29618. */
  29619. pointSize: number;
  29620. /**
  29621. * Stores the z offset value
  29622. */
  29623. zOffset: number;
  29624. get wireframe(): boolean;
  29625. /**
  29626. * Sets the state of wireframe mode
  29627. */
  29628. set wireframe(value: boolean);
  29629. /**
  29630. * Gets the value specifying if point clouds are enabled
  29631. */
  29632. get pointsCloud(): boolean;
  29633. /**
  29634. * Sets the state of point cloud mode
  29635. */
  29636. set pointsCloud(value: boolean);
  29637. /**
  29638. * Gets the material fill mode
  29639. */
  29640. get fillMode(): number;
  29641. /**
  29642. * Sets the material fill mode
  29643. */
  29644. set fillMode(value: number);
  29645. /**
  29646. * @hidden
  29647. * Stores the effects for the material
  29648. */
  29649. _effect: Nullable<Effect>;
  29650. /**
  29651. * Specifies if uniform buffers should be used
  29652. */
  29653. private _useUBO;
  29654. /**
  29655. * Stores a reference to the scene
  29656. */
  29657. private _scene;
  29658. /**
  29659. * Stores the fill mode state
  29660. */
  29661. private _fillMode;
  29662. /**
  29663. * Specifies if the depth write state should be cached
  29664. */
  29665. private _cachedDepthWriteState;
  29666. /**
  29667. * Specifies if the color write state should be cached
  29668. */
  29669. private _cachedColorWriteState;
  29670. /**
  29671. * Specifies if the depth function state should be cached
  29672. */
  29673. private _cachedDepthFunctionState;
  29674. /**
  29675. * Stores the uniform buffer
  29676. */
  29677. protected _uniformBuffer: UniformBuffer;
  29678. /** @hidden */
  29679. _indexInSceneMaterialArray: number;
  29680. /** @hidden */
  29681. meshMap: Nullable<{
  29682. [id: string]: AbstractMesh | undefined;
  29683. }>;
  29684. /**
  29685. * Creates a material instance
  29686. * @param name defines the name of the material
  29687. * @param scene defines the scene to reference
  29688. * @param doNotAdd specifies if the material should be added to the scene
  29689. */
  29690. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  29691. /**
  29692. * Returns a string representation of the current material
  29693. * @param fullDetails defines a boolean indicating which levels of logging is desired
  29694. * @returns a string with material information
  29695. */
  29696. toString(fullDetails?: boolean): string;
  29697. /**
  29698. * Gets the class name of the material
  29699. * @returns a string with the class name of the material
  29700. */
  29701. getClassName(): string;
  29702. /**
  29703. * Specifies if updates for the material been locked
  29704. */
  29705. get isFrozen(): boolean;
  29706. /**
  29707. * Locks updates for the material
  29708. */
  29709. freeze(): void;
  29710. /**
  29711. * Unlocks updates for the material
  29712. */
  29713. unfreeze(): void;
  29714. /**
  29715. * Specifies if the material is ready to be used
  29716. * @param mesh defines the mesh to check
  29717. * @param useInstances specifies if instances should be used
  29718. * @returns a boolean indicating if the material is ready to be used
  29719. */
  29720. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  29721. /**
  29722. * Specifies that the submesh is ready to be used
  29723. * @param mesh defines the mesh to check
  29724. * @param subMesh defines which submesh to check
  29725. * @param useInstances specifies that instances should be used
  29726. * @returns a boolean indicating that the submesh is ready or not
  29727. */
  29728. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29729. /**
  29730. * Returns the material effect
  29731. * @returns the effect associated with the material
  29732. */
  29733. getEffect(): Nullable<Effect>;
  29734. /**
  29735. * Returns the current scene
  29736. * @returns a Scene
  29737. */
  29738. getScene(): Scene;
  29739. /**
  29740. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  29741. */
  29742. protected _forceAlphaTest: boolean;
  29743. /**
  29744. * The transparency mode of the material.
  29745. */
  29746. protected _transparencyMode: Nullable<number>;
  29747. /**
  29748. * Gets the current transparency mode.
  29749. */
  29750. get transparencyMode(): Nullable<number>;
  29751. /**
  29752. * Sets the transparency mode of the material.
  29753. *
  29754. * | Value | Type | Description |
  29755. * | ----- | ----------------------------------- | ----------- |
  29756. * | 0 | OPAQUE | |
  29757. * | 1 | ALPHATEST | |
  29758. * | 2 | ALPHABLEND | |
  29759. * | 3 | ALPHATESTANDBLEND | |
  29760. *
  29761. */
  29762. set transparencyMode(value: Nullable<number>);
  29763. /**
  29764. * Returns true if alpha blending should be disabled.
  29765. */
  29766. protected get _disableAlphaBlending(): boolean;
  29767. /**
  29768. * Specifies whether or not this material should be rendered in alpha blend mode.
  29769. * @returns a boolean specifying if alpha blending is needed
  29770. */
  29771. needAlphaBlending(): boolean;
  29772. /**
  29773. * Specifies if the mesh will require alpha blending
  29774. * @param mesh defines the mesh to check
  29775. * @returns a boolean specifying if alpha blending is needed for the mesh
  29776. */
  29777. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  29778. /**
  29779. * Specifies whether or not this material should be rendered in alpha test mode.
  29780. * @returns a boolean specifying if an alpha test is needed.
  29781. */
  29782. needAlphaTesting(): boolean;
  29783. /**
  29784. * Specifies if material alpha testing should be turned on for the mesh
  29785. * @param mesh defines the mesh to check
  29786. */
  29787. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  29788. /**
  29789. * Gets the texture used for the alpha test
  29790. * @returns the texture to use for alpha testing
  29791. */
  29792. getAlphaTestTexture(): Nullable<BaseTexture>;
  29793. /**
  29794. * Marks the material to indicate that it needs to be re-calculated
  29795. */
  29796. markDirty(): void;
  29797. /** @hidden */
  29798. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  29799. /**
  29800. * Binds the material to the mesh
  29801. * @param world defines the world transformation matrix
  29802. * @param mesh defines the mesh to bind the material to
  29803. */
  29804. bind(world: Matrix, mesh?: Mesh): void;
  29805. /**
  29806. * Binds the submesh to the material
  29807. * @param world defines the world transformation matrix
  29808. * @param mesh defines the mesh containing the submesh
  29809. * @param subMesh defines the submesh to bind the material to
  29810. */
  29811. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29812. /**
  29813. * Binds the world matrix to the material
  29814. * @param world defines the world transformation matrix
  29815. */
  29816. bindOnlyWorldMatrix(world: Matrix): void;
  29817. /**
  29818. * Binds the scene's uniform buffer to the effect.
  29819. * @param effect defines the effect to bind to the scene uniform buffer
  29820. * @param sceneUbo defines the uniform buffer storing scene data
  29821. */
  29822. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  29823. /**
  29824. * Binds the view matrix to the effect
  29825. * @param effect defines the effect to bind the view matrix to
  29826. */
  29827. bindView(effect: Effect): void;
  29828. /**
  29829. * Binds the view projection matrix to the effect
  29830. * @param effect defines the effect to bind the view projection matrix to
  29831. */
  29832. bindViewProjection(effect: Effect): void;
  29833. /**
  29834. * Processes to execute after binding the material to a mesh
  29835. * @param mesh defines the rendered mesh
  29836. */
  29837. protected _afterBind(mesh?: Mesh): void;
  29838. /**
  29839. * Unbinds the material from the mesh
  29840. */
  29841. unbind(): void;
  29842. /**
  29843. * Gets the active textures from the material
  29844. * @returns an array of textures
  29845. */
  29846. getActiveTextures(): BaseTexture[];
  29847. /**
  29848. * Specifies if the material uses a texture
  29849. * @param texture defines the texture to check against the material
  29850. * @returns a boolean specifying if the material uses the texture
  29851. */
  29852. hasTexture(texture: BaseTexture): boolean;
  29853. /**
  29854. * Makes a duplicate of the material, and gives it a new name
  29855. * @param name defines the new name for the duplicated material
  29856. * @returns the cloned material
  29857. */
  29858. clone(name: string): Nullable<Material>;
  29859. /**
  29860. * Gets the meshes bound to the material
  29861. * @returns an array of meshes bound to the material
  29862. */
  29863. getBindedMeshes(): AbstractMesh[];
  29864. /**
  29865. * Force shader compilation
  29866. * @param mesh defines the mesh associated with this material
  29867. * @param onCompiled defines a function to execute once the material is compiled
  29868. * @param options defines the options to configure the compilation
  29869. * @param onError defines a function to execute if the material fails compiling
  29870. */
  29871. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  29872. /**
  29873. * Force shader compilation
  29874. * @param mesh defines the mesh that will use this material
  29875. * @param options defines additional options for compiling the shaders
  29876. * @returns a promise that resolves when the compilation completes
  29877. */
  29878. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  29879. private static readonly _AllDirtyCallBack;
  29880. private static readonly _ImageProcessingDirtyCallBack;
  29881. private static readonly _TextureDirtyCallBack;
  29882. private static readonly _FresnelDirtyCallBack;
  29883. private static readonly _MiscDirtyCallBack;
  29884. private static readonly _PrePassDirtyCallBack;
  29885. private static readonly _LightsDirtyCallBack;
  29886. private static readonly _AttributeDirtyCallBack;
  29887. private static _FresnelAndMiscDirtyCallBack;
  29888. private static _TextureAndMiscDirtyCallBack;
  29889. private static readonly _DirtyCallbackArray;
  29890. private static readonly _RunDirtyCallBacks;
  29891. /**
  29892. * Marks a define in the material to indicate that it needs to be re-computed
  29893. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  29894. */
  29895. markAsDirty(flag: number): void;
  29896. /**
  29897. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  29898. * @param func defines a function which checks material defines against the submeshes
  29899. */
  29900. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  29901. /**
  29902. * Indicates that the scene should check if the rendering now needs a prepass
  29903. */
  29904. protected _markScenePrePassDirty(): void;
  29905. /**
  29906. * Indicates that we need to re-calculated for all submeshes
  29907. */
  29908. protected _markAllSubMeshesAsAllDirty(): void;
  29909. /**
  29910. * Indicates that image processing needs to be re-calculated for all submeshes
  29911. */
  29912. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  29913. /**
  29914. * Indicates that textures need to be re-calculated for all submeshes
  29915. */
  29916. protected _markAllSubMeshesAsTexturesDirty(): void;
  29917. /**
  29918. * Indicates that fresnel needs to be re-calculated for all submeshes
  29919. */
  29920. protected _markAllSubMeshesAsFresnelDirty(): void;
  29921. /**
  29922. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  29923. */
  29924. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  29925. /**
  29926. * Indicates that lights need to be re-calculated for all submeshes
  29927. */
  29928. protected _markAllSubMeshesAsLightsDirty(): void;
  29929. /**
  29930. * Indicates that attributes need to be re-calculated for all submeshes
  29931. */
  29932. protected _markAllSubMeshesAsAttributesDirty(): void;
  29933. /**
  29934. * Indicates that misc needs to be re-calculated for all submeshes
  29935. */
  29936. protected _markAllSubMeshesAsMiscDirty(): void;
  29937. /**
  29938. * Indicates that prepass needs to be re-calculated for all submeshes
  29939. */
  29940. protected _markAllSubMeshesAsPrePassDirty(): void;
  29941. /**
  29942. * Indicates that textures and misc need to be re-calculated for all submeshes
  29943. */
  29944. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  29945. /**
  29946. * Sets the required values to the prepass renderer.
  29947. * @param prePassRenderer defines the prepass renderer to setup.
  29948. * @returns true if the pre pass is needed.
  29949. */
  29950. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  29951. /**
  29952. * Disposes the material
  29953. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29954. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29955. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  29956. */
  29957. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  29958. /** @hidden */
  29959. private releaseVertexArrayObject;
  29960. /**
  29961. * Serializes this material
  29962. * @returns the serialized material object
  29963. */
  29964. serialize(): any;
  29965. /**
  29966. * Creates a material from parsed material data
  29967. * @param parsedMaterial defines parsed material data
  29968. * @param scene defines the hosting scene
  29969. * @param rootUrl defines the root URL to use to load textures
  29970. * @returns a new material
  29971. */
  29972. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  29973. }
  29974. }
  29975. declare module BABYLON {
  29976. /**
  29977. * A multi-material is used to apply different materials to different parts of the same object without the need of
  29978. * separate meshes. This can be use to improve performances.
  29979. * @see https://doc.babylonjs.com/how_to/multi_materials
  29980. */
  29981. export class MultiMaterial extends Material {
  29982. private _subMaterials;
  29983. /**
  29984. * Gets or Sets the list of Materials used within the multi material.
  29985. * They need to be ordered according to the submeshes order in the associated mesh
  29986. */
  29987. get subMaterials(): Nullable<Material>[];
  29988. set subMaterials(value: Nullable<Material>[]);
  29989. /**
  29990. * Function used to align with Node.getChildren()
  29991. * @returns the list of Materials used within the multi material
  29992. */
  29993. getChildren(): Nullable<Material>[];
  29994. /**
  29995. * Instantiates a new Multi Material
  29996. * A multi-material is used to apply different materials to different parts of the same object without the need of
  29997. * separate meshes. This can be use to improve performances.
  29998. * @see https://doc.babylonjs.com/how_to/multi_materials
  29999. * @param name Define the name in the scene
  30000. * @param scene Define the scene the material belongs to
  30001. */
  30002. constructor(name: string, scene: Scene);
  30003. private _hookArray;
  30004. /**
  30005. * Get one of the submaterial by its index in the submaterials array
  30006. * @param index The index to look the sub material at
  30007. * @returns The Material if the index has been defined
  30008. */
  30009. getSubMaterial(index: number): Nullable<Material>;
  30010. /**
  30011. * Get the list of active textures for the whole sub materials list.
  30012. * @returns All the textures that will be used during the rendering
  30013. */
  30014. getActiveTextures(): BaseTexture[];
  30015. /**
  30016. * Specifies if any sub-materials of this multi-material use a given texture.
  30017. * @param texture Defines the texture to check against this multi-material's sub-materials.
  30018. * @returns A boolean specifying if any sub-material of this multi-material uses the texture.
  30019. */
  30020. hasTexture(texture: BaseTexture): boolean;
  30021. /**
  30022. * Gets the current class name of the material e.g. "MultiMaterial"
  30023. * Mainly use in serialization.
  30024. * @returns the class name
  30025. */
  30026. getClassName(): string;
  30027. /**
  30028. * Checks if the material is ready to render the requested sub mesh
  30029. * @param mesh Define the mesh the submesh belongs to
  30030. * @param subMesh Define the sub mesh to look readyness for
  30031. * @param useInstances Define whether or not the material is used with instances
  30032. * @returns true if ready, otherwise false
  30033. */
  30034. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30035. /**
  30036. * Clones the current material and its related sub materials
  30037. * @param name Define the name of the newly cloned material
  30038. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  30039. * @returns the cloned material
  30040. */
  30041. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  30042. /**
  30043. * Serializes the materials into a JSON representation.
  30044. * @returns the JSON representation
  30045. */
  30046. serialize(): any;
  30047. /**
  30048. * Dispose the material and release its associated resources
  30049. * @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)
  30050. * @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)
  30051. * @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)
  30052. */
  30053. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  30054. /**
  30055. * Creates a MultiMaterial from parsed MultiMaterial data.
  30056. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  30057. * @param scene defines the hosting scene
  30058. * @returns a new MultiMaterial
  30059. */
  30060. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  30061. }
  30062. }
  30063. declare module BABYLON {
  30064. /**
  30065. * Defines a subdivision inside a mesh
  30066. */
  30067. export class SubMesh implements ICullable {
  30068. /** the material index to use */
  30069. materialIndex: number;
  30070. /** vertex index start */
  30071. verticesStart: number;
  30072. /** vertices count */
  30073. verticesCount: number;
  30074. /** index start */
  30075. indexStart: number;
  30076. /** indices count */
  30077. indexCount: number;
  30078. /** @hidden */
  30079. _materialDefines: Nullable<MaterialDefines>;
  30080. /** @hidden */
  30081. _materialEffect: Nullable<Effect>;
  30082. /** @hidden */
  30083. _effectOverride: Nullable<Effect>;
  30084. /**
  30085. * Gets material defines used by the effect associated to the sub mesh
  30086. */
  30087. get materialDefines(): Nullable<MaterialDefines>;
  30088. /**
  30089. * Sets material defines used by the effect associated to the sub mesh
  30090. */
  30091. set materialDefines(defines: Nullable<MaterialDefines>);
  30092. /**
  30093. * Gets associated effect
  30094. */
  30095. get effect(): Nullable<Effect>;
  30096. /**
  30097. * Sets associated effect (effect used to render this submesh)
  30098. * @param effect defines the effect to associate with
  30099. * @param defines defines the set of defines used to compile this effect
  30100. */
  30101. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  30102. /** @hidden */
  30103. _linesIndexCount: number;
  30104. private _mesh;
  30105. private _renderingMesh;
  30106. private _boundingInfo;
  30107. private _linesIndexBuffer;
  30108. /** @hidden */
  30109. _lastColliderWorldVertices: Nullable<Vector3[]>;
  30110. /** @hidden */
  30111. _trianglePlanes: Plane[];
  30112. /** @hidden */
  30113. _lastColliderTransformMatrix: Nullable<Matrix>;
  30114. /** @hidden */
  30115. _renderId: number;
  30116. /** @hidden */
  30117. _alphaIndex: number;
  30118. /** @hidden */
  30119. _distanceToCamera: number;
  30120. /** @hidden */
  30121. _id: number;
  30122. private _currentMaterial;
  30123. /**
  30124. * Add a new submesh to a mesh
  30125. * @param materialIndex defines the material index to use
  30126. * @param verticesStart defines vertex index start
  30127. * @param verticesCount defines vertices count
  30128. * @param indexStart defines index start
  30129. * @param indexCount defines indices count
  30130. * @param mesh defines the parent mesh
  30131. * @param renderingMesh defines an optional rendering mesh
  30132. * @param createBoundingBox defines if bounding box should be created for this submesh
  30133. * @returns the new submesh
  30134. */
  30135. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  30136. /**
  30137. * Creates a new submesh
  30138. * @param materialIndex defines the material index to use
  30139. * @param verticesStart defines vertex index start
  30140. * @param verticesCount defines vertices count
  30141. * @param indexStart defines index start
  30142. * @param indexCount defines indices count
  30143. * @param mesh defines the parent mesh
  30144. * @param renderingMesh defines an optional rendering mesh
  30145. * @param createBoundingBox defines if bounding box should be created for this submesh
  30146. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  30147. */
  30148. constructor(
  30149. /** the material index to use */
  30150. materialIndex: number,
  30151. /** vertex index start */
  30152. verticesStart: number,
  30153. /** vertices count */
  30154. verticesCount: number,
  30155. /** index start */
  30156. indexStart: number,
  30157. /** indices count */
  30158. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  30159. /**
  30160. * Returns true if this submesh covers the entire parent mesh
  30161. * @ignorenaming
  30162. */
  30163. get IsGlobal(): boolean;
  30164. /**
  30165. * Returns the submesh BoudingInfo object
  30166. * @returns current bounding info (or mesh's one if the submesh is global)
  30167. */
  30168. getBoundingInfo(): BoundingInfo;
  30169. /**
  30170. * Sets the submesh BoundingInfo
  30171. * @param boundingInfo defines the new bounding info to use
  30172. * @returns the SubMesh
  30173. */
  30174. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  30175. /**
  30176. * Returns the mesh of the current submesh
  30177. * @return the parent mesh
  30178. */
  30179. getMesh(): AbstractMesh;
  30180. /**
  30181. * Returns the rendering mesh of the submesh
  30182. * @returns the rendering mesh (could be different from parent mesh)
  30183. */
  30184. getRenderingMesh(): Mesh;
  30185. /**
  30186. * Returns the replacement mesh of the submesh
  30187. * @returns the replacement mesh (could be different from parent mesh)
  30188. */
  30189. getReplacementMesh(): Nullable<AbstractMesh>;
  30190. /**
  30191. * Returns the effective mesh of the submesh
  30192. * @returns the effective mesh (could be different from parent mesh)
  30193. */
  30194. getEffectiveMesh(): AbstractMesh;
  30195. /**
  30196. * Returns the submesh material
  30197. * @returns null or the current material
  30198. */
  30199. getMaterial(): Nullable<Material>;
  30200. private _IsMultiMaterial;
  30201. /**
  30202. * Sets a new updated BoundingInfo object to the submesh
  30203. * @param data defines an optional position array to use to determine the bounding info
  30204. * @returns the SubMesh
  30205. */
  30206. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  30207. /** @hidden */
  30208. _checkCollision(collider: Collider): boolean;
  30209. /**
  30210. * Updates the submesh BoundingInfo
  30211. * @param world defines the world matrix to use to update the bounding info
  30212. * @returns the submesh
  30213. */
  30214. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  30215. /**
  30216. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  30217. * @param frustumPlanes defines the frustum planes
  30218. * @returns true if the submesh is intersecting with the frustum
  30219. */
  30220. isInFrustum(frustumPlanes: Plane[]): boolean;
  30221. /**
  30222. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  30223. * @param frustumPlanes defines the frustum planes
  30224. * @returns true if the submesh is inside the frustum
  30225. */
  30226. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  30227. /**
  30228. * Renders the submesh
  30229. * @param enableAlphaMode defines if alpha needs to be used
  30230. * @returns the submesh
  30231. */
  30232. render(enableAlphaMode: boolean): SubMesh;
  30233. /**
  30234. * @hidden
  30235. */
  30236. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  30237. /**
  30238. * Checks if the submesh intersects with a ray
  30239. * @param ray defines the ray to test
  30240. * @returns true is the passed ray intersects the submesh bounding box
  30241. */
  30242. canIntersects(ray: Ray): boolean;
  30243. /**
  30244. * Intersects current submesh with a ray
  30245. * @param ray defines the ray to test
  30246. * @param positions defines mesh's positions array
  30247. * @param indices defines mesh's indices array
  30248. * @param fastCheck defines if the first intersection will be used (and not the closest)
  30249. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  30250. * @returns intersection info or null if no intersection
  30251. */
  30252. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  30253. /** @hidden */
  30254. private _intersectLines;
  30255. /** @hidden */
  30256. private _intersectUnIndexedLines;
  30257. /** @hidden */
  30258. private _intersectTriangles;
  30259. /** @hidden */
  30260. private _intersectUnIndexedTriangles;
  30261. /** @hidden */
  30262. _rebuild(): void;
  30263. /**
  30264. * Creates a new submesh from the passed mesh
  30265. * @param newMesh defines the new hosting mesh
  30266. * @param newRenderingMesh defines an optional rendering mesh
  30267. * @returns the new submesh
  30268. */
  30269. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  30270. /**
  30271. * Release associated resources
  30272. */
  30273. dispose(): void;
  30274. /**
  30275. * Gets the class name
  30276. * @returns the string "SubMesh".
  30277. */
  30278. getClassName(): string;
  30279. /**
  30280. * Creates a new submesh from indices data
  30281. * @param materialIndex the index of the main mesh material
  30282. * @param startIndex the index where to start the copy in the mesh indices array
  30283. * @param indexCount the number of indices to copy then from the startIndex
  30284. * @param mesh the main mesh to create the submesh from
  30285. * @param renderingMesh the optional rendering mesh
  30286. * @returns a new submesh
  30287. */
  30288. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  30289. }
  30290. }
  30291. declare module BABYLON {
  30292. /**
  30293. * Class used to represent data loading progression
  30294. */
  30295. export class SceneLoaderFlags {
  30296. private static _ForceFullSceneLoadingForIncremental;
  30297. private static _ShowLoadingScreen;
  30298. private static _CleanBoneMatrixWeights;
  30299. private static _loggingLevel;
  30300. /**
  30301. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  30302. */
  30303. static get ForceFullSceneLoadingForIncremental(): boolean;
  30304. static set ForceFullSceneLoadingForIncremental(value: boolean);
  30305. /**
  30306. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  30307. */
  30308. static get ShowLoadingScreen(): boolean;
  30309. static set ShowLoadingScreen(value: boolean);
  30310. /**
  30311. * Defines the current logging level (while loading the scene)
  30312. * @ignorenaming
  30313. */
  30314. static get loggingLevel(): number;
  30315. static set loggingLevel(value: number);
  30316. /**
  30317. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  30318. */
  30319. static get CleanBoneMatrixWeights(): boolean;
  30320. static set CleanBoneMatrixWeights(value: boolean);
  30321. }
  30322. }
  30323. declare module BABYLON {
  30324. /**
  30325. * Class used to store geometry data (vertex buffers + index buffer)
  30326. */
  30327. export class Geometry implements IGetSetVerticesData {
  30328. /**
  30329. * Gets or sets the ID of the geometry
  30330. */
  30331. id: string;
  30332. /**
  30333. * Gets or sets the unique ID of the geometry
  30334. */
  30335. uniqueId: number;
  30336. /**
  30337. * Gets the delay loading state of the geometry (none by default which means not delayed)
  30338. */
  30339. delayLoadState: number;
  30340. /**
  30341. * Gets the file containing the data to load when running in delay load state
  30342. */
  30343. delayLoadingFile: Nullable<string>;
  30344. /**
  30345. * Callback called when the geometry is updated
  30346. */
  30347. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  30348. private _scene;
  30349. private _engine;
  30350. private _meshes;
  30351. private _totalVertices;
  30352. /** @hidden */
  30353. _indices: IndicesArray;
  30354. /** @hidden */
  30355. _vertexBuffers: {
  30356. [key: string]: VertexBuffer;
  30357. };
  30358. private _isDisposed;
  30359. private _extend;
  30360. private _boundingBias;
  30361. /** @hidden */
  30362. _delayInfo: Array<string>;
  30363. private _indexBuffer;
  30364. private _indexBufferIsUpdatable;
  30365. /** @hidden */
  30366. _boundingInfo: Nullable<BoundingInfo>;
  30367. /** @hidden */
  30368. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  30369. /** @hidden */
  30370. _softwareSkinningFrameId: number;
  30371. private _vertexArrayObjects;
  30372. private _updatable;
  30373. /** @hidden */
  30374. _positions: Nullable<Vector3[]>;
  30375. private _positionsCache;
  30376. /**
  30377. * 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
  30378. */
  30379. get boundingBias(): Vector2;
  30380. /**
  30381. * 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
  30382. */
  30383. set boundingBias(value: Vector2);
  30384. /**
  30385. * Static function used to attach a new empty geometry to a mesh
  30386. * @param mesh defines the mesh to attach the geometry to
  30387. * @returns the new Geometry
  30388. */
  30389. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  30390. /** Get the list of meshes using this geometry */
  30391. get meshes(): Mesh[];
  30392. /**
  30393. * If set to true (false by defaut), the bounding info applied to the meshes sharing this geometry will be the bounding info defined at the class level
  30394. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  30395. */
  30396. useBoundingInfoFromGeometry: boolean;
  30397. /**
  30398. * Creates a new geometry
  30399. * @param id defines the unique ID
  30400. * @param scene defines the hosting scene
  30401. * @param vertexData defines the VertexData used to get geometry data
  30402. * @param updatable defines if geometry must be updatable (false by default)
  30403. * @param mesh defines the mesh that will be associated with the geometry
  30404. */
  30405. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  30406. /**
  30407. * Gets the current extend of the geometry
  30408. */
  30409. get extend(): {
  30410. minimum: Vector3;
  30411. maximum: Vector3;
  30412. };
  30413. /**
  30414. * Gets the hosting scene
  30415. * @returns the hosting Scene
  30416. */
  30417. getScene(): Scene;
  30418. /**
  30419. * Gets the hosting engine
  30420. * @returns the hosting Engine
  30421. */
  30422. getEngine(): Engine;
  30423. /**
  30424. * Defines if the geometry is ready to use
  30425. * @returns true if the geometry is ready to be used
  30426. */
  30427. isReady(): boolean;
  30428. /**
  30429. * Gets a value indicating that the geometry should not be serialized
  30430. */
  30431. get doNotSerialize(): boolean;
  30432. /** @hidden */
  30433. _rebuild(): void;
  30434. /**
  30435. * Affects all geometry data in one call
  30436. * @param vertexData defines the geometry data
  30437. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  30438. */
  30439. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  30440. /**
  30441. * Set specific vertex data
  30442. * @param kind defines the data kind (Position, normal, etc...)
  30443. * @param data defines the vertex data to use
  30444. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  30445. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  30446. */
  30447. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  30448. /**
  30449. * Removes a specific vertex data
  30450. * @param kind defines the data kind (Position, normal, etc...)
  30451. */
  30452. removeVerticesData(kind: string): void;
  30453. /**
  30454. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  30455. * @param buffer defines the vertex buffer to use
  30456. * @param totalVertices defines the total number of vertices for position kind (could be null)
  30457. */
  30458. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  30459. /**
  30460. * Update a specific vertex buffer
  30461. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  30462. * It will do nothing if the buffer is not updatable
  30463. * @param kind defines the data kind (Position, normal, etc...)
  30464. * @param data defines the data to use
  30465. * @param offset defines the offset in the target buffer where to store the data
  30466. * @param useBytes set to true if the offset is in bytes
  30467. */
  30468. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  30469. /**
  30470. * Update a specific vertex buffer
  30471. * This function will create a new buffer if the current one is not updatable
  30472. * @param kind defines the data kind (Position, normal, etc...)
  30473. * @param data defines the data to use
  30474. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  30475. */
  30476. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  30477. private _updateBoundingInfo;
  30478. /** @hidden */
  30479. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  30480. /**
  30481. * Gets total number of vertices
  30482. * @returns the total number of vertices
  30483. */
  30484. getTotalVertices(): number;
  30485. /**
  30486. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  30487. * @param kind defines the data kind (Position, normal, etc...)
  30488. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30489. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30490. * @returns a float array containing vertex data
  30491. */
  30492. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  30493. /**
  30494. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  30495. * @param kind defines the data kind (Position, normal, etc...)
  30496. * @returns true if the vertex buffer with the specified kind is updatable
  30497. */
  30498. isVertexBufferUpdatable(kind: string): boolean;
  30499. /**
  30500. * Gets a specific vertex buffer
  30501. * @param kind defines the data kind (Position, normal, etc...)
  30502. * @returns a VertexBuffer
  30503. */
  30504. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  30505. /**
  30506. * Returns all vertex buffers
  30507. * @return an object holding all vertex buffers indexed by kind
  30508. */
  30509. getVertexBuffers(): Nullable<{
  30510. [key: string]: VertexBuffer;
  30511. }>;
  30512. /**
  30513. * Gets a boolean indicating if specific vertex buffer is present
  30514. * @param kind defines the data kind (Position, normal, etc...)
  30515. * @returns true if data is present
  30516. */
  30517. isVerticesDataPresent(kind: string): boolean;
  30518. /**
  30519. * Gets a list of all attached data kinds (Position, normal, etc...)
  30520. * @returns a list of string containing all kinds
  30521. */
  30522. getVerticesDataKinds(): string[];
  30523. /**
  30524. * Update index buffer
  30525. * @param indices defines the indices to store in the index buffer
  30526. * @param offset defines the offset in the target buffer where to store the data
  30527. * @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)
  30528. */
  30529. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  30530. /**
  30531. * Creates a new index buffer
  30532. * @param indices defines the indices to store in the index buffer
  30533. * @param totalVertices defines the total number of vertices (could be null)
  30534. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  30535. */
  30536. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  30537. /**
  30538. * Return the total number of indices
  30539. * @returns the total number of indices
  30540. */
  30541. getTotalIndices(): number;
  30542. /**
  30543. * Gets the index buffer array
  30544. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30545. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30546. * @returns the index buffer array
  30547. */
  30548. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  30549. /**
  30550. * Gets the index buffer
  30551. * @return the index buffer
  30552. */
  30553. getIndexBuffer(): Nullable<DataBuffer>;
  30554. /** @hidden */
  30555. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  30556. /**
  30557. * Release the associated resources for a specific mesh
  30558. * @param mesh defines the source mesh
  30559. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  30560. */
  30561. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  30562. /**
  30563. * Apply current geometry to a given mesh
  30564. * @param mesh defines the mesh to apply geometry to
  30565. */
  30566. applyToMesh(mesh: Mesh): void;
  30567. private _updateExtend;
  30568. private _applyToMesh;
  30569. private notifyUpdate;
  30570. /**
  30571. * Load the geometry if it was flagged as delay loaded
  30572. * @param scene defines the hosting scene
  30573. * @param onLoaded defines a callback called when the geometry is loaded
  30574. */
  30575. load(scene: Scene, onLoaded?: () => void): void;
  30576. private _queueLoad;
  30577. /**
  30578. * Invert the geometry to move from a right handed system to a left handed one.
  30579. */
  30580. toLeftHanded(): void;
  30581. /** @hidden */
  30582. _resetPointsArrayCache(): void;
  30583. /** @hidden */
  30584. _generatePointsArray(): boolean;
  30585. /**
  30586. * Gets a value indicating if the geometry is disposed
  30587. * @returns true if the geometry was disposed
  30588. */
  30589. isDisposed(): boolean;
  30590. private _disposeVertexArrayObjects;
  30591. /**
  30592. * Free all associated resources
  30593. */
  30594. dispose(): void;
  30595. /**
  30596. * Clone the current geometry into a new geometry
  30597. * @param id defines the unique ID of the new geometry
  30598. * @returns a new geometry object
  30599. */
  30600. copy(id: string): Geometry;
  30601. /**
  30602. * Serialize the current geometry info (and not the vertices data) into a JSON object
  30603. * @return a JSON representation of the current geometry data (without the vertices data)
  30604. */
  30605. serialize(): any;
  30606. private toNumberArray;
  30607. /**
  30608. * Serialize all vertices data into a JSON oject
  30609. * @returns a JSON representation of the current geometry data
  30610. */
  30611. serializeVerticeData(): any;
  30612. /**
  30613. * Extracts a clone of a mesh geometry
  30614. * @param mesh defines the source mesh
  30615. * @param id defines the unique ID of the new geometry object
  30616. * @returns the new geometry object
  30617. */
  30618. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  30619. /**
  30620. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  30621. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30622. * Be aware Math.random() could cause collisions, but:
  30623. * "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"
  30624. * @returns a string containing a new GUID
  30625. */
  30626. static RandomId(): string;
  30627. /** @hidden */
  30628. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  30629. private static _CleanMatricesWeights;
  30630. /**
  30631. * Create a new geometry from persisted data (Using .babylon file format)
  30632. * @param parsedVertexData defines the persisted data
  30633. * @param scene defines the hosting scene
  30634. * @param rootUrl defines the root url to use to load assets (like delayed data)
  30635. * @returns the new geometry object
  30636. */
  30637. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  30638. }
  30639. }
  30640. declare module BABYLON {
  30641. /**
  30642. * Defines a target to use with MorphTargetManager
  30643. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30644. */
  30645. export class MorphTarget implements IAnimatable {
  30646. /** defines the name of the target */
  30647. name: string;
  30648. /**
  30649. * Gets or sets the list of animations
  30650. */
  30651. animations: Animation[];
  30652. private _scene;
  30653. private _positions;
  30654. private _normals;
  30655. private _tangents;
  30656. private _uvs;
  30657. private _influence;
  30658. private _uniqueId;
  30659. /**
  30660. * Observable raised when the influence changes
  30661. */
  30662. onInfluenceChanged: Observable<boolean>;
  30663. /** @hidden */
  30664. _onDataLayoutChanged: Observable<void>;
  30665. /**
  30666. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  30667. */
  30668. get influence(): number;
  30669. set influence(influence: number);
  30670. /**
  30671. * Gets or sets the id of the morph Target
  30672. */
  30673. id: string;
  30674. private _animationPropertiesOverride;
  30675. /**
  30676. * Gets or sets the animation properties override
  30677. */
  30678. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  30679. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  30680. /**
  30681. * Creates a new MorphTarget
  30682. * @param name defines the name of the target
  30683. * @param influence defines the influence to use
  30684. * @param scene defines the scene the morphtarget belongs to
  30685. */
  30686. constructor(
  30687. /** defines the name of the target */
  30688. name: string, influence?: number, scene?: Nullable<Scene>);
  30689. /**
  30690. * Gets the unique ID of this manager
  30691. */
  30692. get uniqueId(): number;
  30693. /**
  30694. * Gets a boolean defining if the target contains position data
  30695. */
  30696. get hasPositions(): boolean;
  30697. /**
  30698. * Gets a boolean defining if the target contains normal data
  30699. */
  30700. get hasNormals(): boolean;
  30701. /**
  30702. * Gets a boolean defining if the target contains tangent data
  30703. */
  30704. get hasTangents(): boolean;
  30705. /**
  30706. * Gets a boolean defining if the target contains texture coordinates data
  30707. */
  30708. get hasUVs(): boolean;
  30709. /**
  30710. * Affects position data to this target
  30711. * @param data defines the position data to use
  30712. */
  30713. setPositions(data: Nullable<FloatArray>): void;
  30714. /**
  30715. * Gets the position data stored in this target
  30716. * @returns a FloatArray containing the position data (or null if not present)
  30717. */
  30718. getPositions(): Nullable<FloatArray>;
  30719. /**
  30720. * Affects normal data to this target
  30721. * @param data defines the normal data to use
  30722. */
  30723. setNormals(data: Nullable<FloatArray>): void;
  30724. /**
  30725. * Gets the normal data stored in this target
  30726. * @returns a FloatArray containing the normal data (or null if not present)
  30727. */
  30728. getNormals(): Nullable<FloatArray>;
  30729. /**
  30730. * Affects tangent data to this target
  30731. * @param data defines the tangent data to use
  30732. */
  30733. setTangents(data: Nullable<FloatArray>): void;
  30734. /**
  30735. * Gets the tangent data stored in this target
  30736. * @returns a FloatArray containing the tangent data (or null if not present)
  30737. */
  30738. getTangents(): Nullable<FloatArray>;
  30739. /**
  30740. * Affects texture coordinates data to this target
  30741. * @param data defines the texture coordinates data to use
  30742. */
  30743. setUVs(data: Nullable<FloatArray>): void;
  30744. /**
  30745. * Gets the texture coordinates data stored in this target
  30746. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  30747. */
  30748. getUVs(): Nullable<FloatArray>;
  30749. /**
  30750. * Clone the current target
  30751. * @returns a new MorphTarget
  30752. */
  30753. clone(): MorphTarget;
  30754. /**
  30755. * Serializes the current target into a Serialization object
  30756. * @returns the serialized object
  30757. */
  30758. serialize(): any;
  30759. /**
  30760. * Returns the string "MorphTarget"
  30761. * @returns "MorphTarget"
  30762. */
  30763. getClassName(): string;
  30764. /**
  30765. * Creates a new target from serialized data
  30766. * @param serializationObject defines the serialized data to use
  30767. * @returns a new MorphTarget
  30768. */
  30769. static Parse(serializationObject: any): MorphTarget;
  30770. /**
  30771. * Creates a MorphTarget from mesh data
  30772. * @param mesh defines the source mesh
  30773. * @param name defines the name to use for the new target
  30774. * @param influence defines the influence to attach to the target
  30775. * @returns a new MorphTarget
  30776. */
  30777. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  30778. }
  30779. }
  30780. declare module BABYLON {
  30781. /**
  30782. * This class is used to deform meshes using morphing between different targets
  30783. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30784. */
  30785. export class MorphTargetManager {
  30786. private _targets;
  30787. private _targetInfluenceChangedObservers;
  30788. private _targetDataLayoutChangedObservers;
  30789. private _activeTargets;
  30790. private _scene;
  30791. private _influences;
  30792. private _supportsNormals;
  30793. private _supportsTangents;
  30794. private _supportsUVs;
  30795. private _vertexCount;
  30796. private _uniqueId;
  30797. private _tempInfluences;
  30798. /**
  30799. * Gets or sets a boolean indicating if normals must be morphed
  30800. */
  30801. enableNormalMorphing: boolean;
  30802. /**
  30803. * Gets or sets a boolean indicating if tangents must be morphed
  30804. */
  30805. enableTangentMorphing: boolean;
  30806. /**
  30807. * Gets or sets a boolean indicating if UV must be morphed
  30808. */
  30809. enableUVMorphing: boolean;
  30810. /**
  30811. * Creates a new MorphTargetManager
  30812. * @param scene defines the current scene
  30813. */
  30814. constructor(scene?: Nullable<Scene>);
  30815. /**
  30816. * Gets the unique ID of this manager
  30817. */
  30818. get uniqueId(): number;
  30819. /**
  30820. * Gets the number of vertices handled by this manager
  30821. */
  30822. get vertexCount(): number;
  30823. /**
  30824. * Gets a boolean indicating if this manager supports morphing of normals
  30825. */
  30826. get supportsNormals(): boolean;
  30827. /**
  30828. * Gets a boolean indicating if this manager supports morphing of tangents
  30829. */
  30830. get supportsTangents(): boolean;
  30831. /**
  30832. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  30833. */
  30834. get supportsUVs(): boolean;
  30835. /**
  30836. * Gets the number of targets stored in this manager
  30837. */
  30838. get numTargets(): number;
  30839. /**
  30840. * Gets the number of influencers (ie. the number of targets with influences > 0)
  30841. */
  30842. get numInfluencers(): number;
  30843. /**
  30844. * Gets the list of influences (one per target)
  30845. */
  30846. get influences(): Float32Array;
  30847. /**
  30848. * Gets the active target at specified index. An active target is a target with an influence > 0
  30849. * @param index defines the index to check
  30850. * @returns the requested target
  30851. */
  30852. getActiveTarget(index: number): MorphTarget;
  30853. /**
  30854. * Gets the target at specified index
  30855. * @param index defines the index to check
  30856. * @returns the requested target
  30857. */
  30858. getTarget(index: number): MorphTarget;
  30859. /**
  30860. * Add a new target to this manager
  30861. * @param target defines the target to add
  30862. */
  30863. addTarget(target: MorphTarget): void;
  30864. /**
  30865. * Removes a target from the manager
  30866. * @param target defines the target to remove
  30867. */
  30868. removeTarget(target: MorphTarget): void;
  30869. /**
  30870. * Clone the current manager
  30871. * @returns a new MorphTargetManager
  30872. */
  30873. clone(): MorphTargetManager;
  30874. /**
  30875. * Serializes the current manager into a Serialization object
  30876. * @returns the serialized object
  30877. */
  30878. serialize(): any;
  30879. private _syncActiveTargets;
  30880. /**
  30881. * Syncrhonize the targets with all the meshes using this morph target manager
  30882. */
  30883. synchronize(): void;
  30884. /**
  30885. * Creates a new MorphTargetManager from serialized data
  30886. * @param serializationObject defines the serialized data
  30887. * @param scene defines the hosting scene
  30888. * @returns the new MorphTargetManager
  30889. */
  30890. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  30891. }
  30892. }
  30893. declare module BABYLON {
  30894. /**
  30895. * Class used to represent a specific level of detail of a mesh
  30896. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  30897. */
  30898. export class MeshLODLevel {
  30899. /** Defines the distance where this level should start being displayed */
  30900. distance: number;
  30901. /** Defines the mesh to use to render this level */
  30902. mesh: Nullable<Mesh>;
  30903. /**
  30904. * Creates a new LOD level
  30905. * @param distance defines the distance where this level should star being displayed
  30906. * @param mesh defines the mesh to use to render this level
  30907. */
  30908. constructor(
  30909. /** Defines the distance where this level should start being displayed */
  30910. distance: number,
  30911. /** Defines the mesh to use to render this level */
  30912. mesh: Nullable<Mesh>);
  30913. }
  30914. }
  30915. declare module BABYLON {
  30916. /**
  30917. * Helper class used to generate a canvas to manipulate images
  30918. */
  30919. export class CanvasGenerator {
  30920. /**
  30921. * Create a new canvas (or offscreen canvas depending on the context)
  30922. * @param width defines the expected width
  30923. * @param height defines the expected height
  30924. * @return a new canvas or offscreen canvas
  30925. */
  30926. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  30927. }
  30928. }
  30929. declare module BABYLON {
  30930. /**
  30931. * Mesh representing the gorund
  30932. */
  30933. export class GroundMesh extends Mesh {
  30934. /** If octree should be generated */
  30935. generateOctree: boolean;
  30936. private _heightQuads;
  30937. /** @hidden */
  30938. _subdivisionsX: number;
  30939. /** @hidden */
  30940. _subdivisionsY: number;
  30941. /** @hidden */
  30942. _width: number;
  30943. /** @hidden */
  30944. _height: number;
  30945. /** @hidden */
  30946. _minX: number;
  30947. /** @hidden */
  30948. _maxX: number;
  30949. /** @hidden */
  30950. _minZ: number;
  30951. /** @hidden */
  30952. _maxZ: number;
  30953. constructor(name: string, scene: Scene);
  30954. /**
  30955. * "GroundMesh"
  30956. * @returns "GroundMesh"
  30957. */
  30958. getClassName(): string;
  30959. /**
  30960. * The minimum of x and y subdivisions
  30961. */
  30962. get subdivisions(): number;
  30963. /**
  30964. * X subdivisions
  30965. */
  30966. get subdivisionsX(): number;
  30967. /**
  30968. * Y subdivisions
  30969. */
  30970. get subdivisionsY(): number;
  30971. /**
  30972. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  30973. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  30974. * @param chunksCount the number of subdivisions for x and y
  30975. * @param octreeBlocksSize (Default: 32)
  30976. */
  30977. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  30978. /**
  30979. * Returns a height (y) value in the Worl system :
  30980. * the ground altitude at the coordinates (x, z) expressed in the World system.
  30981. * @param x x coordinate
  30982. * @param z z coordinate
  30983. * @returns the ground y position if (x, z) are outside the ground surface.
  30984. */
  30985. getHeightAtCoordinates(x: number, z: number): number;
  30986. /**
  30987. * Returns a normalized vector (Vector3) orthogonal to the ground
  30988. * at the ground coordinates (x, z) expressed in the World system.
  30989. * @param x x coordinate
  30990. * @param z z coordinate
  30991. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  30992. */
  30993. getNormalAtCoordinates(x: number, z: number): Vector3;
  30994. /**
  30995. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  30996. * at the ground coordinates (x, z) expressed in the World system.
  30997. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  30998. * @param x x coordinate
  30999. * @param z z coordinate
  31000. * @param ref vector to store the result
  31001. * @returns the GroundMesh.
  31002. */
  31003. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  31004. /**
  31005. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  31006. * if the ground has been updated.
  31007. * This can be used in the render loop.
  31008. * @returns the GroundMesh.
  31009. */
  31010. updateCoordinateHeights(): GroundMesh;
  31011. private _getFacetAt;
  31012. private _initHeightQuads;
  31013. private _computeHeightQuads;
  31014. /**
  31015. * Serializes this ground mesh
  31016. * @param serializationObject object to write serialization to
  31017. */
  31018. serialize(serializationObject: any): void;
  31019. /**
  31020. * Parses a serialized ground mesh
  31021. * @param parsedMesh the serialized mesh
  31022. * @param scene the scene to create the ground mesh in
  31023. * @returns the created ground mesh
  31024. */
  31025. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  31026. }
  31027. }
  31028. declare module BABYLON {
  31029. /**
  31030. * Interface for Physics-Joint data
  31031. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31032. */
  31033. export interface PhysicsJointData {
  31034. /**
  31035. * The main pivot of the joint
  31036. */
  31037. mainPivot?: Vector3;
  31038. /**
  31039. * The connected pivot of the joint
  31040. */
  31041. connectedPivot?: Vector3;
  31042. /**
  31043. * The main axis of the joint
  31044. */
  31045. mainAxis?: Vector3;
  31046. /**
  31047. * The connected axis of the joint
  31048. */
  31049. connectedAxis?: Vector3;
  31050. /**
  31051. * The collision of the joint
  31052. */
  31053. collision?: boolean;
  31054. /**
  31055. * Native Oimo/Cannon/Energy data
  31056. */
  31057. nativeParams?: any;
  31058. }
  31059. /**
  31060. * This is a holder class for the physics joint created by the physics plugin
  31061. * It holds a set of functions to control the underlying joint
  31062. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31063. */
  31064. export class PhysicsJoint {
  31065. /**
  31066. * The type of the physics joint
  31067. */
  31068. type: number;
  31069. /**
  31070. * The data for the physics joint
  31071. */
  31072. jointData: PhysicsJointData;
  31073. private _physicsJoint;
  31074. protected _physicsPlugin: IPhysicsEnginePlugin;
  31075. /**
  31076. * Initializes the physics joint
  31077. * @param type The type of the physics joint
  31078. * @param jointData The data for the physics joint
  31079. */
  31080. constructor(
  31081. /**
  31082. * The type of the physics joint
  31083. */
  31084. type: number,
  31085. /**
  31086. * The data for the physics joint
  31087. */
  31088. jointData: PhysicsJointData);
  31089. /**
  31090. * Gets the physics joint
  31091. */
  31092. get physicsJoint(): any;
  31093. /**
  31094. * Sets the physics joint
  31095. */
  31096. set physicsJoint(newJoint: any);
  31097. /**
  31098. * Sets the physics plugin
  31099. */
  31100. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  31101. /**
  31102. * Execute a function that is physics-plugin specific.
  31103. * @param {Function} func the function that will be executed.
  31104. * It accepts two parameters: the physics world and the physics joint
  31105. */
  31106. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  31107. /**
  31108. * Distance-Joint type
  31109. */
  31110. static DistanceJoint: number;
  31111. /**
  31112. * Hinge-Joint type
  31113. */
  31114. static HingeJoint: number;
  31115. /**
  31116. * Ball-and-Socket joint type
  31117. */
  31118. static BallAndSocketJoint: number;
  31119. /**
  31120. * Wheel-Joint type
  31121. */
  31122. static WheelJoint: number;
  31123. /**
  31124. * Slider-Joint type
  31125. */
  31126. static SliderJoint: number;
  31127. /**
  31128. * Prismatic-Joint type
  31129. */
  31130. static PrismaticJoint: number;
  31131. /**
  31132. * Universal-Joint type
  31133. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  31134. */
  31135. static UniversalJoint: number;
  31136. /**
  31137. * Hinge-Joint 2 type
  31138. */
  31139. static Hinge2Joint: number;
  31140. /**
  31141. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  31142. */
  31143. static PointToPointJoint: number;
  31144. /**
  31145. * Spring-Joint type
  31146. */
  31147. static SpringJoint: number;
  31148. /**
  31149. * Lock-Joint type
  31150. */
  31151. static LockJoint: number;
  31152. }
  31153. /**
  31154. * A class representing a physics distance joint
  31155. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31156. */
  31157. export class DistanceJoint extends PhysicsJoint {
  31158. /**
  31159. *
  31160. * @param jointData The data for the Distance-Joint
  31161. */
  31162. constructor(jointData: DistanceJointData);
  31163. /**
  31164. * Update the predefined distance.
  31165. * @param maxDistance The maximum preferred distance
  31166. * @param minDistance The minimum preferred distance
  31167. */
  31168. updateDistance(maxDistance: number, minDistance?: number): void;
  31169. }
  31170. /**
  31171. * Represents a Motor-Enabled Joint
  31172. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31173. */
  31174. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  31175. /**
  31176. * Initializes the Motor-Enabled Joint
  31177. * @param type The type of the joint
  31178. * @param jointData The physica joint data for the joint
  31179. */
  31180. constructor(type: number, jointData: PhysicsJointData);
  31181. /**
  31182. * Set the motor values.
  31183. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31184. * @param force the force to apply
  31185. * @param maxForce max force for this motor.
  31186. */
  31187. setMotor(force?: number, maxForce?: number): void;
  31188. /**
  31189. * Set the motor's limits.
  31190. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31191. * @param upperLimit The upper limit of the motor
  31192. * @param lowerLimit The lower limit of the motor
  31193. */
  31194. setLimit(upperLimit: number, lowerLimit?: number): void;
  31195. }
  31196. /**
  31197. * This class represents a single physics Hinge-Joint
  31198. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31199. */
  31200. export class HingeJoint extends MotorEnabledJoint {
  31201. /**
  31202. * Initializes the Hinge-Joint
  31203. * @param jointData The joint data for the Hinge-Joint
  31204. */
  31205. constructor(jointData: PhysicsJointData);
  31206. /**
  31207. * Set the motor values.
  31208. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31209. * @param {number} force the force to apply
  31210. * @param {number} maxForce max force for this motor.
  31211. */
  31212. setMotor(force?: number, maxForce?: number): void;
  31213. /**
  31214. * Set the motor's limits.
  31215. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31216. * @param upperLimit The upper limit of the motor
  31217. * @param lowerLimit The lower limit of the motor
  31218. */
  31219. setLimit(upperLimit: number, lowerLimit?: number): void;
  31220. }
  31221. /**
  31222. * This class represents a dual hinge physics joint (same as wheel joint)
  31223. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31224. */
  31225. export class Hinge2Joint extends MotorEnabledJoint {
  31226. /**
  31227. * Initializes the Hinge2-Joint
  31228. * @param jointData The joint data for the Hinge2-Joint
  31229. */
  31230. constructor(jointData: PhysicsJointData);
  31231. /**
  31232. * Set the motor values.
  31233. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31234. * @param {number} targetSpeed the speed the motor is to reach
  31235. * @param {number} maxForce max force for this motor.
  31236. * @param {motorIndex} the motor's index, 0 or 1.
  31237. */
  31238. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  31239. /**
  31240. * Set the motor limits.
  31241. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31242. * @param {number} upperLimit the upper limit
  31243. * @param {number} lowerLimit lower limit
  31244. * @param {motorIndex} the motor's index, 0 or 1.
  31245. */
  31246. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31247. }
  31248. /**
  31249. * Interface for a motor enabled joint
  31250. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31251. */
  31252. export interface IMotorEnabledJoint {
  31253. /**
  31254. * Physics joint
  31255. */
  31256. physicsJoint: any;
  31257. /**
  31258. * Sets the motor of the motor-enabled joint
  31259. * @param force The force of the motor
  31260. * @param maxForce The maximum force of the motor
  31261. * @param motorIndex The index of the motor
  31262. */
  31263. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  31264. /**
  31265. * Sets the limit of the motor
  31266. * @param upperLimit The upper limit of the motor
  31267. * @param lowerLimit The lower limit of the motor
  31268. * @param motorIndex The index of the motor
  31269. */
  31270. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31271. }
  31272. /**
  31273. * Joint data for a Distance-Joint
  31274. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31275. */
  31276. export interface DistanceJointData extends PhysicsJointData {
  31277. /**
  31278. * Max distance the 2 joint objects can be apart
  31279. */
  31280. maxDistance: number;
  31281. }
  31282. /**
  31283. * Joint data from a spring joint
  31284. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31285. */
  31286. export interface SpringJointData extends PhysicsJointData {
  31287. /**
  31288. * Length of the spring
  31289. */
  31290. length: number;
  31291. /**
  31292. * Stiffness of the spring
  31293. */
  31294. stiffness: number;
  31295. /**
  31296. * Damping of the spring
  31297. */
  31298. damping: number;
  31299. /** this callback will be called when applying the force to the impostors. */
  31300. forceApplicationCallback: () => void;
  31301. }
  31302. }
  31303. declare module BABYLON {
  31304. /**
  31305. * Holds the data for the raycast result
  31306. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31307. */
  31308. export class PhysicsRaycastResult {
  31309. private _hasHit;
  31310. private _hitDistance;
  31311. private _hitNormalWorld;
  31312. private _hitPointWorld;
  31313. private _rayFromWorld;
  31314. private _rayToWorld;
  31315. /**
  31316. * Gets if there was a hit
  31317. */
  31318. get hasHit(): boolean;
  31319. /**
  31320. * Gets the distance from the hit
  31321. */
  31322. get hitDistance(): number;
  31323. /**
  31324. * Gets the hit normal/direction in the world
  31325. */
  31326. get hitNormalWorld(): Vector3;
  31327. /**
  31328. * Gets the hit point in the world
  31329. */
  31330. get hitPointWorld(): Vector3;
  31331. /**
  31332. * Gets the ray "start point" of the ray in the world
  31333. */
  31334. get rayFromWorld(): Vector3;
  31335. /**
  31336. * Gets the ray "end point" of the ray in the world
  31337. */
  31338. get rayToWorld(): Vector3;
  31339. /**
  31340. * Sets the hit data (normal & point in world space)
  31341. * @param hitNormalWorld defines the normal in world space
  31342. * @param hitPointWorld defines the point in world space
  31343. */
  31344. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  31345. /**
  31346. * Sets the distance from the start point to the hit point
  31347. * @param distance
  31348. */
  31349. setHitDistance(distance: number): void;
  31350. /**
  31351. * Calculates the distance manually
  31352. */
  31353. calculateHitDistance(): void;
  31354. /**
  31355. * Resets all the values to default
  31356. * @param from The from point on world space
  31357. * @param to The to point on world space
  31358. */
  31359. reset(from?: Vector3, to?: Vector3): void;
  31360. }
  31361. /**
  31362. * Interface for the size containing width and height
  31363. */
  31364. interface IXYZ {
  31365. /**
  31366. * X
  31367. */
  31368. x: number;
  31369. /**
  31370. * Y
  31371. */
  31372. y: number;
  31373. /**
  31374. * Z
  31375. */
  31376. z: number;
  31377. }
  31378. }
  31379. declare module BABYLON {
  31380. /**
  31381. * Interface used to describe a physics joint
  31382. */
  31383. export interface PhysicsImpostorJoint {
  31384. /** Defines the main impostor to which the joint is linked */
  31385. mainImpostor: PhysicsImpostor;
  31386. /** Defines the impostor that is connected to the main impostor using this joint */
  31387. connectedImpostor: PhysicsImpostor;
  31388. /** Defines the joint itself */
  31389. joint: PhysicsJoint;
  31390. }
  31391. /** @hidden */
  31392. export interface IPhysicsEnginePlugin {
  31393. world: any;
  31394. name: string;
  31395. setGravity(gravity: Vector3): void;
  31396. setTimeStep(timeStep: number): void;
  31397. getTimeStep(): number;
  31398. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  31399. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31400. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31401. generatePhysicsBody(impostor: PhysicsImpostor): void;
  31402. removePhysicsBody(impostor: PhysicsImpostor): void;
  31403. generateJoint(joint: PhysicsImpostorJoint): void;
  31404. removeJoint(joint: PhysicsImpostorJoint): void;
  31405. isSupported(): boolean;
  31406. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  31407. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  31408. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31409. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31410. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31411. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31412. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  31413. getBodyMass(impostor: PhysicsImpostor): number;
  31414. getBodyFriction(impostor: PhysicsImpostor): number;
  31415. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  31416. getBodyRestitution(impostor: PhysicsImpostor): number;
  31417. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  31418. getBodyPressure?(impostor: PhysicsImpostor): number;
  31419. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  31420. getBodyStiffness?(impostor: PhysicsImpostor): number;
  31421. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  31422. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  31423. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  31424. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  31425. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  31426. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31427. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31428. sleepBody(impostor: PhysicsImpostor): void;
  31429. wakeUpBody(impostor: PhysicsImpostor): void;
  31430. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  31431. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  31432. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  31433. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31434. getRadius(impostor: PhysicsImpostor): number;
  31435. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  31436. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  31437. dispose(): void;
  31438. }
  31439. /**
  31440. * Interface used to define a physics engine
  31441. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31442. */
  31443. export interface IPhysicsEngine {
  31444. /**
  31445. * Gets the gravity vector used by the simulation
  31446. */
  31447. gravity: Vector3;
  31448. /**
  31449. * Sets the gravity vector used by the simulation
  31450. * @param gravity defines the gravity vector to use
  31451. */
  31452. setGravity(gravity: Vector3): void;
  31453. /**
  31454. * Set the time step of the physics engine.
  31455. * Default is 1/60.
  31456. * To slow it down, enter 1/600 for example.
  31457. * To speed it up, 1/30
  31458. * @param newTimeStep the new timestep to apply to this world.
  31459. */
  31460. setTimeStep(newTimeStep: number): void;
  31461. /**
  31462. * Get the time step of the physics engine.
  31463. * @returns the current time step
  31464. */
  31465. getTimeStep(): number;
  31466. /**
  31467. * Set the sub time step of the physics engine.
  31468. * Default is 0 meaning there is no sub steps
  31469. * To increase physics resolution precision, set a small value (like 1 ms)
  31470. * @param subTimeStep defines the new sub timestep used for physics resolution.
  31471. */
  31472. setSubTimeStep(subTimeStep: number): void;
  31473. /**
  31474. * Get the sub time step of the physics engine.
  31475. * @returns the current sub time step
  31476. */
  31477. getSubTimeStep(): number;
  31478. /**
  31479. * Release all resources
  31480. */
  31481. dispose(): void;
  31482. /**
  31483. * Gets the name of the current physics plugin
  31484. * @returns the name of the plugin
  31485. */
  31486. getPhysicsPluginName(): string;
  31487. /**
  31488. * Adding a new impostor for the impostor tracking.
  31489. * This will be done by the impostor itself.
  31490. * @param impostor the impostor to add
  31491. */
  31492. addImpostor(impostor: PhysicsImpostor): void;
  31493. /**
  31494. * Remove an impostor from the engine.
  31495. * This impostor and its mesh will not longer be updated by the physics engine.
  31496. * @param impostor the impostor to remove
  31497. */
  31498. removeImpostor(impostor: PhysicsImpostor): void;
  31499. /**
  31500. * Add a joint to the physics engine
  31501. * @param mainImpostor defines the main impostor to which the joint is added.
  31502. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  31503. * @param joint defines the joint that will connect both impostors.
  31504. */
  31505. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31506. /**
  31507. * Removes a joint from the simulation
  31508. * @param mainImpostor defines the impostor used with the joint
  31509. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  31510. * @param joint defines the joint to remove
  31511. */
  31512. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31513. /**
  31514. * Gets the current plugin used to run the simulation
  31515. * @returns current plugin
  31516. */
  31517. getPhysicsPlugin(): IPhysicsEnginePlugin;
  31518. /**
  31519. * Gets the list of physic impostors
  31520. * @returns an array of PhysicsImpostor
  31521. */
  31522. getImpostors(): Array<PhysicsImpostor>;
  31523. /**
  31524. * Gets the impostor for a physics enabled object
  31525. * @param object defines the object impersonated by the impostor
  31526. * @returns the PhysicsImpostor or null if not found
  31527. */
  31528. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  31529. /**
  31530. * Gets the impostor for a physics body object
  31531. * @param body defines physics body used by the impostor
  31532. * @returns the PhysicsImpostor or null if not found
  31533. */
  31534. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  31535. /**
  31536. * Does a raycast in the physics world
  31537. * @param from when should the ray start?
  31538. * @param to when should the ray end?
  31539. * @returns PhysicsRaycastResult
  31540. */
  31541. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  31542. /**
  31543. * Called by the scene. No need to call it.
  31544. * @param delta defines the timespam between frames
  31545. */
  31546. _step(delta: number): void;
  31547. }
  31548. }
  31549. declare module BABYLON {
  31550. /**
  31551. * The interface for the physics imposter parameters
  31552. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31553. */
  31554. export interface PhysicsImpostorParameters {
  31555. /**
  31556. * The mass of the physics imposter
  31557. */
  31558. mass: number;
  31559. /**
  31560. * The friction of the physics imposter
  31561. */
  31562. friction?: number;
  31563. /**
  31564. * The coefficient of restitution of the physics imposter
  31565. */
  31566. restitution?: number;
  31567. /**
  31568. * The native options of the physics imposter
  31569. */
  31570. nativeOptions?: any;
  31571. /**
  31572. * Specifies if the parent should be ignored
  31573. */
  31574. ignoreParent?: boolean;
  31575. /**
  31576. * Specifies if bi-directional transformations should be disabled
  31577. */
  31578. disableBidirectionalTransformation?: boolean;
  31579. /**
  31580. * The pressure inside the physics imposter, soft object only
  31581. */
  31582. pressure?: number;
  31583. /**
  31584. * The stiffness the physics imposter, soft object only
  31585. */
  31586. stiffness?: number;
  31587. /**
  31588. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  31589. */
  31590. velocityIterations?: number;
  31591. /**
  31592. * The number of iterations used in maintaining consistent vertex positions, soft object only
  31593. */
  31594. positionIterations?: number;
  31595. /**
  31596. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  31597. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  31598. * Add to fix multiple points
  31599. */
  31600. fixedPoints?: number;
  31601. /**
  31602. * The collision margin around a soft object
  31603. */
  31604. margin?: number;
  31605. /**
  31606. * The collision margin around a soft object
  31607. */
  31608. damping?: number;
  31609. /**
  31610. * The path for a rope based on an extrusion
  31611. */
  31612. path?: any;
  31613. /**
  31614. * The shape of an extrusion used for a rope based on an extrusion
  31615. */
  31616. shape?: any;
  31617. }
  31618. /**
  31619. * Interface for a physics-enabled object
  31620. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31621. */
  31622. export interface IPhysicsEnabledObject {
  31623. /**
  31624. * The position of the physics-enabled object
  31625. */
  31626. position: Vector3;
  31627. /**
  31628. * The rotation of the physics-enabled object
  31629. */
  31630. rotationQuaternion: Nullable<Quaternion>;
  31631. /**
  31632. * The scale of the physics-enabled object
  31633. */
  31634. scaling: Vector3;
  31635. /**
  31636. * The rotation of the physics-enabled object
  31637. */
  31638. rotation?: Vector3;
  31639. /**
  31640. * The parent of the physics-enabled object
  31641. */
  31642. parent?: any;
  31643. /**
  31644. * The bounding info of the physics-enabled object
  31645. * @returns The bounding info of the physics-enabled object
  31646. */
  31647. getBoundingInfo(): BoundingInfo;
  31648. /**
  31649. * Computes the world matrix
  31650. * @param force Specifies if the world matrix should be computed by force
  31651. * @returns A world matrix
  31652. */
  31653. computeWorldMatrix(force: boolean): Matrix;
  31654. /**
  31655. * Gets the world matrix
  31656. * @returns A world matrix
  31657. */
  31658. getWorldMatrix?(): Matrix;
  31659. /**
  31660. * Gets the child meshes
  31661. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  31662. * @returns An array of abstract meshes
  31663. */
  31664. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  31665. /**
  31666. * Gets the vertex data
  31667. * @param kind The type of vertex data
  31668. * @returns A nullable array of numbers, or a float32 array
  31669. */
  31670. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  31671. /**
  31672. * Gets the indices from the mesh
  31673. * @returns A nullable array of index arrays
  31674. */
  31675. getIndices?(): Nullable<IndicesArray>;
  31676. /**
  31677. * Gets the scene from the mesh
  31678. * @returns the indices array or null
  31679. */
  31680. getScene?(): Scene;
  31681. /**
  31682. * Gets the absolute position from the mesh
  31683. * @returns the absolute position
  31684. */
  31685. getAbsolutePosition(): Vector3;
  31686. /**
  31687. * Gets the absolute pivot point from the mesh
  31688. * @returns the absolute pivot point
  31689. */
  31690. getAbsolutePivotPoint(): Vector3;
  31691. /**
  31692. * Rotates the mesh
  31693. * @param axis The axis of rotation
  31694. * @param amount The amount of rotation
  31695. * @param space The space of the rotation
  31696. * @returns The rotation transform node
  31697. */
  31698. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  31699. /**
  31700. * Translates the mesh
  31701. * @param axis The axis of translation
  31702. * @param distance The distance of translation
  31703. * @param space The space of the translation
  31704. * @returns The transform node
  31705. */
  31706. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  31707. /**
  31708. * Sets the absolute position of the mesh
  31709. * @param absolutePosition The absolute position of the mesh
  31710. * @returns The transform node
  31711. */
  31712. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  31713. /**
  31714. * Gets the class name of the mesh
  31715. * @returns The class name
  31716. */
  31717. getClassName(): string;
  31718. }
  31719. /**
  31720. * Represents a physics imposter
  31721. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31722. */
  31723. export class PhysicsImpostor {
  31724. /**
  31725. * The physics-enabled object used as the physics imposter
  31726. */
  31727. object: IPhysicsEnabledObject;
  31728. /**
  31729. * The type of the physics imposter
  31730. */
  31731. type: number;
  31732. private _options;
  31733. private _scene?;
  31734. /**
  31735. * The default object size of the imposter
  31736. */
  31737. static DEFAULT_OBJECT_SIZE: Vector3;
  31738. /**
  31739. * The identity quaternion of the imposter
  31740. */
  31741. static IDENTITY_QUATERNION: Quaternion;
  31742. /** @hidden */
  31743. _pluginData: any;
  31744. private _physicsEngine;
  31745. private _physicsBody;
  31746. private _bodyUpdateRequired;
  31747. private _onBeforePhysicsStepCallbacks;
  31748. private _onAfterPhysicsStepCallbacks;
  31749. /** @hidden */
  31750. _onPhysicsCollideCallbacks: Array<{
  31751. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  31752. otherImpostors: Array<PhysicsImpostor>;
  31753. }>;
  31754. private _deltaPosition;
  31755. private _deltaRotation;
  31756. private _deltaRotationConjugated;
  31757. /** @hidden */
  31758. _isFromLine: boolean;
  31759. private _parent;
  31760. private _isDisposed;
  31761. private static _tmpVecs;
  31762. private static _tmpQuat;
  31763. /**
  31764. * Specifies if the physics imposter is disposed
  31765. */
  31766. get isDisposed(): boolean;
  31767. /**
  31768. * Gets the mass of the physics imposter
  31769. */
  31770. get mass(): number;
  31771. set mass(value: number);
  31772. /**
  31773. * Gets the coefficient of friction
  31774. */
  31775. get friction(): number;
  31776. /**
  31777. * Sets the coefficient of friction
  31778. */
  31779. set friction(value: number);
  31780. /**
  31781. * Gets the coefficient of restitution
  31782. */
  31783. get restitution(): number;
  31784. /**
  31785. * Sets the coefficient of restitution
  31786. */
  31787. set restitution(value: number);
  31788. /**
  31789. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  31790. */
  31791. get pressure(): number;
  31792. /**
  31793. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  31794. */
  31795. set pressure(value: number);
  31796. /**
  31797. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  31798. */
  31799. get stiffness(): number;
  31800. /**
  31801. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  31802. */
  31803. set stiffness(value: number);
  31804. /**
  31805. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  31806. */
  31807. get velocityIterations(): number;
  31808. /**
  31809. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  31810. */
  31811. set velocityIterations(value: number);
  31812. /**
  31813. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  31814. */
  31815. get positionIterations(): number;
  31816. /**
  31817. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  31818. */
  31819. set positionIterations(value: number);
  31820. /**
  31821. * The unique id of the physics imposter
  31822. * set by the physics engine when adding this impostor to the array
  31823. */
  31824. uniqueId: number;
  31825. /**
  31826. * @hidden
  31827. */
  31828. soft: boolean;
  31829. /**
  31830. * @hidden
  31831. */
  31832. segments: number;
  31833. private _joints;
  31834. /**
  31835. * Initializes the physics imposter
  31836. * @param object The physics-enabled object used as the physics imposter
  31837. * @param type The type of the physics imposter
  31838. * @param _options The options for the physics imposter
  31839. * @param _scene The Babylon scene
  31840. */
  31841. constructor(
  31842. /**
  31843. * The physics-enabled object used as the physics imposter
  31844. */
  31845. object: IPhysicsEnabledObject,
  31846. /**
  31847. * The type of the physics imposter
  31848. */
  31849. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  31850. /**
  31851. * This function will completly initialize this impostor.
  31852. * It will create a new body - but only if this mesh has no parent.
  31853. * If it has, this impostor will not be used other than to define the impostor
  31854. * of the child mesh.
  31855. * @hidden
  31856. */
  31857. _init(): void;
  31858. private _getPhysicsParent;
  31859. /**
  31860. * Should a new body be generated.
  31861. * @returns boolean specifying if body initialization is required
  31862. */
  31863. isBodyInitRequired(): boolean;
  31864. /**
  31865. * Sets the updated scaling
  31866. * @param updated Specifies if the scaling is updated
  31867. */
  31868. setScalingUpdated(): void;
  31869. /**
  31870. * Force a regeneration of this or the parent's impostor's body.
  31871. * Use under cautious - This will remove all joints already implemented.
  31872. */
  31873. forceUpdate(): void;
  31874. /**
  31875. * Gets the body that holds this impostor. Either its own, or its parent.
  31876. */
  31877. get physicsBody(): any;
  31878. /**
  31879. * Get the parent of the physics imposter
  31880. * @returns Physics imposter or null
  31881. */
  31882. get parent(): Nullable<PhysicsImpostor>;
  31883. /**
  31884. * Sets the parent of the physics imposter
  31885. */
  31886. set parent(value: Nullable<PhysicsImpostor>);
  31887. /**
  31888. * Set the physics body. Used mainly by the physics engine/plugin
  31889. */
  31890. set physicsBody(physicsBody: any);
  31891. /**
  31892. * Resets the update flags
  31893. */
  31894. resetUpdateFlags(): void;
  31895. /**
  31896. * Gets the object extend size
  31897. * @returns the object extend size
  31898. */
  31899. getObjectExtendSize(): Vector3;
  31900. /**
  31901. * Gets the object center
  31902. * @returns The object center
  31903. */
  31904. getObjectCenter(): Vector3;
  31905. /**
  31906. * Get a specific parameter from the options parameters
  31907. * @param paramName The object parameter name
  31908. * @returns The object parameter
  31909. */
  31910. getParam(paramName: string): any;
  31911. /**
  31912. * Sets a specific parameter in the options given to the physics plugin
  31913. * @param paramName The parameter name
  31914. * @param value The value of the parameter
  31915. */
  31916. setParam(paramName: string, value: number): void;
  31917. /**
  31918. * Specifically change the body's mass option. Won't recreate the physics body object
  31919. * @param mass The mass of the physics imposter
  31920. */
  31921. setMass(mass: number): void;
  31922. /**
  31923. * Gets the linear velocity
  31924. * @returns linear velocity or null
  31925. */
  31926. getLinearVelocity(): Nullable<Vector3>;
  31927. /**
  31928. * Sets the linear velocity
  31929. * @param velocity linear velocity or null
  31930. */
  31931. setLinearVelocity(velocity: Nullable<Vector3>): void;
  31932. /**
  31933. * Gets the angular velocity
  31934. * @returns angular velocity or null
  31935. */
  31936. getAngularVelocity(): Nullable<Vector3>;
  31937. /**
  31938. * Sets the angular velocity
  31939. * @param velocity The velocity or null
  31940. */
  31941. setAngularVelocity(velocity: Nullable<Vector3>): void;
  31942. /**
  31943. * Execute a function with the physics plugin native code
  31944. * Provide a function the will have two variables - the world object and the physics body object
  31945. * @param func The function to execute with the physics plugin native code
  31946. */
  31947. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  31948. /**
  31949. * Register a function that will be executed before the physics world is stepping forward
  31950. * @param func The function to execute before the physics world is stepped forward
  31951. */
  31952. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31953. /**
  31954. * Unregister a function that will be executed before the physics world is stepping forward
  31955. * @param func The function to execute before the physics world is stepped forward
  31956. */
  31957. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31958. /**
  31959. * Register a function that will be executed after the physics step
  31960. * @param func The function to execute after physics step
  31961. */
  31962. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31963. /**
  31964. * Unregisters a function that will be executed after the physics step
  31965. * @param func The function to execute after physics step
  31966. */
  31967. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31968. /**
  31969. * register a function that will be executed when this impostor collides against a different body
  31970. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  31971. * @param func Callback that is executed on collision
  31972. */
  31973. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  31974. /**
  31975. * Unregisters the physics imposter on contact
  31976. * @param collideAgainst The physics object to collide against
  31977. * @param func Callback to execute on collision
  31978. */
  31979. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  31980. private _tmpQuat;
  31981. private _tmpQuat2;
  31982. /**
  31983. * Get the parent rotation
  31984. * @returns The parent rotation
  31985. */
  31986. getParentsRotation(): Quaternion;
  31987. /**
  31988. * this function is executed by the physics engine.
  31989. */
  31990. beforeStep: () => void;
  31991. /**
  31992. * this function is executed by the physics engine
  31993. */
  31994. afterStep: () => void;
  31995. /**
  31996. * Legacy collision detection event support
  31997. */
  31998. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  31999. /**
  32000. * event and body object due to cannon's event-based architecture.
  32001. */
  32002. onCollide: (e: {
  32003. body: any;
  32004. point: Nullable<Vector3>;
  32005. }) => void;
  32006. /**
  32007. * Apply a force
  32008. * @param force The force to apply
  32009. * @param contactPoint The contact point for the force
  32010. * @returns The physics imposter
  32011. */
  32012. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32013. /**
  32014. * Apply an impulse
  32015. * @param force The impulse force
  32016. * @param contactPoint The contact point for the impulse force
  32017. * @returns The physics imposter
  32018. */
  32019. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32020. /**
  32021. * A help function to create a joint
  32022. * @param otherImpostor A physics imposter used to create a joint
  32023. * @param jointType The type of joint
  32024. * @param jointData The data for the joint
  32025. * @returns The physics imposter
  32026. */
  32027. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  32028. /**
  32029. * Add a joint to this impostor with a different impostor
  32030. * @param otherImpostor A physics imposter used to add a joint
  32031. * @param joint The joint to add
  32032. * @returns The physics imposter
  32033. */
  32034. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  32035. /**
  32036. * Add an anchor to a cloth impostor
  32037. * @param otherImpostor rigid impostor to anchor to
  32038. * @param width ratio across width from 0 to 1
  32039. * @param height ratio up height from 0 to 1
  32040. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  32041. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  32042. * @returns impostor the soft imposter
  32043. */
  32044. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32045. /**
  32046. * Add a hook to a rope impostor
  32047. * @param otherImpostor rigid impostor to anchor to
  32048. * @param length ratio across rope from 0 to 1
  32049. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  32050. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  32051. * @returns impostor the rope imposter
  32052. */
  32053. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32054. /**
  32055. * Will keep this body still, in a sleep mode.
  32056. * @returns the physics imposter
  32057. */
  32058. sleep(): PhysicsImpostor;
  32059. /**
  32060. * Wake the body up.
  32061. * @returns The physics imposter
  32062. */
  32063. wakeUp(): PhysicsImpostor;
  32064. /**
  32065. * Clones the physics imposter
  32066. * @param newObject The physics imposter clones to this physics-enabled object
  32067. * @returns A nullable physics imposter
  32068. */
  32069. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32070. /**
  32071. * Disposes the physics imposter
  32072. */
  32073. dispose(): void;
  32074. /**
  32075. * Sets the delta position
  32076. * @param position The delta position amount
  32077. */
  32078. setDeltaPosition(position: Vector3): void;
  32079. /**
  32080. * Sets the delta rotation
  32081. * @param rotation The delta rotation amount
  32082. */
  32083. setDeltaRotation(rotation: Quaternion): void;
  32084. /**
  32085. * Gets the box size of the physics imposter and stores the result in the input parameter
  32086. * @param result Stores the box size
  32087. * @returns The physics imposter
  32088. */
  32089. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  32090. /**
  32091. * Gets the radius of the physics imposter
  32092. * @returns Radius of the physics imposter
  32093. */
  32094. getRadius(): number;
  32095. /**
  32096. * Sync a bone with this impostor
  32097. * @param bone The bone to sync to the impostor.
  32098. * @param boneMesh The mesh that the bone is influencing.
  32099. * @param jointPivot The pivot of the joint / bone in local space.
  32100. * @param distToJoint Optional distance from the impostor to the joint.
  32101. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32102. */
  32103. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  32104. /**
  32105. * Sync impostor to a bone
  32106. * @param bone The bone that the impostor will be synced to.
  32107. * @param boneMesh The mesh that the bone is influencing.
  32108. * @param jointPivot The pivot of the joint / bone in local space.
  32109. * @param distToJoint Optional distance from the impostor to the joint.
  32110. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32111. * @param boneAxis Optional vector3 axis the bone is aligned with
  32112. */
  32113. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  32114. /**
  32115. * No-Imposter type
  32116. */
  32117. static NoImpostor: number;
  32118. /**
  32119. * Sphere-Imposter type
  32120. */
  32121. static SphereImpostor: number;
  32122. /**
  32123. * Box-Imposter type
  32124. */
  32125. static BoxImpostor: number;
  32126. /**
  32127. * Plane-Imposter type
  32128. */
  32129. static PlaneImpostor: number;
  32130. /**
  32131. * Mesh-imposter type
  32132. */
  32133. static MeshImpostor: number;
  32134. /**
  32135. * Capsule-Impostor type (Ammo.js plugin only)
  32136. */
  32137. static CapsuleImpostor: number;
  32138. /**
  32139. * Cylinder-Imposter type
  32140. */
  32141. static CylinderImpostor: number;
  32142. /**
  32143. * Particle-Imposter type
  32144. */
  32145. static ParticleImpostor: number;
  32146. /**
  32147. * Heightmap-Imposter type
  32148. */
  32149. static HeightmapImpostor: number;
  32150. /**
  32151. * ConvexHull-Impostor type (Ammo.js plugin only)
  32152. */
  32153. static ConvexHullImpostor: number;
  32154. /**
  32155. * Custom-Imposter type (Ammo.js plugin only)
  32156. */
  32157. static CustomImpostor: number;
  32158. /**
  32159. * Rope-Imposter type
  32160. */
  32161. static RopeImpostor: number;
  32162. /**
  32163. * Cloth-Imposter type
  32164. */
  32165. static ClothImpostor: number;
  32166. /**
  32167. * Softbody-Imposter type
  32168. */
  32169. static SoftbodyImpostor: number;
  32170. }
  32171. }
  32172. declare module BABYLON {
  32173. /**
  32174. * @hidden
  32175. **/
  32176. export class _CreationDataStorage {
  32177. closePath?: boolean;
  32178. closeArray?: boolean;
  32179. idx: number[];
  32180. dashSize: number;
  32181. gapSize: number;
  32182. path3D: Path3D;
  32183. pathArray: Vector3[][];
  32184. arc: number;
  32185. radius: number;
  32186. cap: number;
  32187. tessellation: number;
  32188. }
  32189. /**
  32190. * @hidden
  32191. **/
  32192. class _InstanceDataStorage {
  32193. visibleInstances: any;
  32194. batchCache: _InstancesBatch;
  32195. instancesBufferSize: number;
  32196. instancesBuffer: Nullable<Buffer>;
  32197. instancesData: Float32Array;
  32198. overridenInstanceCount: number;
  32199. isFrozen: boolean;
  32200. previousBatch: Nullable<_InstancesBatch>;
  32201. hardwareInstancedRendering: boolean;
  32202. sideOrientation: number;
  32203. manualUpdate: boolean;
  32204. previousRenderId: number;
  32205. }
  32206. /**
  32207. * @hidden
  32208. **/
  32209. export class _InstancesBatch {
  32210. mustReturn: boolean;
  32211. visibleInstances: Nullable<InstancedMesh[]>[];
  32212. renderSelf: boolean[];
  32213. hardwareInstancedRendering: boolean[];
  32214. }
  32215. /**
  32216. * @hidden
  32217. **/
  32218. class _ThinInstanceDataStorage {
  32219. instancesCount: number;
  32220. matrixBuffer: Nullable<Buffer>;
  32221. matrixBufferSize: number;
  32222. matrixData: Nullable<Float32Array>;
  32223. boundingVectors: Array<Vector3>;
  32224. worldMatrices: Nullable<Matrix[]>;
  32225. }
  32226. /**
  32227. * Class used to represent renderable models
  32228. */
  32229. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  32230. /**
  32231. * Mesh side orientation : usually the external or front surface
  32232. */
  32233. static readonly FRONTSIDE: number;
  32234. /**
  32235. * Mesh side orientation : usually the internal or back surface
  32236. */
  32237. static readonly BACKSIDE: number;
  32238. /**
  32239. * Mesh side orientation : both internal and external or front and back surfaces
  32240. */
  32241. static readonly DOUBLESIDE: number;
  32242. /**
  32243. * Mesh side orientation : by default, `FRONTSIDE`
  32244. */
  32245. static readonly DEFAULTSIDE: number;
  32246. /**
  32247. * Mesh cap setting : no cap
  32248. */
  32249. static readonly NO_CAP: number;
  32250. /**
  32251. * Mesh cap setting : one cap at the beginning of the mesh
  32252. */
  32253. static readonly CAP_START: number;
  32254. /**
  32255. * Mesh cap setting : one cap at the end of the mesh
  32256. */
  32257. static readonly CAP_END: number;
  32258. /**
  32259. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  32260. */
  32261. static readonly CAP_ALL: number;
  32262. /**
  32263. * Mesh pattern setting : no flip or rotate
  32264. */
  32265. static readonly NO_FLIP: number;
  32266. /**
  32267. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  32268. */
  32269. static readonly FLIP_TILE: number;
  32270. /**
  32271. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  32272. */
  32273. static readonly ROTATE_TILE: number;
  32274. /**
  32275. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  32276. */
  32277. static readonly FLIP_ROW: number;
  32278. /**
  32279. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  32280. */
  32281. static readonly ROTATE_ROW: number;
  32282. /**
  32283. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  32284. */
  32285. static readonly FLIP_N_ROTATE_TILE: number;
  32286. /**
  32287. * Mesh pattern setting : rotate pattern and rotate
  32288. */
  32289. static readonly FLIP_N_ROTATE_ROW: number;
  32290. /**
  32291. * Mesh tile positioning : part tiles same on left/right or top/bottom
  32292. */
  32293. static readonly CENTER: number;
  32294. /**
  32295. * Mesh tile positioning : part tiles on left
  32296. */
  32297. static readonly LEFT: number;
  32298. /**
  32299. * Mesh tile positioning : part tiles on right
  32300. */
  32301. static readonly RIGHT: number;
  32302. /**
  32303. * Mesh tile positioning : part tiles on top
  32304. */
  32305. static readonly TOP: number;
  32306. /**
  32307. * Mesh tile positioning : part tiles on bottom
  32308. */
  32309. static readonly BOTTOM: number;
  32310. /**
  32311. * Gets the default side orientation.
  32312. * @param orientation the orientation to value to attempt to get
  32313. * @returns the default orientation
  32314. * @hidden
  32315. */
  32316. static _GetDefaultSideOrientation(orientation?: number): number;
  32317. private _internalMeshDataInfo;
  32318. get computeBonesUsingShaders(): boolean;
  32319. set computeBonesUsingShaders(value: boolean);
  32320. /**
  32321. * An event triggered before rendering the mesh
  32322. */
  32323. get onBeforeRenderObservable(): Observable<Mesh>;
  32324. /**
  32325. * An event triggered before binding the mesh
  32326. */
  32327. get onBeforeBindObservable(): Observable<Mesh>;
  32328. /**
  32329. * An event triggered after rendering the mesh
  32330. */
  32331. get onAfterRenderObservable(): Observable<Mesh>;
  32332. /**
  32333. * An event triggered before drawing the mesh
  32334. */
  32335. get onBeforeDrawObservable(): Observable<Mesh>;
  32336. private _onBeforeDrawObserver;
  32337. /**
  32338. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  32339. */
  32340. set onBeforeDraw(callback: () => void);
  32341. get hasInstances(): boolean;
  32342. get hasThinInstances(): boolean;
  32343. /**
  32344. * Gets the delay loading state of the mesh (when delay loading is turned on)
  32345. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  32346. */
  32347. delayLoadState: number;
  32348. /**
  32349. * Gets the list of instances created from this mesh
  32350. * it is not supposed to be modified manually.
  32351. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  32352. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  32353. */
  32354. instances: InstancedMesh[];
  32355. /**
  32356. * Gets the file containing delay loading data for this mesh
  32357. */
  32358. delayLoadingFile: string;
  32359. /** @hidden */
  32360. _binaryInfo: any;
  32361. /**
  32362. * User defined function used to change how LOD level selection is done
  32363. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32364. */
  32365. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  32366. /**
  32367. * Gets or sets the morph target manager
  32368. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32369. */
  32370. get morphTargetManager(): Nullable<MorphTargetManager>;
  32371. set morphTargetManager(value: Nullable<MorphTargetManager>);
  32372. /** @hidden */
  32373. _creationDataStorage: Nullable<_CreationDataStorage>;
  32374. /** @hidden */
  32375. _geometry: Nullable<Geometry>;
  32376. /** @hidden */
  32377. _delayInfo: Array<string>;
  32378. /** @hidden */
  32379. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  32380. /** @hidden */
  32381. _instanceDataStorage: _InstanceDataStorage;
  32382. /** @hidden */
  32383. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  32384. private _effectiveMaterial;
  32385. /** @hidden */
  32386. _shouldGenerateFlatShading: boolean;
  32387. /** @hidden */
  32388. _originalBuilderSideOrientation: number;
  32389. /**
  32390. * Use this property to change the original side orientation defined at construction time
  32391. */
  32392. overrideMaterialSideOrientation: Nullable<number>;
  32393. /**
  32394. * Gets the source mesh (the one used to clone this one from)
  32395. */
  32396. get source(): Nullable<Mesh>;
  32397. /**
  32398. * Gets the list of clones of this mesh
  32399. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  32400. * Note that useClonedMeshMap=true is the default setting
  32401. */
  32402. get cloneMeshMap(): Nullable<{
  32403. [id: string]: Mesh | undefined;
  32404. }>;
  32405. /**
  32406. * Gets or sets a boolean indicating that this mesh does not use index buffer
  32407. */
  32408. get isUnIndexed(): boolean;
  32409. set isUnIndexed(value: boolean);
  32410. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  32411. get worldMatrixInstancedBuffer(): Float32Array;
  32412. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  32413. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  32414. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  32415. /**
  32416. * @constructor
  32417. * @param name The value used by scene.getMeshByName() to do a lookup.
  32418. * @param scene The scene to add this mesh to.
  32419. * @param parent The parent of this mesh, if it has one
  32420. * @param source An optional Mesh from which geometry is shared, cloned.
  32421. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  32422. * When false, achieved by calling a clone(), also passing False.
  32423. * This will make creation of children, recursive.
  32424. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  32425. */
  32426. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  32427. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  32428. doNotInstantiate: boolean;
  32429. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  32430. /**
  32431. * Gets the class name
  32432. * @returns the string "Mesh".
  32433. */
  32434. getClassName(): string;
  32435. /** @hidden */
  32436. get _isMesh(): boolean;
  32437. /**
  32438. * Returns a description of this mesh
  32439. * @param fullDetails define if full details about this mesh must be used
  32440. * @returns a descriptive string representing this mesh
  32441. */
  32442. toString(fullDetails?: boolean): string;
  32443. /** @hidden */
  32444. _unBindEffect(): void;
  32445. /**
  32446. * Gets a boolean indicating if this mesh has LOD
  32447. */
  32448. get hasLODLevels(): boolean;
  32449. /**
  32450. * Gets the list of MeshLODLevel associated with the current mesh
  32451. * @returns an array of MeshLODLevel
  32452. */
  32453. getLODLevels(): MeshLODLevel[];
  32454. private _sortLODLevels;
  32455. /**
  32456. * Add a mesh as LOD level triggered at the given distance.
  32457. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32458. * @param distance The distance from the center of the object to show this level
  32459. * @param mesh The mesh to be added as LOD level (can be null)
  32460. * @return This mesh (for chaining)
  32461. */
  32462. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  32463. /**
  32464. * Returns the LOD level mesh at the passed distance or null if not found.
  32465. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32466. * @param distance The distance from the center of the object to show this level
  32467. * @returns a Mesh or `null`
  32468. */
  32469. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  32470. /**
  32471. * Remove a mesh from the LOD array
  32472. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32473. * @param mesh defines the mesh to be removed
  32474. * @return This mesh (for chaining)
  32475. */
  32476. removeLODLevel(mesh: Mesh): Mesh;
  32477. /**
  32478. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  32479. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32480. * @param camera defines the camera to use to compute distance
  32481. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  32482. * @return This mesh (for chaining)
  32483. */
  32484. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  32485. /**
  32486. * Gets the mesh internal Geometry object
  32487. */
  32488. get geometry(): Nullable<Geometry>;
  32489. /**
  32490. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  32491. * @returns the total number of vertices
  32492. */
  32493. getTotalVertices(): number;
  32494. /**
  32495. * Returns the content of an associated vertex buffer
  32496. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32497. * - VertexBuffer.PositionKind
  32498. * - VertexBuffer.UVKind
  32499. * - VertexBuffer.UV2Kind
  32500. * - VertexBuffer.UV3Kind
  32501. * - VertexBuffer.UV4Kind
  32502. * - VertexBuffer.UV5Kind
  32503. * - VertexBuffer.UV6Kind
  32504. * - VertexBuffer.ColorKind
  32505. * - VertexBuffer.MatricesIndicesKind
  32506. * - VertexBuffer.MatricesIndicesExtraKind
  32507. * - VertexBuffer.MatricesWeightsKind
  32508. * - VertexBuffer.MatricesWeightsExtraKind
  32509. * @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
  32510. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  32511. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  32512. */
  32513. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  32514. /**
  32515. * Returns the mesh VertexBuffer object from the requested `kind`
  32516. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32517. * - VertexBuffer.PositionKind
  32518. * - VertexBuffer.NormalKind
  32519. * - VertexBuffer.UVKind
  32520. * - VertexBuffer.UV2Kind
  32521. * - VertexBuffer.UV3Kind
  32522. * - VertexBuffer.UV4Kind
  32523. * - VertexBuffer.UV5Kind
  32524. * - VertexBuffer.UV6Kind
  32525. * - VertexBuffer.ColorKind
  32526. * - VertexBuffer.MatricesIndicesKind
  32527. * - VertexBuffer.MatricesIndicesExtraKind
  32528. * - VertexBuffer.MatricesWeightsKind
  32529. * - VertexBuffer.MatricesWeightsExtraKind
  32530. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  32531. */
  32532. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  32533. /**
  32534. * Tests if a specific vertex buffer is associated with this mesh
  32535. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  32536. * - VertexBuffer.PositionKind
  32537. * - VertexBuffer.NormalKind
  32538. * - VertexBuffer.UVKind
  32539. * - VertexBuffer.UV2Kind
  32540. * - VertexBuffer.UV3Kind
  32541. * - VertexBuffer.UV4Kind
  32542. * - VertexBuffer.UV5Kind
  32543. * - VertexBuffer.UV6Kind
  32544. * - VertexBuffer.ColorKind
  32545. * - VertexBuffer.MatricesIndicesKind
  32546. * - VertexBuffer.MatricesIndicesExtraKind
  32547. * - VertexBuffer.MatricesWeightsKind
  32548. * - VertexBuffer.MatricesWeightsExtraKind
  32549. * @returns a boolean
  32550. */
  32551. isVerticesDataPresent(kind: string): boolean;
  32552. /**
  32553. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  32554. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  32555. * - VertexBuffer.PositionKind
  32556. * - VertexBuffer.UVKind
  32557. * - VertexBuffer.UV2Kind
  32558. * - VertexBuffer.UV3Kind
  32559. * - VertexBuffer.UV4Kind
  32560. * - VertexBuffer.UV5Kind
  32561. * - VertexBuffer.UV6Kind
  32562. * - VertexBuffer.ColorKind
  32563. * - VertexBuffer.MatricesIndicesKind
  32564. * - VertexBuffer.MatricesIndicesExtraKind
  32565. * - VertexBuffer.MatricesWeightsKind
  32566. * - VertexBuffer.MatricesWeightsExtraKind
  32567. * @returns a boolean
  32568. */
  32569. isVertexBufferUpdatable(kind: string): boolean;
  32570. /**
  32571. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  32572. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32573. * - VertexBuffer.PositionKind
  32574. * - VertexBuffer.NormalKind
  32575. * - VertexBuffer.UVKind
  32576. * - VertexBuffer.UV2Kind
  32577. * - VertexBuffer.UV3Kind
  32578. * - VertexBuffer.UV4Kind
  32579. * - VertexBuffer.UV5Kind
  32580. * - VertexBuffer.UV6Kind
  32581. * - VertexBuffer.ColorKind
  32582. * - VertexBuffer.MatricesIndicesKind
  32583. * - VertexBuffer.MatricesIndicesExtraKind
  32584. * - VertexBuffer.MatricesWeightsKind
  32585. * - VertexBuffer.MatricesWeightsExtraKind
  32586. * @returns an array of strings
  32587. */
  32588. getVerticesDataKinds(): string[];
  32589. /**
  32590. * Returns a positive integer : the total number of indices in this mesh geometry.
  32591. * @returns the numner of indices or zero if the mesh has no geometry.
  32592. */
  32593. getTotalIndices(): number;
  32594. /**
  32595. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  32596. * @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.
  32597. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  32598. * @returns the indices array or an empty array if the mesh has no geometry
  32599. */
  32600. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  32601. get isBlocked(): boolean;
  32602. /**
  32603. * Determine if the current mesh is ready to be rendered
  32604. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  32605. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  32606. * @returns true if all associated assets are ready (material, textures, shaders)
  32607. */
  32608. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  32609. /**
  32610. * 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.
  32611. */
  32612. get areNormalsFrozen(): boolean;
  32613. /**
  32614. * 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.
  32615. * @returns the current mesh
  32616. */
  32617. freezeNormals(): Mesh;
  32618. /**
  32619. * 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
  32620. * @returns the current mesh
  32621. */
  32622. unfreezeNormals(): Mesh;
  32623. /**
  32624. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  32625. */
  32626. set overridenInstanceCount(count: number);
  32627. /** @hidden */
  32628. _preActivate(): Mesh;
  32629. /** @hidden */
  32630. _preActivateForIntermediateRendering(renderId: number): Mesh;
  32631. /** @hidden */
  32632. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  32633. protected _afterComputeWorldMatrix(): void;
  32634. /** @hidden */
  32635. _postActivate(): void;
  32636. /**
  32637. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32638. * This means the mesh underlying bounding box and sphere are recomputed.
  32639. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32640. * @returns the current mesh
  32641. */
  32642. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  32643. /** @hidden */
  32644. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  32645. /**
  32646. * This function will subdivide the mesh into multiple submeshes
  32647. * @param count defines the expected number of submeshes
  32648. */
  32649. subdivide(count: number): void;
  32650. /**
  32651. * Copy a FloatArray into a specific associated vertex buffer
  32652. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  32653. * - VertexBuffer.PositionKind
  32654. * - VertexBuffer.UVKind
  32655. * - VertexBuffer.UV2Kind
  32656. * - VertexBuffer.UV3Kind
  32657. * - VertexBuffer.UV4Kind
  32658. * - VertexBuffer.UV5Kind
  32659. * - VertexBuffer.UV6Kind
  32660. * - VertexBuffer.ColorKind
  32661. * - VertexBuffer.MatricesIndicesKind
  32662. * - VertexBuffer.MatricesIndicesExtraKind
  32663. * - VertexBuffer.MatricesWeightsKind
  32664. * - VertexBuffer.MatricesWeightsExtraKind
  32665. * @param data defines the data source
  32666. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  32667. * @param stride defines the data stride size (can be null)
  32668. * @returns the current mesh
  32669. */
  32670. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32671. /**
  32672. * Delete a vertex buffer associated with this mesh
  32673. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  32674. * - VertexBuffer.PositionKind
  32675. * - VertexBuffer.UVKind
  32676. * - VertexBuffer.UV2Kind
  32677. * - VertexBuffer.UV3Kind
  32678. * - VertexBuffer.UV4Kind
  32679. * - VertexBuffer.UV5Kind
  32680. * - VertexBuffer.UV6Kind
  32681. * - VertexBuffer.ColorKind
  32682. * - VertexBuffer.MatricesIndicesKind
  32683. * - VertexBuffer.MatricesIndicesExtraKind
  32684. * - VertexBuffer.MatricesWeightsKind
  32685. * - VertexBuffer.MatricesWeightsExtraKind
  32686. */
  32687. removeVerticesData(kind: string): void;
  32688. /**
  32689. * Flags an associated vertex buffer as updatable
  32690. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  32691. * - VertexBuffer.PositionKind
  32692. * - VertexBuffer.UVKind
  32693. * - VertexBuffer.UV2Kind
  32694. * - VertexBuffer.UV3Kind
  32695. * - VertexBuffer.UV4Kind
  32696. * - VertexBuffer.UV5Kind
  32697. * - VertexBuffer.UV6Kind
  32698. * - VertexBuffer.ColorKind
  32699. * - VertexBuffer.MatricesIndicesKind
  32700. * - VertexBuffer.MatricesIndicesExtraKind
  32701. * - VertexBuffer.MatricesWeightsKind
  32702. * - VertexBuffer.MatricesWeightsExtraKind
  32703. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  32704. */
  32705. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  32706. /**
  32707. * Sets the mesh global Vertex Buffer
  32708. * @param buffer defines the buffer to use
  32709. * @returns the current mesh
  32710. */
  32711. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  32712. /**
  32713. * Update a specific associated vertex buffer
  32714. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  32715. * - VertexBuffer.PositionKind
  32716. * - VertexBuffer.UVKind
  32717. * - VertexBuffer.UV2Kind
  32718. * - VertexBuffer.UV3Kind
  32719. * - VertexBuffer.UV4Kind
  32720. * - VertexBuffer.UV5Kind
  32721. * - VertexBuffer.UV6Kind
  32722. * - VertexBuffer.ColorKind
  32723. * - VertexBuffer.MatricesIndicesKind
  32724. * - VertexBuffer.MatricesIndicesExtraKind
  32725. * - VertexBuffer.MatricesWeightsKind
  32726. * - VertexBuffer.MatricesWeightsExtraKind
  32727. * @param data defines the data source
  32728. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  32729. * @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)
  32730. * @returns the current mesh
  32731. */
  32732. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32733. /**
  32734. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  32735. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  32736. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  32737. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  32738. * @returns the current mesh
  32739. */
  32740. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  32741. /**
  32742. * Creates a un-shared specific occurence of the geometry for the mesh.
  32743. * @returns the current mesh
  32744. */
  32745. makeGeometryUnique(): Mesh;
  32746. /**
  32747. * Set the index buffer of this mesh
  32748. * @param indices defines the source data
  32749. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  32750. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  32751. * @returns the current mesh
  32752. */
  32753. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  32754. /**
  32755. * Update the current index buffer
  32756. * @param indices defines the source data
  32757. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32758. * @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)
  32759. * @returns the current mesh
  32760. */
  32761. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32762. /**
  32763. * Invert the geometry to move from a right handed system to a left handed one.
  32764. * @returns the current mesh
  32765. */
  32766. toLeftHanded(): Mesh;
  32767. /** @hidden */
  32768. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  32769. /** @hidden */
  32770. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  32771. /**
  32772. * Registers for this mesh a javascript function called just before the rendering process
  32773. * @param func defines the function to call before rendering this mesh
  32774. * @returns the current mesh
  32775. */
  32776. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  32777. /**
  32778. * Disposes a previously registered javascript function called before the rendering
  32779. * @param func defines the function to remove
  32780. * @returns the current mesh
  32781. */
  32782. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  32783. /**
  32784. * Registers for this mesh a javascript function called just after the rendering is complete
  32785. * @param func defines the function to call after rendering this mesh
  32786. * @returns the current mesh
  32787. */
  32788. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  32789. /**
  32790. * Disposes a previously registered javascript function called after the rendering.
  32791. * @param func defines the function to remove
  32792. * @returns the current mesh
  32793. */
  32794. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  32795. /** @hidden */
  32796. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  32797. /** @hidden */
  32798. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  32799. /** @hidden */
  32800. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  32801. /** @hidden */
  32802. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  32803. /** @hidden */
  32804. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  32805. /** @hidden */
  32806. _rebuild(): void;
  32807. /** @hidden */
  32808. _freeze(): void;
  32809. /** @hidden */
  32810. _unFreeze(): void;
  32811. /**
  32812. * 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
  32813. * @param subMesh defines the subMesh to render
  32814. * @param enableAlphaMode defines if alpha mode can be changed
  32815. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  32816. * @returns the current mesh
  32817. */
  32818. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  32819. private _onBeforeDraw;
  32820. /**
  32821. * Renormalize the mesh and patch it up if there are no weights
  32822. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  32823. * However in the case of zero weights then we set just a single influence to 1.
  32824. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  32825. */
  32826. cleanMatrixWeights(): void;
  32827. private normalizeSkinFourWeights;
  32828. private normalizeSkinWeightsAndExtra;
  32829. /**
  32830. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  32831. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  32832. * the user know there was an issue with importing the mesh
  32833. * @returns a validation object with skinned, valid and report string
  32834. */
  32835. validateSkinning(): {
  32836. skinned: boolean;
  32837. valid: boolean;
  32838. report: string;
  32839. };
  32840. /** @hidden */
  32841. _checkDelayState(): Mesh;
  32842. private _queueLoad;
  32843. /**
  32844. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32845. * A mesh is in the frustum if its bounding box intersects the frustum
  32846. * @param frustumPlanes defines the frustum to test
  32847. * @returns true if the mesh is in the frustum planes
  32848. */
  32849. isInFrustum(frustumPlanes: Plane[]): boolean;
  32850. /**
  32851. * Sets the mesh material by the material or multiMaterial `id` property
  32852. * @param id is a string identifying the material or the multiMaterial
  32853. * @returns the current mesh
  32854. */
  32855. setMaterialByID(id: string): Mesh;
  32856. /**
  32857. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  32858. * @returns an array of IAnimatable
  32859. */
  32860. getAnimatables(): IAnimatable[];
  32861. /**
  32862. * Modifies the mesh geometry according to the passed transformation matrix.
  32863. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  32864. * The mesh normals are modified using the same transformation.
  32865. * Note that, under the hood, this method sets a new VertexBuffer each call.
  32866. * @param transform defines the transform matrix to use
  32867. * @see https://doc.babylonjs.com/resources/baking_transformations
  32868. * @returns the current mesh
  32869. */
  32870. bakeTransformIntoVertices(transform: Matrix): Mesh;
  32871. /**
  32872. * Modifies the mesh geometry according to its own current World Matrix.
  32873. * The mesh World Matrix is then reset.
  32874. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  32875. * Note that, under the hood, this method sets a new VertexBuffer each call.
  32876. * @see https://doc.babylonjs.com/resources/baking_transformations
  32877. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  32878. * @returns the current mesh
  32879. */
  32880. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  32881. /** @hidden */
  32882. get _positions(): Nullable<Vector3[]>;
  32883. /** @hidden */
  32884. _resetPointsArrayCache(): Mesh;
  32885. /** @hidden */
  32886. _generatePointsArray(): boolean;
  32887. /**
  32888. * Returns a new Mesh object generated from the current mesh properties.
  32889. * This method must not get confused with createInstance()
  32890. * @param name is a string, the name given to the new mesh
  32891. * @param newParent can be any Node object (default `null`)
  32892. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  32893. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  32894. * @returns a new mesh
  32895. */
  32896. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  32897. /**
  32898. * Releases resources associated with this mesh.
  32899. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32900. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32901. */
  32902. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32903. /** @hidden */
  32904. _disposeInstanceSpecificData(): void;
  32905. /** @hidden */
  32906. _disposeThinInstanceSpecificData(): void;
  32907. /**
  32908. * Modifies the mesh geometry according to a displacement map.
  32909. * 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.
  32910. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  32911. * @param url is a string, the URL from the image file is to be downloaded.
  32912. * @param minHeight is the lower limit of the displacement.
  32913. * @param maxHeight is the upper limit of the displacement.
  32914. * @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.
  32915. * @param uvOffset is an optional vector2 used to offset UV.
  32916. * @param uvScale is an optional vector2 used to scale UV.
  32917. * @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.
  32918. * @returns the Mesh.
  32919. */
  32920. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  32921. /**
  32922. * Modifies the mesh geometry according to a displacementMap buffer.
  32923. * 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.
  32924. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  32925. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  32926. * @param heightMapWidth is the width of the buffer image.
  32927. * @param heightMapHeight is the height of the buffer image.
  32928. * @param minHeight is the lower limit of the displacement.
  32929. * @param maxHeight is the upper limit of the displacement.
  32930. * @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.
  32931. * @param uvOffset is an optional vector2 used to offset UV.
  32932. * @param uvScale is an optional vector2 used to scale UV.
  32933. * @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.
  32934. * @returns the Mesh.
  32935. */
  32936. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  32937. /**
  32938. * Modify the mesh to get a flat shading rendering.
  32939. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  32940. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  32941. * @returns current mesh
  32942. */
  32943. convertToFlatShadedMesh(): Mesh;
  32944. /**
  32945. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  32946. * In other words, more vertices, no more indices and a single bigger VBO.
  32947. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  32948. * @returns current mesh
  32949. */
  32950. convertToUnIndexedMesh(): Mesh;
  32951. /**
  32952. * Inverses facet orientations.
  32953. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  32954. * @param flipNormals will also inverts the normals
  32955. * @returns current mesh
  32956. */
  32957. flipFaces(flipNormals?: boolean): Mesh;
  32958. /**
  32959. * Increase the number of facets and hence vertices in a mesh
  32960. * Vertex normals are interpolated from existing vertex normals
  32961. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  32962. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  32963. */
  32964. increaseVertices(numberPerEdge: number): void;
  32965. /**
  32966. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  32967. * This will undo any application of covertToFlatShadedMesh
  32968. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  32969. */
  32970. forceSharedVertices(): void;
  32971. /** @hidden */
  32972. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  32973. /** @hidden */
  32974. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  32975. /**
  32976. * Creates a new InstancedMesh object from the mesh model.
  32977. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  32978. * @param name defines the name of the new instance
  32979. * @returns a new InstancedMesh
  32980. */
  32981. createInstance(name: string): InstancedMesh;
  32982. /**
  32983. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  32984. * After this call, all the mesh instances have the same submeshes than the current mesh.
  32985. * @returns the current mesh
  32986. */
  32987. synchronizeInstances(): Mesh;
  32988. /**
  32989. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  32990. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  32991. * This should be used together with the simplification to avoid disappearing triangles.
  32992. * @param successCallback an optional success callback to be called after the optimization finished.
  32993. * @returns the current mesh
  32994. */
  32995. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  32996. /**
  32997. * Serialize current mesh
  32998. * @param serializationObject defines the object which will receive the serialization data
  32999. */
  33000. serialize(serializationObject: any): void;
  33001. /** @hidden */
  33002. _syncGeometryWithMorphTargetManager(): void;
  33003. /** @hidden */
  33004. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  33005. /**
  33006. * Returns a new Mesh object parsed from the source provided.
  33007. * @param parsedMesh is the source
  33008. * @param scene defines the hosting scene
  33009. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  33010. * @returns a new Mesh
  33011. */
  33012. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  33013. /**
  33014. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  33015. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33016. * @param name defines the name of the mesh to create
  33017. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  33018. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  33019. * @param closePath creates a seam between the first and the last points of each path of the path array
  33020. * @param offset is taken in account only if the `pathArray` is containing a single path
  33021. * @param scene defines the hosting scene
  33022. * @param updatable defines if the mesh must be flagged as updatable
  33023. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33024. * @param instance defines 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)
  33025. * @returns a new Mesh
  33026. */
  33027. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33028. /**
  33029. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  33030. * @param name defines the name of the mesh to create
  33031. * @param radius sets the radius size (float) of the polygon (default 0.5)
  33032. * @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
  33033. * @param scene defines the hosting scene
  33034. * @param updatable defines if the mesh must be flagged as updatable
  33035. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33036. * @returns a new Mesh
  33037. */
  33038. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33039. /**
  33040. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  33041. * @param name defines the name of the mesh to create
  33042. * @param size sets the size (float) of each box side (default 1)
  33043. * @param scene defines the hosting scene
  33044. * @param updatable defines if the mesh must be flagged as updatable
  33045. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33046. * @returns a new Mesh
  33047. */
  33048. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33049. /**
  33050. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  33051. * @param name defines the name of the mesh to create
  33052. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33053. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33054. * @param scene defines the hosting scene
  33055. * @param updatable defines if the mesh must be flagged as updatable
  33056. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33057. * @returns a new Mesh
  33058. */
  33059. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33060. /**
  33061. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  33062. * @param name defines the name of the mesh to create
  33063. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33064. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33065. * @param scene defines the hosting scene
  33066. * @returns a new Mesh
  33067. */
  33068. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  33069. /**
  33070. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  33071. * @param name defines the name of the mesh to create
  33072. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  33073. * @param diameterTop set the top cap diameter (floats, default 1)
  33074. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  33075. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  33076. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  33077. * @param scene defines the hosting scene
  33078. * @param updatable defines if the mesh must be flagged as updatable
  33079. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33080. * @returns a new Mesh
  33081. */
  33082. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  33083. /**
  33084. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  33085. * @param name defines the name of the mesh to create
  33086. * @param diameter sets the diameter size (float) of the torus (default 1)
  33087. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  33088. * @param tessellation sets the number of torus sides (postive integer, default 16)
  33089. * @param scene defines the hosting scene
  33090. * @param updatable defines if the mesh must be flagged as updatable
  33091. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33092. * @returns a new Mesh
  33093. */
  33094. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33095. /**
  33096. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  33097. * @param name defines the name of the mesh to create
  33098. * @param radius sets the global radius size (float) of the torus knot (default 2)
  33099. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  33100. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  33101. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  33102. * @param p the number of windings on X axis (positive integers, default 2)
  33103. * @param q the number of windings on Y axis (positive integers, default 3)
  33104. * @param scene defines the hosting scene
  33105. * @param updatable defines if the mesh must be flagged as updatable
  33106. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33107. * @returns a new Mesh
  33108. */
  33109. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33110. /**
  33111. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  33112. * @param name defines the name of the mesh to create
  33113. * @param points is an array successive Vector3
  33114. * @param scene defines the hosting scene
  33115. * @param updatable defines if the mesh must be flagged as updatable
  33116. * @param 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).
  33117. * @returns a new Mesh
  33118. */
  33119. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  33120. /**
  33121. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  33122. * @param name defines the name of the mesh to create
  33123. * @param points is an array successive Vector3
  33124. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  33125. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  33126. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  33127. * @param scene defines the hosting scene
  33128. * @param updatable defines if the mesh must be flagged as updatable
  33129. * @param 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)
  33130. * @returns a new Mesh
  33131. */
  33132. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  33133. /**
  33134. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  33135. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  33136. * 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.
  33137. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33138. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  33139. * Remember you can only change the shape positions, not their number when updating a polygon.
  33140. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  33141. * @param name defines the name of the mesh to create
  33142. * @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
  33143. * @param scene defines the hosting scene
  33144. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33145. * @param updatable defines if the mesh must be flagged as updatable
  33146. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33147. * @param earcutInjection can be used to inject your own earcut reference
  33148. * @returns a new Mesh
  33149. */
  33150. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33151. /**
  33152. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  33153. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  33154. * @param name defines the name of the mesh to create
  33155. * @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
  33156. * @param depth defines the height of extrusion
  33157. * @param scene defines the hosting scene
  33158. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33159. * @param updatable defines if the mesh must be flagged as updatable
  33160. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33161. * @param earcutInjection can be used to inject your own earcut reference
  33162. * @returns a new Mesh
  33163. */
  33164. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33165. /**
  33166. * Creates an extruded shape mesh.
  33167. * 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
  33168. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33169. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33170. * @param name defines the name of the mesh to create
  33171. * @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
  33172. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33173. * @param scale is the value to scale the shape
  33174. * @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
  33175. * @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
  33176. * @param scene defines the hosting scene
  33177. * @param updatable defines if the mesh must be flagged as updatable
  33178. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33179. * @param 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)
  33180. * @returns a new Mesh
  33181. */
  33182. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33183. /**
  33184. * Creates an custom extruded shape mesh.
  33185. * The custom extrusion is a parametric shape.
  33186. * It has no predefined shape. Its final shape will depend on the input parameters.
  33187. * Please consider using the same method from the MeshBuilder class instead
  33188. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33189. * @param name defines the name of the mesh to create
  33190. * @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
  33191. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33192. * @param scaleFunction is a custom Javascript function called on each path point
  33193. * @param rotationFunction is a custom Javascript function called on each path point
  33194. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  33195. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  33196. * @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
  33197. * @param scene defines the hosting scene
  33198. * @param updatable defines if the mesh must be flagged as updatable
  33199. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33200. * @param 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)
  33201. * @returns a new Mesh
  33202. */
  33203. 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;
  33204. /**
  33205. * Creates lathe mesh.
  33206. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  33207. * Please consider using the same method from the MeshBuilder class instead
  33208. * @param name defines the name of the mesh to create
  33209. * @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
  33210. * @param radius is the radius value of the lathe
  33211. * @param tessellation is the side number of the lathe.
  33212. * @param scene defines the hosting scene
  33213. * @param updatable defines if the mesh must be flagged as updatable
  33214. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33215. * @returns a new Mesh
  33216. */
  33217. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33218. /**
  33219. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  33220. * @param name defines the name of the mesh to create
  33221. * @param size sets the size (float) of both sides of the plane at once (default 1)
  33222. * @param scene defines the hosting scene
  33223. * @param updatable defines if the mesh must be flagged as updatable
  33224. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33225. * @returns a new Mesh
  33226. */
  33227. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33228. /**
  33229. * Creates a ground mesh.
  33230. * Please consider using the same method from the MeshBuilder class instead
  33231. * @param name defines the name of the mesh to create
  33232. * @param width set the width of the ground
  33233. * @param height set the height of the ground
  33234. * @param subdivisions sets the number of subdivisions per side
  33235. * @param scene defines the hosting scene
  33236. * @param updatable defines if the mesh must be flagged as updatable
  33237. * @returns a new Mesh
  33238. */
  33239. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  33240. /**
  33241. * Creates a tiled ground mesh.
  33242. * Please consider using the same method from the MeshBuilder class instead
  33243. * @param name defines the name of the mesh to create
  33244. * @param xmin set the ground minimum X coordinate
  33245. * @param zmin set the ground minimum Y coordinate
  33246. * @param xmax set the ground maximum X coordinate
  33247. * @param zmax set the ground maximum Z coordinate
  33248. * @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
  33249. * @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
  33250. * @param scene defines the hosting scene
  33251. * @param updatable defines if the mesh must be flagged as updatable
  33252. * @returns a new Mesh
  33253. */
  33254. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  33255. w: number;
  33256. h: number;
  33257. }, precision: {
  33258. w: number;
  33259. h: number;
  33260. }, scene: Scene, updatable?: boolean): Mesh;
  33261. /**
  33262. * Creates a ground mesh from a height map.
  33263. * Please consider using the same method from the MeshBuilder class instead
  33264. * @see https://doc.babylonjs.com/babylon101/height_map
  33265. * @param name defines the name of the mesh to create
  33266. * @param url sets the URL of the height map image resource
  33267. * @param width set the ground width size
  33268. * @param height set the ground height size
  33269. * @param subdivisions sets the number of subdivision per side
  33270. * @param minHeight is the minimum altitude on the ground
  33271. * @param maxHeight is the maximum altitude on the ground
  33272. * @param scene defines the hosting scene
  33273. * @param updatable defines if the mesh must be flagged as updatable
  33274. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  33275. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  33276. * @returns a new Mesh
  33277. */
  33278. 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;
  33279. /**
  33280. * Creates a tube mesh.
  33281. * The tube is a parametric shape.
  33282. * It has no predefined shape. Its final shape will depend on the input parameters.
  33283. * Please consider using the same method from the MeshBuilder class instead
  33284. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33285. * @param name defines the name of the mesh to create
  33286. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  33287. * @param radius sets the tube radius size
  33288. * @param tessellation is the number of sides on the tubular surface
  33289. * @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
  33290. * @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
  33291. * @param scene defines the hosting scene
  33292. * @param updatable defines if the mesh must be flagged as updatable
  33293. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33294. * @param 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)
  33295. * @returns a new Mesh
  33296. */
  33297. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  33298. (i: number, distance: number): number;
  33299. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33300. /**
  33301. * Creates a polyhedron mesh.
  33302. * Please consider using the same method from the MeshBuilder class instead.
  33303. * * 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
  33304. * * The parameter `size` (positive float, default 1) sets the polygon size
  33305. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  33306. * * 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`
  33307. * * 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
  33308. * * 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)`)
  33309. * * 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
  33310. * * 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
  33311. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33312. * * 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
  33313. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33314. * @param name defines the name of the mesh to create
  33315. * @param options defines the options used to create the mesh
  33316. * @param scene defines the hosting scene
  33317. * @returns a new Mesh
  33318. */
  33319. static CreatePolyhedron(name: string, options: {
  33320. type?: number;
  33321. size?: number;
  33322. sizeX?: number;
  33323. sizeY?: number;
  33324. sizeZ?: number;
  33325. custom?: any;
  33326. faceUV?: Vector4[];
  33327. faceColors?: Color4[];
  33328. updatable?: boolean;
  33329. sideOrientation?: number;
  33330. }, scene: Scene): Mesh;
  33331. /**
  33332. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  33333. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  33334. * * 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`)
  33335. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  33336. * * 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
  33337. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33338. * * 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
  33339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33340. * @param name defines the name of the mesh
  33341. * @param options defines the options used to create the mesh
  33342. * @param scene defines the hosting scene
  33343. * @returns a new Mesh
  33344. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  33345. */
  33346. static CreateIcoSphere(name: string, options: {
  33347. radius?: number;
  33348. flat?: boolean;
  33349. subdivisions?: number;
  33350. sideOrientation?: number;
  33351. updatable?: boolean;
  33352. }, scene: Scene): Mesh;
  33353. /**
  33354. * Creates a decal mesh.
  33355. * Please consider using the same method from the MeshBuilder class instead.
  33356. * A decal is a mesh usually applied as a model onto the surface of another mesh
  33357. * @param name defines the name of the mesh
  33358. * @param sourceMesh defines the mesh receiving the decal
  33359. * @param position sets the position of the decal in world coordinates
  33360. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  33361. * @param size sets the decal scaling
  33362. * @param angle sets the angle to rotate the decal
  33363. * @returns a new Mesh
  33364. */
  33365. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  33366. /** Creates a Capsule Mesh
  33367. * @param name defines the name of the mesh.
  33368. * @param options the constructors options used to shape the mesh.
  33369. * @param scene defines the scene the mesh is scoped to.
  33370. * @returns the capsule mesh
  33371. * @see https://doc.babylonjs.com/how_to/capsule_shape
  33372. */
  33373. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  33374. /**
  33375. * Prepare internal position array for software CPU skinning
  33376. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  33377. */
  33378. setPositionsForCPUSkinning(): Float32Array;
  33379. /**
  33380. * Prepare internal normal array for software CPU skinning
  33381. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  33382. */
  33383. setNormalsForCPUSkinning(): Float32Array;
  33384. /**
  33385. * Updates the vertex buffer by applying transformation from the bones
  33386. * @param skeleton defines the skeleton to apply to current mesh
  33387. * @returns the current mesh
  33388. */
  33389. applySkeleton(skeleton: Skeleton): Mesh;
  33390. /**
  33391. * 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
  33392. * @param meshes defines the list of meshes to scan
  33393. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  33394. */
  33395. static MinMax(meshes: AbstractMesh[]): {
  33396. min: Vector3;
  33397. max: Vector3;
  33398. };
  33399. /**
  33400. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  33401. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  33402. * @returns a vector3
  33403. */
  33404. static Center(meshesOrMinMaxVector: {
  33405. min: Vector3;
  33406. max: Vector3;
  33407. } | AbstractMesh[]): Vector3;
  33408. /**
  33409. * Merge the array of meshes into a single mesh for performance reasons.
  33410. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  33411. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  33412. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  33413. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  33414. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  33415. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  33416. * @returns a new mesh
  33417. */
  33418. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  33419. /** @hidden */
  33420. addInstance(instance: InstancedMesh): void;
  33421. /** @hidden */
  33422. removeInstance(instance: InstancedMesh): void;
  33423. }
  33424. }
  33425. declare module BABYLON {
  33426. /**
  33427. * The options Interface for creating a Capsule Mesh
  33428. */
  33429. export interface ICreateCapsuleOptions {
  33430. /** The Orientation of the capsule. Default : Vector3.Up() */
  33431. orientation?: Vector3;
  33432. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  33433. subdivisions: number;
  33434. /** Number of cylindrical segments on the capsule. */
  33435. tessellation: number;
  33436. /** Height or Length of the capsule. */
  33437. height: number;
  33438. /** Radius of the capsule. */
  33439. radius: number;
  33440. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  33441. capSubdivisions: number;
  33442. /** Overwrite for the top radius. */
  33443. radiusTop?: number;
  33444. /** Overwrite for the bottom radius. */
  33445. radiusBottom?: number;
  33446. /** Overwrite for the top capSubdivisions. */
  33447. topCapSubdivisions?: number;
  33448. /** Overwrite for the bottom capSubdivisions. */
  33449. bottomCapSubdivisions?: number;
  33450. }
  33451. /**
  33452. * Class containing static functions to help procedurally build meshes
  33453. */
  33454. export class CapsuleBuilder {
  33455. /**
  33456. * Creates a capsule or a pill mesh
  33457. * @param name defines the name of the mesh
  33458. * @param options The constructors options.
  33459. * @param scene The scene the mesh is scoped to.
  33460. * @returns Capsule Mesh
  33461. */
  33462. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  33463. }
  33464. }
  33465. declare module BABYLON {
  33466. /**
  33467. * Define an interface for all classes that will get and set the data on vertices
  33468. */
  33469. export interface IGetSetVerticesData {
  33470. /**
  33471. * Gets a boolean indicating if specific vertex data is present
  33472. * @param kind defines the vertex data kind to use
  33473. * @returns true is data kind is present
  33474. */
  33475. isVerticesDataPresent(kind: string): boolean;
  33476. /**
  33477. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  33478. * @param kind defines the data kind (Position, normal, etc...)
  33479. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  33480. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33481. * @returns a float array containing vertex data
  33482. */
  33483. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  33484. /**
  33485. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  33486. * @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.
  33487. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33488. * @returns the indices array or an empty array if the mesh has no geometry
  33489. */
  33490. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  33491. /**
  33492. * Set specific vertex data
  33493. * @param kind defines the data kind (Position, normal, etc...)
  33494. * @param data defines the vertex data to use
  33495. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  33496. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  33497. */
  33498. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  33499. /**
  33500. * Update a specific associated vertex buffer
  33501. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33502. * - VertexBuffer.PositionKind
  33503. * - VertexBuffer.UVKind
  33504. * - VertexBuffer.UV2Kind
  33505. * - VertexBuffer.UV3Kind
  33506. * - VertexBuffer.UV4Kind
  33507. * - VertexBuffer.UV5Kind
  33508. * - VertexBuffer.UV6Kind
  33509. * - VertexBuffer.ColorKind
  33510. * - VertexBuffer.MatricesIndicesKind
  33511. * - VertexBuffer.MatricesIndicesExtraKind
  33512. * - VertexBuffer.MatricesWeightsKind
  33513. * - VertexBuffer.MatricesWeightsExtraKind
  33514. * @param data defines the data source
  33515. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  33516. * @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)
  33517. */
  33518. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  33519. /**
  33520. * Creates a new index buffer
  33521. * @param indices defines the indices to store in the index buffer
  33522. * @param totalVertices defines the total number of vertices (could be null)
  33523. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  33524. */
  33525. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  33526. }
  33527. /**
  33528. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  33529. */
  33530. export class VertexData {
  33531. /**
  33532. * Mesh side orientation : usually the external or front surface
  33533. */
  33534. static readonly FRONTSIDE: number;
  33535. /**
  33536. * Mesh side orientation : usually the internal or back surface
  33537. */
  33538. static readonly BACKSIDE: number;
  33539. /**
  33540. * Mesh side orientation : both internal and external or front and back surfaces
  33541. */
  33542. static readonly DOUBLESIDE: number;
  33543. /**
  33544. * Mesh side orientation : by default, `FRONTSIDE`
  33545. */
  33546. static readonly DEFAULTSIDE: number;
  33547. /**
  33548. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  33549. */
  33550. positions: Nullable<FloatArray>;
  33551. /**
  33552. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  33553. */
  33554. normals: Nullable<FloatArray>;
  33555. /**
  33556. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  33557. */
  33558. tangents: Nullable<FloatArray>;
  33559. /**
  33560. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33561. */
  33562. uvs: Nullable<FloatArray>;
  33563. /**
  33564. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33565. */
  33566. uvs2: Nullable<FloatArray>;
  33567. /**
  33568. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33569. */
  33570. uvs3: Nullable<FloatArray>;
  33571. /**
  33572. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33573. */
  33574. uvs4: Nullable<FloatArray>;
  33575. /**
  33576. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33577. */
  33578. uvs5: Nullable<FloatArray>;
  33579. /**
  33580. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33581. */
  33582. uvs6: Nullable<FloatArray>;
  33583. /**
  33584. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  33585. */
  33586. colors: Nullable<FloatArray>;
  33587. /**
  33588. * 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).
  33589. */
  33590. matricesIndices: Nullable<FloatArray>;
  33591. /**
  33592. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  33593. */
  33594. matricesWeights: Nullable<FloatArray>;
  33595. /**
  33596. * An array extending the number of possible indices
  33597. */
  33598. matricesIndicesExtra: Nullable<FloatArray>;
  33599. /**
  33600. * An array extending the number of possible weights when the number of indices is extended
  33601. */
  33602. matricesWeightsExtra: Nullable<FloatArray>;
  33603. /**
  33604. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  33605. */
  33606. indices: Nullable<IndicesArray>;
  33607. /**
  33608. * Uses the passed data array to set the set the values for the specified kind of data
  33609. * @param data a linear array of floating numbers
  33610. * @param kind the type of data that is being set, eg positions, colors etc
  33611. */
  33612. set(data: FloatArray, kind: string): void;
  33613. /**
  33614. * Associates the vertexData to the passed Mesh.
  33615. * Sets it as updatable or not (default `false`)
  33616. * @param mesh the mesh the vertexData is applied to
  33617. * @param updatable when used and having the value true allows new data to update the vertexData
  33618. * @returns the VertexData
  33619. */
  33620. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  33621. /**
  33622. * Associates the vertexData to the passed Geometry.
  33623. * Sets it as updatable or not (default `false`)
  33624. * @param geometry the geometry the vertexData is applied to
  33625. * @param updatable when used and having the value true allows new data to update the vertexData
  33626. * @returns VertexData
  33627. */
  33628. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  33629. /**
  33630. * Updates the associated mesh
  33631. * @param mesh the mesh to be updated
  33632. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  33633. * @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
  33634. * @returns VertexData
  33635. */
  33636. updateMesh(mesh: Mesh): VertexData;
  33637. /**
  33638. * Updates the associated geometry
  33639. * @param geometry the geometry to be updated
  33640. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  33641. * @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
  33642. * @returns VertexData.
  33643. */
  33644. updateGeometry(geometry: Geometry): VertexData;
  33645. private _applyTo;
  33646. private _update;
  33647. /**
  33648. * Transforms each position and each normal of the vertexData according to the passed Matrix
  33649. * @param matrix the transforming matrix
  33650. * @returns the VertexData
  33651. */
  33652. transform(matrix: Matrix): VertexData;
  33653. /**
  33654. * Merges the passed VertexData into the current one
  33655. * @param other the VertexData to be merged into the current one
  33656. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  33657. * @returns the modified VertexData
  33658. */
  33659. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  33660. private _mergeElement;
  33661. private _validate;
  33662. /**
  33663. * Serializes the VertexData
  33664. * @returns a serialized object
  33665. */
  33666. serialize(): any;
  33667. /**
  33668. * Extracts the vertexData from a mesh
  33669. * @param mesh the mesh from which to extract the VertexData
  33670. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  33671. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  33672. * @returns the object VertexData associated to the passed mesh
  33673. */
  33674. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  33675. /**
  33676. * Extracts the vertexData from the geometry
  33677. * @param geometry the geometry from which to extract the VertexData
  33678. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  33679. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  33680. * @returns the object VertexData associated to the passed mesh
  33681. */
  33682. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  33683. private static _ExtractFrom;
  33684. /**
  33685. * Creates the VertexData for a Ribbon
  33686. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  33687. * * pathArray array of paths, each of which an array of successive Vector3
  33688. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  33689. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  33690. * * 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
  33691. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33692. * * 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)
  33693. * * 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)
  33694. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  33695. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  33696. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  33697. * @returns the VertexData of the ribbon
  33698. */
  33699. static CreateRibbon(options: {
  33700. pathArray: Vector3[][];
  33701. closeArray?: boolean;
  33702. closePath?: boolean;
  33703. offset?: number;
  33704. sideOrientation?: number;
  33705. frontUVs?: Vector4;
  33706. backUVs?: Vector4;
  33707. invertUV?: boolean;
  33708. uvs?: Vector2[];
  33709. colors?: Color4[];
  33710. }): VertexData;
  33711. /**
  33712. * Creates the VertexData for a box
  33713. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33714. * * size sets the width, height and depth of the box to the value of size, optional default 1
  33715. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  33716. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  33717. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  33718. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  33719. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  33720. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33721. * * 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)
  33722. * * 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)
  33723. * @returns the VertexData of the box
  33724. */
  33725. static CreateBox(options: {
  33726. size?: number;
  33727. width?: number;
  33728. height?: number;
  33729. depth?: number;
  33730. faceUV?: Vector4[];
  33731. faceColors?: Color4[];
  33732. sideOrientation?: number;
  33733. frontUVs?: Vector4;
  33734. backUVs?: Vector4;
  33735. }): VertexData;
  33736. /**
  33737. * Creates the VertexData for a tiled box
  33738. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33739. * * faceTiles sets the pattern, tile size and number of tiles for a face
  33740. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  33741. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  33742. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33743. * @returns the VertexData of the box
  33744. */
  33745. static CreateTiledBox(options: {
  33746. pattern?: number;
  33747. width?: number;
  33748. height?: number;
  33749. depth?: number;
  33750. tileSize?: number;
  33751. tileWidth?: number;
  33752. tileHeight?: number;
  33753. alignHorizontal?: number;
  33754. alignVertical?: number;
  33755. faceUV?: Vector4[];
  33756. faceColors?: Color4[];
  33757. sideOrientation?: number;
  33758. }): VertexData;
  33759. /**
  33760. * Creates the VertexData for a tiled plane
  33761. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33762. * * pattern a limited pattern arrangement depending on the number
  33763. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  33764. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  33765. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  33766. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33767. * * 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)
  33768. * * 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)
  33769. * @returns the VertexData of the tiled plane
  33770. */
  33771. static CreateTiledPlane(options: {
  33772. pattern?: number;
  33773. tileSize?: number;
  33774. tileWidth?: number;
  33775. tileHeight?: number;
  33776. size?: number;
  33777. width?: number;
  33778. height?: number;
  33779. alignHorizontal?: number;
  33780. alignVertical?: number;
  33781. sideOrientation?: number;
  33782. frontUVs?: Vector4;
  33783. backUVs?: Vector4;
  33784. }): VertexData;
  33785. /**
  33786. * Creates the VertexData for an ellipsoid, defaults to a sphere
  33787. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33788. * * segments sets the number of horizontal strips optional, default 32
  33789. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  33790. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  33791. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  33792. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  33793. * * 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
  33794. * * 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
  33795. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33796. * * 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)
  33797. * * 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)
  33798. * @returns the VertexData of the ellipsoid
  33799. */
  33800. static CreateSphere(options: {
  33801. segments?: number;
  33802. diameter?: number;
  33803. diameterX?: number;
  33804. diameterY?: number;
  33805. diameterZ?: number;
  33806. arc?: number;
  33807. slice?: number;
  33808. sideOrientation?: number;
  33809. frontUVs?: Vector4;
  33810. backUVs?: Vector4;
  33811. }): VertexData;
  33812. /**
  33813. * Creates the VertexData for a cylinder, cone or prism
  33814. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33815. * * height sets the height (y direction) of the cylinder, optional, default 2
  33816. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  33817. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  33818. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  33819. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  33820. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  33821. * * 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
  33822. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  33823. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  33824. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  33825. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  33826. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33827. * * 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)
  33828. * * 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)
  33829. * @returns the VertexData of the cylinder, cone or prism
  33830. */
  33831. static CreateCylinder(options: {
  33832. height?: number;
  33833. diameterTop?: number;
  33834. diameterBottom?: number;
  33835. diameter?: number;
  33836. tessellation?: number;
  33837. subdivisions?: number;
  33838. arc?: number;
  33839. faceColors?: Color4[];
  33840. faceUV?: Vector4[];
  33841. hasRings?: boolean;
  33842. enclose?: boolean;
  33843. sideOrientation?: number;
  33844. frontUVs?: Vector4;
  33845. backUVs?: Vector4;
  33846. }): VertexData;
  33847. /**
  33848. * Creates the VertexData for a torus
  33849. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33850. * * diameter the diameter of the torus, optional default 1
  33851. * * thickness the diameter of the tube forming the torus, optional default 0.5
  33852. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  33853. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33854. * * 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)
  33855. * * 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)
  33856. * @returns the VertexData of the torus
  33857. */
  33858. static CreateTorus(options: {
  33859. diameter?: number;
  33860. thickness?: number;
  33861. tessellation?: number;
  33862. sideOrientation?: number;
  33863. frontUVs?: Vector4;
  33864. backUVs?: Vector4;
  33865. }): VertexData;
  33866. /**
  33867. * Creates the VertexData of the LineSystem
  33868. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  33869. * - lines an array of lines, each line being an array of successive Vector3
  33870. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  33871. * @returns the VertexData of the LineSystem
  33872. */
  33873. static CreateLineSystem(options: {
  33874. lines: Vector3[][];
  33875. colors?: Nullable<Color4[][]>;
  33876. }): VertexData;
  33877. /**
  33878. * Create the VertexData for a DashedLines
  33879. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  33880. * - points an array successive Vector3
  33881. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  33882. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  33883. * - dashNb the intended total number of dashes, optional, default 200
  33884. * @returns the VertexData for the DashedLines
  33885. */
  33886. static CreateDashedLines(options: {
  33887. points: Vector3[];
  33888. dashSize?: number;
  33889. gapSize?: number;
  33890. dashNb?: number;
  33891. }): VertexData;
  33892. /**
  33893. * Creates the VertexData for a Ground
  33894. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  33895. * - width the width (x direction) of the ground, optional, default 1
  33896. * - height the height (z direction) of the ground, optional, default 1
  33897. * - subdivisions the number of subdivisions per side, optional, default 1
  33898. * @returns the VertexData of the Ground
  33899. */
  33900. static CreateGround(options: {
  33901. width?: number;
  33902. height?: number;
  33903. subdivisions?: number;
  33904. subdivisionsX?: number;
  33905. subdivisionsY?: number;
  33906. }): VertexData;
  33907. /**
  33908. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  33909. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  33910. * * xmin the ground minimum X coordinate, optional, default -1
  33911. * * zmin the ground minimum Z coordinate, optional, default -1
  33912. * * xmax the ground maximum X coordinate, optional, default 1
  33913. * * zmax the ground maximum Z coordinate, optional, default 1
  33914. * * 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}
  33915. * * 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}
  33916. * @returns the VertexData of the TiledGround
  33917. */
  33918. static CreateTiledGround(options: {
  33919. xmin: number;
  33920. zmin: number;
  33921. xmax: number;
  33922. zmax: number;
  33923. subdivisions?: {
  33924. w: number;
  33925. h: number;
  33926. };
  33927. precision?: {
  33928. w: number;
  33929. h: number;
  33930. };
  33931. }): VertexData;
  33932. /**
  33933. * Creates the VertexData of the Ground designed from a heightmap
  33934. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  33935. * * width the width (x direction) of the ground
  33936. * * height the height (z direction) of the ground
  33937. * * subdivisions the number of subdivisions per side
  33938. * * minHeight the minimum altitude on the ground, optional, default 0
  33939. * * maxHeight the maximum altitude on the ground, optional default 1
  33940. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  33941. * * buffer the array holding the image color data
  33942. * * bufferWidth the width of image
  33943. * * bufferHeight the height of image
  33944. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  33945. * @returns the VertexData of the Ground designed from a heightmap
  33946. */
  33947. static CreateGroundFromHeightMap(options: {
  33948. width: number;
  33949. height: number;
  33950. subdivisions: number;
  33951. minHeight: number;
  33952. maxHeight: number;
  33953. colorFilter: Color3;
  33954. buffer: Uint8Array;
  33955. bufferWidth: number;
  33956. bufferHeight: number;
  33957. alphaFilter: number;
  33958. }): VertexData;
  33959. /**
  33960. * Creates the VertexData for a Plane
  33961. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  33962. * * size sets the width and height of the plane to the value of size, optional default 1
  33963. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  33964. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  33965. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33966. * * 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)
  33967. * * 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)
  33968. * @returns the VertexData of the box
  33969. */
  33970. static CreatePlane(options: {
  33971. size?: number;
  33972. width?: number;
  33973. height?: number;
  33974. sideOrientation?: number;
  33975. frontUVs?: Vector4;
  33976. backUVs?: Vector4;
  33977. }): VertexData;
  33978. /**
  33979. * Creates the VertexData of the Disc or regular Polygon
  33980. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  33981. * * radius the radius of the disc, optional default 0.5
  33982. * * tessellation the number of polygon sides, optional, default 64
  33983. * * 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
  33984. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33985. * * 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)
  33986. * * 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)
  33987. * @returns the VertexData of the box
  33988. */
  33989. static CreateDisc(options: {
  33990. radius?: number;
  33991. tessellation?: number;
  33992. arc?: number;
  33993. sideOrientation?: number;
  33994. frontUVs?: Vector4;
  33995. backUVs?: Vector4;
  33996. }): VertexData;
  33997. /**
  33998. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  33999. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  34000. * @param polygon a mesh built from polygonTriangulation.build()
  34001. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34002. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34003. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34004. * @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)
  34005. * @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)
  34006. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  34007. * @returns the VertexData of the Polygon
  34008. */
  34009. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  34010. /**
  34011. * Creates the VertexData of the IcoSphere
  34012. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  34013. * * radius the radius of the IcoSphere, optional default 1
  34014. * * radiusX allows stretching in the x direction, optional, default radius
  34015. * * radiusY allows stretching in the y direction, optional, default radius
  34016. * * radiusZ allows stretching in the z direction, optional, default radius
  34017. * * flat when true creates a flat shaded mesh, optional, default true
  34018. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  34019. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34020. * * 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)
  34021. * * 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)
  34022. * @returns the VertexData of the IcoSphere
  34023. */
  34024. static CreateIcoSphere(options: {
  34025. radius?: number;
  34026. radiusX?: number;
  34027. radiusY?: number;
  34028. radiusZ?: number;
  34029. flat?: boolean;
  34030. subdivisions?: number;
  34031. sideOrientation?: number;
  34032. frontUVs?: Vector4;
  34033. backUVs?: Vector4;
  34034. }): VertexData;
  34035. /**
  34036. * Creates the VertexData for a Polyhedron
  34037. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  34038. * * type provided types are:
  34039. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  34040. * * 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)
  34041. * * size the size of the IcoSphere, optional default 1
  34042. * * sizeX allows stretching in the x direction, optional, default size
  34043. * * sizeY allows stretching in the y direction, optional, default size
  34044. * * sizeZ allows stretching in the z direction, optional, default size
  34045. * * 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
  34046. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34047. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34048. * * flat when true creates a flat shaded mesh, optional, default true
  34049. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  34050. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34051. * * 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)
  34052. * * 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)
  34053. * @returns the VertexData of the Polyhedron
  34054. */
  34055. static CreatePolyhedron(options: {
  34056. type?: number;
  34057. size?: number;
  34058. sizeX?: number;
  34059. sizeY?: number;
  34060. sizeZ?: number;
  34061. custom?: any;
  34062. faceUV?: Vector4[];
  34063. faceColors?: Color4[];
  34064. flat?: boolean;
  34065. sideOrientation?: number;
  34066. frontUVs?: Vector4;
  34067. backUVs?: Vector4;
  34068. }): VertexData;
  34069. /**
  34070. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  34071. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  34072. * @returns the VertexData of the Capsule
  34073. */
  34074. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  34075. /**
  34076. * Creates the VertexData for a TorusKnot
  34077. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  34078. * * radius the radius of the torus knot, optional, default 2
  34079. * * tube the thickness of the tube, optional, default 0.5
  34080. * * radialSegments the number of sides on each tube segments, optional, default 32
  34081. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  34082. * * p the number of windings around the z axis, optional, default 2
  34083. * * q the number of windings around the x axis, optional, default 3
  34084. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34085. * * 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)
  34086. * * 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)
  34087. * @returns the VertexData of the Torus Knot
  34088. */
  34089. static CreateTorusKnot(options: {
  34090. radius?: number;
  34091. tube?: number;
  34092. radialSegments?: number;
  34093. tubularSegments?: number;
  34094. p?: number;
  34095. q?: number;
  34096. sideOrientation?: number;
  34097. frontUVs?: Vector4;
  34098. backUVs?: Vector4;
  34099. }): VertexData;
  34100. /**
  34101. * Compute normals for given positions and indices
  34102. * @param positions an array of vertex positions, [...., x, y, z, ......]
  34103. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  34104. * @param normals an array of vertex normals, [...., x, y, z, ......]
  34105. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  34106. * * facetNormals : optional array of facet normals (vector3)
  34107. * * facetPositions : optional array of facet positions (vector3)
  34108. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  34109. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  34110. * * bInfo : optional bounding info, required for facetPartitioning computation
  34111. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  34112. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  34113. * * useRightHandedSystem: optional boolean to for right handed system computation
  34114. * * depthSort : optional boolean to enable the facet depth sort computation
  34115. * * distanceTo : optional Vector3 to compute the facet depth from this location
  34116. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  34117. */
  34118. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  34119. facetNormals?: any;
  34120. facetPositions?: any;
  34121. facetPartitioning?: any;
  34122. ratio?: number;
  34123. bInfo?: any;
  34124. bbSize?: Vector3;
  34125. subDiv?: any;
  34126. useRightHandedSystem?: boolean;
  34127. depthSort?: boolean;
  34128. distanceTo?: Vector3;
  34129. depthSortedFacets?: any;
  34130. }): void;
  34131. /** @hidden */
  34132. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  34133. /**
  34134. * Applies VertexData created from the imported parameters to the geometry
  34135. * @param parsedVertexData the parsed data from an imported file
  34136. * @param geometry the geometry to apply the VertexData to
  34137. */
  34138. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  34139. }
  34140. }
  34141. declare module BABYLON {
  34142. /**
  34143. * Class containing static functions to help procedurally build meshes
  34144. */
  34145. export class DiscBuilder {
  34146. /**
  34147. * Creates a plane polygonal mesh. By default, this is a disc
  34148. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  34149. * * 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
  34150. * * 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
  34151. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34152. * * 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
  34153. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34154. * @param name defines the name of the mesh
  34155. * @param options defines the options used to create the mesh
  34156. * @param scene defines the hosting scene
  34157. * @returns the plane polygonal mesh
  34158. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  34159. */
  34160. static CreateDisc(name: string, options: {
  34161. radius?: number;
  34162. tessellation?: number;
  34163. arc?: number;
  34164. updatable?: boolean;
  34165. sideOrientation?: number;
  34166. frontUVs?: Vector4;
  34167. backUVs?: Vector4;
  34168. }, scene?: Nullable<Scene>): Mesh;
  34169. }
  34170. }
  34171. declare module BABYLON {
  34172. /**
  34173. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  34174. *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.
  34175. * The SPS is also a particle system. It provides some methods to manage the particles.
  34176. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  34177. *
  34178. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  34179. */
  34180. export class SolidParticleSystem implements IDisposable {
  34181. /**
  34182. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  34183. * Example : var p = SPS.particles[i];
  34184. */
  34185. particles: SolidParticle[];
  34186. /**
  34187. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  34188. */
  34189. nbParticles: number;
  34190. /**
  34191. * If the particles must ever face the camera (default false). Useful for planar particles.
  34192. */
  34193. billboard: boolean;
  34194. /**
  34195. * Recompute normals when adding a shape
  34196. */
  34197. recomputeNormals: boolean;
  34198. /**
  34199. * This a counter ofr your own usage. It's not set by any SPS functions.
  34200. */
  34201. counter: number;
  34202. /**
  34203. * The SPS name. This name is also given to the underlying mesh.
  34204. */
  34205. name: string;
  34206. /**
  34207. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  34208. */
  34209. mesh: Mesh;
  34210. /**
  34211. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  34212. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  34213. */
  34214. vars: any;
  34215. /**
  34216. * This array is populated when the SPS is set as 'pickable'.
  34217. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  34218. * Each element of this array is an object `{idx: int, faceId: int}`.
  34219. * `idx` is the picked particle index in the `SPS.particles` array
  34220. * `faceId` is the picked face index counted within this particle.
  34221. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  34222. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  34223. * Use the method SPS.pickedParticle(pickingInfo) instead.
  34224. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34225. */
  34226. pickedParticles: {
  34227. idx: number;
  34228. faceId: number;
  34229. }[];
  34230. /**
  34231. * This array is populated when the SPS is set as 'pickable'
  34232. * Each key of this array is a submesh index.
  34233. * Each element of this array is a second array defined like this :
  34234. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  34235. * Each element of this second array is an object `{idx: int, faceId: int}`.
  34236. * `idx` is the picked particle index in the `SPS.particles` array
  34237. * `faceId` is the picked face index counted within this particle.
  34238. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  34239. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34240. */
  34241. pickedBySubMesh: {
  34242. idx: number;
  34243. faceId: number;
  34244. }[][];
  34245. /**
  34246. * This array is populated when `enableDepthSort` is set to true.
  34247. * Each element of this array is an instance of the class DepthSortedParticle.
  34248. */
  34249. depthSortedParticles: DepthSortedParticle[];
  34250. /**
  34251. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  34252. * @hidden
  34253. */
  34254. _bSphereOnly: boolean;
  34255. /**
  34256. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  34257. * @hidden
  34258. */
  34259. _bSphereRadiusFactor: number;
  34260. private _scene;
  34261. private _positions;
  34262. private _indices;
  34263. private _normals;
  34264. private _colors;
  34265. private _uvs;
  34266. private _indices32;
  34267. private _positions32;
  34268. private _normals32;
  34269. private _fixedNormal32;
  34270. private _colors32;
  34271. private _uvs32;
  34272. private _index;
  34273. private _updatable;
  34274. private _pickable;
  34275. private _isVisibilityBoxLocked;
  34276. private _alwaysVisible;
  34277. private _depthSort;
  34278. private _expandable;
  34279. private _shapeCounter;
  34280. private _copy;
  34281. private _color;
  34282. private _computeParticleColor;
  34283. private _computeParticleTexture;
  34284. private _computeParticleRotation;
  34285. private _computeParticleVertex;
  34286. private _computeBoundingBox;
  34287. private _depthSortParticles;
  34288. private _camera;
  34289. private _mustUnrotateFixedNormals;
  34290. private _particlesIntersect;
  34291. private _needs32Bits;
  34292. private _isNotBuilt;
  34293. private _lastParticleId;
  34294. private _idxOfId;
  34295. private _multimaterialEnabled;
  34296. private _useModelMaterial;
  34297. private _indicesByMaterial;
  34298. private _materialIndexes;
  34299. private _depthSortFunction;
  34300. private _materialSortFunction;
  34301. private _materials;
  34302. private _multimaterial;
  34303. private _materialIndexesById;
  34304. private _defaultMaterial;
  34305. private _autoUpdateSubMeshes;
  34306. private _tmpVertex;
  34307. /**
  34308. * Creates a SPS (Solid Particle System) object.
  34309. * @param name (String) is the SPS name, this will be the underlying mesh name.
  34310. * @param scene (Scene) is the scene in which the SPS is added.
  34311. * @param options defines the options of the sps e.g.
  34312. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  34313. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  34314. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  34315. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  34316. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  34317. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  34318. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  34319. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  34320. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  34321. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  34322. */
  34323. constructor(name: string, scene: Scene, options?: {
  34324. updatable?: boolean;
  34325. isPickable?: boolean;
  34326. enableDepthSort?: boolean;
  34327. particleIntersection?: boolean;
  34328. boundingSphereOnly?: boolean;
  34329. bSphereRadiusFactor?: number;
  34330. expandable?: boolean;
  34331. useModelMaterial?: boolean;
  34332. enableMultiMaterial?: boolean;
  34333. });
  34334. /**
  34335. * Builds the SPS underlying mesh. Returns a standard Mesh.
  34336. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  34337. * @returns the created mesh
  34338. */
  34339. buildMesh(): Mesh;
  34340. /**
  34341. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  34342. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  34343. * Thus the particles generated from `digest()` have their property `position` set yet.
  34344. * @param mesh ( Mesh ) is the mesh to be digested
  34345. * @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
  34346. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  34347. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  34348. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34349. * @returns the current SPS
  34350. */
  34351. digest(mesh: Mesh, options?: {
  34352. facetNb?: number;
  34353. number?: number;
  34354. delta?: number;
  34355. storage?: [];
  34356. }): SolidParticleSystem;
  34357. /**
  34358. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  34359. * @hidden
  34360. */
  34361. private _unrotateFixedNormals;
  34362. /**
  34363. * Resets the temporary working copy particle
  34364. * @hidden
  34365. */
  34366. private _resetCopy;
  34367. /**
  34368. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  34369. * @param p the current index in the positions array to be updated
  34370. * @param ind the current index in the indices array
  34371. * @param shape a Vector3 array, the shape geometry
  34372. * @param positions the positions array to be updated
  34373. * @param meshInd the shape indices array
  34374. * @param indices the indices array to be updated
  34375. * @param meshUV the shape uv array
  34376. * @param uvs the uv array to be updated
  34377. * @param meshCol the shape color array
  34378. * @param colors the color array to be updated
  34379. * @param meshNor the shape normals array
  34380. * @param normals the normals array to be updated
  34381. * @param idx the particle index
  34382. * @param idxInShape the particle index in its shape
  34383. * @param options the addShape() method passed options
  34384. * @model the particle model
  34385. * @hidden
  34386. */
  34387. private _meshBuilder;
  34388. /**
  34389. * Returns a shape Vector3 array from positions float array
  34390. * @param positions float array
  34391. * @returns a vector3 array
  34392. * @hidden
  34393. */
  34394. private _posToShape;
  34395. /**
  34396. * Returns a shapeUV array from a float uvs (array deep copy)
  34397. * @param uvs as a float array
  34398. * @returns a shapeUV array
  34399. * @hidden
  34400. */
  34401. private _uvsToShapeUV;
  34402. /**
  34403. * Adds a new particle object in the particles array
  34404. * @param idx particle index in particles array
  34405. * @param id particle id
  34406. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  34407. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  34408. * @param model particle ModelShape object
  34409. * @param shapeId model shape identifier
  34410. * @param idxInShape index of the particle in the current model
  34411. * @param bInfo model bounding info object
  34412. * @param storage target storage array, if any
  34413. * @hidden
  34414. */
  34415. private _addParticle;
  34416. /**
  34417. * Adds some particles to the SPS from the model shape. Returns the shape id.
  34418. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  34419. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  34420. * @param nb (positive integer) the number of particles to be created from this model
  34421. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  34422. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  34423. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34424. * @returns the number of shapes in the system
  34425. */
  34426. addShape(mesh: Mesh, nb: number, options?: {
  34427. positionFunction?: any;
  34428. vertexFunction?: any;
  34429. storage?: [];
  34430. }): number;
  34431. /**
  34432. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  34433. * @hidden
  34434. */
  34435. private _rebuildParticle;
  34436. /**
  34437. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  34438. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  34439. * @returns the SPS.
  34440. */
  34441. rebuildMesh(reset?: boolean): SolidParticleSystem;
  34442. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  34443. * Returns an array with the removed particles.
  34444. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  34445. * The SPS can't be empty so at least one particle needs to remain in place.
  34446. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  34447. * @param start index of the first particle to remove
  34448. * @param end index of the last particle to remove (included)
  34449. * @returns an array populated with the removed particles
  34450. */
  34451. removeParticles(start: number, end: number): SolidParticle[];
  34452. /**
  34453. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  34454. * @param solidParticleArray an array populated with Solid Particles objects
  34455. * @returns the SPS
  34456. */
  34457. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  34458. /**
  34459. * Creates a new particle and modifies the SPS mesh geometry :
  34460. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  34461. * - calls _addParticle() to populate the particle array
  34462. * factorized code from addShape() and insertParticlesFromArray()
  34463. * @param idx particle index in the particles array
  34464. * @param i particle index in its shape
  34465. * @param modelShape particle ModelShape object
  34466. * @param shape shape vertex array
  34467. * @param meshInd shape indices array
  34468. * @param meshUV shape uv array
  34469. * @param meshCol shape color array
  34470. * @param meshNor shape normals array
  34471. * @param bbInfo shape bounding info
  34472. * @param storage target particle storage
  34473. * @options addShape() passed options
  34474. * @hidden
  34475. */
  34476. private _insertNewParticle;
  34477. /**
  34478. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  34479. * This method calls `updateParticle()` for each particle of the SPS.
  34480. * For an animated SPS, it is usually called within the render loop.
  34481. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  34482. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  34483. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  34484. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  34485. * @returns the SPS.
  34486. */
  34487. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  34488. /**
  34489. * Disposes the SPS.
  34490. */
  34491. dispose(): void;
  34492. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  34493. * idx is the particle index in the SPS
  34494. * faceId is the picked face index counted within this particle.
  34495. * Returns null if the pickInfo can't identify a picked particle.
  34496. * @param pickingInfo (PickingInfo object)
  34497. * @returns {idx: number, faceId: number} or null
  34498. */
  34499. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  34500. idx: number;
  34501. faceId: number;
  34502. }>;
  34503. /**
  34504. * Returns a SolidParticle object from its identifier : particle.id
  34505. * @param id (integer) the particle Id
  34506. * @returns the searched particle or null if not found in the SPS.
  34507. */
  34508. getParticleById(id: number): Nullable<SolidParticle>;
  34509. /**
  34510. * Returns a new array populated with the particles having the passed shapeId.
  34511. * @param shapeId (integer) the shape identifier
  34512. * @returns a new solid particle array
  34513. */
  34514. getParticlesByShapeId(shapeId: number): SolidParticle[];
  34515. /**
  34516. * Populates the passed array "ref" with the particles having the passed shapeId.
  34517. * @param shapeId the shape identifier
  34518. * @returns the SPS
  34519. * @param ref
  34520. */
  34521. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  34522. /**
  34523. * Computes the required SubMeshes according the materials assigned to the particles.
  34524. * @returns the solid particle system.
  34525. * Does nothing if called before the SPS mesh is built.
  34526. */
  34527. computeSubMeshes(): SolidParticleSystem;
  34528. /**
  34529. * Sorts the solid particles by material when MultiMaterial is enabled.
  34530. * Updates the indices32 array.
  34531. * Updates the indicesByMaterial array.
  34532. * Updates the mesh indices array.
  34533. * @returns the SPS
  34534. * @hidden
  34535. */
  34536. private _sortParticlesByMaterial;
  34537. /**
  34538. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  34539. * @hidden
  34540. */
  34541. private _setMaterialIndexesById;
  34542. /**
  34543. * Returns an array with unique values of Materials from the passed array
  34544. * @param array the material array to be checked and filtered
  34545. * @hidden
  34546. */
  34547. private _filterUniqueMaterialId;
  34548. /**
  34549. * Sets a new Standard Material as _defaultMaterial if not already set.
  34550. * @hidden
  34551. */
  34552. private _setDefaultMaterial;
  34553. /**
  34554. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  34555. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34556. * @returns the SPS.
  34557. */
  34558. refreshVisibleSize(): SolidParticleSystem;
  34559. /**
  34560. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  34561. * @param size the size (float) of the visibility box
  34562. * note : this doesn't lock the SPS mesh bounding box.
  34563. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34564. */
  34565. setVisibilityBox(size: number): void;
  34566. /**
  34567. * Gets whether the SPS as always visible or not
  34568. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34569. */
  34570. get isAlwaysVisible(): boolean;
  34571. /**
  34572. * Sets the SPS as always visible or not
  34573. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34574. */
  34575. set isAlwaysVisible(val: boolean);
  34576. /**
  34577. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34578. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34579. */
  34580. set isVisibilityBoxLocked(val: boolean);
  34581. /**
  34582. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34583. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34584. */
  34585. get isVisibilityBoxLocked(): boolean;
  34586. /**
  34587. * Tells to `setParticles()` to compute the particle rotations or not.
  34588. * Default value : true. The SPS is faster when it's set to false.
  34589. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34590. */
  34591. set computeParticleRotation(val: boolean);
  34592. /**
  34593. * Tells to `setParticles()` to compute the particle colors or not.
  34594. * Default value : true. The SPS is faster when it's set to false.
  34595. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34596. */
  34597. set computeParticleColor(val: boolean);
  34598. set computeParticleTexture(val: boolean);
  34599. /**
  34600. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  34601. * Default value : false. The SPS is faster when it's set to false.
  34602. * Note : the particle custom vertex positions aren't stored values.
  34603. */
  34604. set computeParticleVertex(val: boolean);
  34605. /**
  34606. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  34607. */
  34608. set computeBoundingBox(val: boolean);
  34609. /**
  34610. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  34611. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34612. * Default : `true`
  34613. */
  34614. set depthSortParticles(val: boolean);
  34615. /**
  34616. * Gets if `setParticles()` computes the particle rotations or not.
  34617. * Default value : true. The SPS is faster when it's set to false.
  34618. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34619. */
  34620. get computeParticleRotation(): boolean;
  34621. /**
  34622. * Gets if `setParticles()` computes the particle colors or not.
  34623. * Default value : true. The SPS is faster when it's set to false.
  34624. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34625. */
  34626. get computeParticleColor(): boolean;
  34627. /**
  34628. * Gets if `setParticles()` computes the particle textures or not.
  34629. * Default value : true. The SPS is faster when it's set to false.
  34630. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  34631. */
  34632. get computeParticleTexture(): boolean;
  34633. /**
  34634. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  34635. * Default value : false. The SPS is faster when it's set to false.
  34636. * Note : the particle custom vertex positions aren't stored values.
  34637. */
  34638. get computeParticleVertex(): boolean;
  34639. /**
  34640. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  34641. */
  34642. get computeBoundingBox(): boolean;
  34643. /**
  34644. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  34645. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34646. * Default : `true`
  34647. */
  34648. get depthSortParticles(): boolean;
  34649. /**
  34650. * Gets if the SPS is created as expandable at construction time.
  34651. * Default : `false`
  34652. */
  34653. get expandable(): boolean;
  34654. /**
  34655. * Gets if the SPS supports the Multi Materials
  34656. */
  34657. get multimaterialEnabled(): boolean;
  34658. /**
  34659. * Gets if the SPS uses the model materials for its own multimaterial.
  34660. */
  34661. get useModelMaterial(): boolean;
  34662. /**
  34663. * The SPS used material array.
  34664. */
  34665. get materials(): Material[];
  34666. /**
  34667. * Sets the SPS MultiMaterial from the passed materials.
  34668. * Note : the passed array is internally copied and not used then by reference.
  34669. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  34670. */
  34671. setMultiMaterial(materials: Material[]): void;
  34672. /**
  34673. * The SPS computed multimaterial object
  34674. */
  34675. get multimaterial(): MultiMaterial;
  34676. set multimaterial(mm: MultiMaterial);
  34677. /**
  34678. * If the subMeshes must be updated on the next call to setParticles()
  34679. */
  34680. get autoUpdateSubMeshes(): boolean;
  34681. set autoUpdateSubMeshes(val: boolean);
  34682. /**
  34683. * This function does nothing. It may be overwritten to set all the particle first values.
  34684. * The SPS doesn't call this function, you may have to call it by your own.
  34685. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34686. */
  34687. initParticles(): void;
  34688. /**
  34689. * This function does nothing. It may be overwritten to recycle a particle.
  34690. * The SPS doesn't call this function, you may have to call it by your own.
  34691. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34692. * @param particle The particle to recycle
  34693. * @returns the recycled particle
  34694. */
  34695. recycleParticle(particle: SolidParticle): SolidParticle;
  34696. /**
  34697. * Updates a particle : this function should be overwritten by the user.
  34698. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  34699. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34700. * @example : just set a particle position or velocity and recycle conditions
  34701. * @param particle The particle to update
  34702. * @returns the updated particle
  34703. */
  34704. updateParticle(particle: SolidParticle): SolidParticle;
  34705. /**
  34706. * Updates a vertex of a particle : it can be overwritten by the user.
  34707. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  34708. * @param particle the current particle
  34709. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  34710. * @param pt the index of the current vertex in the particle shape
  34711. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  34712. * @example : just set a vertex particle position or color
  34713. * @returns the sps
  34714. */
  34715. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  34716. /**
  34717. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  34718. * This does nothing and may be overwritten by the user.
  34719. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34720. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34721. * @param update the boolean update value actually passed to setParticles()
  34722. */
  34723. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  34724. /**
  34725. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  34726. * This will be passed three parameters.
  34727. * This does nothing and may be overwritten by the user.
  34728. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34729. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34730. * @param update the boolean update value actually passed to setParticles()
  34731. */
  34732. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  34733. }
  34734. }
  34735. declare module BABYLON {
  34736. /**
  34737. * Represents one particle of a solid particle system.
  34738. */
  34739. export class SolidParticle {
  34740. /**
  34741. * particle global index
  34742. */
  34743. idx: number;
  34744. /**
  34745. * particle identifier
  34746. */
  34747. id: number;
  34748. /**
  34749. * The color of the particle
  34750. */
  34751. color: Nullable<Color4>;
  34752. /**
  34753. * The world space position of the particle.
  34754. */
  34755. position: Vector3;
  34756. /**
  34757. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  34758. */
  34759. rotation: Vector3;
  34760. /**
  34761. * The world space rotation quaternion of the particle.
  34762. */
  34763. rotationQuaternion: Nullable<Quaternion>;
  34764. /**
  34765. * The scaling of the particle.
  34766. */
  34767. scaling: Vector3;
  34768. /**
  34769. * The uvs of the particle.
  34770. */
  34771. uvs: Vector4;
  34772. /**
  34773. * The current speed of the particle.
  34774. */
  34775. velocity: Vector3;
  34776. /**
  34777. * The pivot point in the particle local space.
  34778. */
  34779. pivot: Vector3;
  34780. /**
  34781. * Must the particle be translated from its pivot point in its local space ?
  34782. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  34783. * Default : false
  34784. */
  34785. translateFromPivot: boolean;
  34786. /**
  34787. * Is the particle active or not ?
  34788. */
  34789. alive: boolean;
  34790. /**
  34791. * Is the particle visible or not ?
  34792. */
  34793. isVisible: boolean;
  34794. /**
  34795. * Index of this particle in the global "positions" array (Internal use)
  34796. * @hidden
  34797. */
  34798. _pos: number;
  34799. /**
  34800. * @hidden Index of this particle in the global "indices" array (Internal use)
  34801. */
  34802. _ind: number;
  34803. /**
  34804. * @hidden ModelShape of this particle (Internal use)
  34805. */
  34806. _model: ModelShape;
  34807. /**
  34808. * ModelShape id of this particle
  34809. */
  34810. shapeId: number;
  34811. /**
  34812. * Index of the particle in its shape id
  34813. */
  34814. idxInShape: number;
  34815. /**
  34816. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  34817. */
  34818. _modelBoundingInfo: BoundingInfo;
  34819. /**
  34820. * @hidden Particle BoundingInfo object (Internal use)
  34821. */
  34822. _boundingInfo: BoundingInfo;
  34823. /**
  34824. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  34825. */
  34826. _sps: SolidParticleSystem;
  34827. /**
  34828. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  34829. */
  34830. _stillInvisible: boolean;
  34831. /**
  34832. * @hidden Last computed particle rotation matrix
  34833. */
  34834. _rotationMatrix: number[];
  34835. /**
  34836. * Parent particle Id, if any.
  34837. * Default null.
  34838. */
  34839. parentId: Nullable<number>;
  34840. /**
  34841. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  34842. */
  34843. materialIndex: Nullable<number>;
  34844. /**
  34845. * Custom object or properties.
  34846. */
  34847. props: Nullable<any>;
  34848. /**
  34849. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  34850. * The possible values are :
  34851. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  34852. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  34853. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  34854. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  34855. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  34856. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  34857. * */
  34858. cullingStrategy: number;
  34859. /**
  34860. * @hidden Internal global position in the SPS.
  34861. */
  34862. _globalPosition: Vector3;
  34863. /**
  34864. * Creates a Solid Particle object.
  34865. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  34866. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  34867. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  34868. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  34869. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  34870. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  34871. * @param shapeId (integer) is the model shape identifier in the SPS.
  34872. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  34873. * @param sps defines the sps it is associated to
  34874. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  34875. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  34876. */
  34877. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  34878. /**
  34879. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  34880. * @param target the particle target
  34881. * @returns the current particle
  34882. */
  34883. copyToRef(target: SolidParticle): SolidParticle;
  34884. /**
  34885. * Legacy support, changed scale to scaling
  34886. */
  34887. get scale(): Vector3;
  34888. /**
  34889. * Legacy support, changed scale to scaling
  34890. */
  34891. set scale(scale: Vector3);
  34892. /**
  34893. * Legacy support, changed quaternion to rotationQuaternion
  34894. */
  34895. get quaternion(): Nullable<Quaternion>;
  34896. /**
  34897. * Legacy support, changed quaternion to rotationQuaternion
  34898. */
  34899. set quaternion(q: Nullable<Quaternion>);
  34900. /**
  34901. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  34902. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  34903. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  34904. * @returns true if it intersects
  34905. */
  34906. intersectsMesh(target: Mesh | SolidParticle): boolean;
  34907. /**
  34908. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  34909. * A particle is in the frustum if its bounding box intersects the frustum
  34910. * @param frustumPlanes defines the frustum to test
  34911. * @returns true if the particle is in the frustum planes
  34912. */
  34913. isInFrustum(frustumPlanes: Plane[]): boolean;
  34914. /**
  34915. * get the rotation matrix of the particle
  34916. * @hidden
  34917. */
  34918. getRotationMatrix(m: Matrix): void;
  34919. }
  34920. /**
  34921. * Represents the shape of the model used by one particle of a solid particle system.
  34922. * SPS internal tool, don't use it manually.
  34923. */
  34924. export class ModelShape {
  34925. /**
  34926. * The shape id
  34927. * @hidden
  34928. */
  34929. shapeID: number;
  34930. /**
  34931. * flat array of model positions (internal use)
  34932. * @hidden
  34933. */
  34934. _shape: Vector3[];
  34935. /**
  34936. * flat array of model UVs (internal use)
  34937. * @hidden
  34938. */
  34939. _shapeUV: number[];
  34940. /**
  34941. * color array of the model
  34942. * @hidden
  34943. */
  34944. _shapeColors: number[];
  34945. /**
  34946. * indices array of the model
  34947. * @hidden
  34948. */
  34949. _indices: number[];
  34950. /**
  34951. * normals array of the model
  34952. * @hidden
  34953. */
  34954. _normals: number[];
  34955. /**
  34956. * length of the shape in the model indices array (internal use)
  34957. * @hidden
  34958. */
  34959. _indicesLength: number;
  34960. /**
  34961. * Custom position function (internal use)
  34962. * @hidden
  34963. */
  34964. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  34965. /**
  34966. * Custom vertex function (internal use)
  34967. * @hidden
  34968. */
  34969. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  34970. /**
  34971. * Model material (internal use)
  34972. * @hidden
  34973. */
  34974. _material: Nullable<Material>;
  34975. /**
  34976. * 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.
  34977. * SPS internal tool, don't use it manually.
  34978. * @hidden
  34979. */
  34980. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  34981. }
  34982. /**
  34983. * Represents a Depth Sorted Particle in the solid particle system.
  34984. * @hidden
  34985. */
  34986. export class DepthSortedParticle {
  34987. /**
  34988. * Particle index
  34989. */
  34990. idx: number;
  34991. /**
  34992. * Index of the particle in the "indices" array
  34993. */
  34994. ind: number;
  34995. /**
  34996. * Length of the particle shape in the "indices" array
  34997. */
  34998. indicesLength: number;
  34999. /**
  35000. * Squared distance from the particle to the camera
  35001. */
  35002. sqDistance: number;
  35003. /**
  35004. * Material index when used with MultiMaterials
  35005. */
  35006. materialIndex: number;
  35007. /**
  35008. * Creates a new sorted particle
  35009. * @param materialIndex
  35010. */
  35011. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  35012. }
  35013. /**
  35014. * Represents a solid particle vertex
  35015. */
  35016. export class SolidParticleVertex {
  35017. /**
  35018. * Vertex position
  35019. */
  35020. position: Vector3;
  35021. /**
  35022. * Vertex color
  35023. */
  35024. color: Color4;
  35025. /**
  35026. * Vertex UV
  35027. */
  35028. uv: Vector2;
  35029. /**
  35030. * Creates a new solid particle vertex
  35031. */
  35032. constructor();
  35033. /** Vertex x coordinate */
  35034. get x(): number;
  35035. set x(val: number);
  35036. /** Vertex y coordinate */
  35037. get y(): number;
  35038. set y(val: number);
  35039. /** Vertex z coordinate */
  35040. get z(): number;
  35041. set z(val: number);
  35042. }
  35043. }
  35044. declare module BABYLON {
  35045. /**
  35046. * @hidden
  35047. */
  35048. export class _MeshCollisionData {
  35049. _checkCollisions: boolean;
  35050. _collisionMask: number;
  35051. _collisionGroup: number;
  35052. _surroundingMeshes: Nullable<AbstractMesh[]>;
  35053. _collider: Nullable<Collider>;
  35054. _oldPositionForCollisions: Vector3;
  35055. _diffPositionForCollisions: Vector3;
  35056. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  35057. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  35058. _collisionResponse: boolean;
  35059. }
  35060. }
  35061. declare module BABYLON {
  35062. /** @hidden */
  35063. class _FacetDataStorage {
  35064. facetPositions: Vector3[];
  35065. facetNormals: Vector3[];
  35066. facetPartitioning: number[][];
  35067. facetNb: number;
  35068. partitioningSubdivisions: number;
  35069. partitioningBBoxRatio: number;
  35070. facetDataEnabled: boolean;
  35071. facetParameters: any;
  35072. bbSize: Vector3;
  35073. subDiv: {
  35074. max: number;
  35075. X: number;
  35076. Y: number;
  35077. Z: number;
  35078. };
  35079. facetDepthSort: boolean;
  35080. facetDepthSortEnabled: boolean;
  35081. depthSortedIndices: IndicesArray;
  35082. depthSortedFacets: {
  35083. ind: number;
  35084. sqDistance: number;
  35085. }[];
  35086. facetDepthSortFunction: (f1: {
  35087. ind: number;
  35088. sqDistance: number;
  35089. }, f2: {
  35090. ind: number;
  35091. sqDistance: number;
  35092. }) => number;
  35093. facetDepthSortFrom: Vector3;
  35094. facetDepthSortOrigin: Vector3;
  35095. invertedMatrix: Matrix;
  35096. }
  35097. /**
  35098. * @hidden
  35099. **/
  35100. class _InternalAbstractMeshDataInfo {
  35101. _hasVertexAlpha: boolean;
  35102. _useVertexColors: boolean;
  35103. _numBoneInfluencers: number;
  35104. _applyFog: boolean;
  35105. _receiveShadows: boolean;
  35106. _facetData: _FacetDataStorage;
  35107. _visibility: number;
  35108. _skeleton: Nullable<Skeleton>;
  35109. _layerMask: number;
  35110. _computeBonesUsingShaders: boolean;
  35111. _isActive: boolean;
  35112. _onlyForInstances: boolean;
  35113. _isActiveIntermediate: boolean;
  35114. _onlyForInstancesIntermediate: boolean;
  35115. _actAsRegularMesh: boolean;
  35116. _currentLOD: Nullable<AbstractMesh>;
  35117. _currentLODIsUpToDate: boolean;
  35118. }
  35119. /**
  35120. * Class used to store all common mesh properties
  35121. */
  35122. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  35123. /** No occlusion */
  35124. static OCCLUSION_TYPE_NONE: number;
  35125. /** Occlusion set to optimisitic */
  35126. static OCCLUSION_TYPE_OPTIMISTIC: number;
  35127. /** Occlusion set to strict */
  35128. static OCCLUSION_TYPE_STRICT: number;
  35129. /** Use an accurante occlusion algorithm */
  35130. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  35131. /** Use a conservative occlusion algorithm */
  35132. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  35133. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  35134. * Test order :
  35135. * Is the bounding sphere outside the frustum ?
  35136. * If not, are the bounding box vertices outside the frustum ?
  35137. * It not, then the cullable object is in the frustum.
  35138. */
  35139. static readonly CULLINGSTRATEGY_STANDARD: number;
  35140. /** Culling strategy : Bounding Sphere Only.
  35141. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  35142. * It's also less accurate than the standard because some not visible objects can still be selected.
  35143. * Test : is the bounding sphere outside the frustum ?
  35144. * If not, then the cullable object is in the frustum.
  35145. */
  35146. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  35147. /** Culling strategy : Optimistic Inclusion.
  35148. * This in an inclusion test first, then the standard exclusion test.
  35149. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  35150. * 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.
  35151. * Anyway, it's as accurate as the standard strategy.
  35152. * Test :
  35153. * Is the cullable object bounding sphere center in the frustum ?
  35154. * If not, apply the default culling strategy.
  35155. */
  35156. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  35157. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  35158. * This in an inclusion test first, then the bounding sphere only exclusion test.
  35159. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  35160. * 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.
  35161. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  35162. * Test :
  35163. * Is the cullable object bounding sphere center in the frustum ?
  35164. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  35165. */
  35166. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  35167. /**
  35168. * No billboard
  35169. */
  35170. static get BILLBOARDMODE_NONE(): number;
  35171. /** Billboard on X axis */
  35172. static get BILLBOARDMODE_X(): number;
  35173. /** Billboard on Y axis */
  35174. static get BILLBOARDMODE_Y(): number;
  35175. /** Billboard on Z axis */
  35176. static get BILLBOARDMODE_Z(): number;
  35177. /** Billboard on all axes */
  35178. static get BILLBOARDMODE_ALL(): number;
  35179. /** Billboard on using position instead of orientation */
  35180. static get BILLBOARDMODE_USE_POSITION(): number;
  35181. /** @hidden */
  35182. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  35183. /**
  35184. * The culling strategy to use to check whether the mesh must be rendered or not.
  35185. * This value can be changed at any time and will be used on the next render mesh selection.
  35186. * The possible values are :
  35187. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35188. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35189. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35190. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35191. * Please read each static variable documentation to get details about the culling process.
  35192. * */
  35193. cullingStrategy: number;
  35194. /**
  35195. * Gets the number of facets in the mesh
  35196. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35197. */
  35198. get facetNb(): number;
  35199. /**
  35200. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  35201. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35202. */
  35203. get partitioningSubdivisions(): number;
  35204. set partitioningSubdivisions(nb: number);
  35205. /**
  35206. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  35207. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  35208. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35209. */
  35210. get partitioningBBoxRatio(): number;
  35211. set partitioningBBoxRatio(ratio: number);
  35212. /**
  35213. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  35214. * Works only for updatable meshes.
  35215. * Doesn't work with multi-materials
  35216. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35217. */
  35218. get mustDepthSortFacets(): boolean;
  35219. set mustDepthSortFacets(sort: boolean);
  35220. /**
  35221. * The location (Vector3) where the facet depth sort must be computed from.
  35222. * By default, the active camera position.
  35223. * Used only when facet depth sort is enabled
  35224. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35225. */
  35226. get facetDepthSortFrom(): Vector3;
  35227. set facetDepthSortFrom(location: Vector3);
  35228. /**
  35229. * gets a boolean indicating if facetData is enabled
  35230. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35231. */
  35232. get isFacetDataEnabled(): boolean;
  35233. /** @hidden */
  35234. _updateNonUniformScalingState(value: boolean): boolean;
  35235. /**
  35236. * An event triggered when this mesh collides with another one
  35237. */
  35238. onCollideObservable: Observable<AbstractMesh>;
  35239. /** Set a function to call when this mesh collides with another one */
  35240. set onCollide(callback: () => void);
  35241. /**
  35242. * An event triggered when the collision's position changes
  35243. */
  35244. onCollisionPositionChangeObservable: Observable<Vector3>;
  35245. /** Set a function to call when the collision's position changes */
  35246. set onCollisionPositionChange(callback: () => void);
  35247. /**
  35248. * An event triggered when material is changed
  35249. */
  35250. onMaterialChangedObservable: Observable<AbstractMesh>;
  35251. /**
  35252. * Gets or sets the orientation for POV movement & rotation
  35253. */
  35254. definedFacingForward: boolean;
  35255. /** @hidden */
  35256. _occlusionQuery: Nullable<WebGLQuery>;
  35257. /** @hidden */
  35258. _renderingGroup: Nullable<RenderingGroup>;
  35259. /**
  35260. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35261. */
  35262. get visibility(): number;
  35263. /**
  35264. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35265. */
  35266. set visibility(value: number);
  35267. /** Gets or sets the alpha index used to sort transparent meshes
  35268. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  35269. */
  35270. alphaIndex: number;
  35271. /**
  35272. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  35273. */
  35274. isVisible: boolean;
  35275. /**
  35276. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  35277. */
  35278. isPickable: boolean;
  35279. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  35280. showSubMeshesBoundingBox: boolean;
  35281. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  35282. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  35283. */
  35284. isBlocker: boolean;
  35285. /**
  35286. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  35287. */
  35288. enablePointerMoveEvents: boolean;
  35289. private _renderingGroupId;
  35290. /**
  35291. * Specifies the rendering group id for this mesh (0 by default)
  35292. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  35293. */
  35294. get renderingGroupId(): number;
  35295. set renderingGroupId(value: number);
  35296. private _material;
  35297. /** Gets or sets current material */
  35298. get material(): Nullable<Material>;
  35299. set material(value: Nullable<Material>);
  35300. /**
  35301. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  35302. * @see https://doc.babylonjs.com/babylon101/shadows
  35303. */
  35304. get receiveShadows(): boolean;
  35305. set receiveShadows(value: boolean);
  35306. /** Defines color to use when rendering outline */
  35307. outlineColor: Color3;
  35308. /** Define width to use when rendering outline */
  35309. outlineWidth: number;
  35310. /** Defines color to use when rendering overlay */
  35311. overlayColor: Color3;
  35312. /** Defines alpha to use when rendering overlay */
  35313. overlayAlpha: number;
  35314. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  35315. get hasVertexAlpha(): boolean;
  35316. set hasVertexAlpha(value: boolean);
  35317. /** 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) */
  35318. get useVertexColors(): boolean;
  35319. set useVertexColors(value: boolean);
  35320. /**
  35321. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  35322. */
  35323. get computeBonesUsingShaders(): boolean;
  35324. set computeBonesUsingShaders(value: boolean);
  35325. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  35326. get numBoneInfluencers(): number;
  35327. set numBoneInfluencers(value: number);
  35328. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  35329. get applyFog(): boolean;
  35330. set applyFog(value: boolean);
  35331. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  35332. useOctreeForRenderingSelection: boolean;
  35333. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  35334. useOctreeForPicking: boolean;
  35335. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  35336. useOctreeForCollisions: boolean;
  35337. /**
  35338. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  35339. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  35340. */
  35341. get layerMask(): number;
  35342. set layerMask(value: number);
  35343. /**
  35344. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  35345. */
  35346. alwaysSelectAsActiveMesh: boolean;
  35347. /**
  35348. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  35349. */
  35350. doNotSyncBoundingInfo: boolean;
  35351. /**
  35352. * Gets or sets the current action manager
  35353. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  35354. */
  35355. actionManager: Nullable<AbstractActionManager>;
  35356. private _meshCollisionData;
  35357. /**
  35358. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  35359. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35360. */
  35361. ellipsoid: Vector3;
  35362. /**
  35363. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  35364. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35365. */
  35366. ellipsoidOffset: Vector3;
  35367. /**
  35368. * Gets or sets a collision mask used to mask collisions (default is -1).
  35369. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35370. */
  35371. get collisionMask(): number;
  35372. set collisionMask(mask: number);
  35373. /**
  35374. * Gets or sets a collision response flag (default is true).
  35375. * when collisionResponse is false, events are still triggered but colliding entity has no response
  35376. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  35377. * to respond to the collision.
  35378. */
  35379. get collisionResponse(): boolean;
  35380. set collisionResponse(response: boolean);
  35381. /**
  35382. * Gets or sets the current collision group mask (-1 by default).
  35383. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35384. */
  35385. get collisionGroup(): number;
  35386. set collisionGroup(mask: number);
  35387. /**
  35388. * Gets or sets current surrounding meshes (null by default).
  35389. *
  35390. * By default collision detection is tested against every mesh in the scene.
  35391. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  35392. * meshes will be tested for the collision.
  35393. *
  35394. * Note: if set to an empty array no collision will happen when this mesh is moved.
  35395. */
  35396. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  35397. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  35398. /**
  35399. * Defines edge width used when edgesRenderer is enabled
  35400. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35401. */
  35402. edgesWidth: number;
  35403. /**
  35404. * Defines edge color used when edgesRenderer is enabled
  35405. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35406. */
  35407. edgesColor: Color4;
  35408. /** @hidden */
  35409. _edgesRenderer: Nullable<IEdgesRenderer>;
  35410. /** @hidden */
  35411. _masterMesh: Nullable<AbstractMesh>;
  35412. /** @hidden */
  35413. _boundingInfo: Nullable<BoundingInfo>;
  35414. /** @hidden */
  35415. _renderId: number;
  35416. /**
  35417. * Gets or sets the list of subMeshes
  35418. * @see https://doc.babylonjs.com/how_to/multi_materials
  35419. */
  35420. subMeshes: SubMesh[];
  35421. /** @hidden */
  35422. _intersectionsInProgress: AbstractMesh[];
  35423. /** @hidden */
  35424. _unIndexed: boolean;
  35425. /** @hidden */
  35426. _lightSources: Light[];
  35427. /** Gets the list of lights affecting that mesh */
  35428. get lightSources(): Light[];
  35429. /** @hidden */
  35430. get _positions(): Nullable<Vector3[]>;
  35431. /** @hidden */
  35432. _waitingData: {
  35433. lods: Nullable<any>;
  35434. actions: Nullable<any>;
  35435. freezeWorldMatrix: Nullable<boolean>;
  35436. };
  35437. /** @hidden */
  35438. _bonesTransformMatrices: Nullable<Float32Array>;
  35439. /** @hidden */
  35440. _transformMatrixTexture: Nullable<RawTexture>;
  35441. /**
  35442. * Gets or sets a skeleton to apply skining transformations
  35443. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35444. */
  35445. set skeleton(value: Nullable<Skeleton>);
  35446. get skeleton(): Nullable<Skeleton>;
  35447. /**
  35448. * An event triggered when the mesh is rebuilt.
  35449. */
  35450. onRebuildObservable: Observable<AbstractMesh>;
  35451. /**
  35452. * Creates a new AbstractMesh
  35453. * @param name defines the name of the mesh
  35454. * @param scene defines the hosting scene
  35455. */
  35456. constructor(name: string, scene?: Nullable<Scene>);
  35457. /**
  35458. * Returns the string "AbstractMesh"
  35459. * @returns "AbstractMesh"
  35460. */
  35461. getClassName(): string;
  35462. /**
  35463. * Gets a string representation of the current mesh
  35464. * @param fullDetails defines a boolean indicating if full details must be included
  35465. * @returns a string representation of the current mesh
  35466. */
  35467. toString(fullDetails?: boolean): string;
  35468. /**
  35469. * @hidden
  35470. */
  35471. protected _getEffectiveParent(): Nullable<Node>;
  35472. /** @hidden */
  35473. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  35474. /** @hidden */
  35475. _rebuild(): void;
  35476. /** @hidden */
  35477. _resyncLightSources(): void;
  35478. /** @hidden */
  35479. _resyncLightSource(light: Light): void;
  35480. /** @hidden */
  35481. _unBindEffect(): void;
  35482. /** @hidden */
  35483. _removeLightSource(light: Light, dispose: boolean): void;
  35484. private _markSubMeshesAsDirty;
  35485. /** @hidden */
  35486. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  35487. /** @hidden */
  35488. _markSubMeshesAsAttributesDirty(): void;
  35489. /** @hidden */
  35490. _markSubMeshesAsMiscDirty(): void;
  35491. /**
  35492. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  35493. */
  35494. get scaling(): Vector3;
  35495. set scaling(newScaling: Vector3);
  35496. /**
  35497. * Returns true if the mesh is blocked. Implemented by child classes
  35498. */
  35499. get isBlocked(): boolean;
  35500. /**
  35501. * Returns the mesh itself by default. Implemented by child classes
  35502. * @param camera defines the camera to use to pick the right LOD level
  35503. * @returns the currentAbstractMesh
  35504. */
  35505. getLOD(camera: Camera): Nullable<AbstractMesh>;
  35506. /**
  35507. * Returns 0 by default. Implemented by child classes
  35508. * @returns an integer
  35509. */
  35510. getTotalVertices(): number;
  35511. /**
  35512. * Returns a positive integer : the total number of indices in this mesh geometry.
  35513. * @returns the numner of indices or zero if the mesh has no geometry.
  35514. */
  35515. getTotalIndices(): number;
  35516. /**
  35517. * Returns null by default. Implemented by child classes
  35518. * @returns null
  35519. */
  35520. getIndices(): Nullable<IndicesArray>;
  35521. /**
  35522. * Returns the array of the requested vertex data kind. Implemented by child classes
  35523. * @param kind defines the vertex data kind to use
  35524. * @returns null
  35525. */
  35526. getVerticesData(kind: string): Nullable<FloatArray>;
  35527. /**
  35528. * Sets the vertex data of the mesh geometry for the requested `kind`.
  35529. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  35530. * Note that a new underlying VertexBuffer object is created each call.
  35531. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  35532. * @param kind defines vertex data kind:
  35533. * * VertexBuffer.PositionKind
  35534. * * VertexBuffer.UVKind
  35535. * * VertexBuffer.UV2Kind
  35536. * * VertexBuffer.UV3Kind
  35537. * * VertexBuffer.UV4Kind
  35538. * * VertexBuffer.UV5Kind
  35539. * * VertexBuffer.UV6Kind
  35540. * * VertexBuffer.ColorKind
  35541. * * VertexBuffer.MatricesIndicesKind
  35542. * * VertexBuffer.MatricesIndicesExtraKind
  35543. * * VertexBuffer.MatricesWeightsKind
  35544. * * VertexBuffer.MatricesWeightsExtraKind
  35545. * @param data defines the data source
  35546. * @param updatable defines if the data must be flagged as updatable (or static)
  35547. * @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
  35548. * @returns the current mesh
  35549. */
  35550. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  35551. /**
  35552. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  35553. * If the mesh has no geometry, it is simply returned as it is.
  35554. * @param kind defines vertex data kind:
  35555. * * VertexBuffer.PositionKind
  35556. * * VertexBuffer.UVKind
  35557. * * VertexBuffer.UV2Kind
  35558. * * VertexBuffer.UV3Kind
  35559. * * VertexBuffer.UV4Kind
  35560. * * VertexBuffer.UV5Kind
  35561. * * VertexBuffer.UV6Kind
  35562. * * VertexBuffer.ColorKind
  35563. * * VertexBuffer.MatricesIndicesKind
  35564. * * VertexBuffer.MatricesIndicesExtraKind
  35565. * * VertexBuffer.MatricesWeightsKind
  35566. * * VertexBuffer.MatricesWeightsExtraKind
  35567. * @param data defines the data source
  35568. * @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
  35569. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  35570. * @returns the current mesh
  35571. */
  35572. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  35573. /**
  35574. * Sets the mesh indices,
  35575. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  35576. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  35577. * @param totalVertices Defines the total number of vertices
  35578. * @returns the current mesh
  35579. */
  35580. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  35581. /**
  35582. * Gets a boolean indicating if specific vertex data is present
  35583. * @param kind defines the vertex data kind to use
  35584. * @returns true is data kind is present
  35585. */
  35586. isVerticesDataPresent(kind: string): boolean;
  35587. /**
  35588. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  35589. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  35590. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  35591. * @returns a BoundingInfo
  35592. */
  35593. getBoundingInfo(): BoundingInfo;
  35594. /**
  35595. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  35596. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  35597. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  35598. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  35599. * @returns the current mesh
  35600. */
  35601. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  35602. /**
  35603. * Overwrite the current bounding info
  35604. * @param boundingInfo defines the new bounding info
  35605. * @returns the current mesh
  35606. */
  35607. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  35608. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  35609. get useBones(): boolean;
  35610. /** @hidden */
  35611. _preActivate(): void;
  35612. /** @hidden */
  35613. _preActivateForIntermediateRendering(renderId: number): void;
  35614. /** @hidden */
  35615. _activate(renderId: number, intermediateRendering: boolean): boolean;
  35616. /** @hidden */
  35617. _postActivate(): void;
  35618. /** @hidden */
  35619. _freeze(): void;
  35620. /** @hidden */
  35621. _unFreeze(): void;
  35622. /**
  35623. * Gets the current world matrix
  35624. * @returns a Matrix
  35625. */
  35626. getWorldMatrix(): Matrix;
  35627. /** @hidden */
  35628. _getWorldMatrixDeterminant(): number;
  35629. /**
  35630. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  35631. */
  35632. get isAnInstance(): boolean;
  35633. /**
  35634. * Gets a boolean indicating if this mesh has instances
  35635. */
  35636. get hasInstances(): boolean;
  35637. /**
  35638. * Gets a boolean indicating if this mesh has thin instances
  35639. */
  35640. get hasThinInstances(): boolean;
  35641. /**
  35642. * Perform relative position change from the point of view of behind the front of the mesh.
  35643. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35644. * Supports definition of mesh facing forward or backward
  35645. * @param amountRight defines the distance on the right axis
  35646. * @param amountUp defines the distance on the up axis
  35647. * @param amountForward defines the distance on the forward axis
  35648. * @returns the current mesh
  35649. */
  35650. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  35651. /**
  35652. * Calculate relative position change from the point of view of behind the front of the mesh.
  35653. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35654. * Supports definition of mesh facing forward or backward
  35655. * @param amountRight defines the distance on the right axis
  35656. * @param amountUp defines the distance on the up axis
  35657. * @param amountForward defines the distance on the forward axis
  35658. * @returns the new displacement vector
  35659. */
  35660. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  35661. /**
  35662. * Perform relative rotation change from the point of view of behind the front of the mesh.
  35663. * Supports definition of mesh facing forward or backward
  35664. * @param flipBack defines the flip
  35665. * @param twirlClockwise defines the twirl
  35666. * @param tiltRight defines the tilt
  35667. * @returns the current mesh
  35668. */
  35669. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  35670. /**
  35671. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  35672. * Supports definition of mesh facing forward or backward.
  35673. * @param flipBack defines the flip
  35674. * @param twirlClockwise defines the twirl
  35675. * @param tiltRight defines the tilt
  35676. * @returns the new rotation vector
  35677. */
  35678. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  35679. /**
  35680. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  35681. * This means the mesh underlying bounding box and sphere are recomputed.
  35682. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  35683. * @returns the current mesh
  35684. */
  35685. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  35686. /** @hidden */
  35687. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  35688. /** @hidden */
  35689. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  35690. /** @hidden */
  35691. _updateBoundingInfo(): AbstractMesh;
  35692. /** @hidden */
  35693. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  35694. /** @hidden */
  35695. protected _afterComputeWorldMatrix(): void;
  35696. /** @hidden */
  35697. get _effectiveMesh(): AbstractMesh;
  35698. /**
  35699. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  35700. * A mesh is in the frustum if its bounding box intersects the frustum
  35701. * @param frustumPlanes defines the frustum to test
  35702. * @returns true if the mesh is in the frustum planes
  35703. */
  35704. isInFrustum(frustumPlanes: Plane[]): boolean;
  35705. /**
  35706. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  35707. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  35708. * @param frustumPlanes defines the frustum to test
  35709. * @returns true if the mesh is completely in the frustum planes
  35710. */
  35711. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  35712. /**
  35713. * True if the mesh intersects another mesh or a SolidParticle object
  35714. * @param mesh defines a target mesh or SolidParticle to test
  35715. * @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)
  35716. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  35717. * @returns true if there is an intersection
  35718. */
  35719. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  35720. /**
  35721. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  35722. * @param point defines the point to test
  35723. * @returns true if there is an intersection
  35724. */
  35725. intersectsPoint(point: Vector3): boolean;
  35726. /**
  35727. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  35728. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35729. */
  35730. get checkCollisions(): boolean;
  35731. set checkCollisions(collisionEnabled: boolean);
  35732. /**
  35733. * Gets Collider object used to compute collisions (not physics)
  35734. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35735. */
  35736. get collider(): Nullable<Collider>;
  35737. /**
  35738. * Move the mesh using collision engine
  35739. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35740. * @param displacement defines the requested displacement vector
  35741. * @returns the current mesh
  35742. */
  35743. moveWithCollisions(displacement: Vector3): AbstractMesh;
  35744. private _onCollisionPositionChange;
  35745. /** @hidden */
  35746. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  35747. /** @hidden */
  35748. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  35749. /** @hidden */
  35750. _checkCollision(collider: Collider): AbstractMesh;
  35751. /** @hidden */
  35752. _generatePointsArray(): boolean;
  35753. /**
  35754. * Checks if the passed Ray intersects with the mesh
  35755. * @param ray defines the ray to use
  35756. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  35757. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35758. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  35759. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  35760. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  35761. * @returns the picking info
  35762. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  35763. */
  35764. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  35765. /**
  35766. * Clones the current mesh
  35767. * @param name defines the mesh name
  35768. * @param newParent defines the new mesh parent
  35769. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  35770. * @returns the new mesh
  35771. */
  35772. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  35773. /**
  35774. * Disposes all the submeshes of the current meshnp
  35775. * @returns the current mesh
  35776. */
  35777. releaseSubMeshes(): AbstractMesh;
  35778. /**
  35779. * Releases resources associated with this abstract mesh.
  35780. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  35781. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  35782. */
  35783. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  35784. /**
  35785. * Adds the passed mesh as a child to the current mesh
  35786. * @param mesh defines the child mesh
  35787. * @returns the current mesh
  35788. */
  35789. addChild(mesh: AbstractMesh): AbstractMesh;
  35790. /**
  35791. * Removes the passed mesh from the current mesh children list
  35792. * @param mesh defines the child mesh
  35793. * @returns the current mesh
  35794. */
  35795. removeChild(mesh: AbstractMesh): AbstractMesh;
  35796. /** @hidden */
  35797. private _initFacetData;
  35798. /**
  35799. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  35800. * This method can be called within the render loop.
  35801. * 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
  35802. * @returns the current mesh
  35803. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35804. */
  35805. updateFacetData(): AbstractMesh;
  35806. /**
  35807. * Returns the facetLocalNormals array.
  35808. * The normals are expressed in the mesh local spac
  35809. * @returns an array of Vector3
  35810. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35811. */
  35812. getFacetLocalNormals(): Vector3[];
  35813. /**
  35814. * Returns the facetLocalPositions array.
  35815. * The facet positions are expressed in the mesh local space
  35816. * @returns an array of Vector3
  35817. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35818. */
  35819. getFacetLocalPositions(): Vector3[];
  35820. /**
  35821. * Returns the facetLocalPartioning array
  35822. * @returns an array of array of numbers
  35823. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35824. */
  35825. getFacetLocalPartitioning(): number[][];
  35826. /**
  35827. * Returns the i-th facet position in the world system.
  35828. * This method allocates a new Vector3 per call
  35829. * @param i defines the facet index
  35830. * @returns a new Vector3
  35831. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35832. */
  35833. getFacetPosition(i: number): Vector3;
  35834. /**
  35835. * Sets the reference Vector3 with the i-th facet position in the world system
  35836. * @param i defines the facet index
  35837. * @param ref defines the target vector
  35838. * @returns the current mesh
  35839. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35840. */
  35841. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  35842. /**
  35843. * Returns the i-th facet normal in the world system.
  35844. * This method allocates a new Vector3 per call
  35845. * @param i defines the facet index
  35846. * @returns a new Vector3
  35847. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35848. */
  35849. getFacetNormal(i: number): Vector3;
  35850. /**
  35851. * Sets the reference Vector3 with the i-th facet normal in the world system
  35852. * @param i defines the facet index
  35853. * @param ref defines the target vector
  35854. * @returns the current mesh
  35855. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35856. */
  35857. getFacetNormalToRef(i: number, ref: Vector3): this;
  35858. /**
  35859. * 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)
  35860. * @param x defines x coordinate
  35861. * @param y defines y coordinate
  35862. * @param z defines z coordinate
  35863. * @returns the array of facet indexes
  35864. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35865. */
  35866. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  35867. /**
  35868. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  35869. * @param projected sets as the (x,y,z) world projection on the facet
  35870. * @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
  35871. * @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
  35872. * @param x defines x coordinate
  35873. * @param y defines y coordinate
  35874. * @param z defines z coordinate
  35875. * @returns the face index if found (or null instead)
  35876. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35877. */
  35878. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  35879. /**
  35880. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  35881. * @param projected sets as the (x,y,z) local projection on the facet
  35882. * @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
  35883. * @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
  35884. * @param x defines x coordinate
  35885. * @param y defines y coordinate
  35886. * @param z defines z coordinate
  35887. * @returns the face index if found (or null instead)
  35888. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35889. */
  35890. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  35891. /**
  35892. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  35893. * @returns the parameters
  35894. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35895. */
  35896. getFacetDataParameters(): any;
  35897. /**
  35898. * Disables the feature FacetData and frees the related memory
  35899. * @returns the current mesh
  35900. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35901. */
  35902. disableFacetData(): AbstractMesh;
  35903. /**
  35904. * Updates the AbstractMesh indices array
  35905. * @param indices defines the data source
  35906. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  35907. * @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)
  35908. * @returns the current mesh
  35909. */
  35910. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  35911. /**
  35912. * Creates new normals data for the mesh
  35913. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  35914. * @returns the current mesh
  35915. */
  35916. createNormals(updatable: boolean): AbstractMesh;
  35917. /**
  35918. * Align the mesh with a normal
  35919. * @param normal defines the normal to use
  35920. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  35921. * @returns the current mesh
  35922. */
  35923. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  35924. /** @hidden */
  35925. _checkOcclusionQuery(): boolean;
  35926. /**
  35927. * Disables the mesh edge rendering mode
  35928. * @returns the currentAbstractMesh
  35929. */
  35930. disableEdgesRendering(): AbstractMesh;
  35931. /**
  35932. * Enables the edge rendering mode on the mesh.
  35933. * This mode makes the mesh edges visible
  35934. * @param epsilon defines the maximal distance between two angles to detect a face
  35935. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  35936. * @param options options to the edge renderer
  35937. * @returns the currentAbstractMesh
  35938. * @see https://www.babylonjs-playground.com/#19O9TU#0
  35939. */
  35940. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  35941. /**
  35942. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  35943. * @returns an array of particle systems in the scene that use the mesh as an emitter
  35944. */
  35945. getConnectedParticleSystems(): IParticleSystem[];
  35946. }
  35947. }
  35948. declare module BABYLON {
  35949. /**
  35950. * Interface used to define ActionEvent
  35951. */
  35952. export interface IActionEvent {
  35953. /** The mesh or sprite that triggered the action */
  35954. source: any;
  35955. /** The X mouse cursor position at the time of the event */
  35956. pointerX: number;
  35957. /** The Y mouse cursor position at the time of the event */
  35958. pointerY: number;
  35959. /** The mesh that is currently pointed at (can be null) */
  35960. meshUnderPointer: Nullable<AbstractMesh>;
  35961. /** the original (browser) event that triggered the ActionEvent */
  35962. sourceEvent?: any;
  35963. /** additional data for the event */
  35964. additionalData?: any;
  35965. }
  35966. /**
  35967. * ActionEvent is the event being sent when an action is triggered.
  35968. */
  35969. export class ActionEvent implements IActionEvent {
  35970. /** The mesh or sprite that triggered the action */
  35971. source: any;
  35972. /** The X mouse cursor position at the time of the event */
  35973. pointerX: number;
  35974. /** The Y mouse cursor position at the time of the event */
  35975. pointerY: number;
  35976. /** The mesh that is currently pointed at (can be null) */
  35977. meshUnderPointer: Nullable<AbstractMesh>;
  35978. /** the original (browser) event that triggered the ActionEvent */
  35979. sourceEvent?: any;
  35980. /** additional data for the event */
  35981. additionalData?: any;
  35982. /**
  35983. * Creates a new ActionEvent
  35984. * @param source The mesh or sprite that triggered the action
  35985. * @param pointerX The X mouse cursor position at the time of the event
  35986. * @param pointerY The Y mouse cursor position at the time of the event
  35987. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  35988. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  35989. * @param additionalData additional data for the event
  35990. */
  35991. constructor(
  35992. /** The mesh or sprite that triggered the action */
  35993. source: any,
  35994. /** The X mouse cursor position at the time of the event */
  35995. pointerX: number,
  35996. /** The Y mouse cursor position at the time of the event */
  35997. pointerY: number,
  35998. /** The mesh that is currently pointed at (can be null) */
  35999. meshUnderPointer: Nullable<AbstractMesh>,
  36000. /** the original (browser) event that triggered the ActionEvent */
  36001. sourceEvent?: any,
  36002. /** additional data for the event */
  36003. additionalData?: any);
  36004. /**
  36005. * Helper function to auto-create an ActionEvent from a source mesh.
  36006. * @param source The source mesh that triggered the event
  36007. * @param evt The original (browser) event
  36008. * @param additionalData additional data for the event
  36009. * @returns the new ActionEvent
  36010. */
  36011. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  36012. /**
  36013. * Helper function to auto-create an ActionEvent from a source sprite
  36014. * @param source The source sprite that triggered the event
  36015. * @param scene Scene associated with the sprite
  36016. * @param evt The original (browser) event
  36017. * @param additionalData additional data for the event
  36018. * @returns the new ActionEvent
  36019. */
  36020. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  36021. /**
  36022. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  36023. * @param scene the scene where the event occurred
  36024. * @param evt The original (browser) event
  36025. * @returns the new ActionEvent
  36026. */
  36027. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  36028. /**
  36029. * Helper function to auto-create an ActionEvent from a primitive
  36030. * @param prim defines the target primitive
  36031. * @param pointerPos defines the pointer position
  36032. * @param evt The original (browser) event
  36033. * @param additionalData additional data for the event
  36034. * @returns the new ActionEvent
  36035. */
  36036. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  36037. }
  36038. }
  36039. declare module BABYLON {
  36040. /**
  36041. * Abstract class used to decouple action Manager from scene and meshes.
  36042. * Do not instantiate.
  36043. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36044. */
  36045. export abstract class AbstractActionManager implements IDisposable {
  36046. /** Gets the list of active triggers */
  36047. static Triggers: {
  36048. [key: string]: number;
  36049. };
  36050. /** Gets the cursor to use when hovering items */
  36051. hoverCursor: string;
  36052. /** Gets the list of actions */
  36053. actions: IAction[];
  36054. /**
  36055. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  36056. */
  36057. isRecursive: boolean;
  36058. /**
  36059. * Releases all associated resources
  36060. */
  36061. abstract dispose(): void;
  36062. /**
  36063. * Does this action manager has pointer triggers
  36064. */
  36065. abstract get hasPointerTriggers(): boolean;
  36066. /**
  36067. * Does this action manager has pick triggers
  36068. */
  36069. abstract get hasPickTriggers(): boolean;
  36070. /**
  36071. * Process a specific trigger
  36072. * @param trigger defines the trigger to process
  36073. * @param evt defines the event details to be processed
  36074. */
  36075. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  36076. /**
  36077. * Does this action manager handles actions of any of the given triggers
  36078. * @param triggers defines the triggers to be tested
  36079. * @return a boolean indicating whether one (or more) of the triggers is handled
  36080. */
  36081. abstract hasSpecificTriggers(triggers: number[]): boolean;
  36082. /**
  36083. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  36084. * speed.
  36085. * @param triggerA defines the trigger to be tested
  36086. * @param triggerB defines the trigger to be tested
  36087. * @return a boolean indicating whether one (or more) of the triggers is handled
  36088. */
  36089. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  36090. /**
  36091. * Does this action manager handles actions of a given trigger
  36092. * @param trigger defines the trigger to be tested
  36093. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  36094. * @return whether the trigger is handled
  36095. */
  36096. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  36097. /**
  36098. * Serialize this manager to a JSON object
  36099. * @param name defines the property name to store this manager
  36100. * @returns a JSON representation of this manager
  36101. */
  36102. abstract serialize(name: string): any;
  36103. /**
  36104. * Registers an action to this action manager
  36105. * @param action defines the action to be registered
  36106. * @return the action amended (prepared) after registration
  36107. */
  36108. abstract registerAction(action: IAction): Nullable<IAction>;
  36109. /**
  36110. * Unregisters an action to this action manager
  36111. * @param action defines the action to be unregistered
  36112. * @return a boolean indicating whether the action has been unregistered
  36113. */
  36114. abstract unregisterAction(action: IAction): Boolean;
  36115. /**
  36116. * Does exist one action manager with at least one trigger
  36117. **/
  36118. static get HasTriggers(): boolean;
  36119. /**
  36120. * Does exist one action manager with at least one pick trigger
  36121. **/
  36122. static get HasPickTriggers(): boolean;
  36123. /**
  36124. * Does exist one action manager that handles actions of a given trigger
  36125. * @param trigger defines the trigger to be tested
  36126. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  36127. **/
  36128. static HasSpecificTrigger(trigger: number): boolean;
  36129. }
  36130. }
  36131. declare module BABYLON {
  36132. /**
  36133. * Defines how a node can be built from a string name.
  36134. */
  36135. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  36136. /**
  36137. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  36138. */
  36139. export class Node implements IBehaviorAware<Node> {
  36140. /** @hidden */
  36141. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  36142. private static _NodeConstructors;
  36143. /**
  36144. * Add a new node constructor
  36145. * @param type defines the type name of the node to construct
  36146. * @param constructorFunc defines the constructor function
  36147. */
  36148. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  36149. /**
  36150. * Returns a node constructor based on type name
  36151. * @param type defines the type name
  36152. * @param name defines the new node name
  36153. * @param scene defines the hosting scene
  36154. * @param options defines optional options to transmit to constructors
  36155. * @returns the new constructor or null
  36156. */
  36157. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  36158. /**
  36159. * Gets or sets the name of the node
  36160. */
  36161. name: string;
  36162. /**
  36163. * Gets or sets the id of the node
  36164. */
  36165. id: string;
  36166. /**
  36167. * Gets or sets the unique id of the node
  36168. */
  36169. uniqueId: number;
  36170. /**
  36171. * Gets or sets a string used to store user defined state for the node
  36172. */
  36173. state: string;
  36174. /**
  36175. * Gets or sets an object used to store user defined information for the node
  36176. */
  36177. metadata: any;
  36178. /**
  36179. * For internal use only. Please do not use.
  36180. */
  36181. reservedDataStore: any;
  36182. /**
  36183. * List of inspectable custom properties (used by the Inspector)
  36184. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  36185. */
  36186. inspectableCustomProperties: IInspectable[];
  36187. private _doNotSerialize;
  36188. /**
  36189. * Gets or sets a boolean used to define if the node must be serialized
  36190. */
  36191. get doNotSerialize(): boolean;
  36192. set doNotSerialize(value: boolean);
  36193. /** @hidden */
  36194. _isDisposed: boolean;
  36195. /**
  36196. * Gets a list of Animations associated with the node
  36197. */
  36198. animations: Animation[];
  36199. protected _ranges: {
  36200. [name: string]: Nullable<AnimationRange>;
  36201. };
  36202. /**
  36203. * Callback raised when the node is ready to be used
  36204. */
  36205. onReady: Nullable<(node: Node) => void>;
  36206. private _isEnabled;
  36207. private _isParentEnabled;
  36208. private _isReady;
  36209. /** @hidden */
  36210. _currentRenderId: number;
  36211. private _parentUpdateId;
  36212. /** @hidden */
  36213. _childUpdateId: number;
  36214. /** @hidden */
  36215. _waitingParentId: Nullable<string>;
  36216. /** @hidden */
  36217. _scene: Scene;
  36218. /** @hidden */
  36219. _cache: any;
  36220. private _parentNode;
  36221. private _children;
  36222. /** @hidden */
  36223. _worldMatrix: Matrix;
  36224. /** @hidden */
  36225. _worldMatrixDeterminant: number;
  36226. /** @hidden */
  36227. _worldMatrixDeterminantIsDirty: boolean;
  36228. /** @hidden */
  36229. private _sceneRootNodesIndex;
  36230. /**
  36231. * Gets a boolean indicating if the node has been disposed
  36232. * @returns true if the node was disposed
  36233. */
  36234. isDisposed(): boolean;
  36235. /**
  36236. * Gets or sets the parent of the node (without keeping the current position in the scene)
  36237. * @see https://doc.babylonjs.com/how_to/parenting
  36238. */
  36239. set parent(parent: Nullable<Node>);
  36240. get parent(): Nullable<Node>;
  36241. /** @hidden */
  36242. _addToSceneRootNodes(): void;
  36243. /** @hidden */
  36244. _removeFromSceneRootNodes(): void;
  36245. private _animationPropertiesOverride;
  36246. /**
  36247. * Gets or sets the animation properties override
  36248. */
  36249. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36250. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36251. /**
  36252. * Gets a string identifying the name of the class
  36253. * @returns "Node" string
  36254. */
  36255. getClassName(): string;
  36256. /** @hidden */
  36257. readonly _isNode: boolean;
  36258. /**
  36259. * An event triggered when the mesh is disposed
  36260. */
  36261. onDisposeObservable: Observable<Node>;
  36262. private _onDisposeObserver;
  36263. /**
  36264. * Sets a callback that will be raised when the node will be disposed
  36265. */
  36266. set onDispose(callback: () => void);
  36267. /**
  36268. * Creates a new Node
  36269. * @param name the name and id to be given to this node
  36270. * @param scene the scene this node will be added to
  36271. */
  36272. constructor(name: string, scene?: Nullable<Scene>);
  36273. /**
  36274. * Gets the scene of the node
  36275. * @returns a scene
  36276. */
  36277. getScene(): Scene;
  36278. /**
  36279. * Gets the engine of the node
  36280. * @returns a Engine
  36281. */
  36282. getEngine(): Engine;
  36283. private _behaviors;
  36284. /**
  36285. * Attach a behavior to the node
  36286. * @see https://doc.babylonjs.com/features/behaviour
  36287. * @param behavior defines the behavior to attach
  36288. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  36289. * @returns the current Node
  36290. */
  36291. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  36292. /**
  36293. * Remove an attached behavior
  36294. * @see https://doc.babylonjs.com/features/behaviour
  36295. * @param behavior defines the behavior to attach
  36296. * @returns the current Node
  36297. */
  36298. removeBehavior(behavior: Behavior<Node>): Node;
  36299. /**
  36300. * Gets the list of attached behaviors
  36301. * @see https://doc.babylonjs.com/features/behaviour
  36302. */
  36303. get behaviors(): Behavior<Node>[];
  36304. /**
  36305. * Gets an attached behavior by name
  36306. * @param name defines the name of the behavior to look for
  36307. * @see https://doc.babylonjs.com/features/behaviour
  36308. * @returns null if behavior was not found else the requested behavior
  36309. */
  36310. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  36311. /**
  36312. * Returns the latest update of the World matrix
  36313. * @returns a Matrix
  36314. */
  36315. getWorldMatrix(): Matrix;
  36316. /** @hidden */
  36317. _getWorldMatrixDeterminant(): number;
  36318. /**
  36319. * Returns directly the latest state of the mesh World matrix.
  36320. * A Matrix is returned.
  36321. */
  36322. get worldMatrixFromCache(): Matrix;
  36323. /** @hidden */
  36324. _initCache(): void;
  36325. /** @hidden */
  36326. updateCache(force?: boolean): void;
  36327. /** @hidden */
  36328. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36329. /** @hidden */
  36330. _updateCache(ignoreParentClass?: boolean): void;
  36331. /** @hidden */
  36332. _isSynchronized(): boolean;
  36333. /** @hidden */
  36334. _markSyncedWithParent(): void;
  36335. /** @hidden */
  36336. isSynchronizedWithParent(): boolean;
  36337. /** @hidden */
  36338. isSynchronized(): boolean;
  36339. /**
  36340. * Is this node ready to be used/rendered
  36341. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  36342. * @return true if the node is ready
  36343. */
  36344. isReady(completeCheck?: boolean): boolean;
  36345. /**
  36346. * Is this node enabled?
  36347. * 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
  36348. * @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
  36349. * @return whether this node (and its parent) is enabled
  36350. */
  36351. isEnabled(checkAncestors?: boolean): boolean;
  36352. /** @hidden */
  36353. protected _syncParentEnabledState(): void;
  36354. /**
  36355. * Set the enabled state of this node
  36356. * @param value defines the new enabled state
  36357. */
  36358. setEnabled(value: boolean): void;
  36359. /**
  36360. * Is this node a descendant of the given node?
  36361. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  36362. * @param ancestor defines the parent node to inspect
  36363. * @returns a boolean indicating if this node is a descendant of the given node
  36364. */
  36365. isDescendantOf(ancestor: Node): boolean;
  36366. /** @hidden */
  36367. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  36368. /**
  36369. * Will return all nodes that have this node as ascendant
  36370. * @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
  36371. * @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
  36372. * @return all children nodes of all types
  36373. */
  36374. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  36375. /**
  36376. * Get all child-meshes of this node
  36377. * @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)
  36378. * @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
  36379. * @returns an array of AbstractMesh
  36380. */
  36381. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  36382. /**
  36383. * Get all direct children of this node
  36384. * @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
  36385. * @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)
  36386. * @returns an array of Node
  36387. */
  36388. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  36389. /** @hidden */
  36390. _setReady(state: boolean): void;
  36391. /**
  36392. * Get an animation by name
  36393. * @param name defines the name of the animation to look for
  36394. * @returns null if not found else the requested animation
  36395. */
  36396. getAnimationByName(name: string): Nullable<Animation>;
  36397. /**
  36398. * Creates an animation range for this node
  36399. * @param name defines the name of the range
  36400. * @param from defines the starting key
  36401. * @param to defines the end key
  36402. */
  36403. createAnimationRange(name: string, from: number, to: number): void;
  36404. /**
  36405. * Delete a specific animation range
  36406. * @param name defines the name of the range to delete
  36407. * @param deleteFrames defines if animation frames from the range must be deleted as well
  36408. */
  36409. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  36410. /**
  36411. * Get an animation range by name
  36412. * @param name defines the name of the animation range to look for
  36413. * @returns null if not found else the requested animation range
  36414. */
  36415. getAnimationRange(name: string): Nullable<AnimationRange>;
  36416. /**
  36417. * Gets the list of all animation ranges defined on this node
  36418. * @returns an array
  36419. */
  36420. getAnimationRanges(): Nullable<AnimationRange>[];
  36421. /**
  36422. * Will start the animation sequence
  36423. * @param name defines the range frames for animation sequence
  36424. * @param loop defines if the animation should loop (false by default)
  36425. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  36426. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  36427. * @returns the object created for this animation. If range does not exist, it will return null
  36428. */
  36429. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  36430. /**
  36431. * Serialize animation ranges into a JSON compatible object
  36432. * @returns serialization object
  36433. */
  36434. serializeAnimationRanges(): any;
  36435. /**
  36436. * Computes the world matrix of the node
  36437. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  36438. * @returns the world matrix
  36439. */
  36440. computeWorldMatrix(force?: boolean): Matrix;
  36441. /**
  36442. * Releases resources associated with this node.
  36443. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36444. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36445. */
  36446. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36447. /**
  36448. * Parse animation range data from a serialization object and store them into a given node
  36449. * @param node defines where to store the animation ranges
  36450. * @param parsedNode defines the serialization object to read data from
  36451. * @param scene defines the hosting scene
  36452. */
  36453. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  36454. /**
  36455. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  36456. * @param includeDescendants Include bounding info from descendants as well (true by default)
  36457. * @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
  36458. * @returns the new bounding vectors
  36459. */
  36460. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  36461. min: Vector3;
  36462. max: Vector3;
  36463. };
  36464. }
  36465. }
  36466. declare module BABYLON {
  36467. /**
  36468. * @hidden
  36469. */
  36470. export class _IAnimationState {
  36471. key: number;
  36472. repeatCount: number;
  36473. workValue?: any;
  36474. loopMode?: number;
  36475. offsetValue?: any;
  36476. highLimitValue?: any;
  36477. }
  36478. /**
  36479. * Class used to store any kind of animation
  36480. */
  36481. export class Animation {
  36482. /**Name of the animation */
  36483. name: string;
  36484. /**Property to animate */
  36485. targetProperty: string;
  36486. /**The frames per second of the animation */
  36487. framePerSecond: number;
  36488. /**The data type of the animation */
  36489. dataType: number;
  36490. /**The loop mode of the animation */
  36491. loopMode?: number | undefined;
  36492. /**Specifies if blending should be enabled */
  36493. enableBlending?: boolean | undefined;
  36494. /**
  36495. * Use matrix interpolation instead of using direct key value when animating matrices
  36496. */
  36497. static AllowMatricesInterpolation: boolean;
  36498. /**
  36499. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  36500. */
  36501. static AllowMatrixDecomposeForInterpolation: boolean;
  36502. /** Define the Url to load snippets */
  36503. static SnippetUrl: string;
  36504. /** Snippet ID if the animation was created from the snippet server */
  36505. snippetId: string;
  36506. /**
  36507. * Stores the key frames of the animation
  36508. */
  36509. private _keys;
  36510. /**
  36511. * Stores the easing function of the animation
  36512. */
  36513. private _easingFunction;
  36514. /**
  36515. * @hidden Internal use only
  36516. */
  36517. _runtimeAnimations: RuntimeAnimation[];
  36518. /**
  36519. * The set of event that will be linked to this animation
  36520. */
  36521. private _events;
  36522. /**
  36523. * Stores an array of target property paths
  36524. */
  36525. targetPropertyPath: string[];
  36526. /**
  36527. * Stores the blending speed of the animation
  36528. */
  36529. blendingSpeed: number;
  36530. /**
  36531. * Stores the animation ranges for the animation
  36532. */
  36533. private _ranges;
  36534. /**
  36535. * @hidden Internal use
  36536. */
  36537. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  36538. /**
  36539. * Sets up an animation
  36540. * @param property The property to animate
  36541. * @param animationType The animation type to apply
  36542. * @param framePerSecond The frames per second of the animation
  36543. * @param easingFunction The easing function used in the animation
  36544. * @returns The created animation
  36545. */
  36546. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  36547. /**
  36548. * Create and start an animation on a node
  36549. * @param name defines the name of the global animation that will be run on all nodes
  36550. * @param node defines the root node where the animation will take place
  36551. * @param targetProperty defines property to animate
  36552. * @param framePerSecond defines the number of frame per second yo use
  36553. * @param totalFrame defines the number of frames in total
  36554. * @param from defines the initial value
  36555. * @param to defines the final value
  36556. * @param loopMode defines which loop mode you want to use (off by default)
  36557. * @param easingFunction defines the easing function to use (linear by default)
  36558. * @param onAnimationEnd defines the callback to call when animation end
  36559. * @returns the animatable created for this animation
  36560. */
  36561. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36562. /**
  36563. * Create and start an animation on a node and its descendants
  36564. * @param name defines the name of the global animation that will be run on all nodes
  36565. * @param node defines the root node where the animation will take place
  36566. * @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
  36567. * @param targetProperty defines property to animate
  36568. * @param framePerSecond defines the number of frame per second to use
  36569. * @param totalFrame defines the number of frames in total
  36570. * @param from defines the initial value
  36571. * @param to defines the final value
  36572. * @param loopMode defines which loop mode you want to use (off by default)
  36573. * @param easingFunction defines the easing function to use (linear by default)
  36574. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  36575. * @returns the list of animatables created for all nodes
  36576. * @example https://www.babylonjs-playground.com/#MH0VLI
  36577. */
  36578. 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[]>;
  36579. /**
  36580. * Creates a new animation, merges it with the existing animations and starts it
  36581. * @param name Name of the animation
  36582. * @param node Node which contains the scene that begins the animations
  36583. * @param targetProperty Specifies which property to animate
  36584. * @param framePerSecond The frames per second of the animation
  36585. * @param totalFrame The total number of frames
  36586. * @param from The frame at the beginning of the animation
  36587. * @param to The frame at the end of the animation
  36588. * @param loopMode Specifies the loop mode of the animation
  36589. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  36590. * @param onAnimationEnd Callback to run once the animation is complete
  36591. * @returns Nullable animation
  36592. */
  36593. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36594. /**
  36595. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  36596. * @param sourceAnimation defines the Animation containing keyframes to convert
  36597. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  36598. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  36599. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  36600. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  36601. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  36602. */
  36603. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  36604. /**
  36605. * Transition property of an host to the target Value
  36606. * @param property The property to transition
  36607. * @param targetValue The target Value of the property
  36608. * @param host The object where the property to animate belongs
  36609. * @param scene Scene used to run the animation
  36610. * @param frameRate Framerate (in frame/s) to use
  36611. * @param transition The transition type we want to use
  36612. * @param duration The duration of the animation, in milliseconds
  36613. * @param onAnimationEnd Callback trigger at the end of the animation
  36614. * @returns Nullable animation
  36615. */
  36616. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  36617. /**
  36618. * Return the array of runtime animations currently using this animation
  36619. */
  36620. get runtimeAnimations(): RuntimeAnimation[];
  36621. /**
  36622. * Specifies if any of the runtime animations are currently running
  36623. */
  36624. get hasRunningRuntimeAnimations(): boolean;
  36625. /**
  36626. * Initializes the animation
  36627. * @param name Name of the animation
  36628. * @param targetProperty Property to animate
  36629. * @param framePerSecond The frames per second of the animation
  36630. * @param dataType The data type of the animation
  36631. * @param loopMode The loop mode of the animation
  36632. * @param enableBlending Specifies if blending should be enabled
  36633. */
  36634. constructor(
  36635. /**Name of the animation */
  36636. name: string,
  36637. /**Property to animate */
  36638. targetProperty: string,
  36639. /**The frames per second of the animation */
  36640. framePerSecond: number,
  36641. /**The data type of the animation */
  36642. dataType: number,
  36643. /**The loop mode of the animation */
  36644. loopMode?: number | undefined,
  36645. /**Specifies if blending should be enabled */
  36646. enableBlending?: boolean | undefined);
  36647. /**
  36648. * Converts the animation to a string
  36649. * @param fullDetails support for multiple levels of logging within scene loading
  36650. * @returns String form of the animation
  36651. */
  36652. toString(fullDetails?: boolean): string;
  36653. /**
  36654. * Add an event to this animation
  36655. * @param event Event to add
  36656. */
  36657. addEvent(event: AnimationEvent): void;
  36658. /**
  36659. * Remove all events found at the given frame
  36660. * @param frame The frame to remove events from
  36661. */
  36662. removeEvents(frame: number): void;
  36663. /**
  36664. * Retrieves all the events from the animation
  36665. * @returns Events from the animation
  36666. */
  36667. getEvents(): AnimationEvent[];
  36668. /**
  36669. * Creates an animation range
  36670. * @param name Name of the animation range
  36671. * @param from Starting frame of the animation range
  36672. * @param to Ending frame of the animation
  36673. */
  36674. createRange(name: string, from: number, to: number): void;
  36675. /**
  36676. * Deletes an animation range by name
  36677. * @param name Name of the animation range to delete
  36678. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  36679. */
  36680. deleteRange(name: string, deleteFrames?: boolean): void;
  36681. /**
  36682. * Gets the animation range by name, or null if not defined
  36683. * @param name Name of the animation range
  36684. * @returns Nullable animation range
  36685. */
  36686. getRange(name: string): Nullable<AnimationRange>;
  36687. /**
  36688. * Gets the key frames from the animation
  36689. * @returns The key frames of the animation
  36690. */
  36691. getKeys(): Array<IAnimationKey>;
  36692. /**
  36693. * Gets the highest frame rate of the animation
  36694. * @returns Highest frame rate of the animation
  36695. */
  36696. getHighestFrame(): number;
  36697. /**
  36698. * Gets the easing function of the animation
  36699. * @returns Easing function of the animation
  36700. */
  36701. getEasingFunction(): IEasingFunction;
  36702. /**
  36703. * Sets the easing function of the animation
  36704. * @param easingFunction A custom mathematical formula for animation
  36705. */
  36706. setEasingFunction(easingFunction: EasingFunction): void;
  36707. /**
  36708. * Interpolates a scalar linearly
  36709. * @param startValue Start value of the animation curve
  36710. * @param endValue End value of the animation curve
  36711. * @param gradient Scalar amount to interpolate
  36712. * @returns Interpolated scalar value
  36713. */
  36714. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  36715. /**
  36716. * Interpolates a scalar cubically
  36717. * @param startValue Start value of the animation curve
  36718. * @param outTangent End tangent of the animation
  36719. * @param endValue End value of the animation curve
  36720. * @param inTangent Start tangent of the animation curve
  36721. * @param gradient Scalar amount to interpolate
  36722. * @returns Interpolated scalar value
  36723. */
  36724. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  36725. /**
  36726. * Interpolates a quaternion using a spherical linear interpolation
  36727. * @param startValue Start value of the animation curve
  36728. * @param endValue End value of the animation curve
  36729. * @param gradient Scalar amount to interpolate
  36730. * @returns Interpolated quaternion value
  36731. */
  36732. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  36733. /**
  36734. * Interpolates a quaternion cubically
  36735. * @param startValue Start value of the animation curve
  36736. * @param outTangent End tangent of the animation curve
  36737. * @param endValue End value of the animation curve
  36738. * @param inTangent Start tangent of the animation curve
  36739. * @param gradient Scalar amount to interpolate
  36740. * @returns Interpolated quaternion value
  36741. */
  36742. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  36743. /**
  36744. * Interpolates a Vector3 linearl
  36745. * @param startValue Start value of the animation curve
  36746. * @param endValue End value of the animation curve
  36747. * @param gradient Scalar amount to interpolate
  36748. * @returns Interpolated scalar value
  36749. */
  36750. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  36751. /**
  36752. * Interpolates a Vector3 cubically
  36753. * @param startValue Start value of the animation curve
  36754. * @param outTangent End tangent of the animation
  36755. * @param endValue End value of the animation curve
  36756. * @param inTangent Start tangent of the animation curve
  36757. * @param gradient Scalar amount to interpolate
  36758. * @returns InterpolatedVector3 value
  36759. */
  36760. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  36761. /**
  36762. * Interpolates a Vector2 linearly
  36763. * @param startValue Start value of the animation curve
  36764. * @param endValue End value of the animation curve
  36765. * @param gradient Scalar amount to interpolate
  36766. * @returns Interpolated Vector2 value
  36767. */
  36768. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  36769. /**
  36770. * Interpolates a Vector2 cubically
  36771. * @param startValue Start value of the animation curve
  36772. * @param outTangent End tangent of the animation
  36773. * @param endValue End value of the animation curve
  36774. * @param inTangent Start tangent of the animation curve
  36775. * @param gradient Scalar amount to interpolate
  36776. * @returns Interpolated Vector2 value
  36777. */
  36778. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  36779. /**
  36780. * Interpolates a size linearly
  36781. * @param startValue Start value of the animation curve
  36782. * @param endValue End value of the animation curve
  36783. * @param gradient Scalar amount to interpolate
  36784. * @returns Interpolated Size value
  36785. */
  36786. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  36787. /**
  36788. * Interpolates a Color3 linearly
  36789. * @param startValue Start value of the animation curve
  36790. * @param endValue End value of the animation curve
  36791. * @param gradient Scalar amount to interpolate
  36792. * @returns Interpolated Color3 value
  36793. */
  36794. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  36795. /**
  36796. * Interpolates a Color4 linearly
  36797. * @param startValue Start value of the animation curve
  36798. * @param endValue End value of the animation curve
  36799. * @param gradient Scalar amount to interpolate
  36800. * @returns Interpolated Color3 value
  36801. */
  36802. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  36803. /**
  36804. * @hidden Internal use only
  36805. */
  36806. _getKeyValue(value: any): any;
  36807. /**
  36808. * @hidden Internal use only
  36809. */
  36810. _interpolate(currentFrame: number, state: _IAnimationState): any;
  36811. /**
  36812. * Defines the function to use to interpolate matrices
  36813. * @param startValue defines the start matrix
  36814. * @param endValue defines the end matrix
  36815. * @param gradient defines the gradient between both matrices
  36816. * @param result defines an optional target matrix where to store the interpolation
  36817. * @returns the interpolated matrix
  36818. */
  36819. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  36820. /**
  36821. * Makes a copy of the animation
  36822. * @returns Cloned animation
  36823. */
  36824. clone(): Animation;
  36825. /**
  36826. * Sets the key frames of the animation
  36827. * @param values The animation key frames to set
  36828. */
  36829. setKeys(values: Array<IAnimationKey>): void;
  36830. /**
  36831. * Serializes the animation to an object
  36832. * @returns Serialized object
  36833. */
  36834. serialize(): any;
  36835. /**
  36836. * Float animation type
  36837. */
  36838. static readonly ANIMATIONTYPE_FLOAT: number;
  36839. /**
  36840. * Vector3 animation type
  36841. */
  36842. static readonly ANIMATIONTYPE_VECTOR3: number;
  36843. /**
  36844. * Quaternion animation type
  36845. */
  36846. static readonly ANIMATIONTYPE_QUATERNION: number;
  36847. /**
  36848. * Matrix animation type
  36849. */
  36850. static readonly ANIMATIONTYPE_MATRIX: number;
  36851. /**
  36852. * Color3 animation type
  36853. */
  36854. static readonly ANIMATIONTYPE_COLOR3: number;
  36855. /**
  36856. * Color3 animation type
  36857. */
  36858. static readonly ANIMATIONTYPE_COLOR4: number;
  36859. /**
  36860. * Vector2 animation type
  36861. */
  36862. static readonly ANIMATIONTYPE_VECTOR2: number;
  36863. /**
  36864. * Size animation type
  36865. */
  36866. static readonly ANIMATIONTYPE_SIZE: number;
  36867. /**
  36868. * Relative Loop Mode
  36869. */
  36870. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  36871. /**
  36872. * Cycle Loop Mode
  36873. */
  36874. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  36875. /**
  36876. * Constant Loop Mode
  36877. */
  36878. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  36879. /** @hidden */
  36880. static _UniversalLerp(left: any, right: any, amount: number): any;
  36881. /**
  36882. * Parses an animation object and creates an animation
  36883. * @param parsedAnimation Parsed animation object
  36884. * @returns Animation object
  36885. */
  36886. static Parse(parsedAnimation: any): Animation;
  36887. /**
  36888. * Appends the serialized animations from the source animations
  36889. * @param source Source containing the animations
  36890. * @param destination Target to store the animations
  36891. */
  36892. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  36893. /**
  36894. * Creates a new animation or an array of animations from a snippet saved in a remote file
  36895. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  36896. * @param url defines the url to load from
  36897. * @returns a promise that will resolve to the new animation or an array of animations
  36898. */
  36899. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  36900. /**
  36901. * Creates an animation or an array of animations from a snippet saved by the Inspector
  36902. * @param snippetId defines the snippet to load
  36903. * @returns a promise that will resolve to the new animation or a new array of animations
  36904. */
  36905. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  36906. }
  36907. }
  36908. declare module BABYLON {
  36909. /**
  36910. * Interface containing an array of animations
  36911. */
  36912. export interface IAnimatable {
  36913. /**
  36914. * Array of animations
  36915. */
  36916. animations: Nullable<Array<Animation>>;
  36917. }
  36918. }
  36919. declare module BABYLON {
  36920. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  36921. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36922. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36923. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36924. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36925. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36926. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36927. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36928. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36929. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36930. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36931. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36932. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36933. /**
  36934. * Decorator used to define property that can be serialized as reference to a camera
  36935. * @param sourceName defines the name of the property to decorate
  36936. */
  36937. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36938. /**
  36939. * Class used to help serialization objects
  36940. */
  36941. export class SerializationHelper {
  36942. /** @hidden */
  36943. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  36944. /** @hidden */
  36945. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  36946. /** @hidden */
  36947. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  36948. /** @hidden */
  36949. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  36950. /**
  36951. * Appends the serialized animations from the source animations
  36952. * @param source Source containing the animations
  36953. * @param destination Target to store the animations
  36954. */
  36955. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  36956. /**
  36957. * Static function used to serialized a specific entity
  36958. * @param entity defines the entity to serialize
  36959. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  36960. * @returns a JSON compatible object representing the serialization of the entity
  36961. */
  36962. static Serialize<T>(entity: T, serializationObject?: any): any;
  36963. /**
  36964. * Creates a new entity from a serialization data object
  36965. * @param creationFunction defines a function used to instanciated the new entity
  36966. * @param source defines the source serialization data
  36967. * @param scene defines the hosting scene
  36968. * @param rootUrl defines the root url for resources
  36969. * @returns a new entity
  36970. */
  36971. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  36972. /**
  36973. * Clones an object
  36974. * @param creationFunction defines the function used to instanciate the new object
  36975. * @param source defines the source object
  36976. * @returns the cloned object
  36977. */
  36978. static Clone<T>(creationFunction: () => T, source: T): T;
  36979. /**
  36980. * Instanciates a new object based on a source one (some data will be shared between both object)
  36981. * @param creationFunction defines the function used to instanciate the new object
  36982. * @param source defines the source object
  36983. * @returns the new object
  36984. */
  36985. static Instanciate<T>(creationFunction: () => T, source: T): T;
  36986. }
  36987. }
  36988. declare module BABYLON {
  36989. /**
  36990. * This is the base class of all the camera used in the application.
  36991. * @see https://doc.babylonjs.com/features/cameras
  36992. */
  36993. export class Camera extends Node {
  36994. /** @hidden */
  36995. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  36996. /**
  36997. * This is the default projection mode used by the cameras.
  36998. * It helps recreating a feeling of perspective and better appreciate depth.
  36999. * This is the best way to simulate real life cameras.
  37000. */
  37001. static readonly PERSPECTIVE_CAMERA: number;
  37002. /**
  37003. * This helps creating camera with an orthographic mode.
  37004. * 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.
  37005. */
  37006. static readonly ORTHOGRAPHIC_CAMERA: number;
  37007. /**
  37008. * This is the default FOV mode for perspective cameras.
  37009. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  37010. */
  37011. static readonly FOVMODE_VERTICAL_FIXED: number;
  37012. /**
  37013. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  37014. */
  37015. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  37016. /**
  37017. * This specifies ther is no need for a camera rig.
  37018. * Basically only one eye is rendered corresponding to the camera.
  37019. */
  37020. static readonly RIG_MODE_NONE: number;
  37021. /**
  37022. * Simulates a camera Rig with one blue eye and one red eye.
  37023. * This can be use with 3d blue and red glasses.
  37024. */
  37025. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  37026. /**
  37027. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  37028. */
  37029. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  37030. /**
  37031. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  37032. */
  37033. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  37034. /**
  37035. * Defines that both eyes of the camera will be rendered over under each other.
  37036. */
  37037. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  37038. /**
  37039. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  37040. */
  37041. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  37042. /**
  37043. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  37044. */
  37045. static readonly RIG_MODE_VR: number;
  37046. /**
  37047. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  37048. */
  37049. static readonly RIG_MODE_WEBVR: number;
  37050. /**
  37051. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  37052. */
  37053. static readonly RIG_MODE_CUSTOM: number;
  37054. /**
  37055. * Defines if by default attaching controls should prevent the default javascript event to continue.
  37056. */
  37057. static ForceAttachControlToAlwaysPreventDefault: boolean;
  37058. /**
  37059. * Define the input manager associated with the camera.
  37060. */
  37061. inputs: CameraInputsManager<Camera>;
  37062. /** @hidden */
  37063. _position: Vector3;
  37064. /**
  37065. * Define the current local position of the camera in the scene
  37066. */
  37067. get position(): Vector3;
  37068. set position(newPosition: Vector3);
  37069. protected _upVector: Vector3;
  37070. /**
  37071. * The vector the camera should consider as up.
  37072. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  37073. */
  37074. set upVector(vec: Vector3);
  37075. get upVector(): Vector3;
  37076. /**
  37077. * Define the current limit on the left side for an orthographic camera
  37078. * In scene unit
  37079. */
  37080. orthoLeft: Nullable<number>;
  37081. /**
  37082. * Define the current limit on the right side for an orthographic camera
  37083. * In scene unit
  37084. */
  37085. orthoRight: Nullable<number>;
  37086. /**
  37087. * Define the current limit on the bottom side for an orthographic camera
  37088. * In scene unit
  37089. */
  37090. orthoBottom: Nullable<number>;
  37091. /**
  37092. * Define the current limit on the top side for an orthographic camera
  37093. * In scene unit
  37094. */
  37095. orthoTop: Nullable<number>;
  37096. /**
  37097. * Field Of View is set in Radians. (default is 0.8)
  37098. */
  37099. fov: number;
  37100. /**
  37101. * Define the minimum distance the camera can see from.
  37102. * This is important to note that the depth buffer are not infinite and the closer it starts
  37103. * the more your scene might encounter depth fighting issue.
  37104. */
  37105. minZ: number;
  37106. /**
  37107. * Define the maximum distance the camera can see to.
  37108. * This is important to note that the depth buffer are not infinite and the further it end
  37109. * the more your scene might encounter depth fighting issue.
  37110. */
  37111. maxZ: number;
  37112. /**
  37113. * Define the default inertia of the camera.
  37114. * This helps giving a smooth feeling to the camera movement.
  37115. */
  37116. inertia: number;
  37117. /**
  37118. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  37119. */
  37120. mode: number;
  37121. /**
  37122. * Define whether the camera is intermediate.
  37123. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  37124. */
  37125. isIntermediate: boolean;
  37126. /**
  37127. * Define the viewport of the camera.
  37128. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  37129. */
  37130. viewport: Viewport;
  37131. /**
  37132. * Restricts the camera to viewing objects with the same layerMask.
  37133. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  37134. */
  37135. layerMask: number;
  37136. /**
  37137. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  37138. */
  37139. fovMode: number;
  37140. /**
  37141. * Rig mode of the camera.
  37142. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  37143. * This is normally controlled byt the camera themselves as internal use.
  37144. */
  37145. cameraRigMode: number;
  37146. /**
  37147. * Defines the distance between both "eyes" in case of a RIG
  37148. */
  37149. interaxialDistance: number;
  37150. /**
  37151. * Defines if stereoscopic rendering is done side by side or over under.
  37152. */
  37153. isStereoscopicSideBySide: boolean;
  37154. /**
  37155. * 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
  37156. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  37157. * else in the scene. (Eg. security camera)
  37158. *
  37159. * 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)
  37160. */
  37161. customRenderTargets: RenderTargetTexture[];
  37162. /**
  37163. * When set, the camera will render to this render target instead of the default canvas
  37164. *
  37165. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  37166. */
  37167. outputRenderTarget: Nullable<RenderTargetTexture>;
  37168. /**
  37169. * Observable triggered when the camera view matrix has changed.
  37170. */
  37171. onViewMatrixChangedObservable: Observable<Camera>;
  37172. /**
  37173. * Observable triggered when the camera Projection matrix has changed.
  37174. */
  37175. onProjectionMatrixChangedObservable: Observable<Camera>;
  37176. /**
  37177. * Observable triggered when the inputs have been processed.
  37178. */
  37179. onAfterCheckInputsObservable: Observable<Camera>;
  37180. /**
  37181. * Observable triggered when reset has been called and applied to the camera.
  37182. */
  37183. onRestoreStateObservable: Observable<Camera>;
  37184. /**
  37185. * Is this camera a part of a rig system?
  37186. */
  37187. isRigCamera: boolean;
  37188. /**
  37189. * If isRigCamera set to true this will be set with the parent camera.
  37190. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  37191. */
  37192. rigParent?: Camera;
  37193. /** @hidden */
  37194. _cameraRigParams: any;
  37195. /** @hidden */
  37196. _rigCameras: Camera[];
  37197. /** @hidden */
  37198. _rigPostProcess: Nullable<PostProcess>;
  37199. protected _webvrViewMatrix: Matrix;
  37200. /** @hidden */
  37201. _skipRendering: boolean;
  37202. /** @hidden */
  37203. _projectionMatrix: Matrix;
  37204. /** @hidden */
  37205. _postProcesses: Nullable<PostProcess>[];
  37206. /** @hidden */
  37207. _activeMeshes: SmartArray<AbstractMesh>;
  37208. protected _globalPosition: Vector3;
  37209. /** @hidden */
  37210. _computedViewMatrix: Matrix;
  37211. private _doNotComputeProjectionMatrix;
  37212. private _transformMatrix;
  37213. private _frustumPlanes;
  37214. private _refreshFrustumPlanes;
  37215. private _storedFov;
  37216. private _stateStored;
  37217. /**
  37218. * Instantiates a new camera object.
  37219. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  37220. * @see https://doc.babylonjs.com/features/cameras
  37221. * @param name Defines the name of the camera in the scene
  37222. * @param position Defines the position of the camera
  37223. * @param scene Defines the scene the camera belongs too
  37224. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  37225. */
  37226. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37227. /**
  37228. * Store current camera state (fov, position, etc..)
  37229. * @returns the camera
  37230. */
  37231. storeState(): Camera;
  37232. /**
  37233. * Restores the camera state values if it has been stored. You must call storeState() first
  37234. */
  37235. protected _restoreStateValues(): boolean;
  37236. /**
  37237. * Restored camera state. You must call storeState() first.
  37238. * @returns true if restored and false otherwise
  37239. */
  37240. restoreState(): boolean;
  37241. /**
  37242. * Gets the class name of the camera.
  37243. * @returns the class name
  37244. */
  37245. getClassName(): string;
  37246. /** @hidden */
  37247. readonly _isCamera: boolean;
  37248. /**
  37249. * Gets a string representation of the camera useful for debug purpose.
  37250. * @param fullDetails Defines that a more verboe level of logging is required
  37251. * @returns the string representation
  37252. */
  37253. toString(fullDetails?: boolean): string;
  37254. /**
  37255. * Gets the current world space position of the camera.
  37256. */
  37257. get globalPosition(): Vector3;
  37258. /**
  37259. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  37260. * @returns the active meshe list
  37261. */
  37262. getActiveMeshes(): SmartArray<AbstractMesh>;
  37263. /**
  37264. * Check whether a mesh is part of the current active mesh list of the camera
  37265. * @param mesh Defines the mesh to check
  37266. * @returns true if active, false otherwise
  37267. */
  37268. isActiveMesh(mesh: Mesh): boolean;
  37269. /**
  37270. * Is this camera ready to be used/rendered
  37271. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  37272. * @return true if the camera is ready
  37273. */
  37274. isReady(completeCheck?: boolean): boolean;
  37275. /** @hidden */
  37276. _initCache(): void;
  37277. /** @hidden */
  37278. _updateCache(ignoreParentClass?: boolean): void;
  37279. /** @hidden */
  37280. _isSynchronized(): boolean;
  37281. /** @hidden */
  37282. _isSynchronizedViewMatrix(): boolean;
  37283. /** @hidden */
  37284. _isSynchronizedProjectionMatrix(): boolean;
  37285. /**
  37286. * Attach the input controls to a specific dom element to get the input from.
  37287. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37288. */
  37289. attachControl(noPreventDefault?: boolean): void;
  37290. /**
  37291. * Attach the input controls to a specific dom element to get the input from.
  37292. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  37293. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37294. * BACK COMPAT SIGNATURE ONLY.
  37295. */
  37296. attachControl(ignored: any, noPreventDefault?: boolean): void;
  37297. /**
  37298. * Detach the current controls from the specified dom element.
  37299. */
  37300. detachControl(): void;
  37301. /**
  37302. * Detach the current controls from the specified dom element.
  37303. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  37304. */
  37305. detachControl(ignored: any): void;
  37306. /**
  37307. * Update the camera state according to the different inputs gathered during the frame.
  37308. */
  37309. update(): void;
  37310. /** @hidden */
  37311. _checkInputs(): void;
  37312. /** @hidden */
  37313. get rigCameras(): Camera[];
  37314. /**
  37315. * Gets the post process used by the rig cameras
  37316. */
  37317. get rigPostProcess(): Nullable<PostProcess>;
  37318. /**
  37319. * Internal, gets the first post proces.
  37320. * @returns the first post process to be run on this camera.
  37321. */
  37322. _getFirstPostProcess(): Nullable<PostProcess>;
  37323. private _cascadePostProcessesToRigCams;
  37324. /**
  37325. * Attach a post process to the camera.
  37326. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  37327. * @param postProcess The post process to attach to the camera
  37328. * @param insertAt The position of the post process in case several of them are in use in the scene
  37329. * @returns the position the post process has been inserted at
  37330. */
  37331. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  37332. /**
  37333. * Detach a post process to the camera.
  37334. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  37335. * @param postProcess The post process to detach from the camera
  37336. */
  37337. detachPostProcess(postProcess: PostProcess): void;
  37338. /**
  37339. * Gets the current world matrix of the camera
  37340. */
  37341. getWorldMatrix(): Matrix;
  37342. /** @hidden */
  37343. _getViewMatrix(): Matrix;
  37344. /**
  37345. * Gets the current view matrix of the camera.
  37346. * @param force forces the camera to recompute the matrix without looking at the cached state
  37347. * @returns the view matrix
  37348. */
  37349. getViewMatrix(force?: boolean): Matrix;
  37350. /**
  37351. * Freeze the projection matrix.
  37352. * It will prevent the cache check of the camera projection compute and can speed up perf
  37353. * if no parameter of the camera are meant to change
  37354. * @param projection Defines manually a projection if necessary
  37355. */
  37356. freezeProjectionMatrix(projection?: Matrix): void;
  37357. /**
  37358. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  37359. */
  37360. unfreezeProjectionMatrix(): void;
  37361. /**
  37362. * Gets the current projection matrix of the camera.
  37363. * @param force forces the camera to recompute the matrix without looking at the cached state
  37364. * @returns the projection matrix
  37365. */
  37366. getProjectionMatrix(force?: boolean): Matrix;
  37367. /**
  37368. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  37369. * @returns a Matrix
  37370. */
  37371. getTransformationMatrix(): Matrix;
  37372. private _updateFrustumPlanes;
  37373. /**
  37374. * Checks if a cullable object (mesh...) is in the camera frustum
  37375. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  37376. * @param target The object to check
  37377. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  37378. * @returns true if the object is in frustum otherwise false
  37379. */
  37380. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  37381. /**
  37382. * Checks if a cullable object (mesh...) is in the camera frustum
  37383. * Unlike isInFrustum this cheks the full bounding box
  37384. * @param target The object to check
  37385. * @returns true if the object is in frustum otherwise false
  37386. */
  37387. isCompletelyInFrustum(target: ICullable): boolean;
  37388. /**
  37389. * Gets a ray in the forward direction from the camera.
  37390. * @param length Defines the length of the ray to create
  37391. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  37392. * @param origin Defines the start point of the ray which defaults to the camera position
  37393. * @returns the forward ray
  37394. */
  37395. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  37396. /**
  37397. * Gets a ray in the forward direction from the camera.
  37398. * @param refRay the ray to (re)use when setting the values
  37399. * @param length Defines the length of the ray to create
  37400. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  37401. * @param origin Defines the start point of the ray which defaults to the camera position
  37402. * @returns the forward ray
  37403. */
  37404. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  37405. /**
  37406. * Releases resources associated with this node.
  37407. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37408. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37409. */
  37410. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37411. /** @hidden */
  37412. _isLeftCamera: boolean;
  37413. /**
  37414. * Gets the left camera of a rig setup in case of Rigged Camera
  37415. */
  37416. get isLeftCamera(): boolean;
  37417. /** @hidden */
  37418. _isRightCamera: boolean;
  37419. /**
  37420. * Gets the right camera of a rig setup in case of Rigged Camera
  37421. */
  37422. get isRightCamera(): boolean;
  37423. /**
  37424. * Gets the left camera of a rig setup in case of Rigged Camera
  37425. */
  37426. get leftCamera(): Nullable<FreeCamera>;
  37427. /**
  37428. * Gets the right camera of a rig setup in case of Rigged Camera
  37429. */
  37430. get rightCamera(): Nullable<FreeCamera>;
  37431. /**
  37432. * Gets the left camera target of a rig setup in case of Rigged Camera
  37433. * @returns the target position
  37434. */
  37435. getLeftTarget(): Nullable<Vector3>;
  37436. /**
  37437. * Gets the right camera target of a rig setup in case of Rigged Camera
  37438. * @returns the target position
  37439. */
  37440. getRightTarget(): Nullable<Vector3>;
  37441. /**
  37442. * @hidden
  37443. */
  37444. setCameraRigMode(mode: number, rigParams: any): void;
  37445. /** @hidden */
  37446. static _setStereoscopicRigMode(camera: Camera): void;
  37447. /** @hidden */
  37448. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  37449. /** @hidden */
  37450. static _setVRRigMode(camera: Camera, rigParams: any): void;
  37451. /** @hidden */
  37452. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  37453. /** @hidden */
  37454. _getVRProjectionMatrix(): Matrix;
  37455. protected _updateCameraRotationMatrix(): void;
  37456. protected _updateWebVRCameraRotationMatrix(): void;
  37457. /**
  37458. * This function MUST be overwritten by the different WebVR cameras available.
  37459. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  37460. * @hidden
  37461. */
  37462. _getWebVRProjectionMatrix(): Matrix;
  37463. /**
  37464. * This function MUST be overwritten by the different WebVR cameras available.
  37465. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  37466. * @hidden
  37467. */
  37468. _getWebVRViewMatrix(): Matrix;
  37469. /** @hidden */
  37470. setCameraRigParameter(name: string, value: any): void;
  37471. /**
  37472. * needs to be overridden by children so sub has required properties to be copied
  37473. * @hidden
  37474. */
  37475. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  37476. /**
  37477. * May need to be overridden by children
  37478. * @hidden
  37479. */
  37480. _updateRigCameras(): void;
  37481. /** @hidden */
  37482. _setupInputs(): void;
  37483. /**
  37484. * Serialiaze the camera setup to a json represention
  37485. * @returns the JSON representation
  37486. */
  37487. serialize(): any;
  37488. /**
  37489. * Clones the current camera.
  37490. * @param name The cloned camera name
  37491. * @returns the cloned camera
  37492. */
  37493. clone(name: string): Camera;
  37494. /**
  37495. * Gets the direction of the camera relative to a given local axis.
  37496. * @param localAxis Defines the reference axis to provide a relative direction.
  37497. * @return the direction
  37498. */
  37499. getDirection(localAxis: Vector3): Vector3;
  37500. /**
  37501. * Returns the current camera absolute rotation
  37502. */
  37503. get absoluteRotation(): Quaternion;
  37504. /**
  37505. * Gets the direction of the camera relative to a given local axis into a passed vector.
  37506. * @param localAxis Defines the reference axis to provide a relative direction.
  37507. * @param result Defines the vector to store the result in
  37508. */
  37509. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  37510. /**
  37511. * Gets a camera constructor for a given camera type
  37512. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  37513. * @param name The name of the camera the result will be able to instantiate
  37514. * @param scene The scene the result will construct the camera in
  37515. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  37516. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  37517. * @returns a factory method to construc the camera
  37518. */
  37519. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  37520. /**
  37521. * Compute the world matrix of the camera.
  37522. * @returns the camera world matrix
  37523. */
  37524. computeWorldMatrix(): Matrix;
  37525. /**
  37526. * Parse a JSON and creates the camera from the parsed information
  37527. * @param parsedCamera The JSON to parse
  37528. * @param scene The scene to instantiate the camera in
  37529. * @returns the newly constructed camera
  37530. */
  37531. static Parse(parsedCamera: any, scene: Scene): Camera;
  37532. }
  37533. }
  37534. declare module BABYLON {
  37535. /**
  37536. * PostProcessManager is used to manage one or more post processes or post process pipelines
  37537. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  37538. */
  37539. export class PostProcessManager {
  37540. private _scene;
  37541. private _indexBuffer;
  37542. private _vertexBuffers;
  37543. /**
  37544. * Creates a new instance PostProcess
  37545. * @param scene The scene that the post process is associated with.
  37546. */
  37547. constructor(scene: Scene);
  37548. private _prepareBuffers;
  37549. private _buildIndexBuffer;
  37550. /**
  37551. * Rebuilds the vertex buffers of the manager.
  37552. * @hidden
  37553. */
  37554. _rebuild(): void;
  37555. /**
  37556. * Prepares a frame to be run through a post process.
  37557. * @param sourceTexture The input texture to the post procesess. (default: null)
  37558. * @param postProcesses An array of post processes to be run. (default: null)
  37559. * @returns True if the post processes were able to be run.
  37560. * @hidden
  37561. */
  37562. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  37563. /**
  37564. * Manually render a set of post processes to a texture.
  37565. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  37566. * @param postProcesses An array of post processes to be run.
  37567. * @param targetTexture The target texture to render to.
  37568. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  37569. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  37570. * @param lodLevel defines which lod of the texture to render to
  37571. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  37572. */
  37573. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  37574. /**
  37575. * Finalize the result of the output of the postprocesses.
  37576. * @param doNotPresent If true the result will not be displayed to the screen.
  37577. * @param targetTexture The target texture to render to.
  37578. * @param faceIndex The index of the face to bind the target texture to.
  37579. * @param postProcesses The array of post processes to render.
  37580. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  37581. * @hidden
  37582. */
  37583. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  37584. /**
  37585. * Disposes of the post process manager.
  37586. */
  37587. dispose(): void;
  37588. }
  37589. }
  37590. declare module BABYLON {
  37591. /**
  37592. * This Helps creating a texture that will be created from a camera in your scene.
  37593. * It is basically a dynamic texture that could be used to create special effects for instance.
  37594. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  37595. */
  37596. export class RenderTargetTexture extends Texture {
  37597. /**
  37598. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  37599. */
  37600. static readonly REFRESHRATE_RENDER_ONCE: number;
  37601. /**
  37602. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  37603. */
  37604. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  37605. /**
  37606. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  37607. * the central point of your effect and can save a lot of performances.
  37608. */
  37609. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  37610. /**
  37611. * Use this predicate to dynamically define the list of mesh you want to render.
  37612. * If set, the renderList property will be overwritten.
  37613. */
  37614. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  37615. private _renderList;
  37616. /**
  37617. * Use this list to define the list of mesh you want to render.
  37618. */
  37619. get renderList(): Nullable<Array<AbstractMesh>>;
  37620. set renderList(value: Nullable<Array<AbstractMesh>>);
  37621. /**
  37622. * Use this function to overload the renderList array at rendering time.
  37623. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  37624. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  37625. * the cube (if the RTT is a cube, else layerOrFace=0).
  37626. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  37627. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  37628. * hold dummy elements!
  37629. */
  37630. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  37631. private _hookArray;
  37632. /**
  37633. * Define if particles should be rendered in your texture.
  37634. */
  37635. renderParticles: boolean;
  37636. /**
  37637. * Define if sprites should be rendered in your texture.
  37638. */
  37639. renderSprites: boolean;
  37640. /**
  37641. * Define the camera used to render the texture.
  37642. */
  37643. activeCamera: Nullable<Camera>;
  37644. /**
  37645. * Override the mesh isReady function with your own one.
  37646. */
  37647. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  37648. /**
  37649. * Override the render function of the texture with your own one.
  37650. */
  37651. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  37652. /**
  37653. * Define if camera post processes should be use while rendering the texture.
  37654. */
  37655. useCameraPostProcesses: boolean;
  37656. /**
  37657. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  37658. */
  37659. ignoreCameraViewport: boolean;
  37660. private _postProcessManager;
  37661. private _postProcesses;
  37662. private _resizeObserver;
  37663. /**
  37664. * An event triggered when the texture is unbind.
  37665. */
  37666. onBeforeBindObservable: Observable<RenderTargetTexture>;
  37667. /**
  37668. * An event triggered when the texture is unbind.
  37669. */
  37670. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  37671. private _onAfterUnbindObserver;
  37672. /**
  37673. * Set a after unbind callback in the texture.
  37674. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  37675. */
  37676. set onAfterUnbind(callback: () => void);
  37677. /**
  37678. * An event triggered before rendering the texture
  37679. */
  37680. onBeforeRenderObservable: Observable<number>;
  37681. private _onBeforeRenderObserver;
  37682. /**
  37683. * Set a before render callback in the texture.
  37684. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  37685. */
  37686. set onBeforeRender(callback: (faceIndex: number) => void);
  37687. /**
  37688. * An event triggered after rendering the texture
  37689. */
  37690. onAfterRenderObservable: Observable<number>;
  37691. private _onAfterRenderObserver;
  37692. /**
  37693. * Set a after render callback in the texture.
  37694. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  37695. */
  37696. set onAfterRender(callback: (faceIndex: number) => void);
  37697. /**
  37698. * An event triggered after the texture clear
  37699. */
  37700. onClearObservable: Observable<Engine>;
  37701. private _onClearObserver;
  37702. /**
  37703. * Set a clear callback in the texture.
  37704. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  37705. */
  37706. set onClear(callback: (Engine: Engine) => void);
  37707. /**
  37708. * An event triggered when the texture is resized.
  37709. */
  37710. onResizeObservable: Observable<RenderTargetTexture>;
  37711. /**
  37712. * Define the clear color of the Render Target if it should be different from the scene.
  37713. */
  37714. clearColor: Color4;
  37715. protected _size: number | {
  37716. width: number;
  37717. height: number;
  37718. layers?: number;
  37719. };
  37720. protected _initialSizeParameter: number | {
  37721. width: number;
  37722. height: number;
  37723. } | {
  37724. ratio: number;
  37725. };
  37726. protected _sizeRatio: Nullable<number>;
  37727. /** @hidden */
  37728. _generateMipMaps: boolean;
  37729. protected _renderingManager: RenderingManager;
  37730. /** @hidden */
  37731. _waitingRenderList?: string[];
  37732. protected _doNotChangeAspectRatio: boolean;
  37733. protected _currentRefreshId: number;
  37734. protected _refreshRate: number;
  37735. protected _textureMatrix: Matrix;
  37736. protected _samples: number;
  37737. protected _renderTargetOptions: RenderTargetCreationOptions;
  37738. /**
  37739. * Gets render target creation options that were used.
  37740. */
  37741. get renderTargetOptions(): RenderTargetCreationOptions;
  37742. protected _onRatioRescale(): void;
  37743. /**
  37744. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  37745. * It must define where the camera used to render the texture is set
  37746. */
  37747. boundingBoxPosition: Vector3;
  37748. private _boundingBoxSize;
  37749. /**
  37750. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  37751. * When defined, the cubemap will switch to local mode
  37752. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  37753. * @example https://www.babylonjs-playground.com/#RNASML
  37754. */
  37755. set boundingBoxSize(value: Vector3);
  37756. get boundingBoxSize(): Vector3;
  37757. /**
  37758. * In case the RTT has been created with a depth texture, get the associated
  37759. * depth texture.
  37760. * Otherwise, return null.
  37761. */
  37762. get depthStencilTexture(): Nullable<InternalTexture>;
  37763. /**
  37764. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  37765. * or used a shadow, depth texture...
  37766. * @param name The friendly name of the texture
  37767. * @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)
  37768. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  37769. * @param generateMipMaps True if mip maps need to be generated after render.
  37770. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  37771. * @param type The type of the buffer in the RTT (int, half float, float...)
  37772. * @param isCube True if a cube texture needs to be created
  37773. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  37774. * @param generateDepthBuffer True to generate a depth buffer
  37775. * @param generateStencilBuffer True to generate a stencil buffer
  37776. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  37777. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  37778. * @param delayAllocation if the texture allocation should be delayed (default: false)
  37779. */
  37780. constructor(name: string, size: number | {
  37781. width: number;
  37782. height: number;
  37783. layers?: number;
  37784. } | {
  37785. ratio: number;
  37786. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  37787. /**
  37788. * Creates a depth stencil texture.
  37789. * This is only available in WebGL 2 or with the depth texture extension available.
  37790. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  37791. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  37792. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  37793. */
  37794. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  37795. private _processSizeParameter;
  37796. /**
  37797. * Define the number of samples to use in case of MSAA.
  37798. * It defaults to one meaning no MSAA has been enabled.
  37799. */
  37800. get samples(): number;
  37801. set samples(value: number);
  37802. /**
  37803. * Resets the refresh counter of the texture and start bak from scratch.
  37804. * Could be useful to regenerate the texture if it is setup to render only once.
  37805. */
  37806. resetRefreshCounter(): void;
  37807. /**
  37808. * Define the refresh rate of the texture or the rendering frequency.
  37809. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  37810. */
  37811. get refreshRate(): number;
  37812. set refreshRate(value: number);
  37813. /**
  37814. * Adds a post process to the render target rendering passes.
  37815. * @param postProcess define the post process to add
  37816. */
  37817. addPostProcess(postProcess: PostProcess): void;
  37818. /**
  37819. * Clear all the post processes attached to the render target
  37820. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  37821. */
  37822. clearPostProcesses(dispose?: boolean): void;
  37823. /**
  37824. * Remove one of the post process from the list of attached post processes to the texture
  37825. * @param postProcess define the post process to remove from the list
  37826. */
  37827. removePostProcess(postProcess: PostProcess): void;
  37828. /** @hidden */
  37829. _shouldRender(): boolean;
  37830. /**
  37831. * Gets the actual render size of the texture.
  37832. * @returns the width of the render size
  37833. */
  37834. getRenderSize(): number;
  37835. /**
  37836. * Gets the actual render width of the texture.
  37837. * @returns the width of the render size
  37838. */
  37839. getRenderWidth(): number;
  37840. /**
  37841. * Gets the actual render height of the texture.
  37842. * @returns the height of the render size
  37843. */
  37844. getRenderHeight(): number;
  37845. /**
  37846. * Gets the actual number of layers of the texture.
  37847. * @returns the number of layers
  37848. */
  37849. getRenderLayers(): number;
  37850. /**
  37851. * Get if the texture can be rescaled or not.
  37852. */
  37853. get canRescale(): boolean;
  37854. /**
  37855. * Resize the texture using a ratio.
  37856. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  37857. */
  37858. scale(ratio: number): void;
  37859. /**
  37860. * Get the texture reflection matrix used to rotate/transform the reflection.
  37861. * @returns the reflection matrix
  37862. */
  37863. getReflectionTextureMatrix(): Matrix;
  37864. /**
  37865. * Resize the texture to a new desired size.
  37866. * Be carrefull as it will recreate all the data in the new texture.
  37867. * @param size Define the new size. It can be:
  37868. * - a number for squared texture,
  37869. * - an object containing { width: number, height: number }
  37870. * - or an object containing a ratio { ratio: number }
  37871. */
  37872. resize(size: number | {
  37873. width: number;
  37874. height: number;
  37875. } | {
  37876. ratio: number;
  37877. }): void;
  37878. private _defaultRenderListPrepared;
  37879. /**
  37880. * Renders all the objects from the render list into the texture.
  37881. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  37882. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  37883. */
  37884. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  37885. private _bestReflectionRenderTargetDimension;
  37886. private _prepareRenderingManager;
  37887. /**
  37888. * @hidden
  37889. * @param faceIndex face index to bind to if this is a cubetexture
  37890. * @param layer defines the index of the texture to bind in the array
  37891. */
  37892. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  37893. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  37894. private renderToTarget;
  37895. /**
  37896. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37897. * This allowed control for front to back rendering or reversly depending of the special needs.
  37898. *
  37899. * @param renderingGroupId The rendering group id corresponding to its index
  37900. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37901. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37902. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37903. */
  37904. 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;
  37905. /**
  37906. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37907. *
  37908. * @param renderingGroupId The rendering group id corresponding to its index
  37909. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37910. */
  37911. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  37912. /**
  37913. * Clones the texture.
  37914. * @returns the cloned texture
  37915. */
  37916. clone(): RenderTargetTexture;
  37917. /**
  37918. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  37919. * @returns The JSON representation of the texture
  37920. */
  37921. serialize(): any;
  37922. /**
  37923. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  37924. */
  37925. disposeFramebufferObjects(): void;
  37926. /**
  37927. * Dispose the texture and release its associated resources.
  37928. */
  37929. dispose(): void;
  37930. /** @hidden */
  37931. _rebuild(): void;
  37932. /**
  37933. * Clear the info related to rendering groups preventing retention point in material dispose.
  37934. */
  37935. freeRenderingGroups(): void;
  37936. /**
  37937. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  37938. * @returns the view count
  37939. */
  37940. getViewCount(): number;
  37941. }
  37942. }
  37943. declare module BABYLON {
  37944. /**
  37945. * Options to be used when creating an effect.
  37946. */
  37947. export interface IEffectCreationOptions {
  37948. /**
  37949. * Atrributes that will be used in the shader.
  37950. */
  37951. attributes: string[];
  37952. /**
  37953. * Uniform varible names that will be set in the shader.
  37954. */
  37955. uniformsNames: string[];
  37956. /**
  37957. * Uniform buffer variable names that will be set in the shader.
  37958. */
  37959. uniformBuffersNames: string[];
  37960. /**
  37961. * Sampler texture variable names that will be set in the shader.
  37962. */
  37963. samplers: string[];
  37964. /**
  37965. * Define statements that will be set in the shader.
  37966. */
  37967. defines: any;
  37968. /**
  37969. * Possible fallbacks for this effect to improve performance when needed.
  37970. */
  37971. fallbacks: Nullable<IEffectFallbacks>;
  37972. /**
  37973. * Callback that will be called when the shader is compiled.
  37974. */
  37975. onCompiled: Nullable<(effect: Effect) => void>;
  37976. /**
  37977. * Callback that will be called if an error occurs during shader compilation.
  37978. */
  37979. onError: Nullable<(effect: Effect, errors: string) => void>;
  37980. /**
  37981. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  37982. */
  37983. indexParameters?: any;
  37984. /**
  37985. * Max number of lights that can be used in the shader.
  37986. */
  37987. maxSimultaneousLights?: number;
  37988. /**
  37989. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  37990. */
  37991. transformFeedbackVaryings?: Nullable<string[]>;
  37992. /**
  37993. * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU
  37994. */
  37995. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  37996. /**
  37997. * Is this effect rendering to several color attachments ?
  37998. */
  37999. multiTarget?: boolean;
  38000. }
  38001. /**
  38002. * Effect containing vertex and fragment shader that can be executed on an object.
  38003. */
  38004. export class Effect implements IDisposable {
  38005. /**
  38006. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  38007. */
  38008. static ShadersRepository: string;
  38009. /**
  38010. * Enable logging of the shader code when a compilation error occurs
  38011. */
  38012. static LogShaderCodeOnCompilationError: boolean;
  38013. /**
  38014. * Name of the effect.
  38015. */
  38016. name: any;
  38017. /**
  38018. * String container all the define statements that should be set on the shader.
  38019. */
  38020. defines: string;
  38021. /**
  38022. * Callback that will be called when the shader is compiled.
  38023. */
  38024. onCompiled: Nullable<(effect: Effect) => void>;
  38025. /**
  38026. * Callback that will be called if an error occurs during shader compilation.
  38027. */
  38028. onError: Nullable<(effect: Effect, errors: string) => void>;
  38029. /**
  38030. * Callback that will be called when effect is bound.
  38031. */
  38032. onBind: Nullable<(effect: Effect) => void>;
  38033. /**
  38034. * Unique ID of the effect.
  38035. */
  38036. uniqueId: number;
  38037. /**
  38038. * Observable that will be called when the shader is compiled.
  38039. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  38040. */
  38041. onCompileObservable: Observable<Effect>;
  38042. /**
  38043. * Observable that will be called if an error occurs during shader compilation.
  38044. */
  38045. onErrorObservable: Observable<Effect>;
  38046. /** @hidden */
  38047. _onBindObservable: Nullable<Observable<Effect>>;
  38048. /**
  38049. * @hidden
  38050. * Specifies if the effect was previously ready
  38051. */
  38052. _wasPreviouslyReady: boolean;
  38053. /**
  38054. * Observable that will be called when effect is bound.
  38055. */
  38056. get onBindObservable(): Observable<Effect>;
  38057. /** @hidden */
  38058. _bonesComputationForcedToCPU: boolean;
  38059. /** @hidden */
  38060. _multiTarget: boolean;
  38061. private static _uniqueIdSeed;
  38062. private _engine;
  38063. private _uniformBuffersNames;
  38064. private _uniformBuffersNamesList;
  38065. private _uniformsNames;
  38066. private _samplerList;
  38067. private _samplers;
  38068. private _isReady;
  38069. private _compilationError;
  38070. private _allFallbacksProcessed;
  38071. private _attributesNames;
  38072. private _attributes;
  38073. private _attributeLocationByName;
  38074. private _uniforms;
  38075. /**
  38076. * Key for the effect.
  38077. * @hidden
  38078. */
  38079. _key: string;
  38080. private _indexParameters;
  38081. private _fallbacks;
  38082. private _vertexSourceCode;
  38083. private _fragmentSourceCode;
  38084. private _vertexSourceCodeOverride;
  38085. private _fragmentSourceCodeOverride;
  38086. private _transformFeedbackVaryings;
  38087. private _rawVertexSourceCode;
  38088. private _rawFragmentSourceCode;
  38089. /**
  38090. * Compiled shader to webGL program.
  38091. * @hidden
  38092. */
  38093. _pipelineContext: Nullable<IPipelineContext>;
  38094. private _valueCache;
  38095. private static _baseCache;
  38096. /**
  38097. * Instantiates an effect.
  38098. * An effect can be used to create/manage/execute vertex and fragment shaders.
  38099. * @param baseName Name of the effect.
  38100. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  38101. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  38102. * @param samplers List of sampler variables that will be passed to the shader.
  38103. * @param engine Engine to be used to render the effect
  38104. * @param defines Define statements to be added to the shader.
  38105. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  38106. * @param onCompiled Callback that will be called when the shader is compiled.
  38107. * @param onError Callback that will be called if an error occurs during shader compilation.
  38108. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38109. */
  38110. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  38111. private _useFinalCode;
  38112. /**
  38113. * Unique key for this effect
  38114. */
  38115. get key(): string;
  38116. /**
  38117. * If the effect has been compiled and prepared.
  38118. * @returns if the effect is compiled and prepared.
  38119. */
  38120. isReady(): boolean;
  38121. private _isReadyInternal;
  38122. /**
  38123. * The engine the effect was initialized with.
  38124. * @returns the engine.
  38125. */
  38126. getEngine(): Engine;
  38127. /**
  38128. * The pipeline context for this effect
  38129. * @returns the associated pipeline context
  38130. */
  38131. getPipelineContext(): Nullable<IPipelineContext>;
  38132. /**
  38133. * The set of names of attribute variables for the shader.
  38134. * @returns An array of attribute names.
  38135. */
  38136. getAttributesNames(): string[];
  38137. /**
  38138. * Returns the attribute at the given index.
  38139. * @param index The index of the attribute.
  38140. * @returns The location of the attribute.
  38141. */
  38142. getAttributeLocation(index: number): number;
  38143. /**
  38144. * Returns the attribute based on the name of the variable.
  38145. * @param name of the attribute to look up.
  38146. * @returns the attribute location.
  38147. */
  38148. getAttributeLocationByName(name: string): number;
  38149. /**
  38150. * The number of attributes.
  38151. * @returns the numnber of attributes.
  38152. */
  38153. getAttributesCount(): number;
  38154. /**
  38155. * Gets the index of a uniform variable.
  38156. * @param uniformName of the uniform to look up.
  38157. * @returns the index.
  38158. */
  38159. getUniformIndex(uniformName: string): number;
  38160. /**
  38161. * Returns the attribute based on the name of the variable.
  38162. * @param uniformName of the uniform to look up.
  38163. * @returns the location of the uniform.
  38164. */
  38165. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  38166. /**
  38167. * Returns an array of sampler variable names
  38168. * @returns The array of sampler variable names.
  38169. */
  38170. getSamplers(): string[];
  38171. /**
  38172. * Returns an array of uniform variable names
  38173. * @returns The array of uniform variable names.
  38174. */
  38175. getUniformNames(): string[];
  38176. /**
  38177. * Returns an array of uniform buffer variable names
  38178. * @returns The array of uniform buffer variable names.
  38179. */
  38180. getUniformBuffersNames(): string[];
  38181. /**
  38182. * Returns the index parameters used to create the effect
  38183. * @returns The index parameters object
  38184. */
  38185. getIndexParameters(): any;
  38186. /**
  38187. * The error from the last compilation.
  38188. * @returns the error string.
  38189. */
  38190. getCompilationError(): string;
  38191. /**
  38192. * Gets a boolean indicating that all fallbacks were used during compilation
  38193. * @returns true if all fallbacks were used
  38194. */
  38195. allFallbacksProcessed(): boolean;
  38196. /**
  38197. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  38198. * @param func The callback to be used.
  38199. */
  38200. executeWhenCompiled(func: (effect: Effect) => void): void;
  38201. private _checkIsReady;
  38202. private _loadShader;
  38203. /**
  38204. * Gets the vertex shader source code of this effect
  38205. */
  38206. get vertexSourceCode(): string;
  38207. /**
  38208. * Gets the fragment shader source code of this effect
  38209. */
  38210. get fragmentSourceCode(): string;
  38211. /**
  38212. * Gets the vertex shader source code before it has been processed by the preprocessor
  38213. */
  38214. get rawVertexSourceCode(): string;
  38215. /**
  38216. * Gets the fragment shader source code before it has been processed by the preprocessor
  38217. */
  38218. get rawFragmentSourceCode(): string;
  38219. /**
  38220. * Recompiles the webGL program
  38221. * @param vertexSourceCode The source code for the vertex shader.
  38222. * @param fragmentSourceCode The source code for the fragment shader.
  38223. * @param onCompiled Callback called when completed.
  38224. * @param onError Callback called on error.
  38225. * @hidden
  38226. */
  38227. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  38228. /**
  38229. * Prepares the effect
  38230. * @hidden
  38231. */
  38232. _prepareEffect(): void;
  38233. private _getShaderCodeAndErrorLine;
  38234. private _processCompilationErrors;
  38235. /**
  38236. * Checks if the effect is supported. (Must be called after compilation)
  38237. */
  38238. get isSupported(): boolean;
  38239. /**
  38240. * Binds a texture to the engine to be used as output of the shader.
  38241. * @param channel Name of the output variable.
  38242. * @param texture Texture to bind.
  38243. * @hidden
  38244. */
  38245. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  38246. /**
  38247. * Sets a texture on the engine to be used in the shader.
  38248. * @param channel Name of the sampler variable.
  38249. * @param texture Texture to set.
  38250. */
  38251. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  38252. /**
  38253. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  38254. * @param channel Name of the sampler variable.
  38255. * @param texture Texture to set.
  38256. */
  38257. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  38258. /**
  38259. * Sets an array of textures on the engine to be used in the shader.
  38260. * @param channel Name of the variable.
  38261. * @param textures Textures to set.
  38262. */
  38263. setTextureArray(channel: string, textures: ThinTexture[]): void;
  38264. /**
  38265. * 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)
  38266. * @param channel Name of the sampler variable.
  38267. * @param postProcess Post process to get the input texture from.
  38268. */
  38269. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  38270. /**
  38271. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  38272. * 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)
  38273. * @param channel Name of the sampler variable.
  38274. * @param postProcess Post process to get the output texture from.
  38275. */
  38276. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  38277. /** @hidden */
  38278. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  38279. /** @hidden */
  38280. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  38281. /** @hidden */
  38282. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  38283. /** @hidden */
  38284. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  38285. /**
  38286. * Binds a buffer to a uniform.
  38287. * @param buffer Buffer to bind.
  38288. * @param name Name of the uniform variable to bind to.
  38289. */
  38290. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  38291. /**
  38292. * Binds block to a uniform.
  38293. * @param blockName Name of the block to bind.
  38294. * @param index Index to bind.
  38295. */
  38296. bindUniformBlock(blockName: string, index: number): void;
  38297. /**
  38298. * Sets an interger value on a uniform variable.
  38299. * @param uniformName Name of the variable.
  38300. * @param value Value to be set.
  38301. * @returns this effect.
  38302. */
  38303. setInt(uniformName: string, value: number): Effect;
  38304. /**
  38305. * Sets an int array on a uniform variable.
  38306. * @param uniformName Name of the variable.
  38307. * @param array array to be set.
  38308. * @returns this effect.
  38309. */
  38310. setIntArray(uniformName: string, array: Int32Array): Effect;
  38311. /**
  38312. * 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)
  38313. * @param uniformName Name of the variable.
  38314. * @param array array to be set.
  38315. * @returns this effect.
  38316. */
  38317. setIntArray2(uniformName: string, array: Int32Array): Effect;
  38318. /**
  38319. * 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)
  38320. * @param uniformName Name of the variable.
  38321. * @param array array to be set.
  38322. * @returns this effect.
  38323. */
  38324. setIntArray3(uniformName: string, array: Int32Array): Effect;
  38325. /**
  38326. * 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)
  38327. * @param uniformName Name of the variable.
  38328. * @param array array to be set.
  38329. * @returns this effect.
  38330. */
  38331. setIntArray4(uniformName: string, array: Int32Array): Effect;
  38332. /**
  38333. * Sets an float array on a uniform variable.
  38334. * @param uniformName Name of the variable.
  38335. * @param array array to be set.
  38336. * @returns this effect.
  38337. */
  38338. setFloatArray(uniformName: string, array: Float32Array): Effect;
  38339. /**
  38340. * 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)
  38341. * @param uniformName Name of the variable.
  38342. * @param array array to be set.
  38343. * @returns this effect.
  38344. */
  38345. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  38346. /**
  38347. * 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)
  38348. * @param uniformName Name of the variable.
  38349. * @param array array to be set.
  38350. * @returns this effect.
  38351. */
  38352. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  38353. /**
  38354. * 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)
  38355. * @param uniformName Name of the variable.
  38356. * @param array array to be set.
  38357. * @returns this effect.
  38358. */
  38359. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  38360. /**
  38361. * Sets an array on a uniform variable.
  38362. * @param uniformName Name of the variable.
  38363. * @param array array to be set.
  38364. * @returns this effect.
  38365. */
  38366. setArray(uniformName: string, array: number[]): Effect;
  38367. /**
  38368. * 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)
  38369. * @param uniformName Name of the variable.
  38370. * @param array array to be set.
  38371. * @returns this effect.
  38372. */
  38373. setArray2(uniformName: string, array: number[]): Effect;
  38374. /**
  38375. * 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)
  38376. * @param uniformName Name of the variable.
  38377. * @param array array to be set.
  38378. * @returns this effect.
  38379. */
  38380. setArray3(uniformName: string, array: number[]): Effect;
  38381. /**
  38382. * 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)
  38383. * @param uniformName Name of the variable.
  38384. * @param array array to be set.
  38385. * @returns this effect.
  38386. */
  38387. setArray4(uniformName: string, array: number[]): Effect;
  38388. /**
  38389. * Sets matrices on a uniform variable.
  38390. * @param uniformName Name of the variable.
  38391. * @param matrices matrices to be set.
  38392. * @returns this effect.
  38393. */
  38394. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  38395. /**
  38396. * Sets matrix on a uniform variable.
  38397. * @param uniformName Name of the variable.
  38398. * @param matrix matrix to be set.
  38399. * @returns this effect.
  38400. */
  38401. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  38402. /**
  38403. * 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)
  38404. * @param uniformName Name of the variable.
  38405. * @param matrix matrix to be set.
  38406. * @returns this effect.
  38407. */
  38408. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  38409. /**
  38410. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  38411. * @param uniformName Name of the variable.
  38412. * @param matrix matrix to be set.
  38413. * @returns this effect.
  38414. */
  38415. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  38416. /**
  38417. * Sets a float on a uniform variable.
  38418. * @param uniformName Name of the variable.
  38419. * @param value value to be set.
  38420. * @returns this effect.
  38421. */
  38422. setFloat(uniformName: string, value: number): Effect;
  38423. /**
  38424. * Sets a boolean on a uniform variable.
  38425. * @param uniformName Name of the variable.
  38426. * @param bool value to be set.
  38427. * @returns this effect.
  38428. */
  38429. setBool(uniformName: string, bool: boolean): Effect;
  38430. /**
  38431. * Sets a Vector2 on a uniform variable.
  38432. * @param uniformName Name of the variable.
  38433. * @param vector2 vector2 to be set.
  38434. * @returns this effect.
  38435. */
  38436. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  38437. /**
  38438. * Sets a float2 on a uniform variable.
  38439. * @param uniformName Name of the variable.
  38440. * @param x First float in float2.
  38441. * @param y Second float in float2.
  38442. * @returns this effect.
  38443. */
  38444. setFloat2(uniformName: string, x: number, y: number): Effect;
  38445. /**
  38446. * Sets a Vector3 on a uniform variable.
  38447. * @param uniformName Name of the variable.
  38448. * @param vector3 Value to be set.
  38449. * @returns this effect.
  38450. */
  38451. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  38452. /**
  38453. * Sets a float3 on a uniform variable.
  38454. * @param uniformName Name of the variable.
  38455. * @param x First float in float3.
  38456. * @param y Second float in float3.
  38457. * @param z Third float in float3.
  38458. * @returns this effect.
  38459. */
  38460. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  38461. /**
  38462. * Sets a Vector4 on a uniform variable.
  38463. * @param uniformName Name of the variable.
  38464. * @param vector4 Value to be set.
  38465. * @returns this effect.
  38466. */
  38467. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  38468. /**
  38469. * Sets a float4 on a uniform variable.
  38470. * @param uniformName Name of the variable.
  38471. * @param x First float in float4.
  38472. * @param y Second float in float4.
  38473. * @param z Third float in float4.
  38474. * @param w Fourth float in float4.
  38475. * @returns this effect.
  38476. */
  38477. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  38478. /**
  38479. * Sets a Color3 on a uniform variable.
  38480. * @param uniformName Name of the variable.
  38481. * @param color3 Value to be set.
  38482. * @returns this effect.
  38483. */
  38484. setColor3(uniformName: string, color3: IColor3Like): Effect;
  38485. /**
  38486. * Sets a Color4 on a uniform variable.
  38487. * @param uniformName Name of the variable.
  38488. * @param color3 Value to be set.
  38489. * @param alpha Alpha value to be set.
  38490. * @returns this effect.
  38491. */
  38492. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  38493. /**
  38494. * Sets a Color4 on a uniform variable
  38495. * @param uniformName defines the name of the variable
  38496. * @param color4 defines the value to be set
  38497. * @returns this effect.
  38498. */
  38499. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  38500. /** Release all associated resources */
  38501. dispose(): void;
  38502. /**
  38503. * This function will add a new shader to the shader store
  38504. * @param name the name of the shader
  38505. * @param pixelShader optional pixel shader content
  38506. * @param vertexShader optional vertex shader content
  38507. */
  38508. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  38509. /**
  38510. * Store of each shader (The can be looked up using effect.key)
  38511. */
  38512. static ShadersStore: {
  38513. [key: string]: string;
  38514. };
  38515. /**
  38516. * Store of each included file for a shader (The can be looked up using effect.key)
  38517. */
  38518. static IncludesShadersStore: {
  38519. [key: string]: string;
  38520. };
  38521. /**
  38522. * Resets the cache of effects.
  38523. */
  38524. static ResetCache(): void;
  38525. }
  38526. }
  38527. declare module BABYLON {
  38528. /**
  38529. * Interface used to describe the capabilities of the engine relatively to the current browser
  38530. */
  38531. export interface EngineCapabilities {
  38532. /** Maximum textures units per fragment shader */
  38533. maxTexturesImageUnits: number;
  38534. /** Maximum texture units per vertex shader */
  38535. maxVertexTextureImageUnits: number;
  38536. /** Maximum textures units in the entire pipeline */
  38537. maxCombinedTexturesImageUnits: number;
  38538. /** Maximum texture size */
  38539. maxTextureSize: number;
  38540. /** Maximum texture samples */
  38541. maxSamples?: number;
  38542. /** Maximum cube texture size */
  38543. maxCubemapTextureSize: number;
  38544. /** Maximum render texture size */
  38545. maxRenderTextureSize: number;
  38546. /** Maximum number of vertex attributes */
  38547. maxVertexAttribs: number;
  38548. /** Maximum number of varyings */
  38549. maxVaryingVectors: number;
  38550. /** Maximum number of uniforms per vertex shader */
  38551. maxVertexUniformVectors: number;
  38552. /** Maximum number of uniforms per fragment shader */
  38553. maxFragmentUniformVectors: number;
  38554. /** Defines if standard derivates (dx/dy) are supported */
  38555. standardDerivatives: boolean;
  38556. /** Defines if s3tc texture compression is supported */
  38557. s3tc?: WEBGL_compressed_texture_s3tc;
  38558. /** Defines if pvrtc texture compression is supported */
  38559. pvrtc: any;
  38560. /** Defines if etc1 texture compression is supported */
  38561. etc1: any;
  38562. /** Defines if etc2 texture compression is supported */
  38563. etc2: any;
  38564. /** Defines if astc texture compression is supported */
  38565. astc: any;
  38566. /** Defines if bptc texture compression is supported */
  38567. bptc: any;
  38568. /** Defines if float textures are supported */
  38569. textureFloat: boolean;
  38570. /** Defines if vertex array objects are supported */
  38571. vertexArrayObject: boolean;
  38572. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  38573. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  38574. /** Gets the maximum level of anisotropy supported */
  38575. maxAnisotropy: number;
  38576. /** Defines if instancing is supported */
  38577. instancedArrays: boolean;
  38578. /** Defines if 32 bits indices are supported */
  38579. uintIndices: boolean;
  38580. /** Defines if high precision shaders are supported */
  38581. highPrecisionShaderSupported: boolean;
  38582. /** Defines if depth reading in the fragment shader is supported */
  38583. fragmentDepthSupported: boolean;
  38584. /** Defines if float texture linear filtering is supported*/
  38585. textureFloatLinearFiltering: boolean;
  38586. /** Defines if rendering to float textures is supported */
  38587. textureFloatRender: boolean;
  38588. /** Defines if half float textures are supported*/
  38589. textureHalfFloat: boolean;
  38590. /** Defines if half float texture linear filtering is supported*/
  38591. textureHalfFloatLinearFiltering: boolean;
  38592. /** Defines if rendering to half float textures is supported */
  38593. textureHalfFloatRender: boolean;
  38594. /** Defines if textureLOD shader command is supported */
  38595. textureLOD: boolean;
  38596. /** Defines if draw buffers extension is supported */
  38597. drawBuffersExtension: boolean;
  38598. /** Defines if depth textures are supported */
  38599. depthTextureExtension: boolean;
  38600. /** Defines if float color buffer are supported */
  38601. colorBufferFloat: boolean;
  38602. /** Gets disjoint timer query extension (null if not supported) */
  38603. timerQuery?: EXT_disjoint_timer_query;
  38604. /** Defines if timestamp can be used with timer query */
  38605. canUseTimestampForTimerQuery: boolean;
  38606. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  38607. multiview?: any;
  38608. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  38609. oculusMultiview?: any;
  38610. /** Function used to let the system compiles shaders in background */
  38611. parallelShaderCompile?: {
  38612. COMPLETION_STATUS_KHR: number;
  38613. };
  38614. /** Max number of texture samples for MSAA */
  38615. maxMSAASamples: number;
  38616. /** Defines if the blend min max extension is supported */
  38617. blendMinMax: boolean;
  38618. }
  38619. }
  38620. declare module BABYLON {
  38621. /**
  38622. * @hidden
  38623. **/
  38624. export class DepthCullingState {
  38625. private _isDepthTestDirty;
  38626. private _isDepthMaskDirty;
  38627. private _isDepthFuncDirty;
  38628. private _isCullFaceDirty;
  38629. private _isCullDirty;
  38630. private _isZOffsetDirty;
  38631. private _isFrontFaceDirty;
  38632. private _depthTest;
  38633. private _depthMask;
  38634. private _depthFunc;
  38635. private _cull;
  38636. private _cullFace;
  38637. private _zOffset;
  38638. private _frontFace;
  38639. /**
  38640. * Initializes the state.
  38641. */
  38642. constructor();
  38643. get isDirty(): boolean;
  38644. get zOffset(): number;
  38645. set zOffset(value: number);
  38646. get cullFace(): Nullable<number>;
  38647. set cullFace(value: Nullable<number>);
  38648. get cull(): Nullable<boolean>;
  38649. set cull(value: Nullable<boolean>);
  38650. get depthFunc(): Nullable<number>;
  38651. set depthFunc(value: Nullable<number>);
  38652. get depthMask(): boolean;
  38653. set depthMask(value: boolean);
  38654. get depthTest(): boolean;
  38655. set depthTest(value: boolean);
  38656. get frontFace(): Nullable<number>;
  38657. set frontFace(value: Nullable<number>);
  38658. reset(): void;
  38659. apply(gl: WebGLRenderingContext): void;
  38660. }
  38661. }
  38662. declare module BABYLON {
  38663. /**
  38664. * @hidden
  38665. **/
  38666. export class StencilState {
  38667. /** 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 */
  38668. static readonly ALWAYS: number;
  38669. /** Passed to stencilOperation to specify that stencil value must be kept */
  38670. static readonly KEEP: number;
  38671. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38672. static readonly REPLACE: number;
  38673. private _isStencilTestDirty;
  38674. private _isStencilMaskDirty;
  38675. private _isStencilFuncDirty;
  38676. private _isStencilOpDirty;
  38677. private _stencilTest;
  38678. private _stencilMask;
  38679. private _stencilFunc;
  38680. private _stencilFuncRef;
  38681. private _stencilFuncMask;
  38682. private _stencilOpStencilFail;
  38683. private _stencilOpDepthFail;
  38684. private _stencilOpStencilDepthPass;
  38685. get isDirty(): boolean;
  38686. get stencilFunc(): number;
  38687. set stencilFunc(value: number);
  38688. get stencilFuncRef(): number;
  38689. set stencilFuncRef(value: number);
  38690. get stencilFuncMask(): number;
  38691. set stencilFuncMask(value: number);
  38692. get stencilOpStencilFail(): number;
  38693. set stencilOpStencilFail(value: number);
  38694. get stencilOpDepthFail(): number;
  38695. set stencilOpDepthFail(value: number);
  38696. get stencilOpStencilDepthPass(): number;
  38697. set stencilOpStencilDepthPass(value: number);
  38698. get stencilMask(): number;
  38699. set stencilMask(value: number);
  38700. get stencilTest(): boolean;
  38701. set stencilTest(value: boolean);
  38702. constructor();
  38703. reset(): void;
  38704. apply(gl: WebGLRenderingContext): void;
  38705. }
  38706. }
  38707. declare module BABYLON {
  38708. /**
  38709. * @hidden
  38710. **/
  38711. export class AlphaState {
  38712. private _isAlphaBlendDirty;
  38713. private _isBlendFunctionParametersDirty;
  38714. private _isBlendEquationParametersDirty;
  38715. private _isBlendConstantsDirty;
  38716. private _alphaBlend;
  38717. private _blendFunctionParameters;
  38718. private _blendEquationParameters;
  38719. private _blendConstants;
  38720. /**
  38721. * Initializes the state.
  38722. */
  38723. constructor();
  38724. get isDirty(): boolean;
  38725. get alphaBlend(): boolean;
  38726. set alphaBlend(value: boolean);
  38727. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  38728. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  38729. setAlphaEquationParameters(rgb: number, alpha: number): void;
  38730. reset(): void;
  38731. apply(gl: WebGLRenderingContext): void;
  38732. }
  38733. }
  38734. declare module BABYLON {
  38735. /** @hidden */
  38736. export class WebGLShaderProcessor implements IShaderProcessor {
  38737. postProcessor(code: string, defines: string[], isFragment: boolean, engine: ThinEngine): string;
  38738. }
  38739. }
  38740. declare module BABYLON {
  38741. /** @hidden */
  38742. export class WebGL2ShaderProcessor implements IShaderProcessor {
  38743. attributeProcessor(attribute: string): string;
  38744. varyingProcessor(varying: string, isFragment: boolean): string;
  38745. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  38746. }
  38747. }
  38748. declare module BABYLON {
  38749. /**
  38750. * Interface for attribute information associated with buffer instanciation
  38751. */
  38752. export interface InstancingAttributeInfo {
  38753. /**
  38754. * Name of the GLSL attribute
  38755. * if attribute index is not specified, this is used to retrieve the index from the effect
  38756. */
  38757. attributeName: string;
  38758. /**
  38759. * Index/offset of the attribute in the vertex shader
  38760. * if not specified, this will be computes from the name.
  38761. */
  38762. index?: number;
  38763. /**
  38764. * size of the attribute, 1, 2, 3 or 4
  38765. */
  38766. attributeSize: number;
  38767. /**
  38768. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  38769. */
  38770. offset: number;
  38771. /**
  38772. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  38773. * default to 1
  38774. */
  38775. divisor?: number;
  38776. /**
  38777. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  38778. * default is FLOAT
  38779. */
  38780. attributeType?: number;
  38781. /**
  38782. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  38783. */
  38784. normalized?: boolean;
  38785. }
  38786. }
  38787. declare module BABYLON {
  38788. interface ThinEngine {
  38789. /**
  38790. * Update a video texture
  38791. * @param texture defines the texture to update
  38792. * @param video defines the video element to use
  38793. * @param invertY defines if data must be stored with Y axis inverted
  38794. */
  38795. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  38796. }
  38797. }
  38798. declare module BABYLON {
  38799. interface ThinEngine {
  38800. /**
  38801. * Creates a dynamic texture
  38802. * @param width defines the width of the texture
  38803. * @param height defines the height of the texture
  38804. * @param generateMipMaps defines if the engine should generate the mip levels
  38805. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  38806. * @returns the dynamic texture inside an InternalTexture
  38807. */
  38808. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  38809. /**
  38810. * Update the content of a dynamic texture
  38811. * @param texture defines the texture to update
  38812. * @param source defines the source containing the data
  38813. * @param invertY defines if data must be stored with Y axis inverted
  38814. * @param premulAlpha defines if alpha is stored as premultiplied
  38815. * @param format defines the format of the data
  38816. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  38817. */
  38818. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  38819. }
  38820. }
  38821. declare module BABYLON {
  38822. /**
  38823. * Settings for finer control over video usage
  38824. */
  38825. export interface VideoTextureSettings {
  38826. /**
  38827. * Applies `autoplay` to video, if specified
  38828. */
  38829. autoPlay?: boolean;
  38830. /**
  38831. * Applies `muted` to video, if specified
  38832. */
  38833. muted?: boolean;
  38834. /**
  38835. * Applies `loop` to video, if specified
  38836. */
  38837. loop?: boolean;
  38838. /**
  38839. * Automatically updates internal texture from video at every frame in the render loop
  38840. */
  38841. autoUpdateTexture: boolean;
  38842. /**
  38843. * Image src displayed during the video loading or until the user interacts with the video.
  38844. */
  38845. poster?: string;
  38846. }
  38847. /**
  38848. * If you want to display a video in your scene, this is the special texture for that.
  38849. * This special texture works similar to other textures, with the exception of a few parameters.
  38850. * @see https://doc.babylonjs.com/how_to/video_texture
  38851. */
  38852. export class VideoTexture extends Texture {
  38853. /**
  38854. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  38855. */
  38856. readonly autoUpdateTexture: boolean;
  38857. /**
  38858. * The video instance used by the texture internally
  38859. */
  38860. readonly video: HTMLVideoElement;
  38861. private _onUserActionRequestedObservable;
  38862. /**
  38863. * Event triggerd when a dom action is required by the user to play the video.
  38864. * This happens due to recent changes in browser policies preventing video to auto start.
  38865. */
  38866. get onUserActionRequestedObservable(): Observable<Texture>;
  38867. private _generateMipMaps;
  38868. private _stillImageCaptured;
  38869. private _displayingPosterTexture;
  38870. private _settings;
  38871. private _createInternalTextureOnEvent;
  38872. private _frameId;
  38873. private _currentSrc;
  38874. /**
  38875. * Creates a video texture.
  38876. * If you want to display a video in your scene, this is the special texture for that.
  38877. * This special texture works similar to other textures, with the exception of a few parameters.
  38878. * @see https://doc.babylonjs.com/how_to/video_texture
  38879. * @param name optional name, will detect from video source, if not defined
  38880. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  38881. * @param scene is obviously the current scene.
  38882. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  38883. * @param invertY is false by default but can be used to invert video on Y axis
  38884. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  38885. * @param settings allows finer control over video usage
  38886. */
  38887. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  38888. private _getName;
  38889. private _getVideo;
  38890. private _createInternalTexture;
  38891. private reset;
  38892. /**
  38893. * @hidden Internal method to initiate `update`.
  38894. */
  38895. _rebuild(): void;
  38896. /**
  38897. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  38898. */
  38899. update(): void;
  38900. /**
  38901. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  38902. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  38903. */
  38904. updateTexture(isVisible: boolean): void;
  38905. protected _updateInternalTexture: () => void;
  38906. /**
  38907. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  38908. * @param url New url.
  38909. */
  38910. updateURL(url: string): void;
  38911. /**
  38912. * Clones the texture.
  38913. * @returns the cloned texture
  38914. */
  38915. clone(): VideoTexture;
  38916. /**
  38917. * Dispose the texture and release its associated resources.
  38918. */
  38919. dispose(): void;
  38920. /**
  38921. * Creates a video texture straight from a stream.
  38922. * @param scene Define the scene the texture should be created in
  38923. * @param stream Define the stream the texture should be created from
  38924. * @returns The created video texture as a promise
  38925. */
  38926. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  38927. /**
  38928. * Creates a video texture straight from your WebCam video feed.
  38929. * @param scene Define the scene the texture should be created in
  38930. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38931. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38932. * @returns The created video texture as a promise
  38933. */
  38934. static CreateFromWebCamAsync(scene: Scene, constraints: {
  38935. minWidth: number;
  38936. maxWidth: number;
  38937. minHeight: number;
  38938. maxHeight: number;
  38939. deviceId: string;
  38940. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  38941. /**
  38942. * Creates a video texture straight from your WebCam video feed.
  38943. * @param scene Define the scene the texture should be created in
  38944. * @param onReady Define a callback to triggered once the texture will be ready
  38945. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38946. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38947. */
  38948. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  38949. minWidth: number;
  38950. maxWidth: number;
  38951. minHeight: number;
  38952. maxHeight: number;
  38953. deviceId: string;
  38954. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  38955. }
  38956. }
  38957. declare module BABYLON {
  38958. /**
  38959. * Defines the interface used by objects working like Scene
  38960. * @hidden
  38961. */
  38962. export interface ISceneLike {
  38963. _addPendingData(data: any): void;
  38964. _removePendingData(data: any): void;
  38965. offlineProvider: IOfflineProvider;
  38966. }
  38967. /**
  38968. * Information about the current host
  38969. */
  38970. export interface HostInformation {
  38971. /**
  38972. * Defines if the current host is a mobile
  38973. */
  38974. isMobile: boolean;
  38975. }
  38976. /** Interface defining initialization parameters for Engine class */
  38977. export interface EngineOptions extends WebGLContextAttributes {
  38978. /**
  38979. * Defines if the engine should no exceed a specified device ratio
  38980. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  38981. */
  38982. limitDeviceRatio?: number;
  38983. /**
  38984. * Defines if webvr should be enabled automatically
  38985. * @see https://doc.babylonjs.com/how_to/webvr_camera
  38986. */
  38987. autoEnableWebVR?: boolean;
  38988. /**
  38989. * Defines if webgl2 should be turned off even if supported
  38990. * @see https://doc.babylonjs.com/features/webgl2
  38991. */
  38992. disableWebGL2Support?: boolean;
  38993. /**
  38994. * Defines if webaudio should be initialized as well
  38995. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38996. */
  38997. audioEngine?: boolean;
  38998. /**
  38999. * Defines if animations should run using a deterministic lock step
  39000. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39001. */
  39002. deterministicLockstep?: boolean;
  39003. /** Defines the maximum steps to use with deterministic lock step mode */
  39004. lockstepMaxSteps?: number;
  39005. /** Defines the seconds between each deterministic lock step */
  39006. timeStep?: number;
  39007. /**
  39008. * Defines that engine should ignore context lost events
  39009. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  39010. */
  39011. doNotHandleContextLost?: boolean;
  39012. /**
  39013. * Defines that engine should ignore modifying touch action attribute and style
  39014. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  39015. */
  39016. doNotHandleTouchAction?: boolean;
  39017. /**
  39018. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  39019. */
  39020. useHighPrecisionFloats?: boolean;
  39021. /**
  39022. * Make the canvas XR Compatible for XR sessions
  39023. */
  39024. xrCompatible?: boolean;
  39025. /**
  39026. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  39027. */
  39028. useHighPrecisionMatrix?: boolean;
  39029. /**
  39030. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  39031. */
  39032. failIfMajorPerformanceCaveat?: boolean;
  39033. }
  39034. /**
  39035. * The base engine class (root of all engines)
  39036. */
  39037. export class ThinEngine {
  39038. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  39039. static ExceptionList: ({
  39040. key: string;
  39041. capture: string;
  39042. captureConstraint: number;
  39043. targets: string[];
  39044. } | {
  39045. key: string;
  39046. capture: null;
  39047. captureConstraint: null;
  39048. targets: string[];
  39049. })[];
  39050. /** @hidden */
  39051. static _TextureLoaders: IInternalTextureLoader[];
  39052. /**
  39053. * Returns the current npm package of the sdk
  39054. */
  39055. static get NpmPackage(): string;
  39056. /**
  39057. * Returns the current version of the framework
  39058. */
  39059. static get Version(): string;
  39060. /**
  39061. * Returns a string describing the current engine
  39062. */
  39063. get description(): string;
  39064. /**
  39065. * Gets or sets the epsilon value used by collision engine
  39066. */
  39067. static CollisionsEpsilon: number;
  39068. /**
  39069. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  39070. */
  39071. static get ShadersRepository(): string;
  39072. static set ShadersRepository(value: string);
  39073. /** @hidden */
  39074. _shaderProcessor: IShaderProcessor;
  39075. /**
  39076. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  39077. */
  39078. forcePOTTextures: boolean;
  39079. /**
  39080. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  39081. */
  39082. isFullscreen: boolean;
  39083. /**
  39084. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  39085. */
  39086. cullBackFaces: boolean;
  39087. /**
  39088. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  39089. */
  39090. renderEvenInBackground: boolean;
  39091. /**
  39092. * Gets or sets a boolean indicating that cache can be kept between frames
  39093. */
  39094. preventCacheWipeBetweenFrames: boolean;
  39095. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  39096. validateShaderPrograms: boolean;
  39097. /**
  39098. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  39099. * This can provide greater z depth for distant objects.
  39100. */
  39101. useReverseDepthBuffer: boolean;
  39102. /**
  39103. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  39104. */
  39105. disableUniformBuffers: boolean;
  39106. /** @hidden */
  39107. _uniformBuffers: UniformBuffer[];
  39108. /**
  39109. * Gets a boolean indicating that the engine supports uniform buffers
  39110. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  39111. */
  39112. get supportsUniformBuffers(): boolean;
  39113. /** @hidden */
  39114. _gl: WebGLRenderingContext;
  39115. /** @hidden */
  39116. _webGLVersion: number;
  39117. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  39118. protected _windowIsBackground: boolean;
  39119. protected _creationOptions: EngineOptions;
  39120. protected _highPrecisionShadersAllowed: boolean;
  39121. /** @hidden */
  39122. get _shouldUseHighPrecisionShader(): boolean;
  39123. /**
  39124. * Gets a boolean indicating that only power of 2 textures are supported
  39125. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  39126. */
  39127. get needPOTTextures(): boolean;
  39128. /** @hidden */
  39129. _badOS: boolean;
  39130. /** @hidden */
  39131. _badDesktopOS: boolean;
  39132. private _hardwareScalingLevel;
  39133. /** @hidden */
  39134. _caps: EngineCapabilities;
  39135. private _isStencilEnable;
  39136. private _glVersion;
  39137. private _glRenderer;
  39138. private _glVendor;
  39139. /** @hidden */
  39140. _videoTextureSupported: boolean;
  39141. protected _renderingQueueLaunched: boolean;
  39142. protected _activeRenderLoops: (() => void)[];
  39143. /**
  39144. * Observable signaled when a context lost event is raised
  39145. */
  39146. onContextLostObservable: Observable<ThinEngine>;
  39147. /**
  39148. * Observable signaled when a context restored event is raised
  39149. */
  39150. onContextRestoredObservable: Observable<ThinEngine>;
  39151. private _onContextLost;
  39152. private _onContextRestored;
  39153. protected _contextWasLost: boolean;
  39154. /** @hidden */
  39155. _doNotHandleContextLost: boolean;
  39156. /**
  39157. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  39158. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  39159. */
  39160. get doNotHandleContextLost(): boolean;
  39161. set doNotHandleContextLost(value: boolean);
  39162. /**
  39163. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  39164. */
  39165. disableVertexArrayObjects: boolean;
  39166. /** @hidden */
  39167. protected _colorWrite: boolean;
  39168. /** @hidden */
  39169. protected _colorWriteChanged: boolean;
  39170. /** @hidden */
  39171. protected _depthCullingState: DepthCullingState;
  39172. /** @hidden */
  39173. protected _stencilState: StencilState;
  39174. /** @hidden */
  39175. _alphaState: AlphaState;
  39176. /** @hidden */
  39177. _alphaMode: number;
  39178. /** @hidden */
  39179. _alphaEquation: number;
  39180. /** @hidden */
  39181. _internalTexturesCache: InternalTexture[];
  39182. /** @hidden */
  39183. protected _activeChannel: number;
  39184. private _currentTextureChannel;
  39185. /** @hidden */
  39186. protected _boundTexturesCache: {
  39187. [key: string]: Nullable<InternalTexture>;
  39188. };
  39189. /** @hidden */
  39190. protected _currentEffect: Nullable<Effect>;
  39191. /** @hidden */
  39192. protected _currentProgram: Nullable<WebGLProgram>;
  39193. private _compiledEffects;
  39194. private _vertexAttribArraysEnabled;
  39195. /** @hidden */
  39196. protected _cachedViewport: Nullable<IViewportLike>;
  39197. private _cachedVertexArrayObject;
  39198. /** @hidden */
  39199. protected _cachedVertexBuffers: any;
  39200. /** @hidden */
  39201. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  39202. /** @hidden */
  39203. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  39204. /** @hidden */
  39205. _currentRenderTarget: Nullable<InternalTexture>;
  39206. private _uintIndicesCurrentlySet;
  39207. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  39208. /** @hidden */
  39209. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  39210. /** @hidden */
  39211. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  39212. private _currentBufferPointers;
  39213. private _currentInstanceLocations;
  39214. private _currentInstanceBuffers;
  39215. private _textureUnits;
  39216. /** @hidden */
  39217. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  39218. /** @hidden */
  39219. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  39220. /** @hidden */
  39221. _boundRenderFunction: any;
  39222. private _vaoRecordInProgress;
  39223. private _mustWipeVertexAttributes;
  39224. private _emptyTexture;
  39225. private _emptyCubeTexture;
  39226. private _emptyTexture3D;
  39227. private _emptyTexture2DArray;
  39228. /** @hidden */
  39229. _frameHandler: number;
  39230. private _nextFreeTextureSlots;
  39231. private _maxSimultaneousTextures;
  39232. private _activeRequests;
  39233. /** @hidden */
  39234. _transformTextureUrl: Nullable<(url: string) => string>;
  39235. /**
  39236. * Gets information about the current host
  39237. */
  39238. hostInformation: HostInformation;
  39239. protected get _supportsHardwareTextureRescaling(): boolean;
  39240. private _framebufferDimensionsObject;
  39241. /**
  39242. * sets the object from which width and height will be taken from when getting render width and height
  39243. * Will fallback to the gl object
  39244. * @param dimensions the framebuffer width and height that will be used.
  39245. */
  39246. set framebufferDimensionsObject(dimensions: Nullable<{
  39247. framebufferWidth: number;
  39248. framebufferHeight: number;
  39249. }>);
  39250. /**
  39251. * Gets the current viewport
  39252. */
  39253. get currentViewport(): Nullable<IViewportLike>;
  39254. /**
  39255. * Gets the default empty texture
  39256. */
  39257. get emptyTexture(): InternalTexture;
  39258. /**
  39259. * Gets the default empty 3D texture
  39260. */
  39261. get emptyTexture3D(): InternalTexture;
  39262. /**
  39263. * Gets the default empty 2D array texture
  39264. */
  39265. get emptyTexture2DArray(): InternalTexture;
  39266. /**
  39267. * Gets the default empty cube texture
  39268. */
  39269. get emptyCubeTexture(): InternalTexture;
  39270. /**
  39271. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  39272. */
  39273. readonly premultipliedAlpha: boolean;
  39274. /**
  39275. * Observable event triggered before each texture is initialized
  39276. */
  39277. onBeforeTextureInitObservable: Observable<Texture>;
  39278. /**
  39279. * Creates a new engine
  39280. * @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
  39281. * @param antialias defines enable antialiasing (default: false)
  39282. * @param options defines further options to be sent to the getContext() function
  39283. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  39284. */
  39285. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  39286. private _rebuildInternalTextures;
  39287. private _rebuildEffects;
  39288. /**
  39289. * Gets a boolean indicating if all created effects are ready
  39290. * @returns true if all effects are ready
  39291. */
  39292. areAllEffectsReady(): boolean;
  39293. protected _rebuildBuffers(): void;
  39294. protected _initGLContext(): void;
  39295. /**
  39296. * Gets version of the current webGL context
  39297. */
  39298. get webGLVersion(): number;
  39299. /**
  39300. * Gets a string identifying the name of the class
  39301. * @returns "Engine" string
  39302. */
  39303. getClassName(): string;
  39304. /**
  39305. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  39306. */
  39307. get isStencilEnable(): boolean;
  39308. /** @hidden */
  39309. _prepareWorkingCanvas(): void;
  39310. /**
  39311. * Reset the texture cache to empty state
  39312. */
  39313. resetTextureCache(): void;
  39314. /**
  39315. * Gets an object containing information about the current webGL context
  39316. * @returns an object containing the vender, the renderer and the version of the current webGL context
  39317. */
  39318. getGlInfo(): {
  39319. vendor: string;
  39320. renderer: string;
  39321. version: string;
  39322. };
  39323. /**
  39324. * Defines the hardware scaling level.
  39325. * By default the hardware scaling level is computed from the window device ratio.
  39326. * 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.
  39327. * @param level defines the level to use
  39328. */
  39329. setHardwareScalingLevel(level: number): void;
  39330. /**
  39331. * Gets the current hardware scaling level.
  39332. * By default the hardware scaling level is computed from the window device ratio.
  39333. * 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.
  39334. * @returns a number indicating the current hardware scaling level
  39335. */
  39336. getHardwareScalingLevel(): number;
  39337. /**
  39338. * Gets the list of loaded textures
  39339. * @returns an array containing all loaded textures
  39340. */
  39341. getLoadedTexturesCache(): InternalTexture[];
  39342. /**
  39343. * Gets the object containing all engine capabilities
  39344. * @returns the EngineCapabilities object
  39345. */
  39346. getCaps(): EngineCapabilities;
  39347. /**
  39348. * stop executing a render loop function and remove it from the execution array
  39349. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  39350. */
  39351. stopRenderLoop(renderFunction?: () => void): void;
  39352. /** @hidden */
  39353. _renderLoop(): void;
  39354. /**
  39355. * Gets the HTML canvas attached with the current webGL context
  39356. * @returns a HTML canvas
  39357. */
  39358. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  39359. /**
  39360. * Gets host window
  39361. * @returns the host window object
  39362. */
  39363. getHostWindow(): Nullable<Window>;
  39364. /**
  39365. * Gets the current render width
  39366. * @param useScreen defines if screen size must be used (or the current render target if any)
  39367. * @returns a number defining the current render width
  39368. */
  39369. getRenderWidth(useScreen?: boolean): number;
  39370. /**
  39371. * Gets the current render height
  39372. * @param useScreen defines if screen size must be used (or the current render target if any)
  39373. * @returns a number defining the current render height
  39374. */
  39375. getRenderHeight(useScreen?: boolean): number;
  39376. /**
  39377. * Can be used to override the current requestAnimationFrame requester.
  39378. * @hidden
  39379. */
  39380. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  39381. /**
  39382. * Register and execute a render loop. The engine can have more than one render function
  39383. * @param renderFunction defines the function to continuously execute
  39384. */
  39385. runRenderLoop(renderFunction: () => void): void;
  39386. /**
  39387. * Clear the current render buffer or the current render target (if any is set up)
  39388. * @param color defines the color to use
  39389. * @param backBuffer defines if the back buffer must be cleared
  39390. * @param depth defines if the depth buffer must be cleared
  39391. * @param stencil defines if the stencil buffer must be cleared
  39392. */
  39393. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  39394. private _viewportCached;
  39395. /** @hidden */
  39396. _viewport(x: number, y: number, width: number, height: number): void;
  39397. /**
  39398. * Set the WebGL's viewport
  39399. * @param viewport defines the viewport element to be used
  39400. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  39401. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  39402. */
  39403. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  39404. /**
  39405. * Begin a new frame
  39406. */
  39407. beginFrame(): void;
  39408. /**
  39409. * Enf the current frame
  39410. */
  39411. endFrame(): void;
  39412. /**
  39413. * Resize the view according to the canvas' size
  39414. */
  39415. resize(): void;
  39416. /**
  39417. * Force a specific size of the canvas
  39418. * @param width defines the new canvas' width
  39419. * @param height defines the new canvas' height
  39420. * @returns true if the size was changed
  39421. */
  39422. setSize(width: number, height: number): boolean;
  39423. /**
  39424. * Binds the frame buffer to the specified texture.
  39425. * @param texture The texture to render to or null for the default canvas
  39426. * @param faceIndex The face of the texture to render to in case of cube texture
  39427. * @param requiredWidth The width of the target to render to
  39428. * @param requiredHeight The height of the target to render to
  39429. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  39430. * @param lodLevel defines the lod level to bind to the frame buffer
  39431. * @param layer defines the 2d array index to bind to frame buffer to
  39432. */
  39433. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  39434. /** @hidden */
  39435. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  39436. /**
  39437. * Unbind the current render target texture from the webGL context
  39438. * @param texture defines the render target texture to unbind
  39439. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  39440. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  39441. */
  39442. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  39443. /**
  39444. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  39445. */
  39446. flushFramebuffer(): void;
  39447. /**
  39448. * Unbind the current render target and bind the default framebuffer
  39449. */
  39450. restoreDefaultFramebuffer(): void;
  39451. /** @hidden */
  39452. protected _resetVertexBufferBinding(): void;
  39453. /**
  39454. * Creates a vertex buffer
  39455. * @param data the data for the vertex buffer
  39456. * @returns the new WebGL static buffer
  39457. */
  39458. createVertexBuffer(data: DataArray): DataBuffer;
  39459. private _createVertexBuffer;
  39460. /**
  39461. * Creates a dynamic vertex buffer
  39462. * @param data the data for the dynamic vertex buffer
  39463. * @returns the new WebGL dynamic buffer
  39464. */
  39465. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  39466. protected _resetIndexBufferBinding(): void;
  39467. /**
  39468. * Creates a new index buffer
  39469. * @param indices defines the content of the index buffer
  39470. * @param updatable defines if the index buffer must be updatable
  39471. * @returns a new webGL buffer
  39472. */
  39473. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  39474. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  39475. /**
  39476. * Bind a webGL buffer to the webGL context
  39477. * @param buffer defines the buffer to bind
  39478. */
  39479. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  39480. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  39481. private bindBuffer;
  39482. /**
  39483. * update the bound buffer with the given data
  39484. * @param data defines the data to update
  39485. */
  39486. updateArrayBuffer(data: Float32Array): void;
  39487. private _vertexAttribPointer;
  39488. /** @hidden */
  39489. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  39490. private _bindVertexBuffersAttributes;
  39491. /**
  39492. * Records a vertex array object
  39493. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  39494. * @param vertexBuffers defines the list of vertex buffers to store
  39495. * @param indexBuffer defines the index buffer to store
  39496. * @param effect defines the effect to store
  39497. * @returns the new vertex array object
  39498. */
  39499. recordVertexArrayObject(vertexBuffers: {
  39500. [key: string]: VertexBuffer;
  39501. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  39502. /**
  39503. * Bind a specific vertex array object
  39504. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  39505. * @param vertexArrayObject defines the vertex array object to bind
  39506. * @param indexBuffer defines the index buffer to bind
  39507. */
  39508. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  39509. /**
  39510. * Bind webGl buffers directly to the webGL context
  39511. * @param vertexBuffer defines the vertex buffer to bind
  39512. * @param indexBuffer defines the index buffer to bind
  39513. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  39514. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  39515. * @param effect defines the effect associated with the vertex buffer
  39516. */
  39517. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  39518. private _unbindVertexArrayObject;
  39519. /**
  39520. * Bind a list of vertex buffers to the webGL context
  39521. * @param vertexBuffers defines the list of vertex buffers to bind
  39522. * @param indexBuffer defines the index buffer to bind
  39523. * @param effect defines the effect associated with the vertex buffers
  39524. */
  39525. bindBuffers(vertexBuffers: {
  39526. [key: string]: Nullable<VertexBuffer>;
  39527. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  39528. /**
  39529. * Unbind all instance attributes
  39530. */
  39531. unbindInstanceAttributes(): void;
  39532. /**
  39533. * Release and free the memory of a vertex array object
  39534. * @param vao defines the vertex array object to delete
  39535. */
  39536. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  39537. /** @hidden */
  39538. _releaseBuffer(buffer: DataBuffer): boolean;
  39539. protected _deleteBuffer(buffer: DataBuffer): void;
  39540. /**
  39541. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  39542. * @param instancesBuffer defines the webGL buffer to update and bind
  39543. * @param data defines the data to store in the buffer
  39544. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  39545. */
  39546. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  39547. /**
  39548. * Bind the content of a webGL buffer used with instantiation
  39549. * @param instancesBuffer defines the webGL buffer to bind
  39550. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  39551. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  39552. */
  39553. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  39554. /**
  39555. * Disable the instance attribute corresponding to the name in parameter
  39556. * @param name defines the name of the attribute to disable
  39557. */
  39558. disableInstanceAttributeByName(name: string): void;
  39559. /**
  39560. * Disable the instance attribute corresponding to the location in parameter
  39561. * @param attributeLocation defines the attribute location of the attribute to disable
  39562. */
  39563. disableInstanceAttribute(attributeLocation: number): void;
  39564. /**
  39565. * Disable the attribute corresponding to the location in parameter
  39566. * @param attributeLocation defines the attribute location of the attribute to disable
  39567. */
  39568. disableAttributeByIndex(attributeLocation: number): void;
  39569. /**
  39570. * Send a draw order
  39571. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  39572. * @param indexStart defines the starting index
  39573. * @param indexCount defines the number of index to draw
  39574. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39575. */
  39576. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  39577. /**
  39578. * Draw a list of points
  39579. * @param verticesStart defines the index of first vertex to draw
  39580. * @param verticesCount defines the count of vertices to draw
  39581. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39582. */
  39583. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39584. /**
  39585. * Draw a list of unindexed primitives
  39586. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  39587. * @param verticesStart defines the index of first vertex to draw
  39588. * @param verticesCount defines the count of vertices to draw
  39589. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39590. */
  39591. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39592. /**
  39593. * Draw a list of indexed primitives
  39594. * @param fillMode defines the primitive to use
  39595. * @param indexStart defines the starting index
  39596. * @param indexCount defines the number of index to draw
  39597. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39598. */
  39599. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  39600. /**
  39601. * Draw a list of unindexed primitives
  39602. * @param fillMode defines the primitive to use
  39603. * @param verticesStart defines the index of first vertex to draw
  39604. * @param verticesCount defines the count of vertices to draw
  39605. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39606. */
  39607. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39608. private _drawMode;
  39609. /** @hidden */
  39610. protected _reportDrawCall(): void;
  39611. /** @hidden */
  39612. _releaseEffect(effect: Effect): void;
  39613. /** @hidden */
  39614. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39615. /**
  39616. * Create a new effect (used to store vertex/fragment shaders)
  39617. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  39618. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  39619. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  39620. * @param samplers defines an array of string used to represent textures
  39621. * @param defines defines the string containing the defines to use to compile the shaders
  39622. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  39623. * @param onCompiled defines a function to call when the effect creation is successful
  39624. * @param onError defines a function to call when the effect creation has failed
  39625. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  39626. * @returns the new Effect
  39627. */
  39628. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  39629. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  39630. private _compileShader;
  39631. private _compileRawShader;
  39632. /** @hidden */
  39633. _getShaderSource(shader: WebGLShader): Nullable<string>;
  39634. /**
  39635. * Directly creates a webGL program
  39636. * @param pipelineContext defines the pipeline context to attach to
  39637. * @param vertexCode defines the vertex shader code to use
  39638. * @param fragmentCode defines the fragment shader code to use
  39639. * @param context defines the webGL context to use (if not set, the current one will be used)
  39640. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39641. * @returns the new webGL program
  39642. */
  39643. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39644. /**
  39645. * Creates a webGL program
  39646. * @param pipelineContext defines the pipeline context to attach to
  39647. * @param vertexCode defines the vertex shader code to use
  39648. * @param fragmentCode defines the fragment shader code to use
  39649. * @param defines defines the string containing the defines to use to compile the shaders
  39650. * @param context defines the webGL context to use (if not set, the current one will be used)
  39651. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39652. * @returns the new webGL program
  39653. */
  39654. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39655. /**
  39656. * Creates a new pipeline context
  39657. * @returns the new pipeline
  39658. */
  39659. createPipelineContext(): IPipelineContext;
  39660. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39661. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  39662. /** @hidden */
  39663. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  39664. /** @hidden */
  39665. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  39666. /** @hidden */
  39667. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  39668. /**
  39669. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  39670. * @param pipelineContext defines the pipeline context to use
  39671. * @param uniformsNames defines the list of uniform names
  39672. * @returns an array of webGL uniform locations
  39673. */
  39674. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  39675. /**
  39676. * Gets the lsit of active attributes for a given webGL program
  39677. * @param pipelineContext defines the pipeline context to use
  39678. * @param attributesNames defines the list of attribute names to get
  39679. * @returns an array of indices indicating the offset of each attribute
  39680. */
  39681. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  39682. /**
  39683. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  39684. * @param effect defines the effect to activate
  39685. */
  39686. enableEffect(effect: Nullable<Effect>): void;
  39687. /**
  39688. * Set the value of an uniform to a number (int)
  39689. * @param uniform defines the webGL uniform location where to store the value
  39690. * @param value defines the int number to store
  39691. * @returns true if the value was set
  39692. */
  39693. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39694. /**
  39695. * Set the value of an uniform to an array of int32
  39696. * @param uniform defines the webGL uniform location where to store the value
  39697. * @param array defines the array of int32 to store
  39698. * @returns true if the value was set
  39699. */
  39700. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39701. /**
  39702. * Set the value of an uniform to an array of int32 (stored as vec2)
  39703. * @param uniform defines the webGL uniform location where to store the value
  39704. * @param array defines the array of int32 to store
  39705. * @returns true if the value was set
  39706. */
  39707. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39708. /**
  39709. * Set the value of an uniform to an array of int32 (stored as vec3)
  39710. * @param uniform defines the webGL uniform location where to store the value
  39711. * @param array defines the array of int32 to store
  39712. * @returns true if the value was set
  39713. */
  39714. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39715. /**
  39716. * Set the value of an uniform to an array of int32 (stored as vec4)
  39717. * @param uniform defines the webGL uniform location where to store the value
  39718. * @param array defines the array of int32 to store
  39719. * @returns true if the value was set
  39720. */
  39721. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39722. /**
  39723. * Set the value of an uniform to an array of number
  39724. * @param uniform defines the webGL uniform location where to store the value
  39725. * @param array defines the array of number to store
  39726. * @returns true if the value was set
  39727. */
  39728. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39729. /**
  39730. * Set the value of an uniform to an array of number (stored as vec2)
  39731. * @param uniform defines the webGL uniform location where to store the value
  39732. * @param array defines the array of number to store
  39733. * @returns true if the value was set
  39734. */
  39735. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39736. /**
  39737. * Set the value of an uniform to an array of number (stored as vec3)
  39738. * @param uniform defines the webGL uniform location where to store the value
  39739. * @param array defines the array of number to store
  39740. * @returns true if the value was set
  39741. */
  39742. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39743. /**
  39744. * Set the value of an uniform to an array of number (stored as vec4)
  39745. * @param uniform defines the webGL uniform location where to store the value
  39746. * @param array defines the array of number to store
  39747. * @returns true if the value was set
  39748. */
  39749. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39750. /**
  39751. * Set the value of an uniform to an array of float32 (stored as matrices)
  39752. * @param uniform defines the webGL uniform location where to store the value
  39753. * @param matrices defines the array of float32 to store
  39754. * @returns true if the value was set
  39755. */
  39756. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  39757. /**
  39758. * Set the value of an uniform to a matrix (3x3)
  39759. * @param uniform defines the webGL uniform location where to store the value
  39760. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  39761. * @returns true if the value was set
  39762. */
  39763. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39764. /**
  39765. * Set the value of an uniform to a matrix (2x2)
  39766. * @param uniform defines the webGL uniform location where to store the value
  39767. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  39768. * @returns true if the value was set
  39769. */
  39770. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39771. /**
  39772. * Set the value of an uniform to a number (float)
  39773. * @param uniform defines the webGL uniform location where to store the value
  39774. * @param value defines the float number to store
  39775. * @returns true if the value was transfered
  39776. */
  39777. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39778. /**
  39779. * Set the value of an uniform to a vec2
  39780. * @param uniform defines the webGL uniform location where to store the value
  39781. * @param x defines the 1st component of the value
  39782. * @param y defines the 2nd component of the value
  39783. * @returns true if the value was set
  39784. */
  39785. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  39786. /**
  39787. * Set the value of an uniform to a vec3
  39788. * @param uniform defines the webGL uniform location where to store the value
  39789. * @param x defines the 1st component of the value
  39790. * @param y defines the 2nd component of the value
  39791. * @param z defines the 3rd component of the value
  39792. * @returns true if the value was set
  39793. */
  39794. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  39795. /**
  39796. * Set the value of an uniform to a vec4
  39797. * @param uniform defines the webGL uniform location where to store the value
  39798. * @param x defines the 1st component of the value
  39799. * @param y defines the 2nd component of the value
  39800. * @param z defines the 3rd component of the value
  39801. * @param w defines the 4th component of the value
  39802. * @returns true if the value was set
  39803. */
  39804. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  39805. /**
  39806. * Apply all cached states (depth, culling, stencil and alpha)
  39807. */
  39808. applyStates(): void;
  39809. /**
  39810. * Enable or disable color writing
  39811. * @param enable defines the state to set
  39812. */
  39813. setColorWrite(enable: boolean): void;
  39814. /**
  39815. * Gets a boolean indicating if color writing is enabled
  39816. * @returns the current color writing state
  39817. */
  39818. getColorWrite(): boolean;
  39819. /**
  39820. * Gets the depth culling state manager
  39821. */
  39822. get depthCullingState(): DepthCullingState;
  39823. /**
  39824. * Gets the alpha state manager
  39825. */
  39826. get alphaState(): AlphaState;
  39827. /**
  39828. * Gets the stencil state manager
  39829. */
  39830. get stencilState(): StencilState;
  39831. /**
  39832. * Clears the list of texture accessible through engine.
  39833. * This can help preventing texture load conflict due to name collision.
  39834. */
  39835. clearInternalTexturesCache(): void;
  39836. /**
  39837. * Force the entire cache to be cleared
  39838. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  39839. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  39840. */
  39841. wipeCaches(bruteForce?: boolean): void;
  39842. /** @hidden */
  39843. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  39844. min: number;
  39845. mag: number;
  39846. };
  39847. /** @hidden */
  39848. _createTexture(): WebGLTexture;
  39849. /**
  39850. * Usually called from Texture.ts.
  39851. * Passed information to create a WebGLTexture
  39852. * @param url defines a value which contains one of the following:
  39853. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  39854. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  39855. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  39856. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  39857. * @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)
  39858. * @param scene needed for loading to the correct scene
  39859. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  39860. * @param onLoad optional callback to be called upon successful completion
  39861. * @param onError optional callback to be called upon failure
  39862. * @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
  39863. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  39864. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  39865. * @param forcedExtension defines the extension to use to pick the right loader
  39866. * @param mimeType defines an optional mime type
  39867. * @param loaderOptions options to be passed to the loader
  39868. * @returns a InternalTexture for assignment back into BABYLON.Texture
  39869. */
  39870. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any): InternalTexture;
  39871. /**
  39872. * Loads an image as an HTMLImageElement.
  39873. * @param input url string, ArrayBuffer, or Blob to load
  39874. * @param onLoad callback called when the image successfully loads
  39875. * @param onError callback called when the image fails to load
  39876. * @param offlineProvider offline provider for caching
  39877. * @param mimeType optional mime type
  39878. * @returns the HTMLImageElement of the loaded image
  39879. * @hidden
  39880. */
  39881. static _FileToolsLoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  39882. /**
  39883. * @hidden
  39884. */
  39885. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39886. private _unpackFlipYCached;
  39887. /**
  39888. * In case you are sharing the context with other applications, it might
  39889. * be interested to not cache the unpack flip y state to ensure a consistent
  39890. * value would be set.
  39891. */
  39892. enableUnpackFlipYCached: boolean;
  39893. /** @hidden */
  39894. _unpackFlipY(value: boolean): void;
  39895. /** @hidden */
  39896. _getUnpackAlignement(): number;
  39897. private _getTextureTarget;
  39898. /**
  39899. * Update the sampling mode of a given texture
  39900. * @param samplingMode defines the required sampling mode
  39901. * @param texture defines the texture to update
  39902. * @param generateMipMaps defines whether to generate mipmaps for the texture
  39903. */
  39904. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  39905. /**
  39906. * Update the sampling mode of a given texture
  39907. * @param texture defines the texture to update
  39908. * @param wrapU defines the texture wrap mode of the u coordinates
  39909. * @param wrapV defines the texture wrap mode of the v coordinates
  39910. * @param wrapR defines the texture wrap mode of the r coordinates
  39911. */
  39912. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  39913. /** @hidden */
  39914. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  39915. width: number;
  39916. height: number;
  39917. layers?: number;
  39918. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  39919. /** @hidden */
  39920. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39921. /** @hidden */
  39922. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  39923. /**
  39924. * Update a portion of an internal texture
  39925. * @param texture defines the texture to update
  39926. * @param imageData defines the data to store into the texture
  39927. * @param xOffset defines the x coordinates of the update rectangle
  39928. * @param yOffset defines the y coordinates of the update rectangle
  39929. * @param width defines the width of the update rectangle
  39930. * @param height defines the height of the update rectangle
  39931. * @param faceIndex defines the face index if texture is a cube (0 by default)
  39932. * @param lod defines the lod level to update (0 by default)
  39933. */
  39934. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  39935. /** @hidden */
  39936. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39937. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  39938. private _prepareWebGLTexture;
  39939. /** @hidden */
  39940. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  39941. private _getDepthStencilBuffer;
  39942. /** @hidden */
  39943. _releaseFramebufferObjects(texture: InternalTexture): void;
  39944. /** @hidden */
  39945. _releaseTexture(texture: InternalTexture): void;
  39946. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  39947. protected _setProgram(program: WebGLProgram): void;
  39948. protected _boundUniforms: {
  39949. [key: number]: WebGLUniformLocation;
  39950. };
  39951. /**
  39952. * Binds an effect to the webGL context
  39953. * @param effect defines the effect to bind
  39954. */
  39955. bindSamplers(effect: Effect): void;
  39956. private _activateCurrentTexture;
  39957. /** @hidden */
  39958. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  39959. /** @hidden */
  39960. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  39961. /**
  39962. * Unbind all textures from the webGL context
  39963. */
  39964. unbindAllTextures(): void;
  39965. /**
  39966. * Sets a texture to the according uniform.
  39967. * @param channel The texture channel
  39968. * @param uniform The uniform to set
  39969. * @param texture The texture to apply
  39970. */
  39971. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>): void;
  39972. private _bindSamplerUniformToChannel;
  39973. private _getTextureWrapMode;
  39974. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  39975. /**
  39976. * Sets an array of texture to the webGL context
  39977. * @param channel defines the channel where the texture array must be set
  39978. * @param uniform defines the associated uniform location
  39979. * @param textures defines the array of textures to bind
  39980. */
  39981. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[]): void;
  39982. /** @hidden */
  39983. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  39984. private _setTextureParameterFloat;
  39985. private _setTextureParameterInteger;
  39986. /**
  39987. * Unbind all vertex attributes from the webGL context
  39988. */
  39989. unbindAllAttributes(): void;
  39990. /**
  39991. * 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
  39992. */
  39993. releaseEffects(): void;
  39994. /**
  39995. * Dispose and release all associated resources
  39996. */
  39997. dispose(): void;
  39998. /**
  39999. * Attach a new callback raised when context lost event is fired
  40000. * @param callback defines the callback to call
  40001. */
  40002. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  40003. /**
  40004. * Attach a new callback raised when context restored event is fired
  40005. * @param callback defines the callback to call
  40006. */
  40007. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  40008. /**
  40009. * Get the current error code of the webGL context
  40010. * @returns the error code
  40011. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  40012. */
  40013. getError(): number;
  40014. private _canRenderToFloatFramebuffer;
  40015. private _canRenderToHalfFloatFramebuffer;
  40016. private _canRenderToFramebuffer;
  40017. /** @hidden */
  40018. _getWebGLTextureType(type: number): number;
  40019. /** @hidden */
  40020. _getInternalFormat(format: number): number;
  40021. /** @hidden */
  40022. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  40023. /** @hidden */
  40024. _getRGBAMultiSampleBufferFormat(type: number): number;
  40025. /** @hidden */
  40026. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  40027. /**
  40028. * Loads a file from a url
  40029. * @param url url to load
  40030. * @param onSuccess callback called when the file successfully loads
  40031. * @param onProgress callback called while file is loading (if the server supports this mode)
  40032. * @param offlineProvider defines the offline provider for caching
  40033. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  40034. * @param onError callback called when the file fails to load
  40035. * @returns a file request object
  40036. * @hidden
  40037. */
  40038. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  40039. /**
  40040. * Reads pixels from the current frame buffer. Please note that this function can be slow
  40041. * @param x defines the x coordinate of the rectangle where pixels must be read
  40042. * @param y defines the y coordinate of the rectangle where pixels must be read
  40043. * @param width defines the width of the rectangle where pixels must be read
  40044. * @param height defines the height of the rectangle where pixels must be read
  40045. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  40046. * @returns a Uint8Array containing RGBA colors
  40047. */
  40048. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  40049. private static _IsSupported;
  40050. private static _HasMajorPerformanceCaveat;
  40051. /**
  40052. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  40053. */
  40054. static get IsSupported(): boolean;
  40055. /**
  40056. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  40057. * @returns true if the engine can be created
  40058. * @ignorenaming
  40059. */
  40060. static isSupported(): boolean;
  40061. /**
  40062. * Gets a boolean indicating if the engine can be instanciated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)
  40063. */
  40064. static get HasMajorPerformanceCaveat(): boolean;
  40065. /**
  40066. * Find the next highest power of two.
  40067. * @param x Number to start search from.
  40068. * @return Next highest power of two.
  40069. */
  40070. static CeilingPOT(x: number): number;
  40071. /**
  40072. * Find the next lowest power of two.
  40073. * @param x Number to start search from.
  40074. * @return Next lowest power of two.
  40075. */
  40076. static FloorPOT(x: number): number;
  40077. /**
  40078. * Find the nearest power of two.
  40079. * @param x Number to start search from.
  40080. * @return Next nearest power of two.
  40081. */
  40082. static NearestPOT(x: number): number;
  40083. /**
  40084. * Get the closest exponent of two
  40085. * @param value defines the value to approximate
  40086. * @param max defines the maximum value to return
  40087. * @param mode defines how to define the closest value
  40088. * @returns closest exponent of two of the given value
  40089. */
  40090. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  40091. /**
  40092. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  40093. * @param func - the function to be called
  40094. * @param requester - the object that will request the next frame. Falls back to window.
  40095. * @returns frame number
  40096. */
  40097. static QueueNewFrame(func: () => void, requester?: any): number;
  40098. /**
  40099. * Gets host document
  40100. * @returns the host document object
  40101. */
  40102. getHostDocument(): Nullable<Document>;
  40103. }
  40104. }
  40105. declare module BABYLON {
  40106. /**
  40107. * Defines the source of the internal texture
  40108. */
  40109. export enum InternalTextureSource {
  40110. /**
  40111. * The source of the texture data is unknown
  40112. */
  40113. Unknown = 0,
  40114. /**
  40115. * Texture data comes from an URL
  40116. */
  40117. Url = 1,
  40118. /**
  40119. * Texture data is only used for temporary storage
  40120. */
  40121. Temp = 2,
  40122. /**
  40123. * Texture data comes from raw data (ArrayBuffer)
  40124. */
  40125. Raw = 3,
  40126. /**
  40127. * Texture content is dynamic (video or dynamic texture)
  40128. */
  40129. Dynamic = 4,
  40130. /**
  40131. * Texture content is generated by rendering to it
  40132. */
  40133. RenderTarget = 5,
  40134. /**
  40135. * Texture content is part of a multi render target process
  40136. */
  40137. MultiRenderTarget = 6,
  40138. /**
  40139. * Texture data comes from a cube data file
  40140. */
  40141. Cube = 7,
  40142. /**
  40143. * Texture data comes from a raw cube data
  40144. */
  40145. CubeRaw = 8,
  40146. /**
  40147. * Texture data come from a prefiltered cube data file
  40148. */
  40149. CubePrefiltered = 9,
  40150. /**
  40151. * Texture content is raw 3D data
  40152. */
  40153. Raw3D = 10,
  40154. /**
  40155. * Texture content is raw 2D array data
  40156. */
  40157. Raw2DArray = 11,
  40158. /**
  40159. * Texture content is a depth texture
  40160. */
  40161. Depth = 12,
  40162. /**
  40163. * Texture data comes from a raw cube data encoded with RGBD
  40164. */
  40165. CubeRawRGBD = 13
  40166. }
  40167. /**
  40168. * Class used to store data associated with WebGL texture data for the engine
  40169. * This class should not be used directly
  40170. */
  40171. export class InternalTexture {
  40172. /** @hidden */
  40173. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  40174. /**
  40175. * Defines if the texture is ready
  40176. */
  40177. isReady: boolean;
  40178. /**
  40179. * Defines if the texture is a cube texture
  40180. */
  40181. isCube: boolean;
  40182. /**
  40183. * Defines if the texture contains 3D data
  40184. */
  40185. is3D: boolean;
  40186. /**
  40187. * Defines if the texture contains 2D array data
  40188. */
  40189. is2DArray: boolean;
  40190. /**
  40191. * Defines if the texture contains multiview data
  40192. */
  40193. isMultiview: boolean;
  40194. /**
  40195. * Gets the URL used to load this texture
  40196. */
  40197. url: string;
  40198. /** @hidden */
  40199. _originalUrl: string;
  40200. /**
  40201. * Gets the sampling mode of the texture
  40202. */
  40203. samplingMode: number;
  40204. /**
  40205. * Gets a boolean indicating if the texture needs mipmaps generation
  40206. */
  40207. generateMipMaps: boolean;
  40208. /**
  40209. * Gets the number of samples used by the texture (WebGL2+ only)
  40210. */
  40211. samples: number;
  40212. /**
  40213. * Gets the type of the texture (int, float...)
  40214. */
  40215. type: number;
  40216. /**
  40217. * Gets the format of the texture (RGB, RGBA...)
  40218. */
  40219. format: number;
  40220. /**
  40221. * Observable called when the texture is loaded
  40222. */
  40223. onLoadedObservable: Observable<InternalTexture>;
  40224. /**
  40225. * Gets the width of the texture
  40226. */
  40227. width: number;
  40228. /**
  40229. * Gets the height of the texture
  40230. */
  40231. height: number;
  40232. /**
  40233. * Gets the depth of the texture
  40234. */
  40235. depth: number;
  40236. /**
  40237. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  40238. */
  40239. baseWidth: number;
  40240. /**
  40241. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  40242. */
  40243. baseHeight: number;
  40244. /**
  40245. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  40246. */
  40247. baseDepth: number;
  40248. /**
  40249. * Gets a boolean indicating if the texture is inverted on Y axis
  40250. */
  40251. invertY: boolean;
  40252. /** @hidden */
  40253. _invertVScale: boolean;
  40254. /** @hidden */
  40255. _associatedChannel: number;
  40256. /** @hidden */
  40257. _source: InternalTextureSource;
  40258. /** @hidden */
  40259. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  40260. /** @hidden */
  40261. _bufferView: Nullable<ArrayBufferView>;
  40262. /** @hidden */
  40263. _bufferViewArray: Nullable<ArrayBufferView[]>;
  40264. /** @hidden */
  40265. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  40266. /** @hidden */
  40267. _size: number;
  40268. /** @hidden */
  40269. _extension: string;
  40270. /** @hidden */
  40271. _files: Nullable<string[]>;
  40272. /** @hidden */
  40273. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40274. /** @hidden */
  40275. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40276. /** @hidden */
  40277. _framebuffer: Nullable<WebGLFramebuffer>;
  40278. /** @hidden */
  40279. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  40280. /** @hidden */
  40281. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  40282. /** @hidden */
  40283. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  40284. /** @hidden */
  40285. _attachments: Nullable<number[]>;
  40286. /** @hidden */
  40287. _textureArray: Nullable<InternalTexture[]>;
  40288. /** @hidden */
  40289. _cachedCoordinatesMode: Nullable<number>;
  40290. /** @hidden */
  40291. _cachedWrapU: Nullable<number>;
  40292. /** @hidden */
  40293. _cachedWrapV: Nullable<number>;
  40294. /** @hidden */
  40295. _cachedWrapR: Nullable<number>;
  40296. /** @hidden */
  40297. _cachedAnisotropicFilteringLevel: Nullable<number>;
  40298. /** @hidden */
  40299. _isDisabled: boolean;
  40300. /** @hidden */
  40301. _compression: Nullable<string>;
  40302. /** @hidden */
  40303. _generateStencilBuffer: boolean;
  40304. /** @hidden */
  40305. _generateDepthBuffer: boolean;
  40306. /** @hidden */
  40307. _comparisonFunction: number;
  40308. /** @hidden */
  40309. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  40310. /** @hidden */
  40311. _lodGenerationScale: number;
  40312. /** @hidden */
  40313. _lodGenerationOffset: number;
  40314. /** @hidden */
  40315. _depthStencilTexture: Nullable<InternalTexture>;
  40316. /** @hidden */
  40317. _colorTextureArray: Nullable<WebGLTexture>;
  40318. /** @hidden */
  40319. _depthStencilTextureArray: Nullable<WebGLTexture>;
  40320. /** @hidden */
  40321. _lodTextureHigh: Nullable<BaseTexture>;
  40322. /** @hidden */
  40323. _lodTextureMid: Nullable<BaseTexture>;
  40324. /** @hidden */
  40325. _lodTextureLow: Nullable<BaseTexture>;
  40326. /** @hidden */
  40327. _isRGBD: boolean;
  40328. /** @hidden */
  40329. _linearSpecularLOD: boolean;
  40330. /** @hidden */
  40331. _irradianceTexture: Nullable<BaseTexture>;
  40332. /** @hidden */
  40333. _webGLTexture: Nullable<WebGLTexture>;
  40334. /** @hidden */
  40335. _references: number;
  40336. /** @hidden */
  40337. _gammaSpace: Nullable<boolean>;
  40338. private _engine;
  40339. /**
  40340. * Gets the Engine the texture belongs to.
  40341. * @returns The babylon engine
  40342. */
  40343. getEngine(): ThinEngine;
  40344. /**
  40345. * Gets the data source type of the texture
  40346. */
  40347. get source(): InternalTextureSource;
  40348. /**
  40349. * Creates a new InternalTexture
  40350. * @param engine defines the engine to use
  40351. * @param source defines the type of data that will be used
  40352. * @param delayAllocation if the texture allocation should be delayed (default: false)
  40353. */
  40354. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  40355. /**
  40356. * Increments the number of references (ie. the number of Texture that point to it)
  40357. */
  40358. incrementReferences(): void;
  40359. /**
  40360. * Change the size of the texture (not the size of the content)
  40361. * @param width defines the new width
  40362. * @param height defines the new height
  40363. * @param depth defines the new depth (1 by default)
  40364. */
  40365. updateSize(width: int, height: int, depth?: int): void;
  40366. /** @hidden */
  40367. _rebuild(): void;
  40368. /** @hidden */
  40369. _swapAndDie(target: InternalTexture): void;
  40370. /**
  40371. * Dispose the current allocated resources
  40372. */
  40373. dispose(): void;
  40374. }
  40375. }
  40376. declare module BABYLON {
  40377. /**
  40378. * Interface used to present a loading screen while loading a scene
  40379. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40380. */
  40381. export interface ILoadingScreen {
  40382. /**
  40383. * Function called to display the loading screen
  40384. */
  40385. displayLoadingUI: () => void;
  40386. /**
  40387. * Function called to hide the loading screen
  40388. */
  40389. hideLoadingUI: () => void;
  40390. /**
  40391. * Gets or sets the color to use for the background
  40392. */
  40393. loadingUIBackgroundColor: string;
  40394. /**
  40395. * Gets or sets the text to display while loading
  40396. */
  40397. loadingUIText: string;
  40398. }
  40399. /**
  40400. * Class used for the default loading screen
  40401. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40402. */
  40403. export class DefaultLoadingScreen implements ILoadingScreen {
  40404. private _renderingCanvas;
  40405. private _loadingText;
  40406. private _loadingDivBackgroundColor;
  40407. private _loadingDiv;
  40408. private _loadingTextDiv;
  40409. /** Gets or sets the logo url to use for the default loading screen */
  40410. static DefaultLogoUrl: string;
  40411. /** Gets or sets the spinner url to use for the default loading screen */
  40412. static DefaultSpinnerUrl: string;
  40413. /**
  40414. * Creates a new default loading screen
  40415. * @param _renderingCanvas defines the canvas used to render the scene
  40416. * @param _loadingText defines the default text to display
  40417. * @param _loadingDivBackgroundColor defines the default background color
  40418. */
  40419. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  40420. /**
  40421. * Function called to display the loading screen
  40422. */
  40423. displayLoadingUI(): void;
  40424. /**
  40425. * Function called to hide the loading screen
  40426. */
  40427. hideLoadingUI(): void;
  40428. /**
  40429. * Gets or sets the text to display while loading
  40430. */
  40431. set loadingUIText(text: string);
  40432. get loadingUIText(): string;
  40433. /**
  40434. * Gets or sets the color to use for the background
  40435. */
  40436. get loadingUIBackgroundColor(): string;
  40437. set loadingUIBackgroundColor(color: string);
  40438. private _resizeLoadingUI;
  40439. }
  40440. }
  40441. declare module BABYLON {
  40442. /**
  40443. * Interface for any object that can request an animation frame
  40444. */
  40445. export interface ICustomAnimationFrameRequester {
  40446. /**
  40447. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  40448. */
  40449. renderFunction?: Function;
  40450. /**
  40451. * Called to request the next frame to render to
  40452. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  40453. */
  40454. requestAnimationFrame: Function;
  40455. /**
  40456. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  40457. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  40458. */
  40459. requestID?: number;
  40460. }
  40461. }
  40462. declare module BABYLON {
  40463. /**
  40464. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  40465. */
  40466. export class PerformanceMonitor {
  40467. private _enabled;
  40468. private _rollingFrameTime;
  40469. private _lastFrameTimeMs;
  40470. /**
  40471. * constructor
  40472. * @param frameSampleSize The number of samples required to saturate the sliding window
  40473. */
  40474. constructor(frameSampleSize?: number);
  40475. /**
  40476. * Samples current frame
  40477. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  40478. */
  40479. sampleFrame(timeMs?: number): void;
  40480. /**
  40481. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40482. */
  40483. get averageFrameTime(): number;
  40484. /**
  40485. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40486. */
  40487. get averageFrameTimeVariance(): number;
  40488. /**
  40489. * Returns the frame time of the most recent frame
  40490. */
  40491. get instantaneousFrameTime(): number;
  40492. /**
  40493. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  40494. */
  40495. get averageFPS(): number;
  40496. /**
  40497. * Returns the average framerate in frames per second using the most recent frame time
  40498. */
  40499. get instantaneousFPS(): number;
  40500. /**
  40501. * Returns true if enough samples have been taken to completely fill the sliding window
  40502. */
  40503. get isSaturated(): boolean;
  40504. /**
  40505. * Enables contributions to the sliding window sample set
  40506. */
  40507. enable(): void;
  40508. /**
  40509. * Disables contributions to the sliding window sample set
  40510. * Samples will not be interpolated over the disabled period
  40511. */
  40512. disable(): void;
  40513. /**
  40514. * Returns true if sampling is enabled
  40515. */
  40516. get isEnabled(): boolean;
  40517. /**
  40518. * Resets performance monitor
  40519. */
  40520. reset(): void;
  40521. }
  40522. /**
  40523. * RollingAverage
  40524. *
  40525. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  40526. */
  40527. export class RollingAverage {
  40528. /**
  40529. * Current average
  40530. */
  40531. average: number;
  40532. /**
  40533. * Current variance
  40534. */
  40535. variance: number;
  40536. protected _samples: Array<number>;
  40537. protected _sampleCount: number;
  40538. protected _pos: number;
  40539. protected _m2: number;
  40540. /**
  40541. * constructor
  40542. * @param length The number of samples required to saturate the sliding window
  40543. */
  40544. constructor(length: number);
  40545. /**
  40546. * Adds a sample to the sample set
  40547. * @param v The sample value
  40548. */
  40549. add(v: number): void;
  40550. /**
  40551. * Returns previously added values or null if outside of history or outside the sliding window domain
  40552. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  40553. * @return Value previously recorded with add() or null if outside of range
  40554. */
  40555. history(i: number): number;
  40556. /**
  40557. * Returns true if enough samples have been taken to completely fill the sliding window
  40558. * @return true if sample-set saturated
  40559. */
  40560. isSaturated(): boolean;
  40561. /**
  40562. * Resets the rolling average (equivalent to 0 samples taken so far)
  40563. */
  40564. reset(): void;
  40565. /**
  40566. * Wraps a value around the sample range boundaries
  40567. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  40568. * @return Wrapped position in sample range
  40569. */
  40570. protected _wrapPosition(i: number): number;
  40571. }
  40572. }
  40573. declare module BABYLON {
  40574. /**
  40575. * This class is used to track a performance counter which is number based.
  40576. * The user has access to many properties which give statistics of different nature.
  40577. *
  40578. * The implementer can track two kinds of Performance Counter: time and count.
  40579. * 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.
  40580. * 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.
  40581. */
  40582. export class PerfCounter {
  40583. /**
  40584. * Gets or sets a global boolean to turn on and off all the counters
  40585. */
  40586. static Enabled: boolean;
  40587. /**
  40588. * Returns the smallest value ever
  40589. */
  40590. get min(): number;
  40591. /**
  40592. * Returns the biggest value ever
  40593. */
  40594. get max(): number;
  40595. /**
  40596. * Returns the average value since the performance counter is running
  40597. */
  40598. get average(): number;
  40599. /**
  40600. * Returns the average value of the last second the counter was monitored
  40601. */
  40602. get lastSecAverage(): number;
  40603. /**
  40604. * Returns the current value
  40605. */
  40606. get current(): number;
  40607. /**
  40608. * Gets the accumulated total
  40609. */
  40610. get total(): number;
  40611. /**
  40612. * Gets the total value count
  40613. */
  40614. get count(): number;
  40615. /**
  40616. * Creates a new counter
  40617. */
  40618. constructor();
  40619. /**
  40620. * Call this method to start monitoring a new frame.
  40621. * 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.
  40622. */
  40623. fetchNewFrame(): void;
  40624. /**
  40625. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  40626. * @param newCount the count value to add to the monitored count
  40627. * @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.
  40628. */
  40629. addCount(newCount: number, fetchResult: boolean): void;
  40630. /**
  40631. * Start monitoring this performance counter
  40632. */
  40633. beginMonitoring(): void;
  40634. /**
  40635. * Compute the time lapsed since the previous beginMonitoring() call.
  40636. * @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
  40637. */
  40638. endMonitoring(newFrame?: boolean): void;
  40639. private _fetchResult;
  40640. private _startMonitoringTime;
  40641. private _min;
  40642. private _max;
  40643. private _average;
  40644. private _current;
  40645. private _totalValueCount;
  40646. private _totalAccumulated;
  40647. private _lastSecAverage;
  40648. private _lastSecAccumulated;
  40649. private _lastSecTime;
  40650. private _lastSecValueCount;
  40651. }
  40652. }
  40653. declare module BABYLON {
  40654. interface ThinEngine {
  40655. /** @hidden */
  40656. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  40657. }
  40658. }
  40659. declare module BABYLON {
  40660. /**
  40661. * Class used to work with sound analyzer using fast fourier transform (FFT)
  40662. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40663. */
  40664. export class Analyser {
  40665. /**
  40666. * Gets or sets the smoothing
  40667. * @ignorenaming
  40668. */
  40669. SMOOTHING: number;
  40670. /**
  40671. * Gets or sets the FFT table size
  40672. * @ignorenaming
  40673. */
  40674. FFT_SIZE: number;
  40675. /**
  40676. * Gets or sets the bar graph amplitude
  40677. * @ignorenaming
  40678. */
  40679. BARGRAPHAMPLITUDE: number;
  40680. /**
  40681. * Gets or sets the position of the debug canvas
  40682. * @ignorenaming
  40683. */
  40684. DEBUGCANVASPOS: {
  40685. x: number;
  40686. y: number;
  40687. };
  40688. /**
  40689. * Gets or sets the debug canvas size
  40690. * @ignorenaming
  40691. */
  40692. DEBUGCANVASSIZE: {
  40693. width: number;
  40694. height: number;
  40695. };
  40696. private _byteFreqs;
  40697. private _byteTime;
  40698. private _floatFreqs;
  40699. private _webAudioAnalyser;
  40700. private _debugCanvas;
  40701. private _debugCanvasContext;
  40702. private _scene;
  40703. private _registerFunc;
  40704. private _audioEngine;
  40705. /**
  40706. * Creates a new analyser
  40707. * @param scene defines hosting scene
  40708. */
  40709. constructor(scene: Scene);
  40710. /**
  40711. * Get the number of data values you will have to play with for the visualization
  40712. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  40713. * @returns a number
  40714. */
  40715. getFrequencyBinCount(): number;
  40716. /**
  40717. * Gets the current frequency data as a byte array
  40718. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  40719. * @returns a Uint8Array
  40720. */
  40721. getByteFrequencyData(): Uint8Array;
  40722. /**
  40723. * Gets the current waveform as a byte array
  40724. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  40725. * @returns a Uint8Array
  40726. */
  40727. getByteTimeDomainData(): Uint8Array;
  40728. /**
  40729. * Gets the current frequency data as a float array
  40730. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  40731. * @returns a Float32Array
  40732. */
  40733. getFloatFrequencyData(): Float32Array;
  40734. /**
  40735. * Renders the debug canvas
  40736. */
  40737. drawDebugCanvas(): void;
  40738. /**
  40739. * Stops rendering the debug canvas and removes it
  40740. */
  40741. stopDebugCanvas(): void;
  40742. /**
  40743. * Connects two audio nodes
  40744. * @param inputAudioNode defines first node to connect
  40745. * @param outputAudioNode defines second node to connect
  40746. */
  40747. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  40748. /**
  40749. * Releases all associated resources
  40750. */
  40751. dispose(): void;
  40752. }
  40753. }
  40754. declare module BABYLON {
  40755. /**
  40756. * This represents an audio engine and it is responsible
  40757. * to play, synchronize and analyse sounds throughout the application.
  40758. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40759. */
  40760. export interface IAudioEngine extends IDisposable {
  40761. /**
  40762. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  40763. */
  40764. readonly canUseWebAudio: boolean;
  40765. /**
  40766. * Gets the current AudioContext if available.
  40767. */
  40768. readonly audioContext: Nullable<AudioContext>;
  40769. /**
  40770. * The master gain node defines the global audio volume of your audio engine.
  40771. */
  40772. readonly masterGain: GainNode;
  40773. /**
  40774. * Gets whether or not mp3 are supported by your browser.
  40775. */
  40776. readonly isMP3supported: boolean;
  40777. /**
  40778. * Gets whether or not ogg are supported by your browser.
  40779. */
  40780. readonly isOGGsupported: boolean;
  40781. /**
  40782. * Defines if Babylon should emit a warning if WebAudio is not supported.
  40783. * @ignoreNaming
  40784. */
  40785. WarnedWebAudioUnsupported: boolean;
  40786. /**
  40787. * Defines if the audio engine relies on a custom unlocked button.
  40788. * In this case, the embedded button will not be displayed.
  40789. */
  40790. useCustomUnlockedButton: boolean;
  40791. /**
  40792. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  40793. */
  40794. readonly unlocked: boolean;
  40795. /**
  40796. * Event raised when audio has been unlocked on the browser.
  40797. */
  40798. onAudioUnlockedObservable: Observable<IAudioEngine>;
  40799. /**
  40800. * Event raised when audio has been locked on the browser.
  40801. */
  40802. onAudioLockedObservable: Observable<IAudioEngine>;
  40803. /**
  40804. * Flags the audio engine in Locked state.
  40805. * This happens due to new browser policies preventing audio to autoplay.
  40806. */
  40807. lock(): void;
  40808. /**
  40809. * Unlocks the audio engine once a user action has been done on the dom.
  40810. * This is helpful to resume play once browser policies have been satisfied.
  40811. */
  40812. unlock(): void;
  40813. /**
  40814. * Gets the global volume sets on the master gain.
  40815. * @returns the global volume if set or -1 otherwise
  40816. */
  40817. getGlobalVolume(): number;
  40818. /**
  40819. * Sets the global volume of your experience (sets on the master gain).
  40820. * @param newVolume Defines the new global volume of the application
  40821. */
  40822. setGlobalVolume(newVolume: number): void;
  40823. /**
  40824. * Connect the audio engine to an audio analyser allowing some amazing
  40825. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  40826. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  40827. * @param analyser The analyser to connect to the engine
  40828. */
  40829. connectToAnalyser(analyser: Analyser): void;
  40830. }
  40831. }
  40832. declare module BABYLON {
  40833. /**
  40834. * Defines the interface used by display changed events
  40835. */
  40836. export interface IDisplayChangedEventArgs {
  40837. /** Gets the vrDisplay object (if any) */
  40838. vrDisplay: Nullable<any>;
  40839. /** Gets a boolean indicating if webVR is supported */
  40840. vrSupported: boolean;
  40841. }
  40842. /**
  40843. * Defines the interface used by objects containing a viewport (like a camera)
  40844. */
  40845. interface IViewportOwnerLike {
  40846. /**
  40847. * Gets or sets the viewport
  40848. */
  40849. viewport: IViewportLike;
  40850. }
  40851. /**
  40852. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  40853. */
  40854. export class Engine extends ThinEngine {
  40855. /** Defines that alpha blending is disabled */
  40856. static readonly ALPHA_DISABLE: number;
  40857. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  40858. static readonly ALPHA_ADD: number;
  40859. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  40860. static readonly ALPHA_COMBINE: number;
  40861. /** Defines that alpha blending to DEST - SRC * DEST */
  40862. static readonly ALPHA_SUBTRACT: number;
  40863. /** Defines that alpha blending to SRC * DEST */
  40864. static readonly ALPHA_MULTIPLY: number;
  40865. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  40866. static readonly ALPHA_MAXIMIZED: number;
  40867. /** Defines that alpha blending to SRC + DEST */
  40868. static readonly ALPHA_ONEONE: number;
  40869. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  40870. static readonly ALPHA_PREMULTIPLIED: number;
  40871. /**
  40872. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  40873. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  40874. */
  40875. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  40876. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  40877. static readonly ALPHA_INTERPOLATE: number;
  40878. /**
  40879. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  40880. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  40881. */
  40882. static readonly ALPHA_SCREENMODE: number;
  40883. /** Defines that the ressource is not delayed*/
  40884. static readonly DELAYLOADSTATE_NONE: number;
  40885. /** Defines that the ressource was successfully delay loaded */
  40886. static readonly DELAYLOADSTATE_LOADED: number;
  40887. /** Defines that the ressource is currently delay loading */
  40888. static readonly DELAYLOADSTATE_LOADING: number;
  40889. /** Defines that the ressource is delayed and has not started loading */
  40890. static readonly DELAYLOADSTATE_NOTLOADED: number;
  40891. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  40892. static readonly NEVER: number;
  40893. /** 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 */
  40894. static readonly ALWAYS: number;
  40895. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  40896. static readonly LESS: number;
  40897. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  40898. static readonly EQUAL: number;
  40899. /** 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 */
  40900. static readonly LEQUAL: number;
  40901. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  40902. static readonly GREATER: number;
  40903. /** 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 */
  40904. static readonly GEQUAL: number;
  40905. /** 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 */
  40906. static readonly NOTEQUAL: number;
  40907. /** Passed to stencilOperation to specify that stencil value must be kept */
  40908. static readonly KEEP: number;
  40909. /** Passed to stencilOperation to specify that stencil value must be replaced */
  40910. static readonly REPLACE: number;
  40911. /** Passed to stencilOperation to specify that stencil value must be incremented */
  40912. static readonly INCR: number;
  40913. /** Passed to stencilOperation to specify that stencil value must be decremented */
  40914. static readonly DECR: number;
  40915. /** Passed to stencilOperation to specify that stencil value must be inverted */
  40916. static readonly INVERT: number;
  40917. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  40918. static readonly INCR_WRAP: number;
  40919. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  40920. static readonly DECR_WRAP: number;
  40921. /** Texture is not repeating outside of 0..1 UVs */
  40922. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  40923. /** Texture is repeating outside of 0..1 UVs */
  40924. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  40925. /** Texture is repeating and mirrored */
  40926. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  40927. /** ALPHA */
  40928. static readonly TEXTUREFORMAT_ALPHA: number;
  40929. /** LUMINANCE */
  40930. static readonly TEXTUREFORMAT_LUMINANCE: number;
  40931. /** LUMINANCE_ALPHA */
  40932. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  40933. /** RGB */
  40934. static readonly TEXTUREFORMAT_RGB: number;
  40935. /** RGBA */
  40936. static readonly TEXTUREFORMAT_RGBA: number;
  40937. /** RED */
  40938. static readonly TEXTUREFORMAT_RED: number;
  40939. /** RED (2nd reference) */
  40940. static readonly TEXTUREFORMAT_R: number;
  40941. /** RG */
  40942. static readonly TEXTUREFORMAT_RG: number;
  40943. /** RED_INTEGER */
  40944. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  40945. /** RED_INTEGER (2nd reference) */
  40946. static readonly TEXTUREFORMAT_R_INTEGER: number;
  40947. /** RG_INTEGER */
  40948. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  40949. /** RGB_INTEGER */
  40950. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  40951. /** RGBA_INTEGER */
  40952. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  40953. /** UNSIGNED_BYTE */
  40954. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  40955. /** UNSIGNED_BYTE (2nd reference) */
  40956. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  40957. /** FLOAT */
  40958. static readonly TEXTURETYPE_FLOAT: number;
  40959. /** HALF_FLOAT */
  40960. static readonly TEXTURETYPE_HALF_FLOAT: number;
  40961. /** BYTE */
  40962. static readonly TEXTURETYPE_BYTE: number;
  40963. /** SHORT */
  40964. static readonly TEXTURETYPE_SHORT: number;
  40965. /** UNSIGNED_SHORT */
  40966. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  40967. /** INT */
  40968. static readonly TEXTURETYPE_INT: number;
  40969. /** UNSIGNED_INT */
  40970. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  40971. /** UNSIGNED_SHORT_4_4_4_4 */
  40972. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  40973. /** UNSIGNED_SHORT_5_5_5_1 */
  40974. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  40975. /** UNSIGNED_SHORT_5_6_5 */
  40976. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  40977. /** UNSIGNED_INT_2_10_10_10_REV */
  40978. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  40979. /** UNSIGNED_INT_24_8 */
  40980. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  40981. /** UNSIGNED_INT_10F_11F_11F_REV */
  40982. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  40983. /** UNSIGNED_INT_5_9_9_9_REV */
  40984. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  40985. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  40986. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  40987. /** nearest is mag = nearest and min = nearest and mip = linear */
  40988. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  40989. /** Bilinear is mag = linear and min = linear and mip = nearest */
  40990. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  40991. /** Trilinear is mag = linear and min = linear and mip = linear */
  40992. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  40993. /** nearest is mag = nearest and min = nearest and mip = linear */
  40994. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  40995. /** Bilinear is mag = linear and min = linear and mip = nearest */
  40996. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  40997. /** Trilinear is mag = linear and min = linear and mip = linear */
  40998. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  40999. /** mag = nearest and min = nearest and mip = nearest */
  41000. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  41001. /** mag = nearest and min = linear and mip = nearest */
  41002. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  41003. /** mag = nearest and min = linear and mip = linear */
  41004. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  41005. /** mag = nearest and min = linear and mip = none */
  41006. static readonly TEXTURE_NEAREST_LINEAR: number;
  41007. /** mag = nearest and min = nearest and mip = none */
  41008. static readonly TEXTURE_NEAREST_NEAREST: number;
  41009. /** mag = linear and min = nearest and mip = nearest */
  41010. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  41011. /** mag = linear and min = nearest and mip = linear */
  41012. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  41013. /** mag = linear and min = linear and mip = none */
  41014. static readonly TEXTURE_LINEAR_LINEAR: number;
  41015. /** mag = linear and min = nearest and mip = none */
  41016. static readonly TEXTURE_LINEAR_NEAREST: number;
  41017. /** Explicit coordinates mode */
  41018. static readonly TEXTURE_EXPLICIT_MODE: number;
  41019. /** Spherical coordinates mode */
  41020. static readonly TEXTURE_SPHERICAL_MODE: number;
  41021. /** Planar coordinates mode */
  41022. static readonly TEXTURE_PLANAR_MODE: number;
  41023. /** Cubic coordinates mode */
  41024. static readonly TEXTURE_CUBIC_MODE: number;
  41025. /** Projection coordinates mode */
  41026. static readonly TEXTURE_PROJECTION_MODE: number;
  41027. /** Skybox coordinates mode */
  41028. static readonly TEXTURE_SKYBOX_MODE: number;
  41029. /** Inverse Cubic coordinates mode */
  41030. static readonly TEXTURE_INVCUBIC_MODE: number;
  41031. /** Equirectangular coordinates mode */
  41032. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  41033. /** Equirectangular Fixed coordinates mode */
  41034. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  41035. /** Equirectangular Fixed Mirrored coordinates mode */
  41036. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  41037. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  41038. static readonly SCALEMODE_FLOOR: number;
  41039. /** Defines that texture rescaling will look for the nearest power of 2 size */
  41040. static readonly SCALEMODE_NEAREST: number;
  41041. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  41042. static readonly SCALEMODE_CEILING: number;
  41043. /**
  41044. * Returns the current npm package of the sdk
  41045. */
  41046. static get NpmPackage(): string;
  41047. /**
  41048. * Returns the current version of the framework
  41049. */
  41050. static get Version(): string;
  41051. /** Gets the list of created engines */
  41052. static get Instances(): Engine[];
  41053. /**
  41054. * Gets the latest created engine
  41055. */
  41056. static get LastCreatedEngine(): Nullable<Engine>;
  41057. /**
  41058. * Gets the latest created scene
  41059. */
  41060. static get LastCreatedScene(): Nullable<Scene>;
  41061. /**
  41062. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  41063. * @param flag defines which part of the materials must be marked as dirty
  41064. * @param predicate defines a predicate used to filter which materials should be affected
  41065. */
  41066. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41067. /**
  41068. * Method called to create the default loading screen.
  41069. * This can be overriden in your own app.
  41070. * @param canvas The rendering canvas element
  41071. * @returns The loading screen
  41072. */
  41073. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  41074. /**
  41075. * Method called to create the default rescale post process on each engine.
  41076. */
  41077. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  41078. /**
  41079. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  41080. **/
  41081. enableOfflineSupport: boolean;
  41082. /**
  41083. * 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)
  41084. **/
  41085. disableManifestCheck: boolean;
  41086. /**
  41087. * Gets the list of created scenes
  41088. */
  41089. scenes: Scene[];
  41090. /**
  41091. * Event raised when a new scene is created
  41092. */
  41093. onNewSceneAddedObservable: Observable<Scene>;
  41094. /**
  41095. * Gets the list of created postprocesses
  41096. */
  41097. postProcesses: PostProcess[];
  41098. /**
  41099. * Gets a boolean indicating if the pointer is currently locked
  41100. */
  41101. isPointerLock: boolean;
  41102. /**
  41103. * Observable event triggered each time the rendering canvas is resized
  41104. */
  41105. onResizeObservable: Observable<Engine>;
  41106. /**
  41107. * Observable event triggered each time the canvas loses focus
  41108. */
  41109. onCanvasBlurObservable: Observable<Engine>;
  41110. /**
  41111. * Observable event triggered each time the canvas gains focus
  41112. */
  41113. onCanvasFocusObservable: Observable<Engine>;
  41114. /**
  41115. * Observable event triggered each time the canvas receives pointerout event
  41116. */
  41117. onCanvasPointerOutObservable: Observable<PointerEvent>;
  41118. /**
  41119. * Observable raised when the engine begins a new frame
  41120. */
  41121. onBeginFrameObservable: Observable<Engine>;
  41122. /**
  41123. * If set, will be used to request the next animation frame for the render loop
  41124. */
  41125. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  41126. /**
  41127. * Observable raised when the engine ends the current frame
  41128. */
  41129. onEndFrameObservable: Observable<Engine>;
  41130. /**
  41131. * Observable raised when the engine is about to compile a shader
  41132. */
  41133. onBeforeShaderCompilationObservable: Observable<Engine>;
  41134. /**
  41135. * Observable raised when the engine has jsut compiled a shader
  41136. */
  41137. onAfterShaderCompilationObservable: Observable<Engine>;
  41138. /**
  41139. * Gets the audio engine
  41140. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41141. * @ignorenaming
  41142. */
  41143. static audioEngine: IAudioEngine;
  41144. /**
  41145. * Default AudioEngine factory responsible of creating the Audio Engine.
  41146. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  41147. */
  41148. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  41149. /**
  41150. * Default offline support factory responsible of creating a tool used to store data locally.
  41151. * By default, this will create a Database object if the workload has been embedded.
  41152. */
  41153. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  41154. private _loadingScreen;
  41155. private _pointerLockRequested;
  41156. private _rescalePostProcess;
  41157. private _deterministicLockstep;
  41158. private _lockstepMaxSteps;
  41159. private _timeStep;
  41160. protected get _supportsHardwareTextureRescaling(): boolean;
  41161. private _fps;
  41162. private _deltaTime;
  41163. /** @hidden */
  41164. _drawCalls: PerfCounter;
  41165. /** Gets or sets the tab index to set to the rendering canvas. 1 is the minimum value to set to be able to capture keyboard events */
  41166. canvasTabIndex: number;
  41167. /**
  41168. * Turn this value on if you want to pause FPS computation when in background
  41169. */
  41170. disablePerformanceMonitorInBackground: boolean;
  41171. private _performanceMonitor;
  41172. /**
  41173. * Gets the performance monitor attached to this engine
  41174. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  41175. */
  41176. get performanceMonitor(): PerformanceMonitor;
  41177. private _onFocus;
  41178. private _onBlur;
  41179. private _onCanvasPointerOut;
  41180. private _onCanvasBlur;
  41181. private _onCanvasFocus;
  41182. private _onFullscreenChange;
  41183. private _onPointerLockChange;
  41184. /**
  41185. * Gets the HTML element used to attach event listeners
  41186. * @returns a HTML element
  41187. */
  41188. getInputElement(): Nullable<HTMLElement>;
  41189. /**
  41190. * Creates a new engine
  41191. * @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
  41192. * @param antialias defines enable antialiasing (default: false)
  41193. * @param options defines further options to be sent to the getContext() function
  41194. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  41195. */
  41196. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  41197. /**
  41198. * Gets current aspect ratio
  41199. * @param viewportOwner defines the camera to use to get the aspect ratio
  41200. * @param useScreen defines if screen size must be used (or the current render target if any)
  41201. * @returns a number defining the aspect ratio
  41202. */
  41203. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  41204. /**
  41205. * Gets current screen aspect ratio
  41206. * @returns a number defining the aspect ratio
  41207. */
  41208. getScreenAspectRatio(): number;
  41209. /**
  41210. * Gets the client rect of the HTML canvas attached with the current webGL context
  41211. * @returns a client rectanglee
  41212. */
  41213. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  41214. /**
  41215. * Gets the client rect of the HTML element used for events
  41216. * @returns a client rectanglee
  41217. */
  41218. getInputElementClientRect(): Nullable<ClientRect>;
  41219. /**
  41220. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  41221. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41222. * @returns true if engine is in deterministic lock step mode
  41223. */
  41224. isDeterministicLockStep(): boolean;
  41225. /**
  41226. * Gets the max steps when engine is running in deterministic lock step
  41227. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41228. * @returns the max steps
  41229. */
  41230. getLockstepMaxSteps(): number;
  41231. /**
  41232. * Returns the time in ms between steps when using deterministic lock step.
  41233. * @returns time step in (ms)
  41234. */
  41235. getTimeStep(): number;
  41236. /**
  41237. * Force the mipmap generation for the given render target texture
  41238. * @param texture defines the render target texture to use
  41239. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  41240. */
  41241. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  41242. /** States */
  41243. /**
  41244. * Set various states to the webGL context
  41245. * @param culling defines backface culling state
  41246. * @param zOffset defines the value to apply to zOffset (0 by default)
  41247. * @param force defines if states must be applied even if cache is up to date
  41248. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  41249. */
  41250. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41251. /**
  41252. * Set the z offset to apply to current rendering
  41253. * @param value defines the offset to apply
  41254. */
  41255. setZOffset(value: number): void;
  41256. /**
  41257. * Gets the current value of the zOffset
  41258. * @returns the current zOffset state
  41259. */
  41260. getZOffset(): number;
  41261. /**
  41262. * Enable or disable depth buffering
  41263. * @param enable defines the state to set
  41264. */
  41265. setDepthBuffer(enable: boolean): void;
  41266. /**
  41267. * Gets a boolean indicating if depth writing is enabled
  41268. * @returns the current depth writing state
  41269. */
  41270. getDepthWrite(): boolean;
  41271. /**
  41272. * Enable or disable depth writing
  41273. * @param enable defines the state to set
  41274. */
  41275. setDepthWrite(enable: boolean): void;
  41276. /**
  41277. * Gets a boolean indicating if stencil buffer is enabled
  41278. * @returns the current stencil buffer state
  41279. */
  41280. getStencilBuffer(): boolean;
  41281. /**
  41282. * Enable or disable the stencil buffer
  41283. * @param enable defines if the stencil buffer must be enabled or disabled
  41284. */
  41285. setStencilBuffer(enable: boolean): void;
  41286. /**
  41287. * Gets the current stencil mask
  41288. * @returns a number defining the new stencil mask to use
  41289. */
  41290. getStencilMask(): number;
  41291. /**
  41292. * Sets the current stencil mask
  41293. * @param mask defines the new stencil mask to use
  41294. */
  41295. setStencilMask(mask: number): void;
  41296. /**
  41297. * Gets the current stencil function
  41298. * @returns a number defining the stencil function to use
  41299. */
  41300. getStencilFunction(): number;
  41301. /**
  41302. * Gets the current stencil reference value
  41303. * @returns a number defining the stencil reference value to use
  41304. */
  41305. getStencilFunctionReference(): number;
  41306. /**
  41307. * Gets the current stencil mask
  41308. * @returns a number defining the stencil mask to use
  41309. */
  41310. getStencilFunctionMask(): number;
  41311. /**
  41312. * Sets the current stencil function
  41313. * @param stencilFunc defines the new stencil function to use
  41314. */
  41315. setStencilFunction(stencilFunc: number): void;
  41316. /**
  41317. * Sets the current stencil reference
  41318. * @param reference defines the new stencil reference to use
  41319. */
  41320. setStencilFunctionReference(reference: number): void;
  41321. /**
  41322. * Sets the current stencil mask
  41323. * @param mask defines the new stencil mask to use
  41324. */
  41325. setStencilFunctionMask(mask: number): void;
  41326. /**
  41327. * Gets the current stencil operation when stencil fails
  41328. * @returns a number defining stencil operation to use when stencil fails
  41329. */
  41330. getStencilOperationFail(): number;
  41331. /**
  41332. * Gets the current stencil operation when depth fails
  41333. * @returns a number defining stencil operation to use when depth fails
  41334. */
  41335. getStencilOperationDepthFail(): number;
  41336. /**
  41337. * Gets the current stencil operation when stencil passes
  41338. * @returns a number defining stencil operation to use when stencil passes
  41339. */
  41340. getStencilOperationPass(): number;
  41341. /**
  41342. * Sets the stencil operation to use when stencil fails
  41343. * @param operation defines the stencil operation to use when stencil fails
  41344. */
  41345. setStencilOperationFail(operation: number): void;
  41346. /**
  41347. * Sets the stencil operation to use when depth fails
  41348. * @param operation defines the stencil operation to use when depth fails
  41349. */
  41350. setStencilOperationDepthFail(operation: number): void;
  41351. /**
  41352. * Sets the stencil operation to use when stencil passes
  41353. * @param operation defines the stencil operation to use when stencil passes
  41354. */
  41355. setStencilOperationPass(operation: number): void;
  41356. /**
  41357. * Sets a boolean indicating if the dithering state is enabled or disabled
  41358. * @param value defines the dithering state
  41359. */
  41360. setDitheringState(value: boolean): void;
  41361. /**
  41362. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  41363. * @param value defines the rasterizer state
  41364. */
  41365. setRasterizerState(value: boolean): void;
  41366. /**
  41367. * Gets the current depth function
  41368. * @returns a number defining the depth function
  41369. */
  41370. getDepthFunction(): Nullable<number>;
  41371. /**
  41372. * Sets the current depth function
  41373. * @param depthFunc defines the function to use
  41374. */
  41375. setDepthFunction(depthFunc: number): void;
  41376. /**
  41377. * Sets the current depth function to GREATER
  41378. */
  41379. setDepthFunctionToGreater(): void;
  41380. /**
  41381. * Sets the current depth function to GEQUAL
  41382. */
  41383. setDepthFunctionToGreaterOrEqual(): void;
  41384. /**
  41385. * Sets the current depth function to LESS
  41386. */
  41387. setDepthFunctionToLess(): void;
  41388. /**
  41389. * Sets the current depth function to LEQUAL
  41390. */
  41391. setDepthFunctionToLessOrEqual(): void;
  41392. private _cachedStencilBuffer;
  41393. private _cachedStencilFunction;
  41394. private _cachedStencilMask;
  41395. private _cachedStencilOperationPass;
  41396. private _cachedStencilOperationFail;
  41397. private _cachedStencilOperationDepthFail;
  41398. private _cachedStencilReference;
  41399. /**
  41400. * Caches the the state of the stencil buffer
  41401. */
  41402. cacheStencilState(): void;
  41403. /**
  41404. * Restores the state of the stencil buffer
  41405. */
  41406. restoreStencilState(): void;
  41407. /**
  41408. * Directly set the WebGL Viewport
  41409. * @param x defines the x coordinate of the viewport (in screen space)
  41410. * @param y defines the y coordinate of the viewport (in screen space)
  41411. * @param width defines the width of the viewport (in screen space)
  41412. * @param height defines the height of the viewport (in screen space)
  41413. * @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
  41414. */
  41415. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  41416. /**
  41417. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  41418. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  41419. * @param y defines the y-coordinate of the corner of the clear rectangle
  41420. * @param width defines the width of the clear rectangle
  41421. * @param height defines the height of the clear rectangle
  41422. * @param clearColor defines the clear color
  41423. */
  41424. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  41425. /**
  41426. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  41427. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  41428. * @param y defines the y-coordinate of the corner of the clear rectangle
  41429. * @param width defines the width of the clear rectangle
  41430. * @param height defines the height of the clear rectangle
  41431. */
  41432. enableScissor(x: number, y: number, width: number, height: number): void;
  41433. /**
  41434. * Disable previously set scissor test rectangle
  41435. */
  41436. disableScissor(): void;
  41437. protected _reportDrawCall(): void;
  41438. /**
  41439. * Initializes a webVR display and starts listening to display change events
  41440. * The onVRDisplayChangedObservable will be notified upon these changes
  41441. * @returns The onVRDisplayChangedObservable
  41442. */
  41443. initWebVR(): Observable<IDisplayChangedEventArgs>;
  41444. /** @hidden */
  41445. _prepareVRComponent(): void;
  41446. /** @hidden */
  41447. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  41448. /** @hidden */
  41449. _submitVRFrame(): void;
  41450. /**
  41451. * Call this function to leave webVR mode
  41452. * Will do nothing if webVR is not supported or if there is no webVR device
  41453. * @see https://doc.babylonjs.com/how_to/webvr_camera
  41454. */
  41455. disableVR(): void;
  41456. /**
  41457. * Gets a boolean indicating that the system is in VR mode and is presenting
  41458. * @returns true if VR mode is engaged
  41459. */
  41460. isVRPresenting(): boolean;
  41461. /** @hidden */
  41462. _requestVRFrame(): void;
  41463. /** @hidden */
  41464. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41465. /**
  41466. * Gets the source code of the vertex shader associated with a specific webGL program
  41467. * @param program defines the program to use
  41468. * @returns a string containing the source code of the vertex shader associated with the program
  41469. */
  41470. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  41471. /**
  41472. * Gets the source code of the fragment shader associated with a specific webGL program
  41473. * @param program defines the program to use
  41474. * @returns a string containing the source code of the fragment shader associated with the program
  41475. */
  41476. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  41477. /**
  41478. * Sets a depth stencil texture from a render target to the according uniform.
  41479. * @param channel The texture channel
  41480. * @param uniform The uniform to set
  41481. * @param texture The render target texture containing the depth stencil texture to apply
  41482. */
  41483. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  41484. /**
  41485. * Sets a texture to the webGL context from a postprocess
  41486. * @param channel defines the channel to use
  41487. * @param postProcess defines the source postprocess
  41488. */
  41489. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  41490. /**
  41491. * Binds the output of the passed in post process to the texture channel specified
  41492. * @param channel The channel the texture should be bound to
  41493. * @param postProcess The post process which's output should be bound
  41494. */
  41495. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  41496. protected _rebuildBuffers(): void;
  41497. /** @hidden */
  41498. _renderFrame(): void;
  41499. _renderLoop(): void;
  41500. /** @hidden */
  41501. _renderViews(): boolean;
  41502. /**
  41503. * Toggle full screen mode
  41504. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41505. */
  41506. switchFullscreen(requestPointerLock: boolean): void;
  41507. /**
  41508. * Enters full screen mode
  41509. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41510. */
  41511. enterFullscreen(requestPointerLock: boolean): void;
  41512. /**
  41513. * Exits full screen mode
  41514. */
  41515. exitFullscreen(): void;
  41516. /**
  41517. * Enters Pointerlock mode
  41518. */
  41519. enterPointerlock(): void;
  41520. /**
  41521. * Exits Pointerlock mode
  41522. */
  41523. exitPointerlock(): void;
  41524. /**
  41525. * Begin a new frame
  41526. */
  41527. beginFrame(): void;
  41528. /**
  41529. * Enf the current frame
  41530. */
  41531. endFrame(): void;
  41532. resize(): void;
  41533. /**
  41534. * Force a specific size of the canvas
  41535. * @param width defines the new canvas' width
  41536. * @param height defines the new canvas' height
  41537. * @returns true if the size was changed
  41538. */
  41539. setSize(width: number, height: number): boolean;
  41540. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  41541. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41542. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41543. _releaseTexture(texture: InternalTexture): void;
  41544. /**
  41545. * @hidden
  41546. * Rescales a texture
  41547. * @param source input texutre
  41548. * @param destination destination texture
  41549. * @param scene scene to use to render the resize
  41550. * @param internalFormat format to use when resizing
  41551. * @param onComplete callback to be called when resize has completed
  41552. */
  41553. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  41554. /**
  41555. * Gets the current framerate
  41556. * @returns a number representing the framerate
  41557. */
  41558. getFps(): number;
  41559. /**
  41560. * Gets the time spent between current and previous frame
  41561. * @returns a number representing the delta time in ms
  41562. */
  41563. getDeltaTime(): number;
  41564. private _measureFps;
  41565. /** @hidden */
  41566. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  41567. /**
  41568. * Updates the sample count of a render target texture
  41569. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  41570. * @param texture defines the texture to update
  41571. * @param samples defines the sample count to set
  41572. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  41573. */
  41574. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  41575. /**
  41576. * Updates a depth texture Comparison Mode and Function.
  41577. * If the comparison Function is equal to 0, the mode will be set to none.
  41578. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  41579. * @param texture The texture to set the comparison function for
  41580. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  41581. */
  41582. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  41583. /**
  41584. * Creates a webGL buffer to use with instanciation
  41585. * @param capacity defines the size of the buffer
  41586. * @returns the webGL buffer
  41587. */
  41588. createInstancesBuffer(capacity: number): DataBuffer;
  41589. /**
  41590. * Delete a webGL buffer used with instanciation
  41591. * @param buffer defines the webGL buffer to delete
  41592. */
  41593. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  41594. private _clientWaitAsync;
  41595. /** @hidden */
  41596. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  41597. dispose(): void;
  41598. private _disableTouchAction;
  41599. /**
  41600. * Display the loading screen
  41601. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41602. */
  41603. displayLoadingUI(): void;
  41604. /**
  41605. * Hide the loading screen
  41606. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41607. */
  41608. hideLoadingUI(): void;
  41609. /**
  41610. * Gets the current loading screen object
  41611. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41612. */
  41613. get loadingScreen(): ILoadingScreen;
  41614. /**
  41615. * Sets the current loading screen object
  41616. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41617. */
  41618. set loadingScreen(loadingScreen: ILoadingScreen);
  41619. /**
  41620. * Sets the current loading screen text
  41621. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41622. */
  41623. set loadingUIText(text: string);
  41624. /**
  41625. * Sets the current loading screen background color
  41626. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41627. */
  41628. set loadingUIBackgroundColor(color: string);
  41629. /** Pointerlock and fullscreen */
  41630. /**
  41631. * Ask the browser to promote the current element to pointerlock mode
  41632. * @param element defines the DOM element to promote
  41633. */
  41634. static _RequestPointerlock(element: HTMLElement): void;
  41635. /**
  41636. * Asks the browser to exit pointerlock mode
  41637. */
  41638. static _ExitPointerlock(): void;
  41639. /**
  41640. * Ask the browser to promote the current element to fullscreen rendering mode
  41641. * @param element defines the DOM element to promote
  41642. */
  41643. static _RequestFullscreen(element: HTMLElement): void;
  41644. /**
  41645. * Asks the browser to exit fullscreen mode
  41646. */
  41647. static _ExitFullscreen(): void;
  41648. }
  41649. }
  41650. declare module BABYLON {
  41651. /**
  41652. * The engine store class is responsible to hold all the instances of Engine and Scene created
  41653. * during the life time of the application.
  41654. */
  41655. export class EngineStore {
  41656. /** Gets the list of created engines */
  41657. static Instances: Engine[];
  41658. /** @hidden */
  41659. static _LastCreatedScene: Nullable<Scene>;
  41660. /**
  41661. * Gets the latest created engine
  41662. */
  41663. static get LastCreatedEngine(): Nullable<Engine>;
  41664. /**
  41665. * Gets the latest created scene
  41666. */
  41667. static get LastCreatedScene(): Nullable<Scene>;
  41668. /**
  41669. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41670. * @ignorenaming
  41671. */
  41672. static UseFallbackTexture: boolean;
  41673. /**
  41674. * Texture content used if a texture cannot loaded
  41675. * @ignorenaming
  41676. */
  41677. static FallbackTexture: string;
  41678. }
  41679. }
  41680. declare module BABYLON {
  41681. /**
  41682. * Helper class that provides a small promise polyfill
  41683. */
  41684. export class PromisePolyfill {
  41685. /**
  41686. * Static function used to check if the polyfill is required
  41687. * If this is the case then the function will inject the polyfill to window.Promise
  41688. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  41689. */
  41690. static Apply(force?: boolean): void;
  41691. }
  41692. }
  41693. declare module BABYLON {
  41694. /**
  41695. * Interface for screenshot methods with describe argument called `size` as object with options
  41696. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  41697. */
  41698. export interface IScreenshotSize {
  41699. /**
  41700. * number in pixels for canvas height
  41701. */
  41702. height?: number;
  41703. /**
  41704. * multiplier allowing render at a higher or lower resolution
  41705. * If value is defined then height and width will be ignored and taken from camera
  41706. */
  41707. precision?: number;
  41708. /**
  41709. * number in pixels for canvas width
  41710. */
  41711. width?: number;
  41712. }
  41713. }
  41714. declare module BABYLON {
  41715. interface IColor4Like {
  41716. r: float;
  41717. g: float;
  41718. b: float;
  41719. a: float;
  41720. }
  41721. /**
  41722. * Class containing a set of static utilities functions
  41723. */
  41724. export class Tools {
  41725. /**
  41726. * Gets or sets the base URL to use to load assets
  41727. */
  41728. static get BaseUrl(): string;
  41729. static set BaseUrl(value: string);
  41730. /**
  41731. * Enable/Disable Custom HTTP Request Headers globally.
  41732. * default = false
  41733. * @see CustomRequestHeaders
  41734. */
  41735. static UseCustomRequestHeaders: boolean;
  41736. /**
  41737. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  41738. * i.e. when loading files, where the server/service expects an Authorization header
  41739. */
  41740. static CustomRequestHeaders: {
  41741. [key: string]: string;
  41742. };
  41743. /**
  41744. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  41745. */
  41746. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  41747. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  41748. /**
  41749. * Default behaviour for cors in the application.
  41750. * It can be a string if the expected behavior is identical in the entire app.
  41751. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  41752. */
  41753. static get CorsBehavior(): string | ((url: string | string[]) => string);
  41754. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  41755. /**
  41756. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41757. * @ignorenaming
  41758. */
  41759. static get UseFallbackTexture(): boolean;
  41760. static set UseFallbackTexture(value: boolean);
  41761. /**
  41762. * Use this object to register external classes like custom textures or material
  41763. * to allow the laoders to instantiate them
  41764. */
  41765. static get RegisteredExternalClasses(): {
  41766. [key: string]: Object;
  41767. };
  41768. static set RegisteredExternalClasses(classes: {
  41769. [key: string]: Object;
  41770. });
  41771. /**
  41772. * Texture content used if a texture cannot loaded
  41773. * @ignorenaming
  41774. */
  41775. static get fallbackTexture(): string;
  41776. static set fallbackTexture(value: string);
  41777. /**
  41778. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  41779. * @param u defines the coordinate on X axis
  41780. * @param v defines the coordinate on Y axis
  41781. * @param width defines the width of the source data
  41782. * @param height defines the height of the source data
  41783. * @param pixels defines the source byte array
  41784. * @param color defines the output color
  41785. */
  41786. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  41787. /**
  41788. * Interpolates between a and b via alpha
  41789. * @param a The lower value (returned when alpha = 0)
  41790. * @param b The upper value (returned when alpha = 1)
  41791. * @param alpha The interpolation-factor
  41792. * @return The mixed value
  41793. */
  41794. static Mix(a: number, b: number, alpha: number): number;
  41795. /**
  41796. * Tries to instantiate a new object from a given class name
  41797. * @param className defines the class name to instantiate
  41798. * @returns the new object or null if the system was not able to do the instantiation
  41799. */
  41800. static Instantiate(className: string): any;
  41801. /**
  41802. * Provides a slice function that will work even on IE
  41803. * @param data defines the array to slice
  41804. * @param start defines the start of the data (optional)
  41805. * @param end defines the end of the data (optional)
  41806. * @returns the new sliced array
  41807. */
  41808. static Slice<T>(data: T, start?: number, end?: number): T;
  41809. /**
  41810. * Provides a slice function that will work even on IE
  41811. * The difference between this and Slice is that this will force-convert to array
  41812. * @param data defines the array to slice
  41813. * @param start defines the start of the data (optional)
  41814. * @param end defines the end of the data (optional)
  41815. * @returns the new sliced array
  41816. */
  41817. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  41818. /**
  41819. * Polyfill for setImmediate
  41820. * @param action defines the action to execute after the current execution block
  41821. */
  41822. static SetImmediate(action: () => void): void;
  41823. /**
  41824. * Function indicating if a number is an exponent of 2
  41825. * @param value defines the value to test
  41826. * @returns true if the value is an exponent of 2
  41827. */
  41828. static IsExponentOfTwo(value: number): boolean;
  41829. private static _tmpFloatArray;
  41830. /**
  41831. * Returns the nearest 32-bit single precision float representation of a Number
  41832. * @param value A Number. If the parameter is of a different type, it will get converted
  41833. * to a number or to NaN if it cannot be converted
  41834. * @returns number
  41835. */
  41836. static FloatRound(value: number): number;
  41837. /**
  41838. * Extracts the filename from a path
  41839. * @param path defines the path to use
  41840. * @returns the filename
  41841. */
  41842. static GetFilename(path: string): string;
  41843. /**
  41844. * Extracts the "folder" part of a path (everything before the filename).
  41845. * @param uri The URI to extract the info from
  41846. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  41847. * @returns The "folder" part of the path
  41848. */
  41849. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  41850. /**
  41851. * Extracts text content from a DOM element hierarchy
  41852. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  41853. */
  41854. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  41855. /**
  41856. * Convert an angle in radians to degrees
  41857. * @param angle defines the angle to convert
  41858. * @returns the angle in degrees
  41859. */
  41860. static ToDegrees(angle: number): number;
  41861. /**
  41862. * Convert an angle in degrees to radians
  41863. * @param angle defines the angle to convert
  41864. * @returns the angle in radians
  41865. */
  41866. static ToRadians(angle: number): number;
  41867. /**
  41868. * Returns an array if obj is not an array
  41869. * @param obj defines the object to evaluate as an array
  41870. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  41871. * @returns either obj directly if obj is an array or a new array containing obj
  41872. */
  41873. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  41874. /**
  41875. * Gets the pointer prefix to use
  41876. * @param engine defines the engine we are finding the prefix for
  41877. * @returns "pointer" if touch is enabled. Else returns "mouse"
  41878. */
  41879. static GetPointerPrefix(engine: Engine): string;
  41880. /**
  41881. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  41882. * @param url define the url we are trying
  41883. * @param element define the dom element where to configure the cors policy
  41884. */
  41885. static SetCorsBehavior(url: string | string[], element: {
  41886. crossOrigin: string | null;
  41887. }): void;
  41888. /**
  41889. * Removes unwanted characters from an url
  41890. * @param url defines the url to clean
  41891. * @returns the cleaned url
  41892. */
  41893. static CleanUrl(url: string): string;
  41894. /**
  41895. * Gets or sets a function used to pre-process url before using them to load assets
  41896. */
  41897. static get PreprocessUrl(): (url: string) => string;
  41898. static set PreprocessUrl(processor: (url: string) => string);
  41899. /**
  41900. * Loads an image as an HTMLImageElement.
  41901. * @param input url string, ArrayBuffer, or Blob to load
  41902. * @param onLoad callback called when the image successfully loads
  41903. * @param onError callback called when the image fails to load
  41904. * @param offlineProvider offline provider for caching
  41905. * @param mimeType optional mime type
  41906. * @returns the HTMLImageElement of the loaded image
  41907. */
  41908. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  41909. /**
  41910. * Loads a file from a url
  41911. * @param url url string, ArrayBuffer, or Blob to load
  41912. * @param onSuccess callback called when the file successfully loads
  41913. * @param onProgress callback called while file is loading (if the server supports this mode)
  41914. * @param offlineProvider defines the offline provider for caching
  41915. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41916. * @param onError callback called when the file fails to load
  41917. * @returns a file request object
  41918. */
  41919. 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;
  41920. /**
  41921. * Loads a file from a url
  41922. * @param url the file url to load
  41923. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41924. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  41925. */
  41926. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  41927. /**
  41928. * Load a script (identified by an url). When the url returns, the
  41929. * content of this file is added into a new script element, attached to the DOM (body element)
  41930. * @param scriptUrl defines the url of the script to laod
  41931. * @param onSuccess defines the callback called when the script is loaded
  41932. * @param onError defines the callback to call if an error occurs
  41933. * @param scriptId defines the id of the script element
  41934. */
  41935. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  41936. /**
  41937. * Load an asynchronous script (identified by an url). When the url returns, the
  41938. * content of this file is added into a new script element, attached to the DOM (body element)
  41939. * @param scriptUrl defines the url of the script to laod
  41940. * @param scriptId defines the id of the script element
  41941. * @returns a promise request object
  41942. */
  41943. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  41944. /**
  41945. * Loads a file from a blob
  41946. * @param fileToLoad defines the blob to use
  41947. * @param callback defines the callback to call when data is loaded
  41948. * @param progressCallback defines the callback to call during loading process
  41949. * @returns a file request object
  41950. */
  41951. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  41952. /**
  41953. * Reads a file from a File object
  41954. * @param file defines the file to load
  41955. * @param onSuccess defines the callback to call when data is loaded
  41956. * @param onProgress defines the callback to call during loading process
  41957. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  41958. * @param onError defines the callback to call when an error occurs
  41959. * @returns a file request object
  41960. */
  41961. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41962. /**
  41963. * Creates a data url from a given string content
  41964. * @param content defines the content to convert
  41965. * @returns the new data url link
  41966. */
  41967. static FileAsURL(content: string): string;
  41968. /**
  41969. * Format the given number to a specific decimal format
  41970. * @param value defines the number to format
  41971. * @param decimals defines the number of decimals to use
  41972. * @returns the formatted string
  41973. */
  41974. static Format(value: number, decimals?: number): string;
  41975. /**
  41976. * Tries to copy an object by duplicating every property
  41977. * @param source defines the source object
  41978. * @param destination defines the target object
  41979. * @param doNotCopyList defines a list of properties to avoid
  41980. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  41981. */
  41982. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  41983. /**
  41984. * Gets a boolean indicating if the given object has no own property
  41985. * @param obj defines the object to test
  41986. * @returns true if object has no own property
  41987. */
  41988. static IsEmpty(obj: any): boolean;
  41989. /**
  41990. * Function used to register events at window level
  41991. * @param windowElement defines the Window object to use
  41992. * @param events defines the events to register
  41993. */
  41994. static RegisterTopRootEvents(windowElement: Window, events: {
  41995. name: string;
  41996. handler: Nullable<(e: FocusEvent) => any>;
  41997. }[]): void;
  41998. /**
  41999. * Function used to unregister events from window level
  42000. * @param windowElement defines the Window object to use
  42001. * @param events defines the events to unregister
  42002. */
  42003. static UnregisterTopRootEvents(windowElement: Window, events: {
  42004. name: string;
  42005. handler: Nullable<(e: FocusEvent) => any>;
  42006. }[]): void;
  42007. /**
  42008. * @ignore
  42009. */
  42010. static _ScreenshotCanvas: HTMLCanvasElement;
  42011. /**
  42012. * Dumps the current bound framebuffer
  42013. * @param width defines the rendering width
  42014. * @param height defines the rendering height
  42015. * @param engine defines the hosting engine
  42016. * @param successCallback defines the callback triggered once the data are available
  42017. * @param mimeType defines the mime type of the result
  42018. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  42019. */
  42020. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  42021. /**
  42022. * Converts the canvas data to blob.
  42023. * This acts as a polyfill for browsers not supporting the to blob function.
  42024. * @param canvas Defines the canvas to extract the data from
  42025. * @param successCallback Defines the callback triggered once the data are available
  42026. * @param mimeType Defines the mime type of the result
  42027. */
  42028. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  42029. /**
  42030. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  42031. * @param successCallback defines the callback triggered once the data are available
  42032. * @param mimeType defines the mime type of the result
  42033. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  42034. */
  42035. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  42036. /**
  42037. * Downloads a blob in the browser
  42038. * @param blob defines the blob to download
  42039. * @param fileName defines the name of the downloaded file
  42040. */
  42041. static Download(blob: Blob, fileName: string): void;
  42042. /**
  42043. * Will return the right value of the noPreventDefault variable
  42044. * Needed to keep backwards compatibility to the old API.
  42045. *
  42046. * @param args arguments passed to the attachControl function
  42047. * @returns the correct value for noPreventDefault
  42048. */
  42049. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  42050. /**
  42051. * Captures a screenshot of the current rendering
  42052. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  42053. * @param engine defines the rendering engine
  42054. * @param camera defines the source camera
  42055. * @param size This parameter can be set to a single number or to an object with the
  42056. * following (optional) properties: precision, width, height. If a single number is passed,
  42057. * it will be used for both width and height. If an object is passed, the screenshot size
  42058. * will be derived from the parameters. The precision property is a multiplier allowing
  42059. * rendering at a higher or lower resolution
  42060. * @param successCallback defines the callback receives a single parameter which contains the
  42061. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  42062. * src parameter of an <img> to display it
  42063. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  42064. * Check your browser for supported MIME types
  42065. */
  42066. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  42067. /**
  42068. * Captures a screenshot of the current rendering
  42069. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  42070. * @param engine defines the rendering engine
  42071. * @param camera defines the source camera
  42072. * @param size This parameter can be set to a single number or to an object with the
  42073. * following (optional) properties: precision, width, height. If a single number is passed,
  42074. * it will be used for both width and height. If an object is passed, the screenshot size
  42075. * will be derived from the parameters. The precision property is a multiplier allowing
  42076. * rendering at a higher or lower resolution
  42077. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  42078. * Check your browser for supported MIME types
  42079. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  42080. * to the src parameter of an <img> to display it
  42081. */
  42082. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  42083. /**
  42084. * Generates an image screenshot from the specified camera.
  42085. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  42086. * @param engine The engine to use for rendering
  42087. * @param camera The camera to use for rendering
  42088. * @param size This parameter can be set to a single number or to an object with the
  42089. * following (optional) properties: precision, width, height. If a single number is passed,
  42090. * it will be used for both width and height. If an object is passed, the screenshot size
  42091. * will be derived from the parameters. The precision property is a multiplier allowing
  42092. * rendering at a higher or lower resolution
  42093. * @param successCallback The callback receives a single parameter which contains the
  42094. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  42095. * src parameter of an <img> to display it
  42096. * @param mimeType The MIME type of the screenshot image (default: image/png).
  42097. * Check your browser for supported MIME types
  42098. * @param samples Texture samples (default: 1)
  42099. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  42100. * @param fileName A name for for the downloaded file.
  42101. */
  42102. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  42103. /**
  42104. * Generates an image screenshot from the specified camera.
  42105. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  42106. * @param engine The engine to use for rendering
  42107. * @param camera The camera to use for rendering
  42108. * @param size This parameter can be set to a single number or to an object with the
  42109. * following (optional) properties: precision, width, height. If a single number is passed,
  42110. * it will be used for both width and height. If an object is passed, the screenshot size
  42111. * will be derived from the parameters. The precision property is a multiplier allowing
  42112. * rendering at a higher or lower resolution
  42113. * @param mimeType The MIME type of the screenshot image (default: image/png).
  42114. * Check your browser for supported MIME types
  42115. * @param samples Texture samples (default: 1)
  42116. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  42117. * @param fileName A name for for the downloaded file.
  42118. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  42119. * to the src parameter of an <img> to display it
  42120. */
  42121. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  42122. /**
  42123. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  42124. * Be aware Math.random() could cause collisions, but:
  42125. * "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"
  42126. * @returns a pseudo random id
  42127. */
  42128. static RandomId(): string;
  42129. /**
  42130. * Test if the given uri is a base64 string
  42131. * @param uri The uri to test
  42132. * @return True if the uri is a base64 string or false otherwise
  42133. */
  42134. static IsBase64(uri: string): boolean;
  42135. /**
  42136. * Decode the given base64 uri.
  42137. * @param uri The uri to decode
  42138. * @return The decoded base64 data.
  42139. */
  42140. static DecodeBase64(uri: string): ArrayBuffer;
  42141. /**
  42142. * Gets the absolute url.
  42143. * @param url the input url
  42144. * @return the absolute url
  42145. */
  42146. static GetAbsoluteUrl(url: string): string;
  42147. /**
  42148. * No log
  42149. */
  42150. static readonly NoneLogLevel: number;
  42151. /**
  42152. * Only message logs
  42153. */
  42154. static readonly MessageLogLevel: number;
  42155. /**
  42156. * Only warning logs
  42157. */
  42158. static readonly WarningLogLevel: number;
  42159. /**
  42160. * Only error logs
  42161. */
  42162. static readonly ErrorLogLevel: number;
  42163. /**
  42164. * All logs
  42165. */
  42166. static readonly AllLogLevel: number;
  42167. /**
  42168. * Gets a value indicating the number of loading errors
  42169. * @ignorenaming
  42170. */
  42171. static get errorsCount(): number;
  42172. /**
  42173. * Callback called when a new log is added
  42174. */
  42175. static OnNewCacheEntry: (entry: string) => void;
  42176. /**
  42177. * Log a message to the console
  42178. * @param message defines the message to log
  42179. */
  42180. static Log(message: string): void;
  42181. /**
  42182. * Write a warning message to the console
  42183. * @param message defines the message to log
  42184. */
  42185. static Warn(message: string): void;
  42186. /**
  42187. * Write an error message to the console
  42188. * @param message defines the message to log
  42189. */
  42190. static Error(message: string): void;
  42191. /**
  42192. * Gets current log cache (list of logs)
  42193. */
  42194. static get LogCache(): string;
  42195. /**
  42196. * Clears the log cache
  42197. */
  42198. static ClearLogCache(): void;
  42199. /**
  42200. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  42201. */
  42202. static set LogLevels(level: number);
  42203. /**
  42204. * Checks if the window object exists
  42205. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  42206. */
  42207. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  42208. /**
  42209. * No performance log
  42210. */
  42211. static readonly PerformanceNoneLogLevel: number;
  42212. /**
  42213. * Use user marks to log performance
  42214. */
  42215. static readonly PerformanceUserMarkLogLevel: number;
  42216. /**
  42217. * Log performance to the console
  42218. */
  42219. static readonly PerformanceConsoleLogLevel: number;
  42220. private static _performance;
  42221. /**
  42222. * Sets the current performance log level
  42223. */
  42224. static set PerformanceLogLevel(level: number);
  42225. private static _StartPerformanceCounterDisabled;
  42226. private static _EndPerformanceCounterDisabled;
  42227. private static _StartUserMark;
  42228. private static _EndUserMark;
  42229. private static _StartPerformanceConsole;
  42230. private static _EndPerformanceConsole;
  42231. /**
  42232. * Starts a performance counter
  42233. */
  42234. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  42235. /**
  42236. * Ends a specific performance coutner
  42237. */
  42238. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  42239. /**
  42240. * Gets either window.performance.now() if supported or Date.now() else
  42241. */
  42242. static get Now(): number;
  42243. /**
  42244. * This method will return the name of the class used to create the instance of the given object.
  42245. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  42246. * @param object the object to get the class name from
  42247. * @param isType defines if the object is actually a type
  42248. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  42249. */
  42250. static GetClassName(object: any, isType?: boolean): string;
  42251. /**
  42252. * Gets the first element of an array satisfying a given predicate
  42253. * @param array defines the array to browse
  42254. * @param predicate defines the predicate to use
  42255. * @returns null if not found or the element
  42256. */
  42257. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  42258. /**
  42259. * This method will return the name of the full name of the class, including its owning module (if any).
  42260. * 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).
  42261. * @param object the object to get the class name from
  42262. * @param isType defines if the object is actually a type
  42263. * @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.
  42264. * @ignorenaming
  42265. */
  42266. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  42267. /**
  42268. * Returns a promise that resolves after the given amount of time.
  42269. * @param delay Number of milliseconds to delay
  42270. * @returns Promise that resolves after the given amount of time
  42271. */
  42272. static DelayAsync(delay: number): Promise<void>;
  42273. /**
  42274. * Utility function to detect if the current user agent is Safari
  42275. * @returns whether or not the current user agent is safari
  42276. */
  42277. static IsSafari(): boolean;
  42278. }
  42279. /**
  42280. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  42281. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  42282. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  42283. * @param name The name of the class, case should be preserved
  42284. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  42285. */
  42286. export function className(name: string, module?: string): (target: Object) => void;
  42287. /**
  42288. * An implementation of a loop for asynchronous functions.
  42289. */
  42290. export class AsyncLoop {
  42291. /**
  42292. * Defines the number of iterations for the loop
  42293. */
  42294. iterations: number;
  42295. /**
  42296. * Defines the current index of the loop.
  42297. */
  42298. index: number;
  42299. private _done;
  42300. private _fn;
  42301. private _successCallback;
  42302. /**
  42303. * Constructor.
  42304. * @param iterations the number of iterations.
  42305. * @param func the function to run each iteration
  42306. * @param successCallback the callback that will be called upon succesful execution
  42307. * @param offset starting offset.
  42308. */
  42309. constructor(
  42310. /**
  42311. * Defines the number of iterations for the loop
  42312. */
  42313. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  42314. /**
  42315. * Execute the next iteration. Must be called after the last iteration was finished.
  42316. */
  42317. executeNext(): void;
  42318. /**
  42319. * Break the loop and run the success callback.
  42320. */
  42321. breakLoop(): void;
  42322. /**
  42323. * Create and run an async loop.
  42324. * @param iterations the number of iterations.
  42325. * @param fn the function to run each iteration
  42326. * @param successCallback the callback that will be called upon succesful execution
  42327. * @param offset starting offset.
  42328. * @returns the created async loop object
  42329. */
  42330. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  42331. /**
  42332. * A for-loop that will run a given number of iterations synchronous and the rest async.
  42333. * @param iterations total number of iterations
  42334. * @param syncedIterations number of synchronous iterations in each async iteration.
  42335. * @param fn the function to call each iteration.
  42336. * @param callback a success call back that will be called when iterating stops.
  42337. * @param breakFunction a break condition (optional)
  42338. * @param timeout timeout settings for the setTimeout function. default - 0.
  42339. * @returns the created async loop object
  42340. */
  42341. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  42342. }
  42343. }
  42344. declare module BABYLON {
  42345. /**
  42346. * This class implement a typical dictionary using a string as key and the generic type T as value.
  42347. * The underlying implementation relies on an associative array to ensure the best performances.
  42348. * The value can be anything including 'null' but except 'undefined'
  42349. */
  42350. export class StringDictionary<T> {
  42351. /**
  42352. * This will clear this dictionary and copy the content from the 'source' one.
  42353. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  42354. * @param source the dictionary to take the content from and copy to this dictionary
  42355. */
  42356. copyFrom(source: StringDictionary<T>): void;
  42357. /**
  42358. * Get a value based from its key
  42359. * @param key the given key to get the matching value from
  42360. * @return the value if found, otherwise undefined is returned
  42361. */
  42362. get(key: string): T | undefined;
  42363. /**
  42364. * Get a value from its key or add it if it doesn't exist.
  42365. * This method will ensure you that a given key/data will be present in the dictionary.
  42366. * @param key the given key to get the matching value from
  42367. * @param factory the factory that will create the value if the key is not present in the dictionary.
  42368. * The factory will only be invoked if there's no data for the given key.
  42369. * @return the value corresponding to the key.
  42370. */
  42371. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  42372. /**
  42373. * Get a value from its key if present in the dictionary otherwise add it
  42374. * @param key the key to get the value from
  42375. * @param val if there's no such key/value pair in the dictionary add it with this value
  42376. * @return the value corresponding to the key
  42377. */
  42378. getOrAdd(key: string, val: T): T;
  42379. /**
  42380. * Check if there's a given key in the dictionary
  42381. * @param key the key to check for
  42382. * @return true if the key is present, false otherwise
  42383. */
  42384. contains(key: string): boolean;
  42385. /**
  42386. * Add a new key and its corresponding value
  42387. * @param key the key to add
  42388. * @param value the value corresponding to the key
  42389. * @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
  42390. */
  42391. add(key: string, value: T): boolean;
  42392. /**
  42393. * Update a specific value associated to a key
  42394. * @param key defines the key to use
  42395. * @param value defines the value to store
  42396. * @returns true if the value was updated (or false if the key was not found)
  42397. */
  42398. set(key: string, value: T): boolean;
  42399. /**
  42400. * Get the element of the given key and remove it from the dictionary
  42401. * @param key defines the key to search
  42402. * @returns the value associated with the key or null if not found
  42403. */
  42404. getAndRemove(key: string): Nullable<T>;
  42405. /**
  42406. * Remove a key/value from the dictionary.
  42407. * @param key the key to remove
  42408. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  42409. */
  42410. remove(key: string): boolean;
  42411. /**
  42412. * Clear the whole content of the dictionary
  42413. */
  42414. clear(): void;
  42415. /**
  42416. * Gets the current count
  42417. */
  42418. get count(): number;
  42419. /**
  42420. * Execute a callback on each key/val of the dictionary.
  42421. * Note that you can remove any element in this dictionary in the callback implementation
  42422. * @param callback the callback to execute on a given key/value pair
  42423. */
  42424. forEach(callback: (key: string, val: T) => void): void;
  42425. /**
  42426. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  42427. * If the callback returns null or undefined the method will iterate to the next key/value pair
  42428. * Note that you can remove any element in this dictionary in the callback implementation
  42429. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  42430. * @returns the first item
  42431. */
  42432. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  42433. private _count;
  42434. private _data;
  42435. }
  42436. }
  42437. declare module BABYLON {
  42438. /** @hidden */
  42439. export interface ICollisionCoordinator {
  42440. createCollider(): Collider;
  42441. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  42442. init(scene: Scene): void;
  42443. }
  42444. /** @hidden */
  42445. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  42446. private _scene;
  42447. private _scaledPosition;
  42448. private _scaledVelocity;
  42449. private _finalPosition;
  42450. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  42451. createCollider(): Collider;
  42452. init(scene: Scene): void;
  42453. private _collideWithWorld;
  42454. }
  42455. }
  42456. declare module BABYLON {
  42457. /**
  42458. * Class used to manage all inputs for the scene.
  42459. */
  42460. export class InputManager {
  42461. /** The distance in pixel that you have to move to prevent some events */
  42462. static DragMovementThreshold: number;
  42463. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  42464. static LongPressDelay: number;
  42465. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  42466. static DoubleClickDelay: number;
  42467. /** If you need to check double click without raising a single click at first click, enable this flag */
  42468. static ExclusiveDoubleClickMode: boolean;
  42469. /** This is a defensive check to not allow control attachment prior to an already active one. If already attached, previous control is unattached before attaching the new one. */
  42470. private _alreadyAttached;
  42471. private _alreadyAttachedTo;
  42472. private _wheelEventName;
  42473. private _onPointerMove;
  42474. private _onPointerDown;
  42475. private _onPointerUp;
  42476. private _initClickEvent;
  42477. private _initActionManager;
  42478. private _delayedSimpleClick;
  42479. private _delayedSimpleClickTimeout;
  42480. private _previousDelayedSimpleClickTimeout;
  42481. private _meshPickProceed;
  42482. private _previousButtonPressed;
  42483. private _currentPickResult;
  42484. private _previousPickResult;
  42485. private _totalPointersPressed;
  42486. private _doubleClickOccured;
  42487. private _pointerOverMesh;
  42488. private _pickedDownMesh;
  42489. private _pickedUpMesh;
  42490. private _pointerX;
  42491. private _pointerY;
  42492. private _unTranslatedPointerX;
  42493. private _unTranslatedPointerY;
  42494. private _startingPointerPosition;
  42495. private _previousStartingPointerPosition;
  42496. private _startingPointerTime;
  42497. private _previousStartingPointerTime;
  42498. private _pointerCaptures;
  42499. private _meshUnderPointerId;
  42500. private _onKeyDown;
  42501. private _onKeyUp;
  42502. private _keyboardIsAttached;
  42503. private _onCanvasFocusObserver;
  42504. private _onCanvasBlurObserver;
  42505. private _scene;
  42506. /**
  42507. * Creates a new InputManager
  42508. * @param scene defines the hosting scene
  42509. */
  42510. constructor(scene: Scene);
  42511. /**
  42512. * Gets the mesh that is currently under the pointer
  42513. */
  42514. get meshUnderPointer(): Nullable<AbstractMesh>;
  42515. /**
  42516. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  42517. * @param pointerId the pointer id to use
  42518. * @returns The mesh under this pointer id or null if not found
  42519. */
  42520. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  42521. /**
  42522. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  42523. */
  42524. get unTranslatedPointer(): Vector2;
  42525. /**
  42526. * Gets or sets the current on-screen X position of the pointer
  42527. */
  42528. get pointerX(): number;
  42529. set pointerX(value: number);
  42530. /**
  42531. * Gets or sets the current on-screen Y position of the pointer
  42532. */
  42533. get pointerY(): number;
  42534. set pointerY(value: number);
  42535. private _updatePointerPosition;
  42536. private _processPointerMove;
  42537. private _setRayOnPointerInfo;
  42538. private _checkPrePointerObservable;
  42539. /**
  42540. * Use this method to simulate a pointer move on a mesh
  42541. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42542. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42543. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42544. */
  42545. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42546. /**
  42547. * Use this method to simulate a pointer down on a mesh
  42548. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42549. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42550. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42551. */
  42552. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42553. private _processPointerDown;
  42554. /** @hidden */
  42555. _isPointerSwiping(): boolean;
  42556. /**
  42557. * Use this method to simulate a pointer up on a mesh
  42558. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42559. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42560. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42561. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  42562. */
  42563. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  42564. private _processPointerUp;
  42565. /**
  42566. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  42567. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  42568. * @returns true if the pointer was captured
  42569. */
  42570. isPointerCaptured(pointerId?: number): boolean;
  42571. /**
  42572. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  42573. * @param attachUp defines if you want to attach events to pointerup
  42574. * @param attachDown defines if you want to attach events to pointerdown
  42575. * @param attachMove defines if you want to attach events to pointermove
  42576. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  42577. */
  42578. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  42579. /**
  42580. * Detaches all event handlers
  42581. */
  42582. detachControl(): void;
  42583. /**
  42584. * Force the value of meshUnderPointer
  42585. * @param mesh defines the mesh to use
  42586. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  42587. */
  42588. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  42589. /**
  42590. * Gets the mesh under the pointer
  42591. * @returns a Mesh or null if no mesh is under the pointer
  42592. */
  42593. getPointerOverMesh(): Nullable<AbstractMesh>;
  42594. }
  42595. }
  42596. declare module BABYLON {
  42597. /**
  42598. * This class defines the direct association between an animation and a target
  42599. */
  42600. export class TargetedAnimation {
  42601. /**
  42602. * Animation to perform
  42603. */
  42604. animation: Animation;
  42605. /**
  42606. * Target to animate
  42607. */
  42608. target: any;
  42609. /**
  42610. * Returns the string "TargetedAnimation"
  42611. * @returns "TargetedAnimation"
  42612. */
  42613. getClassName(): string;
  42614. /**
  42615. * Serialize the object
  42616. * @returns the JSON object representing the current entity
  42617. */
  42618. serialize(): any;
  42619. }
  42620. /**
  42621. * Use this class to create coordinated animations on multiple targets
  42622. */
  42623. export class AnimationGroup implements IDisposable {
  42624. /** The name of the animation group */
  42625. name: string;
  42626. private _scene;
  42627. private _targetedAnimations;
  42628. private _animatables;
  42629. private _from;
  42630. private _to;
  42631. private _isStarted;
  42632. private _isPaused;
  42633. private _speedRatio;
  42634. private _loopAnimation;
  42635. private _isAdditive;
  42636. /**
  42637. * Gets or sets the unique id of the node
  42638. */
  42639. uniqueId: number;
  42640. /**
  42641. * This observable will notify when one animation have ended
  42642. */
  42643. onAnimationEndObservable: Observable<TargetedAnimation>;
  42644. /**
  42645. * Observer raised when one animation loops
  42646. */
  42647. onAnimationLoopObservable: Observable<TargetedAnimation>;
  42648. /**
  42649. * Observer raised when all animations have looped
  42650. */
  42651. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  42652. /**
  42653. * This observable will notify when all animations have ended.
  42654. */
  42655. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  42656. /**
  42657. * This observable will notify when all animations have paused.
  42658. */
  42659. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  42660. /**
  42661. * This observable will notify when all animations are playing.
  42662. */
  42663. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  42664. /**
  42665. * Gets the first frame
  42666. */
  42667. get from(): number;
  42668. /**
  42669. * Gets the last frame
  42670. */
  42671. get to(): number;
  42672. /**
  42673. * Define if the animations are started
  42674. */
  42675. get isStarted(): boolean;
  42676. /**
  42677. * Gets a value indicating that the current group is playing
  42678. */
  42679. get isPlaying(): boolean;
  42680. /**
  42681. * Gets or sets the speed ratio to use for all animations
  42682. */
  42683. get speedRatio(): number;
  42684. /**
  42685. * Gets or sets the speed ratio to use for all animations
  42686. */
  42687. set speedRatio(value: number);
  42688. /**
  42689. * Gets or sets if all animations should loop or not
  42690. */
  42691. get loopAnimation(): boolean;
  42692. set loopAnimation(value: boolean);
  42693. /**
  42694. * Gets or sets if all animations should be evaluated additively
  42695. */
  42696. get isAdditive(): boolean;
  42697. set isAdditive(value: boolean);
  42698. /**
  42699. * Gets the targeted animations for this animation group
  42700. */
  42701. get targetedAnimations(): Array<TargetedAnimation>;
  42702. /**
  42703. * returning the list of animatables controlled by this animation group.
  42704. */
  42705. get animatables(): Array<Animatable>;
  42706. /**
  42707. * Gets the list of target animations
  42708. */
  42709. get children(): TargetedAnimation[];
  42710. /**
  42711. * Instantiates a new Animation Group.
  42712. * This helps managing several animations at once.
  42713. * @see https://doc.babylonjs.com/how_to/group
  42714. * @param name Defines the name of the group
  42715. * @param scene Defines the scene the group belongs to
  42716. */
  42717. constructor(
  42718. /** The name of the animation group */
  42719. name: string, scene?: Nullable<Scene>);
  42720. /**
  42721. * Add an animation (with its target) in the group
  42722. * @param animation defines the animation we want to add
  42723. * @param target defines the target of the animation
  42724. * @returns the TargetedAnimation object
  42725. */
  42726. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  42727. /**
  42728. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  42729. * It can add constant keys at begin or end
  42730. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  42731. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  42732. * @returns the animation group
  42733. */
  42734. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  42735. private _animationLoopCount;
  42736. private _animationLoopFlags;
  42737. private _processLoop;
  42738. /**
  42739. * Start all animations on given targets
  42740. * @param loop defines if animations must loop
  42741. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  42742. * @param from defines the from key (optional)
  42743. * @param to defines the to key (optional)
  42744. * @param isAdditive defines the additive state for the resulting animatables (optional)
  42745. * @returns the current animation group
  42746. */
  42747. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  42748. /**
  42749. * Pause all animations
  42750. * @returns the animation group
  42751. */
  42752. pause(): AnimationGroup;
  42753. /**
  42754. * Play all animations to initial state
  42755. * This function will start() the animations if they were not started or will restart() them if they were paused
  42756. * @param loop defines if animations must loop
  42757. * @returns the animation group
  42758. */
  42759. play(loop?: boolean): AnimationGroup;
  42760. /**
  42761. * Reset all animations to initial state
  42762. * @returns the animation group
  42763. */
  42764. reset(): AnimationGroup;
  42765. /**
  42766. * Restart animations from key 0
  42767. * @returns the animation group
  42768. */
  42769. restart(): AnimationGroup;
  42770. /**
  42771. * Stop all animations
  42772. * @returns the animation group
  42773. */
  42774. stop(): AnimationGroup;
  42775. /**
  42776. * Set animation weight for all animatables
  42777. * @param weight defines the weight to use
  42778. * @return the animationGroup
  42779. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42780. */
  42781. setWeightForAllAnimatables(weight: number): AnimationGroup;
  42782. /**
  42783. * Synchronize and normalize all animatables with a source animatable
  42784. * @param root defines the root animatable to synchronize with
  42785. * @return the animationGroup
  42786. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42787. */
  42788. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  42789. /**
  42790. * Goes to a specific frame in this animation group
  42791. * @param frame the frame number to go to
  42792. * @return the animationGroup
  42793. */
  42794. goToFrame(frame: number): AnimationGroup;
  42795. /**
  42796. * Dispose all associated resources
  42797. */
  42798. dispose(): void;
  42799. private _checkAnimationGroupEnded;
  42800. /**
  42801. * Clone the current animation group and returns a copy
  42802. * @param newName defines the name of the new group
  42803. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  42804. * @returns the new aniamtion group
  42805. */
  42806. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  42807. /**
  42808. * Serializes the animationGroup to an object
  42809. * @returns Serialized object
  42810. */
  42811. serialize(): any;
  42812. /**
  42813. * Returns a new AnimationGroup object parsed from the source provided.
  42814. * @param parsedAnimationGroup defines the source
  42815. * @param scene defines the scene that will receive the animationGroup
  42816. * @returns a new AnimationGroup
  42817. */
  42818. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  42819. /**
  42820. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  42821. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  42822. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  42823. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  42824. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  42825. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  42826. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  42827. */
  42828. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  42829. /**
  42830. * Returns the string "AnimationGroup"
  42831. * @returns "AnimationGroup"
  42832. */
  42833. getClassName(): string;
  42834. /**
  42835. * Creates a detailled string about the object
  42836. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  42837. * @returns a string representing the object
  42838. */
  42839. toString(fullDetails?: boolean): string;
  42840. }
  42841. }
  42842. declare module BABYLON {
  42843. /**
  42844. * Define an interface for all classes that will hold resources
  42845. */
  42846. export interface IDisposable {
  42847. /**
  42848. * Releases all held resources
  42849. */
  42850. dispose(): void;
  42851. }
  42852. /** Interface defining initialization parameters for Scene class */
  42853. export interface SceneOptions {
  42854. /**
  42855. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  42856. * It will improve performance when the number of geometries becomes important.
  42857. */
  42858. useGeometryUniqueIdsMap?: boolean;
  42859. /**
  42860. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  42861. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42862. */
  42863. useMaterialMeshMap?: boolean;
  42864. /**
  42865. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  42866. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42867. */
  42868. useClonedMeshMap?: boolean;
  42869. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  42870. virtual?: boolean;
  42871. }
  42872. /**
  42873. * Represents a scene to be rendered by the engine.
  42874. * @see https://doc.babylonjs.com/features/scene
  42875. */
  42876. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  42877. /** The fog is deactivated */
  42878. static readonly FOGMODE_NONE: number;
  42879. /** The fog density is following an exponential function */
  42880. static readonly FOGMODE_EXP: number;
  42881. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  42882. static readonly FOGMODE_EXP2: number;
  42883. /** The fog density is following a linear function. */
  42884. static readonly FOGMODE_LINEAR: number;
  42885. /**
  42886. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  42887. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42888. */
  42889. static MinDeltaTime: number;
  42890. /**
  42891. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  42892. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42893. */
  42894. static MaxDeltaTime: number;
  42895. /**
  42896. * Factory used to create the default material.
  42897. * @param name The name of the material to create
  42898. * @param scene The scene to create the material for
  42899. * @returns The default material
  42900. */
  42901. static DefaultMaterialFactory(scene: Scene): Material;
  42902. /**
  42903. * Factory used to create the a collision coordinator.
  42904. * @returns The collision coordinator
  42905. */
  42906. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  42907. /** @hidden */
  42908. _inputManager: InputManager;
  42909. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  42910. cameraToUseForPointers: Nullable<Camera>;
  42911. /** @hidden */
  42912. readonly _isScene: boolean;
  42913. /** @hidden */
  42914. _blockEntityCollection: boolean;
  42915. /**
  42916. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  42917. */
  42918. autoClear: boolean;
  42919. /**
  42920. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  42921. */
  42922. autoClearDepthAndStencil: boolean;
  42923. /**
  42924. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  42925. */
  42926. clearColor: Color4;
  42927. /**
  42928. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  42929. */
  42930. ambientColor: Color3;
  42931. /**
  42932. * This is use to store the default BRDF lookup for PBR materials in your scene.
  42933. * It should only be one of the following (if not the default embedded one):
  42934. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  42935. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  42936. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  42937. * The material properties need to be setup according to the type of texture in use.
  42938. */
  42939. environmentBRDFTexture: BaseTexture;
  42940. /**
  42941. * Texture used in all pbr material as the reflection texture.
  42942. * As in the majority of the scene they are the same (exception for multi room and so on),
  42943. * this is easier to reference from here than from all the materials.
  42944. */
  42945. get environmentTexture(): Nullable<BaseTexture>;
  42946. /**
  42947. * Texture used in all pbr material as the reflection texture.
  42948. * As in the majority of the scene they are the same (exception for multi room and so on),
  42949. * this is easier to set here than in all the materials.
  42950. */
  42951. set environmentTexture(value: Nullable<BaseTexture>);
  42952. /** @hidden */
  42953. protected _environmentIntensity: number;
  42954. /**
  42955. * Intensity of the environment in all pbr material.
  42956. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42957. * As in the majority of the scene they are the same (exception for multi room and so on),
  42958. * this is easier to reference from here than from all the materials.
  42959. */
  42960. get environmentIntensity(): number;
  42961. /**
  42962. * Intensity of the environment in all pbr material.
  42963. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42964. * As in the majority of the scene they are the same (exception for multi room and so on),
  42965. * this is easier to set here than in all the materials.
  42966. */
  42967. set environmentIntensity(value: number);
  42968. /** @hidden */
  42969. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42970. /**
  42971. * Default image processing configuration used either in the rendering
  42972. * Forward main pass or through the imageProcessingPostProcess if present.
  42973. * As in the majority of the scene they are the same (exception for multi camera),
  42974. * this is easier to reference from here than from all the materials and post process.
  42975. *
  42976. * No setter as we it is a shared configuration, you can set the values instead.
  42977. */
  42978. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42979. private _forceWireframe;
  42980. /**
  42981. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  42982. */
  42983. set forceWireframe(value: boolean);
  42984. get forceWireframe(): boolean;
  42985. private _skipFrustumClipping;
  42986. /**
  42987. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  42988. */
  42989. set skipFrustumClipping(value: boolean);
  42990. get skipFrustumClipping(): boolean;
  42991. private _forcePointsCloud;
  42992. /**
  42993. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  42994. */
  42995. set forcePointsCloud(value: boolean);
  42996. get forcePointsCloud(): boolean;
  42997. /**
  42998. * Gets or sets the active clipplane 1
  42999. */
  43000. clipPlane: Nullable<Plane>;
  43001. /**
  43002. * Gets or sets the active clipplane 2
  43003. */
  43004. clipPlane2: Nullable<Plane>;
  43005. /**
  43006. * Gets or sets the active clipplane 3
  43007. */
  43008. clipPlane3: Nullable<Plane>;
  43009. /**
  43010. * Gets or sets the active clipplane 4
  43011. */
  43012. clipPlane4: Nullable<Plane>;
  43013. /**
  43014. * Gets or sets the active clipplane 5
  43015. */
  43016. clipPlane5: Nullable<Plane>;
  43017. /**
  43018. * Gets or sets the active clipplane 6
  43019. */
  43020. clipPlane6: Nullable<Plane>;
  43021. /**
  43022. * Gets or sets a boolean indicating if animations are enabled
  43023. */
  43024. animationsEnabled: boolean;
  43025. private _animationPropertiesOverride;
  43026. /**
  43027. * Gets or sets the animation properties override
  43028. */
  43029. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  43030. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  43031. /**
  43032. * Gets or sets a boolean indicating if a constant deltatime has to be used
  43033. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  43034. */
  43035. useConstantAnimationDeltaTime: boolean;
  43036. /**
  43037. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  43038. * Please note that it requires to run a ray cast through the scene on every frame
  43039. */
  43040. constantlyUpdateMeshUnderPointer: boolean;
  43041. /**
  43042. * Defines the HTML cursor to use when hovering over interactive elements
  43043. */
  43044. hoverCursor: string;
  43045. /**
  43046. * Defines the HTML default cursor to use (empty by default)
  43047. */
  43048. defaultCursor: string;
  43049. /**
  43050. * Defines whether cursors are handled by the scene.
  43051. */
  43052. doNotHandleCursors: boolean;
  43053. /**
  43054. * This is used to call preventDefault() on pointer down
  43055. * in order to block unwanted artifacts like system double clicks
  43056. */
  43057. preventDefaultOnPointerDown: boolean;
  43058. /**
  43059. * This is used to call preventDefault() on pointer up
  43060. * in order to block unwanted artifacts like system double clicks
  43061. */
  43062. preventDefaultOnPointerUp: boolean;
  43063. /**
  43064. * Gets or sets user defined metadata
  43065. */
  43066. metadata: any;
  43067. /**
  43068. * For internal use only. Please do not use.
  43069. */
  43070. reservedDataStore: any;
  43071. /**
  43072. * Gets the name of the plugin used to load this scene (null by default)
  43073. */
  43074. loadingPluginName: string;
  43075. /**
  43076. * Use this array to add regular expressions used to disable offline support for specific urls
  43077. */
  43078. disableOfflineSupportExceptionRules: RegExp[];
  43079. /**
  43080. * An event triggered when the scene is disposed.
  43081. */
  43082. onDisposeObservable: Observable<Scene>;
  43083. private _onDisposeObserver;
  43084. /** Sets a function to be executed when this scene is disposed. */
  43085. set onDispose(callback: () => void);
  43086. /**
  43087. * An event triggered before rendering the scene (right after animations and physics)
  43088. */
  43089. onBeforeRenderObservable: Observable<Scene>;
  43090. private _onBeforeRenderObserver;
  43091. /** Sets a function to be executed before rendering this scene */
  43092. set beforeRender(callback: Nullable<() => void>);
  43093. /**
  43094. * An event triggered after rendering the scene
  43095. */
  43096. onAfterRenderObservable: Observable<Scene>;
  43097. /**
  43098. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  43099. */
  43100. onAfterRenderCameraObservable: Observable<Camera>;
  43101. private _onAfterRenderObserver;
  43102. /** Sets a function to be executed after rendering this scene */
  43103. set afterRender(callback: Nullable<() => void>);
  43104. /**
  43105. * An event triggered before animating the scene
  43106. */
  43107. onBeforeAnimationsObservable: Observable<Scene>;
  43108. /**
  43109. * An event triggered after animations processing
  43110. */
  43111. onAfterAnimationsObservable: Observable<Scene>;
  43112. /**
  43113. * An event triggered before draw calls are ready to be sent
  43114. */
  43115. onBeforeDrawPhaseObservable: Observable<Scene>;
  43116. /**
  43117. * An event triggered after draw calls have been sent
  43118. */
  43119. onAfterDrawPhaseObservable: Observable<Scene>;
  43120. /**
  43121. * An event triggered when the scene is ready
  43122. */
  43123. onReadyObservable: Observable<Scene>;
  43124. /**
  43125. * An event triggered before rendering a camera
  43126. */
  43127. onBeforeCameraRenderObservable: Observable<Camera>;
  43128. private _onBeforeCameraRenderObserver;
  43129. /** Sets a function to be executed before rendering a camera*/
  43130. set beforeCameraRender(callback: () => void);
  43131. /**
  43132. * An event triggered after rendering a camera
  43133. */
  43134. onAfterCameraRenderObservable: Observable<Camera>;
  43135. private _onAfterCameraRenderObserver;
  43136. /** Sets a function to be executed after rendering a camera*/
  43137. set afterCameraRender(callback: () => void);
  43138. /**
  43139. * An event triggered when active meshes evaluation is about to start
  43140. */
  43141. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  43142. /**
  43143. * An event triggered when active meshes evaluation is done
  43144. */
  43145. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  43146. /**
  43147. * An event triggered when particles rendering is about to start
  43148. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  43149. */
  43150. onBeforeParticlesRenderingObservable: Observable<Scene>;
  43151. /**
  43152. * An event triggered when particles rendering is done
  43153. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  43154. */
  43155. onAfterParticlesRenderingObservable: Observable<Scene>;
  43156. /**
  43157. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  43158. */
  43159. onDataLoadedObservable: Observable<Scene>;
  43160. /**
  43161. * An event triggered when a camera is created
  43162. */
  43163. onNewCameraAddedObservable: Observable<Camera>;
  43164. /**
  43165. * An event triggered when a camera is removed
  43166. */
  43167. onCameraRemovedObservable: Observable<Camera>;
  43168. /**
  43169. * An event triggered when a light is created
  43170. */
  43171. onNewLightAddedObservable: Observable<Light>;
  43172. /**
  43173. * An event triggered when a light is removed
  43174. */
  43175. onLightRemovedObservable: Observable<Light>;
  43176. /**
  43177. * An event triggered when a geometry is created
  43178. */
  43179. onNewGeometryAddedObservable: Observable<Geometry>;
  43180. /**
  43181. * An event triggered when a geometry is removed
  43182. */
  43183. onGeometryRemovedObservable: Observable<Geometry>;
  43184. /**
  43185. * An event triggered when a transform node is created
  43186. */
  43187. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  43188. /**
  43189. * An event triggered when a transform node is removed
  43190. */
  43191. onTransformNodeRemovedObservable: Observable<TransformNode>;
  43192. /**
  43193. * An event triggered when a mesh is created
  43194. */
  43195. onNewMeshAddedObservable: Observable<AbstractMesh>;
  43196. /**
  43197. * An event triggered when a mesh is removed
  43198. */
  43199. onMeshRemovedObservable: Observable<AbstractMesh>;
  43200. /**
  43201. * An event triggered when a skeleton is created
  43202. */
  43203. onNewSkeletonAddedObservable: Observable<Skeleton>;
  43204. /**
  43205. * An event triggered when a skeleton is removed
  43206. */
  43207. onSkeletonRemovedObservable: Observable<Skeleton>;
  43208. /**
  43209. * An event triggered when a material is created
  43210. */
  43211. onNewMaterialAddedObservable: Observable<Material>;
  43212. /**
  43213. * An event triggered when a multi material is created
  43214. */
  43215. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  43216. /**
  43217. * An event triggered when a material is removed
  43218. */
  43219. onMaterialRemovedObservable: Observable<Material>;
  43220. /**
  43221. * An event triggered when a multi material is removed
  43222. */
  43223. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  43224. /**
  43225. * An event triggered when a texture is created
  43226. */
  43227. onNewTextureAddedObservable: Observable<BaseTexture>;
  43228. /**
  43229. * An event triggered when a texture is removed
  43230. */
  43231. onTextureRemovedObservable: Observable<BaseTexture>;
  43232. /**
  43233. * An event triggered when render targets are about to be rendered
  43234. * Can happen multiple times per frame.
  43235. */
  43236. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  43237. /**
  43238. * An event triggered when render targets were rendered.
  43239. * Can happen multiple times per frame.
  43240. */
  43241. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  43242. /**
  43243. * An event triggered before calculating deterministic simulation step
  43244. */
  43245. onBeforeStepObservable: Observable<Scene>;
  43246. /**
  43247. * An event triggered after calculating deterministic simulation step
  43248. */
  43249. onAfterStepObservable: Observable<Scene>;
  43250. /**
  43251. * An event triggered when the activeCamera property is updated
  43252. */
  43253. onActiveCameraChanged: Observable<Scene>;
  43254. /**
  43255. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  43256. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  43257. * 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)
  43258. */
  43259. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  43260. /**
  43261. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  43262. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  43263. * 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)
  43264. */
  43265. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  43266. /**
  43267. * This Observable will when a mesh has been imported into the scene.
  43268. */
  43269. onMeshImportedObservable: Observable<AbstractMesh>;
  43270. /**
  43271. * This Observable will when an animation file has been imported into the scene.
  43272. */
  43273. onAnimationFileImportedObservable: Observable<Scene>;
  43274. /**
  43275. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  43276. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  43277. */
  43278. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  43279. /** @hidden */
  43280. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  43281. /**
  43282. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  43283. */
  43284. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  43285. /**
  43286. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  43287. */
  43288. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  43289. /**
  43290. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  43291. */
  43292. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  43293. /** Callback called when a pointer move is detected */
  43294. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  43295. /** Callback called when a pointer down is detected */
  43296. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  43297. /** Callback called when a pointer up is detected */
  43298. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  43299. /** Callback called when a pointer pick is detected */
  43300. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  43301. /**
  43302. * 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).
  43303. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  43304. */
  43305. onPrePointerObservable: Observable<PointerInfoPre>;
  43306. /**
  43307. * Observable event triggered each time an input event is received from the rendering canvas
  43308. */
  43309. onPointerObservable: Observable<PointerInfo>;
  43310. /**
  43311. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  43312. */
  43313. get unTranslatedPointer(): Vector2;
  43314. /**
  43315. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  43316. */
  43317. static get DragMovementThreshold(): number;
  43318. static set DragMovementThreshold(value: number);
  43319. /**
  43320. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  43321. */
  43322. static get LongPressDelay(): number;
  43323. static set LongPressDelay(value: number);
  43324. /**
  43325. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  43326. */
  43327. static get DoubleClickDelay(): number;
  43328. static set DoubleClickDelay(value: number);
  43329. /** If you need to check double click without raising a single click at first click, enable this flag */
  43330. static get ExclusiveDoubleClickMode(): boolean;
  43331. static set ExclusiveDoubleClickMode(value: boolean);
  43332. /** @hidden */
  43333. _mirroredCameraPosition: Nullable<Vector3>;
  43334. /**
  43335. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  43336. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  43337. */
  43338. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  43339. /**
  43340. * Observable event triggered each time an keyboard event is received from the hosting window
  43341. */
  43342. onKeyboardObservable: Observable<KeyboardInfo>;
  43343. private _useRightHandedSystem;
  43344. /**
  43345. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  43346. */
  43347. set useRightHandedSystem(value: boolean);
  43348. get useRightHandedSystem(): boolean;
  43349. private _timeAccumulator;
  43350. private _currentStepId;
  43351. private _currentInternalStep;
  43352. /**
  43353. * Sets the step Id used by deterministic lock step
  43354. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43355. * @param newStepId defines the step Id
  43356. */
  43357. setStepId(newStepId: number): void;
  43358. /**
  43359. * Gets the step Id used by deterministic lock step
  43360. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43361. * @returns the step Id
  43362. */
  43363. getStepId(): number;
  43364. /**
  43365. * Gets the internal step used by deterministic lock step
  43366. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43367. * @returns the internal step
  43368. */
  43369. getInternalStep(): number;
  43370. private _fogEnabled;
  43371. /**
  43372. * Gets or sets a boolean indicating if fog is enabled on this scene
  43373. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43374. * (Default is true)
  43375. */
  43376. set fogEnabled(value: boolean);
  43377. get fogEnabled(): boolean;
  43378. private _fogMode;
  43379. /**
  43380. * Gets or sets the fog mode to use
  43381. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43382. * | mode | value |
  43383. * | --- | --- |
  43384. * | FOGMODE_NONE | 0 |
  43385. * | FOGMODE_EXP | 1 |
  43386. * | FOGMODE_EXP2 | 2 |
  43387. * | FOGMODE_LINEAR | 3 |
  43388. */
  43389. set fogMode(value: number);
  43390. get fogMode(): number;
  43391. /**
  43392. * Gets or sets the fog color to use
  43393. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43394. * (Default is Color3(0.2, 0.2, 0.3))
  43395. */
  43396. fogColor: Color3;
  43397. /**
  43398. * Gets or sets the fog density to use
  43399. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43400. * (Default is 0.1)
  43401. */
  43402. fogDensity: number;
  43403. /**
  43404. * Gets or sets the fog start distance to use
  43405. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43406. * (Default is 0)
  43407. */
  43408. fogStart: number;
  43409. /**
  43410. * Gets or sets the fog end distance to use
  43411. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43412. * (Default is 1000)
  43413. */
  43414. fogEnd: number;
  43415. /**
  43416. * Flag indicating that the frame buffer binding is handled by another component
  43417. */
  43418. prePass: boolean;
  43419. private _shadowsEnabled;
  43420. /**
  43421. * Gets or sets a boolean indicating if shadows are enabled on this scene
  43422. */
  43423. set shadowsEnabled(value: boolean);
  43424. get shadowsEnabled(): boolean;
  43425. private _lightsEnabled;
  43426. /**
  43427. * Gets or sets a boolean indicating if lights are enabled on this scene
  43428. */
  43429. set lightsEnabled(value: boolean);
  43430. get lightsEnabled(): boolean;
  43431. /** All of the active cameras added to this scene. */
  43432. activeCameras: Camera[];
  43433. /** @hidden */
  43434. _activeCamera: Nullable<Camera>;
  43435. /** Gets or sets the current active camera */
  43436. get activeCamera(): Nullable<Camera>;
  43437. set activeCamera(value: Nullable<Camera>);
  43438. private _defaultMaterial;
  43439. /** The default material used on meshes when no material is affected */
  43440. get defaultMaterial(): Material;
  43441. /** The default material used on meshes when no material is affected */
  43442. set defaultMaterial(value: Material);
  43443. private _texturesEnabled;
  43444. /**
  43445. * Gets or sets a boolean indicating if textures are enabled on this scene
  43446. */
  43447. set texturesEnabled(value: boolean);
  43448. get texturesEnabled(): boolean;
  43449. /**
  43450. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  43451. */
  43452. physicsEnabled: boolean;
  43453. /**
  43454. * Gets or sets a boolean indicating if particles are enabled on this scene
  43455. */
  43456. particlesEnabled: boolean;
  43457. /**
  43458. * Gets or sets a boolean indicating if sprites are enabled on this scene
  43459. */
  43460. spritesEnabled: boolean;
  43461. private _skeletonsEnabled;
  43462. /**
  43463. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  43464. */
  43465. set skeletonsEnabled(value: boolean);
  43466. get skeletonsEnabled(): boolean;
  43467. /**
  43468. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  43469. */
  43470. lensFlaresEnabled: boolean;
  43471. /**
  43472. * Gets or sets a boolean indicating if collisions are enabled on this scene
  43473. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  43474. */
  43475. collisionsEnabled: boolean;
  43476. private _collisionCoordinator;
  43477. /** @hidden */
  43478. get collisionCoordinator(): ICollisionCoordinator;
  43479. /**
  43480. * Defines the gravity applied to this scene (used only for collisions)
  43481. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  43482. */
  43483. gravity: Vector3;
  43484. /**
  43485. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  43486. */
  43487. postProcessesEnabled: boolean;
  43488. /**
  43489. * Gets the current postprocess manager
  43490. */
  43491. postProcessManager: PostProcessManager;
  43492. /**
  43493. * Gets or sets a boolean indicating if render targets are enabled on this scene
  43494. */
  43495. renderTargetsEnabled: boolean;
  43496. /**
  43497. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  43498. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  43499. */
  43500. dumpNextRenderTargets: boolean;
  43501. /**
  43502. * The list of user defined render targets added to the scene
  43503. */
  43504. customRenderTargets: RenderTargetTexture[];
  43505. /**
  43506. * Defines if texture loading must be delayed
  43507. * If true, textures will only be loaded when they need to be rendered
  43508. */
  43509. useDelayedTextureLoading: boolean;
  43510. /**
  43511. * Gets the list of meshes imported to the scene through SceneLoader
  43512. */
  43513. importedMeshesFiles: String[];
  43514. /**
  43515. * Gets or sets a boolean indicating if probes are enabled on this scene
  43516. */
  43517. probesEnabled: boolean;
  43518. /**
  43519. * Gets or sets the current offline provider to use to store scene data
  43520. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  43521. */
  43522. offlineProvider: IOfflineProvider;
  43523. /**
  43524. * Gets or sets the action manager associated with the scene
  43525. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43526. */
  43527. actionManager: AbstractActionManager;
  43528. private _meshesForIntersections;
  43529. /**
  43530. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  43531. */
  43532. proceduralTexturesEnabled: boolean;
  43533. private _engine;
  43534. private _totalVertices;
  43535. /** @hidden */
  43536. _activeIndices: PerfCounter;
  43537. /** @hidden */
  43538. _activeParticles: PerfCounter;
  43539. /** @hidden */
  43540. _activeBones: PerfCounter;
  43541. private _animationRatio;
  43542. /** @hidden */
  43543. _animationTimeLast: number;
  43544. /** @hidden */
  43545. _animationTime: number;
  43546. /**
  43547. * Gets or sets a general scale for animation speed
  43548. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  43549. */
  43550. animationTimeScale: number;
  43551. /** @hidden */
  43552. _cachedMaterial: Nullable<Material>;
  43553. /** @hidden */
  43554. _cachedEffect: Nullable<Effect>;
  43555. /** @hidden */
  43556. _cachedVisibility: Nullable<number>;
  43557. private _renderId;
  43558. private _frameId;
  43559. private _executeWhenReadyTimeoutId;
  43560. private _intermediateRendering;
  43561. private _viewUpdateFlag;
  43562. private _projectionUpdateFlag;
  43563. /** @hidden */
  43564. _toBeDisposed: Nullable<IDisposable>[];
  43565. private _activeRequests;
  43566. /** @hidden */
  43567. _pendingData: any[];
  43568. private _isDisposed;
  43569. /**
  43570. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  43571. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  43572. */
  43573. dispatchAllSubMeshesOfActiveMeshes: boolean;
  43574. private _activeMeshes;
  43575. private _processedMaterials;
  43576. private _renderTargets;
  43577. /** @hidden */
  43578. _activeParticleSystems: SmartArray<IParticleSystem>;
  43579. private _activeSkeletons;
  43580. private _softwareSkinnedMeshes;
  43581. private _renderingManager;
  43582. /** @hidden */
  43583. _activeAnimatables: Animatable[];
  43584. private _transformMatrix;
  43585. private _sceneUbo;
  43586. /** @hidden */
  43587. _viewMatrix: Matrix;
  43588. private _projectionMatrix;
  43589. /** @hidden */
  43590. _forcedViewPosition: Nullable<Vector3>;
  43591. /** @hidden */
  43592. _frustumPlanes: Plane[];
  43593. /**
  43594. * Gets the list of frustum planes (built from the active camera)
  43595. */
  43596. get frustumPlanes(): Plane[];
  43597. /**
  43598. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  43599. * This is useful if there are more lights that the maximum simulteanous authorized
  43600. */
  43601. requireLightSorting: boolean;
  43602. /** @hidden */
  43603. readonly useMaterialMeshMap: boolean;
  43604. /** @hidden */
  43605. readonly useClonedMeshMap: boolean;
  43606. private _externalData;
  43607. private _uid;
  43608. /**
  43609. * @hidden
  43610. * Backing store of defined scene components.
  43611. */
  43612. _components: ISceneComponent[];
  43613. /**
  43614. * @hidden
  43615. * Backing store of defined scene components.
  43616. */
  43617. _serializableComponents: ISceneSerializableComponent[];
  43618. /**
  43619. * List of components to register on the next registration step.
  43620. */
  43621. private _transientComponents;
  43622. /**
  43623. * Registers the transient components if needed.
  43624. */
  43625. private _registerTransientComponents;
  43626. /**
  43627. * @hidden
  43628. * Add a component to the scene.
  43629. * Note that the ccomponent could be registered on th next frame if this is called after
  43630. * the register component stage.
  43631. * @param component Defines the component to add to the scene
  43632. */
  43633. _addComponent(component: ISceneComponent): void;
  43634. /**
  43635. * @hidden
  43636. * Gets a component from the scene.
  43637. * @param name defines the name of the component to retrieve
  43638. * @returns the component or null if not present
  43639. */
  43640. _getComponent(name: string): Nullable<ISceneComponent>;
  43641. /**
  43642. * @hidden
  43643. * Defines the actions happening before camera updates.
  43644. */
  43645. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  43646. /**
  43647. * @hidden
  43648. * Defines the actions happening before clear the canvas.
  43649. */
  43650. _beforeClearStage: Stage<SimpleStageAction>;
  43651. /**
  43652. * @hidden
  43653. * Defines the actions when collecting render targets for the frame.
  43654. */
  43655. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43656. /**
  43657. * @hidden
  43658. * Defines the actions happening for one camera in the frame.
  43659. */
  43660. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43661. /**
  43662. * @hidden
  43663. * Defines the actions happening during the per mesh ready checks.
  43664. */
  43665. _isReadyForMeshStage: Stage<MeshStageAction>;
  43666. /**
  43667. * @hidden
  43668. * Defines the actions happening before evaluate active mesh checks.
  43669. */
  43670. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  43671. /**
  43672. * @hidden
  43673. * Defines the actions happening during the evaluate sub mesh checks.
  43674. */
  43675. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  43676. /**
  43677. * @hidden
  43678. * Defines the actions happening during the active mesh stage.
  43679. */
  43680. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  43681. /**
  43682. * @hidden
  43683. * Defines the actions happening during the per camera render target step.
  43684. */
  43685. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  43686. /**
  43687. * @hidden
  43688. * Defines the actions happening just before the active camera is drawing.
  43689. */
  43690. _beforeCameraDrawStage: Stage<CameraStageAction>;
  43691. /**
  43692. * @hidden
  43693. * Defines the actions happening just before a render target is drawing.
  43694. */
  43695. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43696. /**
  43697. * @hidden
  43698. * Defines the actions happening just before a rendering group is drawing.
  43699. */
  43700. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43701. /**
  43702. * @hidden
  43703. * Defines the actions happening just before a mesh is drawing.
  43704. */
  43705. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43706. /**
  43707. * @hidden
  43708. * Defines the actions happening just after a mesh has been drawn.
  43709. */
  43710. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43711. /**
  43712. * @hidden
  43713. * Defines the actions happening just after a rendering group has been drawn.
  43714. */
  43715. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43716. /**
  43717. * @hidden
  43718. * Defines the actions happening just after the active camera has been drawn.
  43719. */
  43720. _afterCameraDrawStage: Stage<CameraStageAction>;
  43721. /**
  43722. * @hidden
  43723. * Defines the actions happening just after a render target has been drawn.
  43724. */
  43725. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43726. /**
  43727. * @hidden
  43728. * Defines the actions happening just after rendering all cameras and computing intersections.
  43729. */
  43730. _afterRenderStage: Stage<SimpleStageAction>;
  43731. /**
  43732. * @hidden
  43733. * Defines the actions happening when a pointer move event happens.
  43734. */
  43735. _pointerMoveStage: Stage<PointerMoveStageAction>;
  43736. /**
  43737. * @hidden
  43738. * Defines the actions happening when a pointer down event happens.
  43739. */
  43740. _pointerDownStage: Stage<PointerUpDownStageAction>;
  43741. /**
  43742. * @hidden
  43743. * Defines the actions happening when a pointer up event happens.
  43744. */
  43745. _pointerUpStage: Stage<PointerUpDownStageAction>;
  43746. /**
  43747. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  43748. */
  43749. private geometriesByUniqueId;
  43750. /**
  43751. * Creates a new Scene
  43752. * @param engine defines the engine to use to render this scene
  43753. * @param options defines the scene options
  43754. */
  43755. constructor(engine: Engine, options?: SceneOptions);
  43756. /**
  43757. * Gets a string identifying the name of the class
  43758. * @returns "Scene" string
  43759. */
  43760. getClassName(): string;
  43761. private _defaultMeshCandidates;
  43762. /**
  43763. * @hidden
  43764. */
  43765. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43766. private _defaultSubMeshCandidates;
  43767. /**
  43768. * @hidden
  43769. */
  43770. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43771. /**
  43772. * Sets the default candidate providers for the scene.
  43773. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  43774. * and getCollidingSubMeshCandidates to their default function
  43775. */
  43776. setDefaultCandidateProviders(): void;
  43777. /**
  43778. * Gets the mesh that is currently under the pointer
  43779. */
  43780. get meshUnderPointer(): Nullable<AbstractMesh>;
  43781. /**
  43782. * Gets or sets the current on-screen X position of the pointer
  43783. */
  43784. get pointerX(): number;
  43785. set pointerX(value: number);
  43786. /**
  43787. * Gets or sets the current on-screen Y position of the pointer
  43788. */
  43789. get pointerY(): number;
  43790. set pointerY(value: number);
  43791. /**
  43792. * Gets the cached material (ie. the latest rendered one)
  43793. * @returns the cached material
  43794. */
  43795. getCachedMaterial(): Nullable<Material>;
  43796. /**
  43797. * Gets the cached effect (ie. the latest rendered one)
  43798. * @returns the cached effect
  43799. */
  43800. getCachedEffect(): Nullable<Effect>;
  43801. /**
  43802. * Gets the cached visibility state (ie. the latest rendered one)
  43803. * @returns the cached visibility state
  43804. */
  43805. getCachedVisibility(): Nullable<number>;
  43806. /**
  43807. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  43808. * @param material defines the current material
  43809. * @param effect defines the current effect
  43810. * @param visibility defines the current visibility state
  43811. * @returns true if one parameter is not cached
  43812. */
  43813. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  43814. /**
  43815. * Gets the engine associated with the scene
  43816. * @returns an Engine
  43817. */
  43818. getEngine(): Engine;
  43819. /**
  43820. * Gets the total number of vertices rendered per frame
  43821. * @returns the total number of vertices rendered per frame
  43822. */
  43823. getTotalVertices(): number;
  43824. /**
  43825. * Gets the performance counter for total vertices
  43826. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43827. */
  43828. get totalVerticesPerfCounter(): PerfCounter;
  43829. /**
  43830. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  43831. * @returns the total number of active indices rendered per frame
  43832. */
  43833. getActiveIndices(): number;
  43834. /**
  43835. * Gets the performance counter for active indices
  43836. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43837. */
  43838. get totalActiveIndicesPerfCounter(): PerfCounter;
  43839. /**
  43840. * Gets the total number of active particles rendered per frame
  43841. * @returns the total number of active particles rendered per frame
  43842. */
  43843. getActiveParticles(): number;
  43844. /**
  43845. * Gets the performance counter for active particles
  43846. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43847. */
  43848. get activeParticlesPerfCounter(): PerfCounter;
  43849. /**
  43850. * Gets the total number of active bones rendered per frame
  43851. * @returns the total number of active bones rendered per frame
  43852. */
  43853. getActiveBones(): number;
  43854. /**
  43855. * Gets the performance counter for active bones
  43856. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43857. */
  43858. get activeBonesPerfCounter(): PerfCounter;
  43859. /**
  43860. * Gets the array of active meshes
  43861. * @returns an array of AbstractMesh
  43862. */
  43863. getActiveMeshes(): SmartArray<AbstractMesh>;
  43864. /**
  43865. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  43866. * @returns a number
  43867. */
  43868. getAnimationRatio(): number;
  43869. /**
  43870. * Gets an unique Id for the current render phase
  43871. * @returns a number
  43872. */
  43873. getRenderId(): number;
  43874. /**
  43875. * Gets an unique Id for the current frame
  43876. * @returns a number
  43877. */
  43878. getFrameId(): number;
  43879. /** Call this function if you want to manually increment the render Id*/
  43880. incrementRenderId(): void;
  43881. private _createUbo;
  43882. /**
  43883. * Use this method to simulate a pointer move on a mesh
  43884. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43885. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43886. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43887. * @returns the current scene
  43888. */
  43889. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43890. /**
  43891. * Use this method to simulate a pointer down on a mesh
  43892. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43893. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43894. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43895. * @returns the current scene
  43896. */
  43897. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43898. /**
  43899. * Use this method to simulate a pointer up on a mesh
  43900. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43901. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43902. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43903. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43904. * @returns the current scene
  43905. */
  43906. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  43907. /**
  43908. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43909. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43910. * @returns true if the pointer was captured
  43911. */
  43912. isPointerCaptured(pointerId?: number): boolean;
  43913. /**
  43914. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43915. * @param attachUp defines if you want to attach events to pointerup
  43916. * @param attachDown defines if you want to attach events to pointerdown
  43917. * @param attachMove defines if you want to attach events to pointermove
  43918. */
  43919. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  43920. /** Detaches all event handlers*/
  43921. detachControl(): void;
  43922. /**
  43923. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  43924. * Delay loaded resources are not taking in account
  43925. * @return true if all required resources are ready
  43926. */
  43927. isReady(): boolean;
  43928. /** Resets all cached information relative to material (including effect and visibility) */
  43929. resetCachedMaterial(): void;
  43930. /**
  43931. * Registers a function to be called before every frame render
  43932. * @param func defines the function to register
  43933. */
  43934. registerBeforeRender(func: () => void): void;
  43935. /**
  43936. * Unregisters a function called before every frame render
  43937. * @param func defines the function to unregister
  43938. */
  43939. unregisterBeforeRender(func: () => void): void;
  43940. /**
  43941. * Registers a function to be called after every frame render
  43942. * @param func defines the function to register
  43943. */
  43944. registerAfterRender(func: () => void): void;
  43945. /**
  43946. * Unregisters a function called after every frame render
  43947. * @param func defines the function to unregister
  43948. */
  43949. unregisterAfterRender(func: () => void): void;
  43950. private _executeOnceBeforeRender;
  43951. /**
  43952. * The provided function will run before render once and will be disposed afterwards.
  43953. * A timeout delay can be provided so that the function will be executed in N ms.
  43954. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  43955. * @param func The function to be executed.
  43956. * @param timeout optional delay in ms
  43957. */
  43958. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  43959. /** @hidden */
  43960. _addPendingData(data: any): void;
  43961. /** @hidden */
  43962. _removePendingData(data: any): void;
  43963. /**
  43964. * Returns the number of items waiting to be loaded
  43965. * @returns the number of items waiting to be loaded
  43966. */
  43967. getWaitingItemsCount(): number;
  43968. /**
  43969. * Returns a boolean indicating if the scene is still loading data
  43970. */
  43971. get isLoading(): boolean;
  43972. /**
  43973. * Registers a function to be executed when the scene is ready
  43974. * @param {Function} func - the function to be executed
  43975. */
  43976. executeWhenReady(func: () => void): void;
  43977. /**
  43978. * Returns a promise that resolves when the scene is ready
  43979. * @returns A promise that resolves when the scene is ready
  43980. */
  43981. whenReadyAsync(): Promise<void>;
  43982. /** @hidden */
  43983. _checkIsReady(): void;
  43984. /**
  43985. * Gets all animatable attached to the scene
  43986. */
  43987. get animatables(): Animatable[];
  43988. /**
  43989. * Resets the last animation time frame.
  43990. * Useful to override when animations start running when loading a scene for the first time.
  43991. */
  43992. resetLastAnimationTimeFrame(): void;
  43993. /**
  43994. * Gets the current view matrix
  43995. * @returns a Matrix
  43996. */
  43997. getViewMatrix(): Matrix;
  43998. /**
  43999. * Gets the current projection matrix
  44000. * @returns a Matrix
  44001. */
  44002. getProjectionMatrix(): Matrix;
  44003. /**
  44004. * Gets the current transform matrix
  44005. * @returns a Matrix made of View * Projection
  44006. */
  44007. getTransformMatrix(): Matrix;
  44008. /**
  44009. * Sets the current transform matrix
  44010. * @param viewL defines the View matrix to use
  44011. * @param projectionL defines the Projection matrix to use
  44012. * @param viewR defines the right View matrix to use (if provided)
  44013. * @param projectionR defines the right Projection matrix to use (if provided)
  44014. */
  44015. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  44016. /**
  44017. * Gets the uniform buffer used to store scene data
  44018. * @returns a UniformBuffer
  44019. */
  44020. getSceneUniformBuffer(): UniformBuffer;
  44021. /**
  44022. * Gets an unique (relatively to the current scene) Id
  44023. * @returns an unique number for the scene
  44024. */
  44025. getUniqueId(): number;
  44026. /**
  44027. * Add a mesh to the list of scene's meshes
  44028. * @param newMesh defines the mesh to add
  44029. * @param recursive if all child meshes should also be added to the scene
  44030. */
  44031. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  44032. /**
  44033. * Remove a mesh for the list of scene's meshes
  44034. * @param toRemove defines the mesh to remove
  44035. * @param recursive if all child meshes should also be removed from the scene
  44036. * @returns the index where the mesh was in the mesh list
  44037. */
  44038. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  44039. /**
  44040. * Add a transform node to the list of scene's transform nodes
  44041. * @param newTransformNode defines the transform node to add
  44042. */
  44043. addTransformNode(newTransformNode: TransformNode): void;
  44044. /**
  44045. * Remove a transform node for the list of scene's transform nodes
  44046. * @param toRemove defines the transform node to remove
  44047. * @returns the index where the transform node was in the transform node list
  44048. */
  44049. removeTransformNode(toRemove: TransformNode): number;
  44050. /**
  44051. * Remove a skeleton for the list of scene's skeletons
  44052. * @param toRemove defines the skeleton to remove
  44053. * @returns the index where the skeleton was in the skeleton list
  44054. */
  44055. removeSkeleton(toRemove: Skeleton): number;
  44056. /**
  44057. * Remove a morph target for the list of scene's morph targets
  44058. * @param toRemove defines the morph target to remove
  44059. * @returns the index where the morph target was in the morph target list
  44060. */
  44061. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  44062. /**
  44063. * Remove a light for the list of scene's lights
  44064. * @param toRemove defines the light to remove
  44065. * @returns the index where the light was in the light list
  44066. */
  44067. removeLight(toRemove: Light): number;
  44068. /**
  44069. * Remove a camera for the list of scene's cameras
  44070. * @param toRemove defines the camera to remove
  44071. * @returns the index where the camera was in the camera list
  44072. */
  44073. removeCamera(toRemove: Camera): number;
  44074. /**
  44075. * Remove a particle system for the list of scene's particle systems
  44076. * @param toRemove defines the particle system to remove
  44077. * @returns the index where the particle system was in the particle system list
  44078. */
  44079. removeParticleSystem(toRemove: IParticleSystem): number;
  44080. /**
  44081. * Remove a animation for the list of scene's animations
  44082. * @param toRemove defines the animation to remove
  44083. * @returns the index where the animation was in the animation list
  44084. */
  44085. removeAnimation(toRemove: Animation): number;
  44086. /**
  44087. * Will stop the animation of the given target
  44088. * @param target - the target
  44089. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  44090. * @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)
  44091. */
  44092. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  44093. /**
  44094. * Removes the given animation group from this scene.
  44095. * @param toRemove The animation group to remove
  44096. * @returns The index of the removed animation group
  44097. */
  44098. removeAnimationGroup(toRemove: AnimationGroup): number;
  44099. /**
  44100. * Removes the given multi-material from this scene.
  44101. * @param toRemove The multi-material to remove
  44102. * @returns The index of the removed multi-material
  44103. */
  44104. removeMultiMaterial(toRemove: MultiMaterial): number;
  44105. /**
  44106. * Removes the given material from this scene.
  44107. * @param toRemove The material to remove
  44108. * @returns The index of the removed material
  44109. */
  44110. removeMaterial(toRemove: Material): number;
  44111. /**
  44112. * Removes the given action manager from this scene.
  44113. * @param toRemove The action manager to remove
  44114. * @returns The index of the removed action manager
  44115. */
  44116. removeActionManager(toRemove: AbstractActionManager): number;
  44117. /**
  44118. * Removes the given texture from this scene.
  44119. * @param toRemove The texture to remove
  44120. * @returns The index of the removed texture
  44121. */
  44122. removeTexture(toRemove: BaseTexture): number;
  44123. /**
  44124. * Adds the given light to this scene
  44125. * @param newLight The light to add
  44126. */
  44127. addLight(newLight: Light): void;
  44128. /**
  44129. * Sorts the list list based on light priorities
  44130. */
  44131. sortLightsByPriority(): void;
  44132. /**
  44133. * Adds the given camera to this scene
  44134. * @param newCamera The camera to add
  44135. */
  44136. addCamera(newCamera: Camera): void;
  44137. /**
  44138. * Adds the given skeleton to this scene
  44139. * @param newSkeleton The skeleton to add
  44140. */
  44141. addSkeleton(newSkeleton: Skeleton): void;
  44142. /**
  44143. * Adds the given particle system to this scene
  44144. * @param newParticleSystem The particle system to add
  44145. */
  44146. addParticleSystem(newParticleSystem: IParticleSystem): void;
  44147. /**
  44148. * Adds the given animation to this scene
  44149. * @param newAnimation The animation to add
  44150. */
  44151. addAnimation(newAnimation: Animation): void;
  44152. /**
  44153. * Adds the given animation group to this scene.
  44154. * @param newAnimationGroup The animation group to add
  44155. */
  44156. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  44157. /**
  44158. * Adds the given multi-material to this scene
  44159. * @param newMultiMaterial The multi-material to add
  44160. */
  44161. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  44162. /**
  44163. * Adds the given material to this scene
  44164. * @param newMaterial The material to add
  44165. */
  44166. addMaterial(newMaterial: Material): void;
  44167. /**
  44168. * Adds the given morph target to this scene
  44169. * @param newMorphTargetManager The morph target to add
  44170. */
  44171. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  44172. /**
  44173. * Adds the given geometry to this scene
  44174. * @param newGeometry The geometry to add
  44175. */
  44176. addGeometry(newGeometry: Geometry): void;
  44177. /**
  44178. * Adds the given action manager to this scene
  44179. * @param newActionManager The action manager to add
  44180. */
  44181. addActionManager(newActionManager: AbstractActionManager): void;
  44182. /**
  44183. * Adds the given texture to this scene.
  44184. * @param newTexture The texture to add
  44185. */
  44186. addTexture(newTexture: BaseTexture): void;
  44187. /**
  44188. * Switch active camera
  44189. * @param newCamera defines the new active camera
  44190. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  44191. */
  44192. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  44193. /**
  44194. * sets the active camera of the scene using its ID
  44195. * @param id defines the camera's ID
  44196. * @return the new active camera or null if none found.
  44197. */
  44198. setActiveCameraByID(id: string): Nullable<Camera>;
  44199. /**
  44200. * sets the active camera of the scene using its name
  44201. * @param name defines the camera's name
  44202. * @returns the new active camera or null if none found.
  44203. */
  44204. setActiveCameraByName(name: string): Nullable<Camera>;
  44205. /**
  44206. * get an animation group using its name
  44207. * @param name defines the material's name
  44208. * @return the animation group or null if none found.
  44209. */
  44210. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  44211. /**
  44212. * Get a material using its unique id
  44213. * @param uniqueId defines the material's unique id
  44214. * @return the material or null if none found.
  44215. */
  44216. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  44217. /**
  44218. * get a material using its id
  44219. * @param id defines the material's ID
  44220. * @return the material or null if none found.
  44221. */
  44222. getMaterialByID(id: string): Nullable<Material>;
  44223. /**
  44224. * Gets a the last added material using a given id
  44225. * @param id defines the material's ID
  44226. * @return the last material with the given id or null if none found.
  44227. */
  44228. getLastMaterialByID(id: string): Nullable<Material>;
  44229. /**
  44230. * Gets a material using its name
  44231. * @param name defines the material's name
  44232. * @return the material or null if none found.
  44233. */
  44234. getMaterialByName(name: string): Nullable<Material>;
  44235. /**
  44236. * Get a texture using its unique id
  44237. * @param uniqueId defines the texture's unique id
  44238. * @return the texture or null if none found.
  44239. */
  44240. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  44241. /**
  44242. * Gets a camera using its id
  44243. * @param id defines the id to look for
  44244. * @returns the camera or null if not found
  44245. */
  44246. getCameraByID(id: string): Nullable<Camera>;
  44247. /**
  44248. * Gets a camera using its unique id
  44249. * @param uniqueId defines the unique id to look for
  44250. * @returns the camera or null if not found
  44251. */
  44252. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  44253. /**
  44254. * Gets a camera using its name
  44255. * @param name defines the camera's name
  44256. * @return the camera or null if none found.
  44257. */
  44258. getCameraByName(name: string): Nullable<Camera>;
  44259. /**
  44260. * Gets a bone using its id
  44261. * @param id defines the bone's id
  44262. * @return the bone or null if not found
  44263. */
  44264. getBoneByID(id: string): Nullable<Bone>;
  44265. /**
  44266. * Gets a bone using its id
  44267. * @param name defines the bone's name
  44268. * @return the bone or null if not found
  44269. */
  44270. getBoneByName(name: string): Nullable<Bone>;
  44271. /**
  44272. * Gets a light node using its name
  44273. * @param name defines the the light's name
  44274. * @return the light or null if none found.
  44275. */
  44276. getLightByName(name: string): Nullable<Light>;
  44277. /**
  44278. * Gets a light node using its id
  44279. * @param id defines the light's id
  44280. * @return the light or null if none found.
  44281. */
  44282. getLightByID(id: string): Nullable<Light>;
  44283. /**
  44284. * Gets a light node using its scene-generated unique ID
  44285. * @param uniqueId defines the light's unique id
  44286. * @return the light or null if none found.
  44287. */
  44288. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  44289. /**
  44290. * Gets a particle system by id
  44291. * @param id defines the particle system id
  44292. * @return the corresponding system or null if none found
  44293. */
  44294. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  44295. /**
  44296. * Gets a geometry using its ID
  44297. * @param id defines the geometry's id
  44298. * @return the geometry or null if none found.
  44299. */
  44300. getGeometryByID(id: string): Nullable<Geometry>;
  44301. private _getGeometryByUniqueID;
  44302. /**
  44303. * Add a new geometry to this scene
  44304. * @param geometry defines the geometry to be added to the scene.
  44305. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  44306. * @return a boolean defining if the geometry was added or not
  44307. */
  44308. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  44309. /**
  44310. * Removes an existing geometry
  44311. * @param geometry defines the geometry to be removed from the scene
  44312. * @return a boolean defining if the geometry was removed or not
  44313. */
  44314. removeGeometry(geometry: Geometry): boolean;
  44315. /**
  44316. * Gets the list of geometries attached to the scene
  44317. * @returns an array of Geometry
  44318. */
  44319. getGeometries(): Geometry[];
  44320. /**
  44321. * Gets the first added mesh found of a given ID
  44322. * @param id defines the id to search for
  44323. * @return the mesh found or null if not found at all
  44324. */
  44325. getMeshByID(id: string): Nullable<AbstractMesh>;
  44326. /**
  44327. * Gets a list of meshes using their id
  44328. * @param id defines the id to search for
  44329. * @returns a list of meshes
  44330. */
  44331. getMeshesByID(id: string): Array<AbstractMesh>;
  44332. /**
  44333. * Gets the first added transform node found of a given ID
  44334. * @param id defines the id to search for
  44335. * @return the found transform node or null if not found at all.
  44336. */
  44337. getTransformNodeByID(id: string): Nullable<TransformNode>;
  44338. /**
  44339. * Gets a transform node with its auto-generated unique id
  44340. * @param uniqueId efines the unique id to search for
  44341. * @return the found transform node or null if not found at all.
  44342. */
  44343. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  44344. /**
  44345. * Gets a list of transform nodes using their id
  44346. * @param id defines the id to search for
  44347. * @returns a list of transform nodes
  44348. */
  44349. getTransformNodesByID(id: string): Array<TransformNode>;
  44350. /**
  44351. * Gets a mesh with its auto-generated unique id
  44352. * @param uniqueId defines the unique id to search for
  44353. * @return the found mesh or null if not found at all.
  44354. */
  44355. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  44356. /**
  44357. * Gets a the last added mesh using a given id
  44358. * @param id defines the id to search for
  44359. * @return the found mesh or null if not found at all.
  44360. */
  44361. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  44362. /**
  44363. * Gets a the last added node (Mesh, Camera, Light) using a given id
  44364. * @param id defines the id to search for
  44365. * @return the found node or null if not found at all
  44366. */
  44367. getLastEntryByID(id: string): Nullable<Node>;
  44368. /**
  44369. * Gets a node (Mesh, Camera, Light) using a given id
  44370. * @param id defines the id to search for
  44371. * @return the found node or null if not found at all
  44372. */
  44373. getNodeByID(id: string): Nullable<Node>;
  44374. /**
  44375. * Gets a node (Mesh, Camera, Light) using a given name
  44376. * @param name defines the name to search for
  44377. * @return the found node or null if not found at all.
  44378. */
  44379. getNodeByName(name: string): Nullable<Node>;
  44380. /**
  44381. * Gets a mesh using a given name
  44382. * @param name defines the name to search for
  44383. * @return the found mesh or null if not found at all.
  44384. */
  44385. getMeshByName(name: string): Nullable<AbstractMesh>;
  44386. /**
  44387. * Gets a transform node using a given name
  44388. * @param name defines the name to search for
  44389. * @return the found transform node or null if not found at all.
  44390. */
  44391. getTransformNodeByName(name: string): Nullable<TransformNode>;
  44392. /**
  44393. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  44394. * @param id defines the id to search for
  44395. * @return the found skeleton or null if not found at all.
  44396. */
  44397. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  44398. /**
  44399. * Gets a skeleton using a given auto generated unique id
  44400. * @param uniqueId defines the unique id to search for
  44401. * @return the found skeleton or null if not found at all.
  44402. */
  44403. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  44404. /**
  44405. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  44406. * @param id defines the id to search for
  44407. * @return the found skeleton or null if not found at all.
  44408. */
  44409. getSkeletonById(id: string): Nullable<Skeleton>;
  44410. /**
  44411. * Gets a skeleton using a given name
  44412. * @param name defines the name to search for
  44413. * @return the found skeleton or null if not found at all.
  44414. */
  44415. getSkeletonByName(name: string): Nullable<Skeleton>;
  44416. /**
  44417. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  44418. * @param id defines the id to search for
  44419. * @return the found morph target manager or null if not found at all.
  44420. */
  44421. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  44422. /**
  44423. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  44424. * @param id defines the id to search for
  44425. * @return the found morph target or null if not found at all.
  44426. */
  44427. getMorphTargetById(id: string): Nullable<MorphTarget>;
  44428. /**
  44429. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  44430. * @param name defines the name to search for
  44431. * @return the found morph target or null if not found at all.
  44432. */
  44433. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  44434. /**
  44435. * Gets a post process using a given name (if many are found, this function will pick the first one)
  44436. * @param name defines the name to search for
  44437. * @return the found post process or null if not found at all.
  44438. */
  44439. getPostProcessByName(name: string): Nullable<PostProcess>;
  44440. /**
  44441. * Gets a boolean indicating if the given mesh is active
  44442. * @param mesh defines the mesh to look for
  44443. * @returns true if the mesh is in the active list
  44444. */
  44445. isActiveMesh(mesh: AbstractMesh): boolean;
  44446. /**
  44447. * Return a unique id as a string which can serve as an identifier for the scene
  44448. */
  44449. get uid(): string;
  44450. /**
  44451. * Add an externaly attached data from its key.
  44452. * This method call will fail and return false, if such key already exists.
  44453. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  44454. * @param key the unique key that identifies the data
  44455. * @param data the data object to associate to the key for this Engine instance
  44456. * @return true if no such key were already present and the data was added successfully, false otherwise
  44457. */
  44458. addExternalData<T>(key: string, data: T): boolean;
  44459. /**
  44460. * Get an externaly attached data from its key
  44461. * @param key the unique key that identifies the data
  44462. * @return the associated data, if present (can be null), or undefined if not present
  44463. */
  44464. getExternalData<T>(key: string): Nullable<T>;
  44465. /**
  44466. * Get an externaly attached data from its key, create it using a factory if it's not already present
  44467. * @param key the unique key that identifies the data
  44468. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  44469. * @return the associated data, can be null if the factory returned null.
  44470. */
  44471. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  44472. /**
  44473. * Remove an externaly attached data from the Engine instance
  44474. * @param key the unique key that identifies the data
  44475. * @return true if the data was successfully removed, false if it doesn't exist
  44476. */
  44477. removeExternalData(key: string): boolean;
  44478. private _evaluateSubMesh;
  44479. /**
  44480. * Clear the processed materials smart array preventing retention point in material dispose.
  44481. */
  44482. freeProcessedMaterials(): void;
  44483. private _preventFreeActiveMeshesAndRenderingGroups;
  44484. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  44485. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  44486. * when disposing several meshes in a row or a hierarchy of meshes.
  44487. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  44488. */
  44489. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  44490. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  44491. /**
  44492. * Clear the active meshes smart array preventing retention point in mesh dispose.
  44493. */
  44494. freeActiveMeshes(): void;
  44495. /**
  44496. * Clear the info related to rendering groups preventing retention points during dispose.
  44497. */
  44498. freeRenderingGroups(): void;
  44499. /** @hidden */
  44500. _isInIntermediateRendering(): boolean;
  44501. /**
  44502. * Lambda returning the list of potentially active meshes.
  44503. */
  44504. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  44505. /**
  44506. * Lambda returning the list of potentially active sub meshes.
  44507. */
  44508. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  44509. /**
  44510. * Lambda returning the list of potentially intersecting sub meshes.
  44511. */
  44512. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  44513. /**
  44514. * Lambda returning the list of potentially colliding sub meshes.
  44515. */
  44516. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  44517. /** @hidden */
  44518. _activeMeshesFrozen: boolean;
  44519. private _skipEvaluateActiveMeshesCompletely;
  44520. /**
  44521. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  44522. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  44523. * @param onSuccess optional success callback
  44524. * @param onError optional error callback
  44525. * @returns the current scene
  44526. */
  44527. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  44528. /**
  44529. * Use this function to restart evaluating active meshes on every frame
  44530. * @returns the current scene
  44531. */
  44532. unfreezeActiveMeshes(): Scene;
  44533. private _evaluateActiveMeshes;
  44534. private _activeMesh;
  44535. /**
  44536. * Update the transform matrix to update from the current active camera
  44537. * @param force defines a boolean used to force the update even if cache is up to date
  44538. */
  44539. updateTransformMatrix(force?: boolean): void;
  44540. private _bindFrameBuffer;
  44541. /** @hidden */
  44542. _allowPostProcessClearColor: boolean;
  44543. /** @hidden */
  44544. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  44545. private _processSubCameras;
  44546. private _checkIntersections;
  44547. /** @hidden */
  44548. _advancePhysicsEngineStep(step: number): void;
  44549. /**
  44550. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  44551. */
  44552. getDeterministicFrameTime: () => number;
  44553. /** @hidden */
  44554. _animate(): void;
  44555. /** Execute all animations (for a frame) */
  44556. animate(): void;
  44557. /**
  44558. * Render the scene
  44559. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  44560. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  44561. */
  44562. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  44563. /**
  44564. * Freeze all materials
  44565. * A frozen material will not be updatable but should be faster to render
  44566. */
  44567. freezeMaterials(): void;
  44568. /**
  44569. * Unfreeze all materials
  44570. * A frozen material will not be updatable but should be faster to render
  44571. */
  44572. unfreezeMaterials(): void;
  44573. /**
  44574. * Releases all held ressources
  44575. */
  44576. dispose(): void;
  44577. /**
  44578. * Gets if the scene is already disposed
  44579. */
  44580. get isDisposed(): boolean;
  44581. /**
  44582. * Call this function to reduce memory footprint of the scene.
  44583. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  44584. */
  44585. clearCachedVertexData(): void;
  44586. /**
  44587. * This function will remove the local cached buffer data from texture.
  44588. * It will save memory but will prevent the texture from being rebuilt
  44589. */
  44590. cleanCachedTextureBuffer(): void;
  44591. /**
  44592. * Get the world extend vectors with an optional filter
  44593. *
  44594. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  44595. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  44596. */
  44597. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  44598. min: Vector3;
  44599. max: Vector3;
  44600. };
  44601. /**
  44602. * Creates a ray that can be used to pick in the scene
  44603. * @param x defines the x coordinate of the origin (on-screen)
  44604. * @param y defines the y coordinate of the origin (on-screen)
  44605. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44606. * @param camera defines the camera to use for the picking
  44607. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44608. * @returns a Ray
  44609. */
  44610. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  44611. /**
  44612. * Creates a ray that can be used to pick in the scene
  44613. * @param x defines the x coordinate of the origin (on-screen)
  44614. * @param y defines the y coordinate of the origin (on-screen)
  44615. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44616. * @param result defines the ray where to store the picking ray
  44617. * @param camera defines the camera to use for the picking
  44618. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44619. * @returns the current scene
  44620. */
  44621. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  44622. /**
  44623. * Creates a ray that can be used to pick in the scene
  44624. * @param x defines the x coordinate of the origin (on-screen)
  44625. * @param y defines the y coordinate of the origin (on-screen)
  44626. * @param camera defines the camera to use for the picking
  44627. * @returns a Ray
  44628. */
  44629. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  44630. /**
  44631. * Creates a ray that can be used to pick in the scene
  44632. * @param x defines the x coordinate of the origin (on-screen)
  44633. * @param y defines the y coordinate of the origin (on-screen)
  44634. * @param result defines the ray where to store the picking ray
  44635. * @param camera defines the camera to use for the picking
  44636. * @returns the current scene
  44637. */
  44638. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  44639. /** Launch a ray to try to pick a mesh in the scene
  44640. * @param x position on screen
  44641. * @param y position on screen
  44642. * @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
  44643. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44644. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44645. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44646. * @returns a PickingInfo
  44647. */
  44648. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44649. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  44650. * @param x position on screen
  44651. * @param y position on screen
  44652. * @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
  44653. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44654. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44655. * @returns a PickingInfo (Please note that some info will not be set like distance, bv, bu and everything that cannot be capture by only using bounding infos)
  44656. */
  44657. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  44658. /** Use the given ray to pick a mesh in the scene
  44659. * @param ray The ray to use to pick meshes
  44660. * @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
  44661. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44662. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44663. * @returns a PickingInfo
  44664. */
  44665. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44666. /**
  44667. * Launch a ray to try to pick a mesh in the scene
  44668. * @param x X position on screen
  44669. * @param y Y position on screen
  44670. * @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
  44671. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44672. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44673. * @returns an array of PickingInfo
  44674. */
  44675. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44676. /**
  44677. * Launch a ray to try to pick a mesh in the scene
  44678. * @param ray Ray to use
  44679. * @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
  44680. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44681. * @returns an array of PickingInfo
  44682. */
  44683. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44684. /**
  44685. * Force the value of meshUnderPointer
  44686. * @param mesh defines the mesh to use
  44687. * @param pointerId optional pointer id when using more than one pointer
  44688. */
  44689. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  44690. /**
  44691. * Gets the mesh under the pointer
  44692. * @returns a Mesh or null if no mesh is under the pointer
  44693. */
  44694. getPointerOverMesh(): Nullable<AbstractMesh>;
  44695. /** @hidden */
  44696. _rebuildGeometries(): void;
  44697. /** @hidden */
  44698. _rebuildTextures(): void;
  44699. private _getByTags;
  44700. /**
  44701. * Get a list of meshes by tags
  44702. * @param tagsQuery defines the tags query to use
  44703. * @param forEach defines a predicate used to filter results
  44704. * @returns an array of Mesh
  44705. */
  44706. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  44707. /**
  44708. * Get a list of cameras by tags
  44709. * @param tagsQuery defines the tags query to use
  44710. * @param forEach defines a predicate used to filter results
  44711. * @returns an array of Camera
  44712. */
  44713. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  44714. /**
  44715. * Get a list of lights by tags
  44716. * @param tagsQuery defines the tags query to use
  44717. * @param forEach defines a predicate used to filter results
  44718. * @returns an array of Light
  44719. */
  44720. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  44721. /**
  44722. * Get a list of materials by tags
  44723. * @param tagsQuery defines the tags query to use
  44724. * @param forEach defines a predicate used to filter results
  44725. * @returns an array of Material
  44726. */
  44727. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  44728. /**
  44729. * Get a list of transform nodes by tags
  44730. * @param tagsQuery defines the tags query to use
  44731. * @param forEach defines a predicate used to filter results
  44732. * @returns an array of TransformNode
  44733. */
  44734. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  44735. /**
  44736. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  44737. * This allowed control for front to back rendering or reversly depending of the special needs.
  44738. *
  44739. * @param renderingGroupId The rendering group id corresponding to its index
  44740. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  44741. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  44742. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  44743. */
  44744. 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;
  44745. /**
  44746. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  44747. *
  44748. * @param renderingGroupId The rendering group id corresponding to its index
  44749. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  44750. * @param depth Automatically clears depth between groups if true and autoClear is true.
  44751. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  44752. */
  44753. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  44754. /**
  44755. * Gets the current auto clear configuration for one rendering group of the rendering
  44756. * manager.
  44757. * @param index the rendering group index to get the information for
  44758. * @returns The auto clear setup for the requested rendering group
  44759. */
  44760. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  44761. private _blockMaterialDirtyMechanism;
  44762. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  44763. get blockMaterialDirtyMechanism(): boolean;
  44764. set blockMaterialDirtyMechanism(value: boolean);
  44765. /**
  44766. * Will flag all materials as dirty to trigger new shader compilation
  44767. * @param flag defines the flag used to specify which material part must be marked as dirty
  44768. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  44769. */
  44770. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  44771. /** @hidden */
  44772. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  44773. /** @hidden */
  44774. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44775. /** @hidden */
  44776. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  44777. /** @hidden */
  44778. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  44779. /** @hidden */
  44780. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  44781. /** @hidden */
  44782. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44783. }
  44784. }
  44785. declare module BABYLON {
  44786. /**
  44787. * Set of assets to keep when moving a scene into an asset container.
  44788. */
  44789. export class KeepAssets extends AbstractScene {
  44790. }
  44791. /**
  44792. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  44793. */
  44794. export class InstantiatedEntries {
  44795. /**
  44796. * List of new root nodes (eg. nodes with no parent)
  44797. */
  44798. rootNodes: TransformNode[];
  44799. /**
  44800. * List of new skeletons
  44801. */
  44802. skeletons: Skeleton[];
  44803. /**
  44804. * List of new animation groups
  44805. */
  44806. animationGroups: AnimationGroup[];
  44807. }
  44808. /**
  44809. * Container with a set of assets that can be added or removed from a scene.
  44810. */
  44811. export class AssetContainer extends AbstractScene {
  44812. private _wasAddedToScene;
  44813. /**
  44814. * The scene the AssetContainer belongs to.
  44815. */
  44816. scene: Scene;
  44817. /**
  44818. * Instantiates an AssetContainer.
  44819. * @param scene The scene the AssetContainer belongs to.
  44820. */
  44821. constructor(scene: Scene);
  44822. /**
  44823. * Instantiate or clone all meshes and add the new ones to the scene.
  44824. * Skeletons and animation groups will all be cloned
  44825. * @param nameFunction defines an optional function used to get new names for clones
  44826. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  44827. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  44828. */
  44829. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  44830. /**
  44831. * Adds all the assets from the container to the scene.
  44832. */
  44833. addAllToScene(): void;
  44834. /**
  44835. * Removes all the assets in the container from the scene
  44836. */
  44837. removeAllFromScene(): void;
  44838. /**
  44839. * Disposes all the assets in the container
  44840. */
  44841. dispose(): void;
  44842. private _moveAssets;
  44843. /**
  44844. * Removes all the assets contained in the scene and adds them to the container.
  44845. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  44846. */
  44847. moveAllFromScene(keepAssets?: KeepAssets): void;
  44848. /**
  44849. * 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.
  44850. * @returns the root mesh
  44851. */
  44852. createRootMesh(): Mesh;
  44853. /**
  44854. * Merge animations (direct and animation groups) from this asset container into a scene
  44855. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44856. * @param animatables set of animatables to retarget to a node from the scene
  44857. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  44858. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  44859. */
  44860. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  44861. }
  44862. }
  44863. declare module BABYLON {
  44864. /**
  44865. * Defines how the parser contract is defined.
  44866. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  44867. */
  44868. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  44869. /**
  44870. * Defines how the individual parser contract is defined.
  44871. * These parser can parse an individual asset
  44872. */
  44873. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  44874. /**
  44875. * Base class of the scene acting as a container for the different elements composing a scene.
  44876. * This class is dynamically extended by the different components of the scene increasing
  44877. * flexibility and reducing coupling
  44878. */
  44879. export abstract class AbstractScene {
  44880. /**
  44881. * Stores the list of available parsers in the application.
  44882. */
  44883. private static _BabylonFileParsers;
  44884. /**
  44885. * Stores the list of available individual parsers in the application.
  44886. */
  44887. private static _IndividualBabylonFileParsers;
  44888. /**
  44889. * Adds a parser in the list of available ones
  44890. * @param name Defines the name of the parser
  44891. * @param parser Defines the parser to add
  44892. */
  44893. static AddParser(name: string, parser: BabylonFileParser): void;
  44894. /**
  44895. * Gets a general parser from the list of avaialble ones
  44896. * @param name Defines the name of the parser
  44897. * @returns the requested parser or null
  44898. */
  44899. static GetParser(name: string): Nullable<BabylonFileParser>;
  44900. /**
  44901. * Adds n individual parser in the list of available ones
  44902. * @param name Defines the name of the parser
  44903. * @param parser Defines the parser to add
  44904. */
  44905. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  44906. /**
  44907. * Gets an individual parser from the list of avaialble ones
  44908. * @param name Defines the name of the parser
  44909. * @returns the requested parser or null
  44910. */
  44911. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  44912. /**
  44913. * Parser json data and populate both a scene and its associated container object
  44914. * @param jsonData Defines the data to parse
  44915. * @param scene Defines the scene to parse the data for
  44916. * @param container Defines the container attached to the parsing sequence
  44917. * @param rootUrl Defines the root url of the data
  44918. */
  44919. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  44920. /**
  44921. * Gets the list of root nodes (ie. nodes with no parent)
  44922. */
  44923. rootNodes: Node[];
  44924. /** All of the cameras added to this scene
  44925. * @see https://doc.babylonjs.com/babylon101/cameras
  44926. */
  44927. cameras: Camera[];
  44928. /**
  44929. * All of the lights added to this scene
  44930. * @see https://doc.babylonjs.com/babylon101/lights
  44931. */
  44932. lights: Light[];
  44933. /**
  44934. * All of the (abstract) meshes added to this scene
  44935. */
  44936. meshes: AbstractMesh[];
  44937. /**
  44938. * The list of skeletons added to the scene
  44939. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  44940. */
  44941. skeletons: Skeleton[];
  44942. /**
  44943. * All of the particle systems added to this scene
  44944. * @see https://doc.babylonjs.com/babylon101/particles
  44945. */
  44946. particleSystems: IParticleSystem[];
  44947. /**
  44948. * Gets a list of Animations associated with the scene
  44949. */
  44950. animations: Animation[];
  44951. /**
  44952. * All of the animation groups added to this scene
  44953. * @see https://doc.babylonjs.com/how_to/group
  44954. */
  44955. animationGroups: AnimationGroup[];
  44956. /**
  44957. * All of the multi-materials added to this scene
  44958. * @see https://doc.babylonjs.com/how_to/multi_materials
  44959. */
  44960. multiMaterials: MultiMaterial[];
  44961. /**
  44962. * All of the materials added to this scene
  44963. * In the context of a Scene, it is not supposed to be modified manually.
  44964. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  44965. * Note also that the order of the Material within the array is not significant and might change.
  44966. * @see https://doc.babylonjs.com/babylon101/materials
  44967. */
  44968. materials: Material[];
  44969. /**
  44970. * The list of morph target managers added to the scene
  44971. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  44972. */
  44973. morphTargetManagers: MorphTargetManager[];
  44974. /**
  44975. * The list of geometries used in the scene.
  44976. */
  44977. geometries: Geometry[];
  44978. /**
  44979. * All of the tranform nodes added to this scene
  44980. * In the context of a Scene, it is not supposed to be modified manually.
  44981. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  44982. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  44983. * @see https://doc.babylonjs.com/how_to/transformnode
  44984. */
  44985. transformNodes: TransformNode[];
  44986. /**
  44987. * ActionManagers available on the scene.
  44988. */
  44989. actionManagers: AbstractActionManager[];
  44990. /**
  44991. * Textures to keep.
  44992. */
  44993. textures: BaseTexture[];
  44994. /** @hidden */
  44995. protected _environmentTexture: Nullable<BaseTexture>;
  44996. /**
  44997. * Texture used in all pbr material as the reflection texture.
  44998. * As in the majority of the scene they are the same (exception for multi room and so on),
  44999. * this is easier to reference from here than from all the materials.
  45000. */
  45001. get environmentTexture(): Nullable<BaseTexture>;
  45002. set environmentTexture(value: Nullable<BaseTexture>);
  45003. /**
  45004. * The list of postprocesses added to the scene
  45005. */
  45006. postProcesses: PostProcess[];
  45007. /**
  45008. * @returns all meshes, lights, cameras, transformNodes and bones
  45009. */
  45010. getNodes(): Array<Node>;
  45011. }
  45012. }
  45013. declare module BABYLON {
  45014. /**
  45015. * Interface used to define options for Sound class
  45016. */
  45017. export interface ISoundOptions {
  45018. /**
  45019. * Does the sound autoplay once loaded.
  45020. */
  45021. autoplay?: boolean;
  45022. /**
  45023. * Does the sound loop after it finishes playing once.
  45024. */
  45025. loop?: boolean;
  45026. /**
  45027. * Sound's volume
  45028. */
  45029. volume?: number;
  45030. /**
  45031. * Is it a spatial sound?
  45032. */
  45033. spatialSound?: boolean;
  45034. /**
  45035. * Maximum distance to hear that sound
  45036. */
  45037. maxDistance?: number;
  45038. /**
  45039. * Uses user defined attenuation function
  45040. */
  45041. useCustomAttenuation?: boolean;
  45042. /**
  45043. * Define the roll off factor of spatial sounds.
  45044. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45045. */
  45046. rolloffFactor?: number;
  45047. /**
  45048. * Define the reference distance the sound should be heard perfectly.
  45049. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45050. */
  45051. refDistance?: number;
  45052. /**
  45053. * Define the distance attenuation model the sound will follow.
  45054. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45055. */
  45056. distanceModel?: string;
  45057. /**
  45058. * Defines the playback speed (1 by default)
  45059. */
  45060. playbackRate?: number;
  45061. /**
  45062. * Defines if the sound is from a streaming source
  45063. */
  45064. streaming?: boolean;
  45065. /**
  45066. * Defines an optional length (in seconds) inside the sound file
  45067. */
  45068. length?: number;
  45069. /**
  45070. * Defines an optional offset (in seconds) inside the sound file
  45071. */
  45072. offset?: number;
  45073. /**
  45074. * If true, URLs will not be required to state the audio file codec to use.
  45075. */
  45076. skipCodecCheck?: boolean;
  45077. }
  45078. }
  45079. declare module BABYLON {
  45080. /**
  45081. * Defines a sound that can be played in the application.
  45082. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  45083. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45084. */
  45085. export class Sound {
  45086. /**
  45087. * The name of the sound in the scene.
  45088. */
  45089. name: string;
  45090. /**
  45091. * Does the sound autoplay once loaded.
  45092. */
  45093. autoplay: boolean;
  45094. /**
  45095. * Does the sound loop after it finishes playing once.
  45096. */
  45097. loop: boolean;
  45098. /**
  45099. * Does the sound use a custom attenuation curve to simulate the falloff
  45100. * happening when the source gets further away from the camera.
  45101. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  45102. */
  45103. useCustomAttenuation: boolean;
  45104. /**
  45105. * The sound track id this sound belongs to.
  45106. */
  45107. soundTrackId: number;
  45108. /**
  45109. * Is this sound currently played.
  45110. */
  45111. isPlaying: boolean;
  45112. /**
  45113. * Is this sound currently paused.
  45114. */
  45115. isPaused: boolean;
  45116. /**
  45117. * Does this sound enables spatial sound.
  45118. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45119. */
  45120. spatialSound: boolean;
  45121. /**
  45122. * Define the reference distance the sound should be heard perfectly.
  45123. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45124. */
  45125. refDistance: number;
  45126. /**
  45127. * Define the roll off factor of spatial sounds.
  45128. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45129. */
  45130. rolloffFactor: number;
  45131. /**
  45132. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  45133. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45134. */
  45135. maxDistance: number;
  45136. /**
  45137. * Define the distance attenuation model the sound will follow.
  45138. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45139. */
  45140. distanceModel: string;
  45141. /**
  45142. * @hidden
  45143. * Back Compat
  45144. **/
  45145. onended: () => any;
  45146. /**
  45147. * Gets or sets an object used to store user defined information for the sound.
  45148. */
  45149. metadata: any;
  45150. /**
  45151. * Observable event when the current playing sound finishes.
  45152. */
  45153. onEndedObservable: Observable<Sound>;
  45154. /**
  45155. * Gets the current time for the sound.
  45156. */
  45157. get currentTime(): number;
  45158. private _panningModel;
  45159. private _playbackRate;
  45160. private _streaming;
  45161. private _startTime;
  45162. private _startOffset;
  45163. private _position;
  45164. /** @hidden */
  45165. _positionInEmitterSpace: boolean;
  45166. private _localDirection;
  45167. private _volume;
  45168. private _isReadyToPlay;
  45169. private _isDirectional;
  45170. private _readyToPlayCallback;
  45171. private _audioBuffer;
  45172. private _soundSource;
  45173. private _streamingSource;
  45174. private _soundPanner;
  45175. private _soundGain;
  45176. private _inputAudioNode;
  45177. private _outputAudioNode;
  45178. private _coneInnerAngle;
  45179. private _coneOuterAngle;
  45180. private _coneOuterGain;
  45181. private _scene;
  45182. private _connectedTransformNode;
  45183. private _customAttenuationFunction;
  45184. private _registerFunc;
  45185. private _isOutputConnected;
  45186. private _htmlAudioElement;
  45187. private _urlType;
  45188. private _length?;
  45189. private _offset?;
  45190. /** @hidden */
  45191. static _SceneComponentInitialization: (scene: Scene) => void;
  45192. /**
  45193. * Create a sound and attach it to a scene
  45194. * @param name Name of your sound
  45195. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  45196. * @param scene defines the scene the sound belongs to
  45197. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  45198. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  45199. */
  45200. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  45201. /**
  45202. * Release the sound and its associated resources
  45203. */
  45204. dispose(): void;
  45205. /**
  45206. * Gets if the sounds is ready to be played or not.
  45207. * @returns true if ready, otherwise false
  45208. */
  45209. isReady(): boolean;
  45210. private _soundLoaded;
  45211. /**
  45212. * Sets the data of the sound from an audiobuffer
  45213. * @param audioBuffer The audioBuffer containing the data
  45214. */
  45215. setAudioBuffer(audioBuffer: AudioBuffer): void;
  45216. /**
  45217. * Updates the current sounds options such as maxdistance, loop...
  45218. * @param options A JSON object containing values named as the object properties
  45219. */
  45220. updateOptions(options: ISoundOptions): void;
  45221. private _createSpatialParameters;
  45222. private _updateSpatialParameters;
  45223. /**
  45224. * Switch the panning model to HRTF:
  45225. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  45226. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45227. */
  45228. switchPanningModelToHRTF(): void;
  45229. /**
  45230. * Switch the panning model to Equal Power:
  45231. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  45232. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45233. */
  45234. switchPanningModelToEqualPower(): void;
  45235. private _switchPanningModel;
  45236. /**
  45237. * Connect this sound to a sound track audio node like gain...
  45238. * @param soundTrackAudioNode the sound track audio node to connect to
  45239. */
  45240. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  45241. /**
  45242. * Transform this sound into a directional source
  45243. * @param coneInnerAngle Size of the inner cone in degree
  45244. * @param coneOuterAngle Size of the outer cone in degree
  45245. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  45246. */
  45247. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  45248. /**
  45249. * Gets or sets the inner angle for the directional cone.
  45250. */
  45251. get directionalConeInnerAngle(): number;
  45252. /**
  45253. * Gets or sets the inner angle for the directional cone.
  45254. */
  45255. set directionalConeInnerAngle(value: number);
  45256. /**
  45257. * Gets or sets the outer angle for the directional cone.
  45258. */
  45259. get directionalConeOuterAngle(): number;
  45260. /**
  45261. * Gets or sets the outer angle for the directional cone.
  45262. */
  45263. set directionalConeOuterAngle(value: number);
  45264. /**
  45265. * Sets the position of the emitter if spatial sound is enabled
  45266. * @param newPosition Defines the new posisiton
  45267. */
  45268. setPosition(newPosition: Vector3): void;
  45269. /**
  45270. * Sets the local direction of the emitter if spatial sound is enabled
  45271. * @param newLocalDirection Defines the new local direction
  45272. */
  45273. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  45274. private _updateDirection;
  45275. /** @hidden */
  45276. updateDistanceFromListener(): void;
  45277. /**
  45278. * Sets a new custom attenuation function for the sound.
  45279. * @param callback Defines the function used for the attenuation
  45280. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  45281. */
  45282. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  45283. /**
  45284. * Play the sound
  45285. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  45286. * @param offset (optional) Start the sound at a specific time in seconds
  45287. * @param length (optional) Sound duration (in seconds)
  45288. */
  45289. play(time?: number, offset?: number, length?: number): void;
  45290. private _onended;
  45291. /**
  45292. * Stop the sound
  45293. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  45294. */
  45295. stop(time?: number): void;
  45296. /**
  45297. * Put the sound in pause
  45298. */
  45299. pause(): void;
  45300. /**
  45301. * Sets a dedicated volume for this sounds
  45302. * @param newVolume Define the new volume of the sound
  45303. * @param time Define time for gradual change to new volume
  45304. */
  45305. setVolume(newVolume: number, time?: number): void;
  45306. /**
  45307. * Set the sound play back rate
  45308. * @param newPlaybackRate Define the playback rate the sound should be played at
  45309. */
  45310. setPlaybackRate(newPlaybackRate: number): void;
  45311. /**
  45312. * Gets the volume of the sound.
  45313. * @returns the volume of the sound
  45314. */
  45315. getVolume(): number;
  45316. /**
  45317. * Attach the sound to a dedicated mesh
  45318. * @param transformNode The transform node to connect the sound with
  45319. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  45320. */
  45321. attachToMesh(transformNode: TransformNode): void;
  45322. /**
  45323. * Detach the sound from the previously attached mesh
  45324. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  45325. */
  45326. detachFromMesh(): void;
  45327. private _onRegisterAfterWorldMatrixUpdate;
  45328. /**
  45329. * Clone the current sound in the scene.
  45330. * @returns the new sound clone
  45331. */
  45332. clone(): Nullable<Sound>;
  45333. /**
  45334. * Gets the current underlying audio buffer containing the data
  45335. * @returns the audio buffer
  45336. */
  45337. getAudioBuffer(): Nullable<AudioBuffer>;
  45338. /**
  45339. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  45340. * @returns the source node
  45341. */
  45342. getSoundSource(): Nullable<AudioBufferSourceNode>;
  45343. /**
  45344. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  45345. * @returns the gain node
  45346. */
  45347. getSoundGain(): Nullable<GainNode>;
  45348. /**
  45349. * Serializes the Sound in a JSON representation
  45350. * @returns the JSON representation of the sound
  45351. */
  45352. serialize(): any;
  45353. /**
  45354. * Parse a JSON representation of a sound to innstantiate in a given scene
  45355. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  45356. * @param scene Define the scene the new parsed sound should be created in
  45357. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  45358. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  45359. * @returns the newly parsed sound
  45360. */
  45361. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  45362. }
  45363. }
  45364. declare module BABYLON {
  45365. /**
  45366. * This defines an action helpful to play a defined sound on a triggered action.
  45367. */
  45368. export class PlaySoundAction extends Action {
  45369. private _sound;
  45370. /**
  45371. * Instantiate the action
  45372. * @param triggerOptions defines the trigger options
  45373. * @param sound defines the sound to play
  45374. * @param condition defines the trigger related conditions
  45375. */
  45376. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  45377. /** @hidden */
  45378. _prepare(): void;
  45379. /**
  45380. * Execute the action and play the sound.
  45381. */
  45382. execute(): void;
  45383. /**
  45384. * Serializes the actions and its related information.
  45385. * @param parent defines the object to serialize in
  45386. * @returns the serialized object
  45387. */
  45388. serialize(parent: any): any;
  45389. }
  45390. /**
  45391. * This defines an action helpful to stop a defined sound on a triggered action.
  45392. */
  45393. export class StopSoundAction extends Action {
  45394. private _sound;
  45395. /**
  45396. * Instantiate the action
  45397. * @param triggerOptions defines the trigger options
  45398. * @param sound defines the sound to stop
  45399. * @param condition defines the trigger related conditions
  45400. */
  45401. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  45402. /** @hidden */
  45403. _prepare(): void;
  45404. /**
  45405. * Execute the action and stop the sound.
  45406. */
  45407. execute(): void;
  45408. /**
  45409. * Serializes the actions and its related information.
  45410. * @param parent defines the object to serialize in
  45411. * @returns the serialized object
  45412. */
  45413. serialize(parent: any): any;
  45414. }
  45415. }
  45416. declare module BABYLON {
  45417. /**
  45418. * This defines an action responsible to change the value of a property
  45419. * by interpolating between its current value and the newly set one once triggered.
  45420. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  45421. */
  45422. export class InterpolateValueAction extends Action {
  45423. /**
  45424. * Defines the path of the property where the value should be interpolated
  45425. */
  45426. propertyPath: string;
  45427. /**
  45428. * Defines the target value at the end of the interpolation.
  45429. */
  45430. value: any;
  45431. /**
  45432. * Defines the time it will take for the property to interpolate to the value.
  45433. */
  45434. duration: number;
  45435. /**
  45436. * Defines if the other scene animations should be stopped when the action has been triggered
  45437. */
  45438. stopOtherAnimations?: boolean;
  45439. /**
  45440. * Defines a callback raised once the interpolation animation has been done.
  45441. */
  45442. onInterpolationDone?: () => void;
  45443. /**
  45444. * Observable triggered once the interpolation animation has been done.
  45445. */
  45446. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  45447. private _target;
  45448. private _effectiveTarget;
  45449. private _property;
  45450. /**
  45451. * Instantiate the action
  45452. * @param triggerOptions defines the trigger options
  45453. * @param target defines the object containing the value to interpolate
  45454. * @param propertyPath defines the path to the property in the target object
  45455. * @param value defines the target value at the end of the interpolation
  45456. * @param duration deines the time it will take for the property to interpolate to the value.
  45457. * @param condition defines the trigger related conditions
  45458. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  45459. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  45460. */
  45461. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  45462. /** @hidden */
  45463. _prepare(): void;
  45464. /**
  45465. * Execute the action starts the value interpolation.
  45466. */
  45467. execute(): void;
  45468. /**
  45469. * Serializes the actions and its related information.
  45470. * @param parent defines the object to serialize in
  45471. * @returns the serialized object
  45472. */
  45473. serialize(parent: any): any;
  45474. }
  45475. }
  45476. declare module BABYLON {
  45477. /**
  45478. * This represents the default audio engine used in babylon.
  45479. * It is responsible to play, synchronize and analyse sounds throughout the application.
  45480. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45481. */
  45482. export class AudioEngine implements IAudioEngine {
  45483. private _audioContext;
  45484. private _audioContextInitialized;
  45485. private _muteButton;
  45486. private _hostElement;
  45487. /**
  45488. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  45489. */
  45490. canUseWebAudio: boolean;
  45491. /**
  45492. * The master gain node defines the global audio volume of your audio engine.
  45493. */
  45494. masterGain: GainNode;
  45495. /**
  45496. * Defines if Babylon should emit a warning if WebAudio is not supported.
  45497. * @ignoreNaming
  45498. */
  45499. WarnedWebAudioUnsupported: boolean;
  45500. /**
  45501. * Gets whether or not mp3 are supported by your browser.
  45502. */
  45503. isMP3supported: boolean;
  45504. /**
  45505. * Gets whether or not ogg are supported by your browser.
  45506. */
  45507. isOGGsupported: boolean;
  45508. /**
  45509. * Gets whether audio has been unlocked on the device.
  45510. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  45511. * a user interaction has happened.
  45512. */
  45513. unlocked: boolean;
  45514. /**
  45515. * Defines if the audio engine relies on a custom unlocked button.
  45516. * In this case, the embedded button will not be displayed.
  45517. */
  45518. useCustomUnlockedButton: boolean;
  45519. /**
  45520. * Event raised when audio has been unlocked on the browser.
  45521. */
  45522. onAudioUnlockedObservable: Observable<IAudioEngine>;
  45523. /**
  45524. * Event raised when audio has been locked on the browser.
  45525. */
  45526. onAudioLockedObservable: Observable<IAudioEngine>;
  45527. /**
  45528. * Gets the current AudioContext if available.
  45529. */
  45530. get audioContext(): Nullable<AudioContext>;
  45531. private _connectedAnalyser;
  45532. /**
  45533. * Instantiates a new audio engine.
  45534. *
  45535. * There should be only one per page as some browsers restrict the number
  45536. * of audio contexts you can create.
  45537. * @param hostElement defines the host element where to display the mute icon if necessary
  45538. */
  45539. constructor(hostElement?: Nullable<HTMLElement>);
  45540. /**
  45541. * Flags the audio engine in Locked state.
  45542. * This happens due to new browser policies preventing audio to autoplay.
  45543. */
  45544. lock(): void;
  45545. /**
  45546. * Unlocks the audio engine once a user action has been done on the dom.
  45547. * This is helpful to resume play once browser policies have been satisfied.
  45548. */
  45549. unlock(): void;
  45550. private _resumeAudioContext;
  45551. private _initializeAudioContext;
  45552. private _tryToRun;
  45553. private _triggerRunningState;
  45554. private _triggerSuspendedState;
  45555. private _displayMuteButton;
  45556. private _moveButtonToTopLeft;
  45557. private _onResize;
  45558. private _hideMuteButton;
  45559. /**
  45560. * Destroy and release the resources associated with the audio ccontext.
  45561. */
  45562. dispose(): void;
  45563. /**
  45564. * Gets the global volume sets on the master gain.
  45565. * @returns the global volume if set or -1 otherwise
  45566. */
  45567. getGlobalVolume(): number;
  45568. /**
  45569. * Sets the global volume of your experience (sets on the master gain).
  45570. * @param newVolume Defines the new global volume of the application
  45571. */
  45572. setGlobalVolume(newVolume: number): void;
  45573. /**
  45574. * Connect the audio engine to an audio analyser allowing some amazing
  45575. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  45576. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  45577. * @param analyser The analyser to connect to the engine
  45578. */
  45579. connectToAnalyser(analyser: Analyser): void;
  45580. }
  45581. }
  45582. declare module BABYLON {
  45583. /**
  45584. * Options allowed during the creation of a sound track.
  45585. */
  45586. export interface ISoundTrackOptions {
  45587. /**
  45588. * The volume the sound track should take during creation
  45589. */
  45590. volume?: number;
  45591. /**
  45592. * Define if the sound track is the main sound track of the scene
  45593. */
  45594. mainTrack?: boolean;
  45595. }
  45596. /**
  45597. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  45598. * It will be also used in a future release to apply effects on a specific track.
  45599. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  45600. */
  45601. export class SoundTrack {
  45602. /**
  45603. * The unique identifier of the sound track in the scene.
  45604. */
  45605. id: number;
  45606. /**
  45607. * The list of sounds included in the sound track.
  45608. */
  45609. soundCollection: Array<Sound>;
  45610. private _outputAudioNode;
  45611. private _scene;
  45612. private _connectedAnalyser;
  45613. private _options;
  45614. private _isInitialized;
  45615. /**
  45616. * Creates a new sound track.
  45617. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  45618. * @param scene Define the scene the sound track belongs to
  45619. * @param options
  45620. */
  45621. constructor(scene: Scene, options?: ISoundTrackOptions);
  45622. private _initializeSoundTrackAudioGraph;
  45623. /**
  45624. * Release the sound track and its associated resources
  45625. */
  45626. dispose(): void;
  45627. /**
  45628. * Adds a sound to this sound track
  45629. * @param sound define the cound to add
  45630. * @ignoreNaming
  45631. */
  45632. addSound(sound: Sound): void;
  45633. /**
  45634. * Removes a sound to this sound track
  45635. * @param sound define the cound to remove
  45636. * @ignoreNaming
  45637. */
  45638. removeSound(sound: Sound): void;
  45639. /**
  45640. * Set a global volume for the full sound track.
  45641. * @param newVolume Define the new volume of the sound track
  45642. */
  45643. setVolume(newVolume: number): void;
  45644. /**
  45645. * Switch the panning model to HRTF:
  45646. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  45647. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45648. */
  45649. switchPanningModelToHRTF(): void;
  45650. /**
  45651. * Switch the panning model to Equal Power:
  45652. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  45653. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45654. */
  45655. switchPanningModelToEqualPower(): void;
  45656. /**
  45657. * Connect the sound track to an audio analyser allowing some amazing
  45658. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  45659. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  45660. * @param analyser The analyser to connect to the engine
  45661. */
  45662. connectToAnalyser(analyser: Analyser): void;
  45663. }
  45664. }
  45665. declare module BABYLON {
  45666. interface AbstractScene {
  45667. /**
  45668. * The list of sounds used in the scene.
  45669. */
  45670. sounds: Nullable<Array<Sound>>;
  45671. }
  45672. interface Scene {
  45673. /**
  45674. * @hidden
  45675. * Backing field
  45676. */
  45677. _mainSoundTrack: SoundTrack;
  45678. /**
  45679. * The main sound track played by the scene.
  45680. * It cotains your primary collection of sounds.
  45681. */
  45682. mainSoundTrack: SoundTrack;
  45683. /**
  45684. * The list of sound tracks added to the scene
  45685. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45686. */
  45687. soundTracks: Nullable<Array<SoundTrack>>;
  45688. /**
  45689. * Gets a sound using a given name
  45690. * @param name defines the name to search for
  45691. * @return the found sound or null if not found at all.
  45692. */
  45693. getSoundByName(name: string): Nullable<Sound>;
  45694. /**
  45695. * Gets or sets if audio support is enabled
  45696. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45697. */
  45698. audioEnabled: boolean;
  45699. /**
  45700. * Gets or sets if audio will be output to headphones
  45701. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45702. */
  45703. headphone: boolean;
  45704. /**
  45705. * Gets or sets custom audio listener position provider
  45706. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45707. */
  45708. audioListenerPositionProvider: Nullable<() => Vector3>;
  45709. /**
  45710. * Gets or sets a refresh rate when using 3D audio positioning
  45711. */
  45712. audioPositioningRefreshRate: number;
  45713. }
  45714. /**
  45715. * Defines the sound scene component responsible to manage any sounds
  45716. * in a given scene.
  45717. */
  45718. export class AudioSceneComponent implements ISceneSerializableComponent {
  45719. private static _CameraDirectionLH;
  45720. private static _CameraDirectionRH;
  45721. /**
  45722. * The component name helpfull to identify the component in the list of scene components.
  45723. */
  45724. readonly name: string;
  45725. /**
  45726. * The scene the component belongs to.
  45727. */
  45728. scene: Scene;
  45729. private _audioEnabled;
  45730. /**
  45731. * Gets whether audio is enabled or not.
  45732. * Please use related enable/disable method to switch state.
  45733. */
  45734. get audioEnabled(): boolean;
  45735. private _headphone;
  45736. /**
  45737. * Gets whether audio is outputing to headphone or not.
  45738. * Please use the according Switch methods to change output.
  45739. */
  45740. get headphone(): boolean;
  45741. /**
  45742. * Gets or sets a refresh rate when using 3D audio positioning
  45743. */
  45744. audioPositioningRefreshRate: number;
  45745. private _audioListenerPositionProvider;
  45746. /**
  45747. * Gets the current audio listener position provider
  45748. */
  45749. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  45750. /**
  45751. * Sets a custom listener position for all sounds in the scene
  45752. * By default, this is the position of the first active camera
  45753. */
  45754. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  45755. /**
  45756. * Creates a new instance of the component for the given scene
  45757. * @param scene Defines the scene to register the component in
  45758. */
  45759. constructor(scene: Scene);
  45760. /**
  45761. * Registers the component in a given scene
  45762. */
  45763. register(): void;
  45764. /**
  45765. * Rebuilds the elements related to this component in case of
  45766. * context lost for instance.
  45767. */
  45768. rebuild(): void;
  45769. /**
  45770. * Serializes the component data to the specified json object
  45771. * @param serializationObject The object to serialize to
  45772. */
  45773. serialize(serializationObject: any): void;
  45774. /**
  45775. * Adds all the elements from the container to the scene
  45776. * @param container the container holding the elements
  45777. */
  45778. addFromContainer(container: AbstractScene): void;
  45779. /**
  45780. * Removes all the elements in the container from the scene
  45781. * @param container contains the elements to remove
  45782. * @param dispose if the removed element should be disposed (default: false)
  45783. */
  45784. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  45785. /**
  45786. * Disposes the component and the associated ressources.
  45787. */
  45788. dispose(): void;
  45789. /**
  45790. * Disables audio in the associated scene.
  45791. */
  45792. disableAudio(): void;
  45793. /**
  45794. * Enables audio in the associated scene.
  45795. */
  45796. enableAudio(): void;
  45797. /**
  45798. * Switch audio to headphone output.
  45799. */
  45800. switchAudioModeForHeadphones(): void;
  45801. /**
  45802. * Switch audio to normal speakers.
  45803. */
  45804. switchAudioModeForNormalSpeakers(): void;
  45805. private _cachedCameraDirection;
  45806. private _cachedCameraPosition;
  45807. private _lastCheck;
  45808. private _afterRender;
  45809. }
  45810. }
  45811. declare module BABYLON {
  45812. /**
  45813. * Wraps one or more Sound objects and selects one with random weight for playback.
  45814. */
  45815. export class WeightedSound {
  45816. /** When true a Sound will be selected and played when the current playing Sound completes. */
  45817. loop: boolean;
  45818. private _coneInnerAngle;
  45819. private _coneOuterAngle;
  45820. private _volume;
  45821. /** A Sound is currently playing. */
  45822. isPlaying: boolean;
  45823. /** A Sound is currently paused. */
  45824. isPaused: boolean;
  45825. private _sounds;
  45826. private _weights;
  45827. private _currentIndex?;
  45828. /**
  45829. * Creates a new WeightedSound from the list of sounds given.
  45830. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  45831. * @param sounds Array of Sounds that will be selected from.
  45832. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  45833. */
  45834. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  45835. /**
  45836. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  45837. */
  45838. get directionalConeInnerAngle(): number;
  45839. /**
  45840. * The size of cone in degress for a directional sound in which there will be no attenuation.
  45841. */
  45842. set directionalConeInnerAngle(value: number);
  45843. /**
  45844. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45845. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45846. */
  45847. get directionalConeOuterAngle(): number;
  45848. /**
  45849. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45850. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45851. */
  45852. set directionalConeOuterAngle(value: number);
  45853. /**
  45854. * Playback volume.
  45855. */
  45856. get volume(): number;
  45857. /**
  45858. * Playback volume.
  45859. */
  45860. set volume(value: number);
  45861. private _onended;
  45862. /**
  45863. * Suspend playback
  45864. */
  45865. pause(): void;
  45866. /**
  45867. * Stop playback
  45868. */
  45869. stop(): void;
  45870. /**
  45871. * Start playback.
  45872. * @param startOffset Position the clip head at a specific time in seconds.
  45873. */
  45874. play(startOffset?: number): void;
  45875. }
  45876. }
  45877. declare module BABYLON {
  45878. /**
  45879. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  45880. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  45881. */
  45882. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  45883. /**
  45884. * Gets the name of the behavior.
  45885. */
  45886. get name(): string;
  45887. /**
  45888. * The easing function used by animations
  45889. */
  45890. static EasingFunction: BackEase;
  45891. /**
  45892. * The easing mode used by animations
  45893. */
  45894. static EasingMode: number;
  45895. /**
  45896. * The duration of the animation, in milliseconds
  45897. */
  45898. transitionDuration: number;
  45899. /**
  45900. * Length of the distance animated by the transition when lower radius is reached
  45901. */
  45902. lowerRadiusTransitionRange: number;
  45903. /**
  45904. * Length of the distance animated by the transition when upper radius is reached
  45905. */
  45906. upperRadiusTransitionRange: number;
  45907. private _autoTransitionRange;
  45908. /**
  45909. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45910. */
  45911. get autoTransitionRange(): boolean;
  45912. /**
  45913. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45914. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  45915. */
  45916. set autoTransitionRange(value: boolean);
  45917. private _attachedCamera;
  45918. private _onAfterCheckInputsObserver;
  45919. private _onMeshTargetChangedObserver;
  45920. /**
  45921. * Initializes the behavior.
  45922. */
  45923. init(): void;
  45924. /**
  45925. * Attaches the behavior to its arc rotate camera.
  45926. * @param camera Defines the camera to attach the behavior to
  45927. */
  45928. attach(camera: ArcRotateCamera): void;
  45929. /**
  45930. * Detaches the behavior from its current arc rotate camera.
  45931. */
  45932. detach(): void;
  45933. private _radiusIsAnimating;
  45934. private _radiusBounceTransition;
  45935. private _animatables;
  45936. private _cachedWheelPrecision;
  45937. /**
  45938. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  45939. * @param radiusLimit The limit to check against.
  45940. * @return Bool to indicate if at limit.
  45941. */
  45942. private _isRadiusAtLimit;
  45943. /**
  45944. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  45945. * @param radiusDelta The delta by which to animate to. Can be negative.
  45946. */
  45947. private _applyBoundRadiusAnimation;
  45948. /**
  45949. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  45950. */
  45951. protected _clearAnimationLocks(): void;
  45952. /**
  45953. * Stops and removes all animations that have been applied to the camera
  45954. */
  45955. stopAllAnimations(): void;
  45956. }
  45957. }
  45958. declare module BABYLON {
  45959. /**
  45960. * 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.
  45961. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  45962. */
  45963. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  45964. /**
  45965. * Gets the name of the behavior.
  45966. */
  45967. get name(): string;
  45968. private _mode;
  45969. private _radiusScale;
  45970. private _positionScale;
  45971. private _defaultElevation;
  45972. private _elevationReturnTime;
  45973. private _elevationReturnWaitTime;
  45974. private _zoomStopsAnimation;
  45975. private _framingTime;
  45976. /**
  45977. * The easing function used by animations
  45978. */
  45979. static EasingFunction: ExponentialEase;
  45980. /**
  45981. * The easing mode used by animations
  45982. */
  45983. static EasingMode: number;
  45984. /**
  45985. * Sets the current mode used by the behavior
  45986. */
  45987. set mode(mode: number);
  45988. /**
  45989. * Gets current mode used by the behavior.
  45990. */
  45991. get mode(): number;
  45992. /**
  45993. * Sets the scale applied to the radius (1 by default)
  45994. */
  45995. set radiusScale(radius: number);
  45996. /**
  45997. * Gets the scale applied to the radius
  45998. */
  45999. get radiusScale(): number;
  46000. /**
  46001. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  46002. */
  46003. set positionScale(scale: number);
  46004. /**
  46005. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  46006. */
  46007. get positionScale(): number;
  46008. /**
  46009. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  46010. * behaviour is triggered, in radians.
  46011. */
  46012. set defaultElevation(elevation: number);
  46013. /**
  46014. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  46015. * behaviour is triggered, in radians.
  46016. */
  46017. get defaultElevation(): number;
  46018. /**
  46019. * Sets the time (in milliseconds) taken to return to the default beta position.
  46020. * Negative value indicates camera should not return to default.
  46021. */
  46022. set elevationReturnTime(speed: number);
  46023. /**
  46024. * Gets the time (in milliseconds) taken to return to the default beta position.
  46025. * Negative value indicates camera should not return to default.
  46026. */
  46027. get elevationReturnTime(): number;
  46028. /**
  46029. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  46030. */
  46031. set elevationReturnWaitTime(time: number);
  46032. /**
  46033. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  46034. */
  46035. get elevationReturnWaitTime(): number;
  46036. /**
  46037. * Sets the flag that indicates if user zooming should stop animation.
  46038. */
  46039. set zoomStopsAnimation(flag: boolean);
  46040. /**
  46041. * Gets the flag that indicates if user zooming should stop animation.
  46042. */
  46043. get zoomStopsAnimation(): boolean;
  46044. /**
  46045. * Sets the transition time when framing the mesh, in milliseconds
  46046. */
  46047. set framingTime(time: number);
  46048. /**
  46049. * Gets the transition time when framing the mesh, in milliseconds
  46050. */
  46051. get framingTime(): number;
  46052. /**
  46053. * Define if the behavior should automatically change the configured
  46054. * camera limits and sensibilities.
  46055. */
  46056. autoCorrectCameraLimitsAndSensibility: boolean;
  46057. private _onPrePointerObservableObserver;
  46058. private _onAfterCheckInputsObserver;
  46059. private _onMeshTargetChangedObserver;
  46060. private _attachedCamera;
  46061. private _isPointerDown;
  46062. private _lastInteractionTime;
  46063. /**
  46064. * Initializes the behavior.
  46065. */
  46066. init(): void;
  46067. /**
  46068. * Attaches the behavior to its arc rotate camera.
  46069. * @param camera Defines the camera to attach the behavior to
  46070. */
  46071. attach(camera: ArcRotateCamera): void;
  46072. /**
  46073. * Detaches the behavior from its current arc rotate camera.
  46074. */
  46075. detach(): void;
  46076. private _animatables;
  46077. private _betaIsAnimating;
  46078. private _betaTransition;
  46079. private _radiusTransition;
  46080. private _vectorTransition;
  46081. /**
  46082. * Targets the given mesh and updates zoom level accordingly.
  46083. * @param mesh The mesh to target.
  46084. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  46085. * @param onAnimationEnd Callback triggered at the end of the framing animation
  46086. */
  46087. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  46088. /**
  46089. * Targets the given mesh with its children and updates zoom level accordingly.
  46090. * @param mesh The mesh to target.
  46091. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  46092. * @param onAnimationEnd Callback triggered at the end of the framing animation
  46093. */
  46094. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  46095. /**
  46096. * Targets the given meshes with their children and updates zoom level accordingly.
  46097. * @param meshes The mesh to target.
  46098. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  46099. * @param onAnimationEnd Callback triggered at the end of the framing animation
  46100. */
  46101. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  46102. /**
  46103. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  46104. * @param minimumWorld Determines the smaller position of the bounding box extend
  46105. * @param maximumWorld Determines the bigger position of the bounding box extend
  46106. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  46107. * @param onAnimationEnd Callback triggered at the end of the framing animation
  46108. */
  46109. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  46110. /**
  46111. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  46112. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  46113. * frustum width.
  46114. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  46115. * to fully enclose the mesh in the viewing frustum.
  46116. */
  46117. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  46118. /**
  46119. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  46120. * is automatically returned to its default position (expected to be above ground plane).
  46121. */
  46122. private _maintainCameraAboveGround;
  46123. /**
  46124. * Returns the frustum slope based on the canvas ratio and camera FOV
  46125. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  46126. */
  46127. private _getFrustumSlope;
  46128. /**
  46129. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  46130. */
  46131. private _clearAnimationLocks;
  46132. /**
  46133. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  46134. */
  46135. private _applyUserInteraction;
  46136. /**
  46137. * Stops and removes all animations that have been applied to the camera
  46138. */
  46139. stopAllAnimations(): void;
  46140. /**
  46141. * Gets a value indicating if the user is moving the camera
  46142. */
  46143. get isUserIsMoving(): boolean;
  46144. /**
  46145. * The camera can move all the way towards the mesh.
  46146. */
  46147. static IgnoreBoundsSizeMode: number;
  46148. /**
  46149. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  46150. */
  46151. static FitFrustumSidesMode: number;
  46152. }
  46153. }
  46154. declare module BABYLON {
  46155. /**
  46156. * Base class for Camera Pointer Inputs.
  46157. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  46158. * for example usage.
  46159. */
  46160. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  46161. /**
  46162. * Defines the camera the input is attached to.
  46163. */
  46164. abstract camera: Camera;
  46165. /**
  46166. * Whether keyboard modifier keys are pressed at time of last mouse event.
  46167. */
  46168. protected _altKey: boolean;
  46169. protected _ctrlKey: boolean;
  46170. protected _metaKey: boolean;
  46171. protected _shiftKey: boolean;
  46172. /**
  46173. * Which mouse buttons were pressed at time of last mouse event.
  46174. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  46175. */
  46176. protected _buttonsPressed: number;
  46177. /**
  46178. * Defines the buttons associated with the input to handle camera move.
  46179. */
  46180. buttons: number[];
  46181. /**
  46182. * Attach the input controls to a specific dom element to get the input from.
  46183. * @param element Defines the element the controls should be listened from
  46184. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46185. */
  46186. attachControl(noPreventDefault?: boolean): void;
  46187. /**
  46188. * Detach the current controls from the specified dom element.
  46189. */
  46190. detachControl(): void;
  46191. /**
  46192. * Gets the class name of the current input.
  46193. * @returns the class name
  46194. */
  46195. getClassName(): string;
  46196. /**
  46197. * Get the friendly name associated with the input class.
  46198. * @returns the input friendly name
  46199. */
  46200. getSimpleName(): string;
  46201. /**
  46202. * Called on pointer POINTERDOUBLETAP event.
  46203. * Override this method to provide functionality on POINTERDOUBLETAP event.
  46204. */
  46205. protected onDoubleTap(type: string): void;
  46206. /**
  46207. * Called on pointer POINTERMOVE event if only a single touch is active.
  46208. * Override this method to provide functionality.
  46209. */
  46210. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46211. /**
  46212. * Called on pointer POINTERMOVE event if multiple touches are active.
  46213. * Override this method to provide functionality.
  46214. */
  46215. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46216. /**
  46217. * Called on JS contextmenu event.
  46218. * Override this method to provide functionality.
  46219. */
  46220. protected onContextMenu(evt: PointerEvent): void;
  46221. /**
  46222. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  46223. * press.
  46224. * Override this method to provide functionality.
  46225. */
  46226. protected onButtonDown(evt: PointerEvent): void;
  46227. /**
  46228. * Called each time a new POINTERUP event occurs. Ie, for each button
  46229. * release.
  46230. * Override this method to provide functionality.
  46231. */
  46232. protected onButtonUp(evt: PointerEvent): void;
  46233. /**
  46234. * Called when window becomes inactive.
  46235. * Override this method to provide functionality.
  46236. */
  46237. protected onLostFocus(): void;
  46238. private _pointerInput;
  46239. private _observer;
  46240. private _onLostFocus;
  46241. private pointA;
  46242. private pointB;
  46243. }
  46244. }
  46245. declare module BABYLON {
  46246. /**
  46247. * Manage the pointers inputs to control an arc rotate camera.
  46248. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46249. */
  46250. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  46251. /**
  46252. * Defines the camera the input is attached to.
  46253. */
  46254. camera: ArcRotateCamera;
  46255. /**
  46256. * Gets the class name of the current input.
  46257. * @returns the class name
  46258. */
  46259. getClassName(): string;
  46260. /**
  46261. * Defines the buttons associated with the input to handle camera move.
  46262. */
  46263. buttons: number[];
  46264. /**
  46265. * Defines the pointer angular sensibility along the X axis or how fast is
  46266. * the camera rotating.
  46267. */
  46268. angularSensibilityX: number;
  46269. /**
  46270. * Defines the pointer angular sensibility along the Y axis or how fast is
  46271. * the camera rotating.
  46272. */
  46273. angularSensibilityY: number;
  46274. /**
  46275. * Defines the pointer pinch precision or how fast is the camera zooming.
  46276. */
  46277. pinchPrecision: number;
  46278. /**
  46279. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  46280. * from 0.
  46281. * It defines the percentage of current camera.radius to use as delta when
  46282. * pinch zoom is used.
  46283. */
  46284. pinchDeltaPercentage: number;
  46285. /**
  46286. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  46287. * that any object in the plane at the camera's target point will scale
  46288. * perfectly with finger motion.
  46289. * Overrides pinchDeltaPercentage and pinchPrecision.
  46290. */
  46291. useNaturalPinchZoom: boolean;
  46292. /**
  46293. * Defines the pointer panning sensibility or how fast is the camera moving.
  46294. */
  46295. panningSensibility: number;
  46296. /**
  46297. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  46298. */
  46299. multiTouchPanning: boolean;
  46300. /**
  46301. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  46302. * zoom (pinch) through multitouch.
  46303. */
  46304. multiTouchPanAndZoom: boolean;
  46305. /**
  46306. * Revers pinch action direction.
  46307. */
  46308. pinchInwards: boolean;
  46309. private _isPanClick;
  46310. private _twoFingerActivityCount;
  46311. private _isPinching;
  46312. /**
  46313. * Called on pointer POINTERMOVE event if only a single touch is active.
  46314. */
  46315. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46316. /**
  46317. * Called on pointer POINTERDOUBLETAP event.
  46318. */
  46319. protected onDoubleTap(type: string): void;
  46320. /**
  46321. * Called on pointer POINTERMOVE event if multiple touches are active.
  46322. */
  46323. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46324. /**
  46325. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  46326. * press.
  46327. */
  46328. protected onButtonDown(evt: PointerEvent): void;
  46329. /**
  46330. * Called each time a new POINTERUP event occurs. Ie, for each button
  46331. * release.
  46332. */
  46333. protected onButtonUp(evt: PointerEvent): void;
  46334. /**
  46335. * Called when window becomes inactive.
  46336. */
  46337. protected onLostFocus(): void;
  46338. }
  46339. }
  46340. declare module BABYLON {
  46341. /**
  46342. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  46343. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46344. */
  46345. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  46346. /**
  46347. * Defines the camera the input is attached to.
  46348. */
  46349. camera: ArcRotateCamera;
  46350. /**
  46351. * Defines the list of key codes associated with the up action (increase alpha)
  46352. */
  46353. keysUp: number[];
  46354. /**
  46355. * Defines the list of key codes associated with the down action (decrease alpha)
  46356. */
  46357. keysDown: number[];
  46358. /**
  46359. * Defines the list of key codes associated with the left action (increase beta)
  46360. */
  46361. keysLeft: number[];
  46362. /**
  46363. * Defines the list of key codes associated with the right action (decrease beta)
  46364. */
  46365. keysRight: number[];
  46366. /**
  46367. * Defines the list of key codes associated with the reset action.
  46368. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  46369. */
  46370. keysReset: number[];
  46371. /**
  46372. * Defines the panning sensibility of the inputs.
  46373. * (How fast is the camera panning)
  46374. */
  46375. panningSensibility: number;
  46376. /**
  46377. * Defines the zooming sensibility of the inputs.
  46378. * (How fast is the camera zooming)
  46379. */
  46380. zoomingSensibility: number;
  46381. /**
  46382. * Defines whether maintaining the alt key down switch the movement mode from
  46383. * orientation to zoom.
  46384. */
  46385. useAltToZoom: boolean;
  46386. /**
  46387. * Rotation speed of the camera
  46388. */
  46389. angularSpeed: number;
  46390. private _keys;
  46391. private _ctrlPressed;
  46392. private _altPressed;
  46393. private _onCanvasBlurObserver;
  46394. private _onKeyboardObserver;
  46395. private _engine;
  46396. private _scene;
  46397. /**
  46398. * Attach the input controls to a specific dom element to get the input from.
  46399. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46400. */
  46401. attachControl(noPreventDefault?: boolean): void;
  46402. /**
  46403. * Detach the current controls from the specified dom element.
  46404. */
  46405. detachControl(): void;
  46406. /**
  46407. * Update the current camera state depending on the inputs that have been used this frame.
  46408. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46409. */
  46410. checkInputs(): void;
  46411. /**
  46412. * Gets the class name of the current intput.
  46413. * @returns the class name
  46414. */
  46415. getClassName(): string;
  46416. /**
  46417. * Get the friendly name associated with the input class.
  46418. * @returns the input friendly name
  46419. */
  46420. getSimpleName(): string;
  46421. }
  46422. }
  46423. declare module BABYLON {
  46424. /**
  46425. * Manage the mouse wheel inputs to control an arc rotate camera.
  46426. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46427. */
  46428. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  46429. /**
  46430. * Defines the camera the input is attached to.
  46431. */
  46432. camera: ArcRotateCamera;
  46433. /**
  46434. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  46435. */
  46436. wheelPrecision: number;
  46437. /**
  46438. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  46439. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  46440. */
  46441. wheelDeltaPercentage: number;
  46442. private _wheel;
  46443. private _observer;
  46444. private computeDeltaFromMouseWheelLegacyEvent;
  46445. /**
  46446. * Attach the input controls to a specific dom element to get the input from.
  46447. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46448. */
  46449. attachControl(noPreventDefault?: boolean): void;
  46450. /**
  46451. * Detach the current controls from the specified dom element.
  46452. */
  46453. detachControl(): void;
  46454. /**
  46455. * Gets the class name of the current intput.
  46456. * @returns the class name
  46457. */
  46458. getClassName(): string;
  46459. /**
  46460. * Get the friendly name associated with the input class.
  46461. * @returns the input friendly name
  46462. */
  46463. getSimpleName(): string;
  46464. }
  46465. }
  46466. declare module BABYLON {
  46467. /**
  46468. * Default Inputs manager for the ArcRotateCamera.
  46469. * It groups all the default supported inputs for ease of use.
  46470. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46471. */
  46472. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  46473. /**
  46474. * Instantiates a new ArcRotateCameraInputsManager.
  46475. * @param camera Defines the camera the inputs belong to
  46476. */
  46477. constructor(camera: ArcRotateCamera);
  46478. /**
  46479. * Add mouse wheel input support to the input manager.
  46480. * @returns the current input manager
  46481. */
  46482. addMouseWheel(): ArcRotateCameraInputsManager;
  46483. /**
  46484. * Add pointers input support to the input manager.
  46485. * @returns the current input manager
  46486. */
  46487. addPointers(): ArcRotateCameraInputsManager;
  46488. /**
  46489. * Add keyboard input support to the input manager.
  46490. * @returns the current input manager
  46491. */
  46492. addKeyboard(): ArcRotateCameraInputsManager;
  46493. }
  46494. }
  46495. declare module BABYLON {
  46496. /**
  46497. * This represents an orbital type of camera.
  46498. *
  46499. * 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.
  46500. * 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.
  46501. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  46502. */
  46503. export class ArcRotateCamera extends TargetCamera {
  46504. /**
  46505. * Defines the rotation angle of the camera along the longitudinal axis.
  46506. */
  46507. alpha: number;
  46508. /**
  46509. * Defines the rotation angle of the camera along the latitudinal axis.
  46510. */
  46511. beta: number;
  46512. /**
  46513. * Defines the radius of the camera from it s target point.
  46514. */
  46515. radius: number;
  46516. protected _target: Vector3;
  46517. protected _targetHost: Nullable<AbstractMesh>;
  46518. /**
  46519. * Defines the target point of the camera.
  46520. * The camera looks towards it form the radius distance.
  46521. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  46522. */
  46523. get target(): Vector3;
  46524. set target(value: Vector3);
  46525. /**
  46526. * Define the current local position of the camera in the scene
  46527. */
  46528. get position(): Vector3;
  46529. set position(newPosition: Vector3);
  46530. protected _upToYMatrix: Matrix;
  46531. protected _YToUpMatrix: Matrix;
  46532. /**
  46533. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  46534. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  46535. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  46536. */
  46537. set upVector(vec: Vector3);
  46538. get upVector(): Vector3;
  46539. /**
  46540. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  46541. */
  46542. setMatUp(): void;
  46543. /**
  46544. * Current inertia value on the longitudinal axis.
  46545. * The bigger this number the longer it will take for the camera to stop.
  46546. */
  46547. inertialAlphaOffset: number;
  46548. /**
  46549. * Current inertia value on the latitudinal axis.
  46550. * The bigger this number the longer it will take for the camera to stop.
  46551. */
  46552. inertialBetaOffset: number;
  46553. /**
  46554. * Current inertia value on the radius axis.
  46555. * The bigger this number the longer it will take for the camera to stop.
  46556. */
  46557. inertialRadiusOffset: number;
  46558. /**
  46559. * Minimum allowed angle on the longitudinal axis.
  46560. * This can help limiting how the Camera is able to move in the scene.
  46561. */
  46562. lowerAlphaLimit: Nullable<number>;
  46563. /**
  46564. * Maximum allowed angle on the longitudinal axis.
  46565. * This can help limiting how the Camera is able to move in the scene.
  46566. */
  46567. upperAlphaLimit: Nullable<number>;
  46568. /**
  46569. * Minimum allowed angle on the latitudinal axis.
  46570. * This can help limiting how the Camera is able to move in the scene.
  46571. */
  46572. lowerBetaLimit: number;
  46573. /**
  46574. * Maximum allowed angle on the latitudinal axis.
  46575. * This can help limiting how the Camera is able to move in the scene.
  46576. */
  46577. upperBetaLimit: number;
  46578. /**
  46579. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  46580. * This can help limiting how the Camera is able to move in the scene.
  46581. */
  46582. lowerRadiusLimit: Nullable<number>;
  46583. /**
  46584. * Maximum allowed distance of the camera to the target (The camera can not get further).
  46585. * This can help limiting how the Camera is able to move in the scene.
  46586. */
  46587. upperRadiusLimit: Nullable<number>;
  46588. /**
  46589. * Defines the current inertia value used during panning of the camera along the X axis.
  46590. */
  46591. inertialPanningX: number;
  46592. /**
  46593. * Defines the current inertia value used during panning of the camera along the Y axis.
  46594. */
  46595. inertialPanningY: number;
  46596. /**
  46597. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  46598. * Basically if your fingers moves away from more than this distance you will be considered
  46599. * in pinch mode.
  46600. */
  46601. pinchToPanMaxDistance: number;
  46602. /**
  46603. * Defines the maximum distance the camera can pan.
  46604. * This could help keeping the cammera always in your scene.
  46605. */
  46606. panningDistanceLimit: Nullable<number>;
  46607. /**
  46608. * Defines the target of the camera before paning.
  46609. */
  46610. panningOriginTarget: Vector3;
  46611. /**
  46612. * Defines the value of the inertia used during panning.
  46613. * 0 would mean stop inertia and one would mean no decelleration at all.
  46614. */
  46615. panningInertia: number;
  46616. /**
  46617. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  46618. */
  46619. get angularSensibilityX(): number;
  46620. set angularSensibilityX(value: number);
  46621. /**
  46622. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  46623. */
  46624. get angularSensibilityY(): number;
  46625. set angularSensibilityY(value: number);
  46626. /**
  46627. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  46628. */
  46629. get pinchPrecision(): number;
  46630. set pinchPrecision(value: number);
  46631. /**
  46632. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  46633. * It will be used instead of pinchDeltaPrecision if different from 0.
  46634. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46635. */
  46636. get pinchDeltaPercentage(): number;
  46637. set pinchDeltaPercentage(value: number);
  46638. /**
  46639. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  46640. * and pinch delta percentage.
  46641. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  46642. * that any object in the plane at the camera's target point will scale
  46643. * perfectly with finger motion.
  46644. */
  46645. get useNaturalPinchZoom(): boolean;
  46646. set useNaturalPinchZoom(value: boolean);
  46647. /**
  46648. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  46649. */
  46650. get panningSensibility(): number;
  46651. set panningSensibility(value: number);
  46652. /**
  46653. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  46654. */
  46655. get keysUp(): number[];
  46656. set keysUp(value: number[]);
  46657. /**
  46658. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  46659. */
  46660. get keysDown(): number[];
  46661. set keysDown(value: number[]);
  46662. /**
  46663. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  46664. */
  46665. get keysLeft(): number[];
  46666. set keysLeft(value: number[]);
  46667. /**
  46668. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  46669. */
  46670. get keysRight(): number[];
  46671. set keysRight(value: number[]);
  46672. /**
  46673. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  46674. */
  46675. get wheelPrecision(): number;
  46676. set wheelPrecision(value: number);
  46677. /**
  46678. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  46679. * It will be used instead of pinchDeltaPrecision if different from 0.
  46680. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46681. */
  46682. get wheelDeltaPercentage(): number;
  46683. set wheelDeltaPercentage(value: number);
  46684. /**
  46685. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  46686. */
  46687. zoomOnFactor: number;
  46688. /**
  46689. * Defines a screen offset for the camera position.
  46690. */
  46691. targetScreenOffset: Vector2;
  46692. /**
  46693. * Allows the camera to be completely reversed.
  46694. * If false the camera can not arrive upside down.
  46695. */
  46696. allowUpsideDown: boolean;
  46697. /**
  46698. * Define if double tap/click is used to restore the previously saved state of the camera.
  46699. */
  46700. useInputToRestoreState: boolean;
  46701. /** @hidden */
  46702. _viewMatrix: Matrix;
  46703. /** @hidden */
  46704. _useCtrlForPanning: boolean;
  46705. /** @hidden */
  46706. _panningMouseButton: number;
  46707. /**
  46708. * Defines the input associated to the camera.
  46709. */
  46710. inputs: ArcRotateCameraInputsManager;
  46711. /** @hidden */
  46712. _reset: () => void;
  46713. /**
  46714. * Defines the allowed panning axis.
  46715. */
  46716. panningAxis: Vector3;
  46717. protected _localDirection: Vector3;
  46718. protected _transformedDirection: Vector3;
  46719. private _bouncingBehavior;
  46720. /**
  46721. * Gets the bouncing behavior of the camera if it has been enabled.
  46722. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46723. */
  46724. get bouncingBehavior(): Nullable<BouncingBehavior>;
  46725. /**
  46726. * Defines if the bouncing behavior of the camera is enabled on the camera.
  46727. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46728. */
  46729. get useBouncingBehavior(): boolean;
  46730. set useBouncingBehavior(value: boolean);
  46731. private _framingBehavior;
  46732. /**
  46733. * Gets the framing behavior of the camera if it has been enabled.
  46734. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46735. */
  46736. get framingBehavior(): Nullable<FramingBehavior>;
  46737. /**
  46738. * Defines if the framing behavior of the camera is enabled on the camera.
  46739. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46740. */
  46741. get useFramingBehavior(): boolean;
  46742. set useFramingBehavior(value: boolean);
  46743. private _autoRotationBehavior;
  46744. /**
  46745. * Gets the auto rotation behavior of the camera if it has been enabled.
  46746. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46747. */
  46748. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  46749. /**
  46750. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  46751. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46752. */
  46753. get useAutoRotationBehavior(): boolean;
  46754. set useAutoRotationBehavior(value: boolean);
  46755. /**
  46756. * Observable triggered when the mesh target has been changed on the camera.
  46757. */
  46758. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  46759. /**
  46760. * Event raised when the camera is colliding with a mesh.
  46761. */
  46762. onCollide: (collidedMesh: AbstractMesh) => void;
  46763. /**
  46764. * Defines whether the camera should check collision with the objects oh the scene.
  46765. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  46766. */
  46767. checkCollisions: boolean;
  46768. /**
  46769. * Defines the collision radius of the camera.
  46770. * This simulates a sphere around the camera.
  46771. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  46772. */
  46773. collisionRadius: Vector3;
  46774. protected _collider: Collider;
  46775. protected _previousPosition: Vector3;
  46776. protected _collisionVelocity: Vector3;
  46777. protected _newPosition: Vector3;
  46778. protected _previousAlpha: number;
  46779. protected _previousBeta: number;
  46780. protected _previousRadius: number;
  46781. protected _collisionTriggered: boolean;
  46782. protected _targetBoundingCenter: Nullable<Vector3>;
  46783. private _computationVector;
  46784. /**
  46785. * Instantiates a new ArcRotateCamera in a given scene
  46786. * @param name Defines the name of the camera
  46787. * @param alpha Defines the camera rotation along the logitudinal axis
  46788. * @param beta Defines the camera rotation along the latitudinal axis
  46789. * @param radius Defines the camera distance from its target
  46790. * @param target Defines the camera target
  46791. * @param scene Defines the scene the camera belongs to
  46792. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  46793. */
  46794. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  46795. /** @hidden */
  46796. _initCache(): void;
  46797. /** @hidden */
  46798. _updateCache(ignoreParentClass?: boolean): void;
  46799. protected _getTargetPosition(): Vector3;
  46800. private _storedAlpha;
  46801. private _storedBeta;
  46802. private _storedRadius;
  46803. private _storedTarget;
  46804. private _storedTargetScreenOffset;
  46805. /**
  46806. * Stores the current state of the camera (alpha, beta, radius and target)
  46807. * @returns the camera itself
  46808. */
  46809. storeState(): Camera;
  46810. /**
  46811. * @hidden
  46812. * Restored camera state. You must call storeState() first
  46813. */
  46814. _restoreStateValues(): boolean;
  46815. /** @hidden */
  46816. _isSynchronizedViewMatrix(): boolean;
  46817. /**
  46818. * Attach the input controls to a specific dom element to get the input from.
  46819. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46820. */
  46821. attachControl(noPreventDefault?: boolean): void;
  46822. /**
  46823. * Attach the input controls to a specific dom element to get the input from.
  46824. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  46825. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46826. */
  46827. attachControl(ignored: any, noPreventDefault?: boolean): void;
  46828. /**
  46829. * Attached controls to the current camera.
  46830. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46831. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46832. */
  46833. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  46834. /**
  46835. * Attached controls to the current camera.
  46836. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  46837. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46838. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46839. */
  46840. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  46841. /**
  46842. * Attached controls to the current camera.
  46843. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46844. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46845. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  46846. */
  46847. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  46848. /**
  46849. * Detach the current controls from the specified dom element.
  46850. */
  46851. detachControl(): void;
  46852. /**
  46853. * Detach the current controls from the specified dom element.
  46854. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  46855. */
  46856. detachControl(ignored: any): void;
  46857. /** @hidden */
  46858. _checkInputs(): void;
  46859. protected _checkLimits(): void;
  46860. /**
  46861. * Rebuilds angles (alpha, beta) and radius from the give position and target
  46862. */
  46863. rebuildAnglesAndRadius(): void;
  46864. /**
  46865. * Use a position to define the current camera related information like alpha, beta and radius
  46866. * @param position Defines the position to set the camera at
  46867. */
  46868. setPosition(position: Vector3): void;
  46869. /**
  46870. * Defines the target the camera should look at.
  46871. * This will automatically adapt alpha beta and radius to fit within the new target.
  46872. * @param target Defines the new target as a Vector or a mesh
  46873. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  46874. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  46875. */
  46876. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  46877. /** @hidden */
  46878. _getViewMatrix(): Matrix;
  46879. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  46880. /**
  46881. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  46882. * @param meshes Defines the mesh to zoom on
  46883. * @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)
  46884. */
  46885. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  46886. /**
  46887. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  46888. * The target will be changed but the radius
  46889. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  46890. * @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)
  46891. */
  46892. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  46893. min: Vector3;
  46894. max: Vector3;
  46895. distance: number;
  46896. }, doNotUpdateMaxZ?: boolean): void;
  46897. /**
  46898. * @override
  46899. * Override Camera.createRigCamera
  46900. */
  46901. createRigCamera(name: string, cameraIndex: number): Camera;
  46902. /**
  46903. * @hidden
  46904. * @override
  46905. * Override Camera._updateRigCameras
  46906. */
  46907. _updateRigCameras(): void;
  46908. /**
  46909. * Destroy the camera and release the current resources hold by it.
  46910. */
  46911. dispose(): void;
  46912. /**
  46913. * Gets the current object class name.
  46914. * @return the class name
  46915. */
  46916. getClassName(): string;
  46917. }
  46918. }
  46919. declare module BABYLON {
  46920. /**
  46921. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  46922. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46923. */
  46924. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  46925. /**
  46926. * Gets the name of the behavior.
  46927. */
  46928. get name(): string;
  46929. private _zoomStopsAnimation;
  46930. private _idleRotationSpeed;
  46931. private _idleRotationWaitTime;
  46932. private _idleRotationSpinupTime;
  46933. /**
  46934. * Sets the flag that indicates if user zooming should stop animation.
  46935. */
  46936. set zoomStopsAnimation(flag: boolean);
  46937. /**
  46938. * Gets the flag that indicates if user zooming should stop animation.
  46939. */
  46940. get zoomStopsAnimation(): boolean;
  46941. /**
  46942. * Sets the default speed at which the camera rotates around the model.
  46943. */
  46944. set idleRotationSpeed(speed: number);
  46945. /**
  46946. * Gets the default speed at which the camera rotates around the model.
  46947. */
  46948. get idleRotationSpeed(): number;
  46949. /**
  46950. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  46951. */
  46952. set idleRotationWaitTime(time: number);
  46953. /**
  46954. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  46955. */
  46956. get idleRotationWaitTime(): number;
  46957. /**
  46958. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46959. */
  46960. set idleRotationSpinupTime(time: number);
  46961. /**
  46962. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46963. */
  46964. get idleRotationSpinupTime(): number;
  46965. /**
  46966. * Gets a value indicating if the camera is currently rotating because of this behavior
  46967. */
  46968. get rotationInProgress(): boolean;
  46969. private _onPrePointerObservableObserver;
  46970. private _onAfterCheckInputsObserver;
  46971. private _attachedCamera;
  46972. private _isPointerDown;
  46973. private _lastFrameTime;
  46974. private _lastInteractionTime;
  46975. private _cameraRotationSpeed;
  46976. /**
  46977. * Initializes the behavior.
  46978. */
  46979. init(): void;
  46980. /**
  46981. * Attaches the behavior to its arc rotate camera.
  46982. * @param camera Defines the camera to attach the behavior to
  46983. */
  46984. attach(camera: ArcRotateCamera): void;
  46985. /**
  46986. * Detaches the behavior from its current arc rotate camera.
  46987. */
  46988. detach(): void;
  46989. /**
  46990. * Returns true if user is scrolling.
  46991. * @return true if user is scrolling.
  46992. */
  46993. private _userIsZooming;
  46994. private _lastFrameRadius;
  46995. private _shouldAnimationStopForInteraction;
  46996. /**
  46997. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  46998. */
  46999. private _applyUserInteraction;
  47000. private _userIsMoving;
  47001. }
  47002. }
  47003. declare module BABYLON {
  47004. /**
  47005. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  47006. */
  47007. export class AttachToBoxBehavior implements Behavior<Mesh> {
  47008. private ui;
  47009. /**
  47010. * The name of the behavior
  47011. */
  47012. name: string;
  47013. /**
  47014. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  47015. */
  47016. distanceAwayFromFace: number;
  47017. /**
  47018. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  47019. */
  47020. distanceAwayFromBottomOfFace: number;
  47021. private _faceVectors;
  47022. private _target;
  47023. private _scene;
  47024. private _onRenderObserver;
  47025. private _tmpMatrix;
  47026. private _tmpVector;
  47027. /**
  47028. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  47029. * @param ui The transform node that should be attched to the mesh
  47030. */
  47031. constructor(ui: TransformNode);
  47032. /**
  47033. * Initializes the behavior
  47034. */
  47035. init(): void;
  47036. private _closestFace;
  47037. private _zeroVector;
  47038. private _lookAtTmpMatrix;
  47039. private _lookAtToRef;
  47040. /**
  47041. * Attaches the AttachToBoxBehavior to the passed in mesh
  47042. * @param target The mesh that the specified node will be attached to
  47043. */
  47044. attach(target: Mesh): void;
  47045. /**
  47046. * Detaches the behavior from the mesh
  47047. */
  47048. detach(): void;
  47049. }
  47050. }
  47051. declare module BABYLON {
  47052. /**
  47053. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  47054. */
  47055. export class FadeInOutBehavior implements Behavior<Mesh> {
  47056. /**
  47057. * Time in milliseconds to delay before fading in (Default: 0)
  47058. */
  47059. delay: number;
  47060. /**
  47061. * Time in milliseconds for the mesh to fade in (Default: 300)
  47062. */
  47063. fadeInTime: number;
  47064. private _millisecondsPerFrame;
  47065. private _hovered;
  47066. private _hoverValue;
  47067. private _ownerNode;
  47068. /**
  47069. * Instatiates the FadeInOutBehavior
  47070. */
  47071. constructor();
  47072. /**
  47073. * The name of the behavior
  47074. */
  47075. get name(): string;
  47076. /**
  47077. * Initializes the behavior
  47078. */
  47079. init(): void;
  47080. /**
  47081. * Attaches the fade behavior on the passed in mesh
  47082. * @param ownerNode The mesh that will be faded in/out once attached
  47083. */
  47084. attach(ownerNode: Mesh): void;
  47085. /**
  47086. * Detaches the behavior from the mesh
  47087. */
  47088. detach(): void;
  47089. /**
  47090. * Triggers the mesh to begin fading in or out
  47091. * @param value if the object should fade in or out (true to fade in)
  47092. */
  47093. fadeIn(value: boolean): void;
  47094. private _update;
  47095. private _setAllVisibility;
  47096. }
  47097. }
  47098. declare module BABYLON {
  47099. /**
  47100. * Class containing a set of static utilities functions for managing Pivots
  47101. * @hidden
  47102. */
  47103. export class PivotTools {
  47104. private static _PivotCached;
  47105. private static _OldPivotPoint;
  47106. private static _PivotTranslation;
  47107. private static _PivotTmpVector;
  47108. private static _PivotPostMultiplyPivotMatrix;
  47109. /** @hidden */
  47110. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  47111. /** @hidden */
  47112. static _RestorePivotPoint(mesh: AbstractMesh): void;
  47113. }
  47114. }
  47115. declare module BABYLON {
  47116. /**
  47117. * Class containing static functions to help procedurally build meshes
  47118. */
  47119. export class PlaneBuilder {
  47120. /**
  47121. * Creates a plane mesh
  47122. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  47123. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  47124. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  47125. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47126. * * 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
  47127. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47128. * @param name defines the name of the mesh
  47129. * @param options defines the options used to create the mesh
  47130. * @param scene defines the hosting scene
  47131. * @returns the plane mesh
  47132. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  47133. */
  47134. static CreatePlane(name: string, options: {
  47135. size?: number;
  47136. width?: number;
  47137. height?: number;
  47138. sideOrientation?: number;
  47139. frontUVs?: Vector4;
  47140. backUVs?: Vector4;
  47141. updatable?: boolean;
  47142. sourcePlane?: Plane;
  47143. }, scene?: Nullable<Scene>): Mesh;
  47144. }
  47145. }
  47146. declare module BABYLON {
  47147. /**
  47148. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  47149. */
  47150. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  47151. private static _AnyMouseID;
  47152. /**
  47153. * Abstract mesh the behavior is set on
  47154. */
  47155. attachedNode: AbstractMesh;
  47156. private _dragPlane;
  47157. private _scene;
  47158. private _pointerObserver;
  47159. private _beforeRenderObserver;
  47160. private static _planeScene;
  47161. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  47162. /**
  47163. * 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)
  47164. */
  47165. maxDragAngle: number;
  47166. /**
  47167. * @hidden
  47168. */
  47169. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  47170. /**
  47171. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  47172. */
  47173. currentDraggingPointerID: number;
  47174. /**
  47175. * The last position where the pointer hit the drag plane in world space
  47176. */
  47177. lastDragPosition: Vector3;
  47178. /**
  47179. * If the behavior is currently in a dragging state
  47180. */
  47181. dragging: boolean;
  47182. /**
  47183. * 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)
  47184. */
  47185. dragDeltaRatio: number;
  47186. /**
  47187. * If the drag plane orientation should be updated during the dragging (Default: true)
  47188. */
  47189. updateDragPlane: boolean;
  47190. private _debugMode;
  47191. private _moving;
  47192. /**
  47193. * Fires each time the attached mesh is dragged with the pointer
  47194. * * delta between last drag position and current drag position in world space
  47195. * * dragDistance along the drag axis
  47196. * * dragPlaneNormal normal of the current drag plane used during the drag
  47197. * * dragPlanePoint in world space where the drag intersects the drag plane
  47198. */
  47199. onDragObservable: Observable<{
  47200. delta: Vector3;
  47201. dragPlanePoint: Vector3;
  47202. dragPlaneNormal: Vector3;
  47203. dragDistance: number;
  47204. pointerId: number;
  47205. }>;
  47206. /**
  47207. * Fires each time a drag begins (eg. mouse down on mesh)
  47208. */
  47209. onDragStartObservable: Observable<{
  47210. dragPlanePoint: Vector3;
  47211. pointerId: number;
  47212. }>;
  47213. /**
  47214. * Fires each time a drag ends (eg. mouse release after drag)
  47215. */
  47216. onDragEndObservable: Observable<{
  47217. dragPlanePoint: Vector3;
  47218. pointerId: number;
  47219. }>;
  47220. /**
  47221. * If the attached mesh should be moved when dragged
  47222. */
  47223. moveAttached: boolean;
  47224. /**
  47225. * If the drag behavior will react to drag events (Default: true)
  47226. */
  47227. enabled: boolean;
  47228. /**
  47229. * If pointer events should start and release the drag (Default: true)
  47230. */
  47231. startAndReleaseDragOnPointerEvents: boolean;
  47232. /**
  47233. * If camera controls should be detached during the drag
  47234. */
  47235. detachCameraControls: boolean;
  47236. /**
  47237. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  47238. */
  47239. useObjectOrientationForDragging: boolean;
  47240. private _options;
  47241. /**
  47242. * Gets the options used by the behavior
  47243. */
  47244. get options(): {
  47245. dragAxis?: Vector3;
  47246. dragPlaneNormal?: Vector3;
  47247. };
  47248. /**
  47249. * Sets the options used by the behavior
  47250. */
  47251. set options(options: {
  47252. dragAxis?: Vector3;
  47253. dragPlaneNormal?: Vector3;
  47254. });
  47255. /**
  47256. * Creates a pointer drag behavior that can be attached to a mesh
  47257. * @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)
  47258. */
  47259. constructor(options?: {
  47260. dragAxis?: Vector3;
  47261. dragPlaneNormal?: Vector3;
  47262. });
  47263. /**
  47264. * Predicate to determine if it is valid to move the object to a new position when it is moved
  47265. */
  47266. validateDrag: (targetPosition: Vector3) => boolean;
  47267. /**
  47268. * The name of the behavior
  47269. */
  47270. get name(): string;
  47271. /**
  47272. * Initializes the behavior
  47273. */
  47274. init(): void;
  47275. private _tmpVector;
  47276. private _alternatePickedPoint;
  47277. private _worldDragAxis;
  47278. private _targetPosition;
  47279. private _attachedToElement;
  47280. /**
  47281. * Attaches the drag behavior the passed in mesh
  47282. * @param ownerNode The mesh that will be dragged around once attached
  47283. * @param predicate Predicate to use for pick filtering
  47284. */
  47285. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  47286. /**
  47287. * Force relase the drag action by code.
  47288. */
  47289. releaseDrag(): void;
  47290. private _startDragRay;
  47291. private _lastPointerRay;
  47292. /**
  47293. * Simulates the start of a pointer drag event on the behavior
  47294. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  47295. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  47296. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  47297. */
  47298. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  47299. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  47300. private _dragDelta;
  47301. protected _moveDrag(ray: Ray): void;
  47302. private _pickWithRayOnDragPlane;
  47303. private _pointA;
  47304. private _pointC;
  47305. private _localAxis;
  47306. private _lookAt;
  47307. private _updateDragPlanePosition;
  47308. /**
  47309. * Detaches the behavior from the mesh
  47310. */
  47311. detach(): void;
  47312. }
  47313. }
  47314. declare module BABYLON {
  47315. /**
  47316. * A behavior that when attached to a mesh will allow the mesh to be scaled
  47317. */
  47318. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  47319. private _dragBehaviorA;
  47320. private _dragBehaviorB;
  47321. private _startDistance;
  47322. private _initialScale;
  47323. private _targetScale;
  47324. private _ownerNode;
  47325. private _sceneRenderObserver;
  47326. /**
  47327. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  47328. */
  47329. constructor();
  47330. /**
  47331. * The name of the behavior
  47332. */
  47333. get name(): string;
  47334. /**
  47335. * Initializes the behavior
  47336. */
  47337. init(): void;
  47338. private _getCurrentDistance;
  47339. /**
  47340. * Attaches the scale behavior the passed in mesh
  47341. * @param ownerNode The mesh that will be scaled around once attached
  47342. */
  47343. attach(ownerNode: Mesh): void;
  47344. /**
  47345. * Detaches the behavior from the mesh
  47346. */
  47347. detach(): void;
  47348. }
  47349. }
  47350. declare module BABYLON {
  47351. /**
  47352. * 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
  47353. */
  47354. export class SixDofDragBehavior implements Behavior<Mesh> {
  47355. private static _virtualScene;
  47356. private _ownerNode;
  47357. private _sceneRenderObserver;
  47358. private _scene;
  47359. private _targetPosition;
  47360. private _virtualOriginMesh;
  47361. private _virtualDragMesh;
  47362. private _pointerObserver;
  47363. private _moving;
  47364. private _startingOrientation;
  47365. private _attachedToElement;
  47366. /**
  47367. * 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)
  47368. */
  47369. private zDragFactor;
  47370. /**
  47371. * If the object should rotate to face the drag origin
  47372. */
  47373. rotateDraggedObject: boolean;
  47374. /**
  47375. * If the behavior is currently in a dragging state
  47376. */
  47377. dragging: boolean;
  47378. /**
  47379. * 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)
  47380. */
  47381. dragDeltaRatio: number;
  47382. /**
  47383. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  47384. */
  47385. currentDraggingPointerID: number;
  47386. /**
  47387. * If camera controls should be detached during the drag
  47388. */
  47389. detachCameraControls: boolean;
  47390. /**
  47391. * Fires each time a drag starts
  47392. */
  47393. onDragStartObservable: Observable<{}>;
  47394. /**
  47395. * Fires each time a drag happens
  47396. */
  47397. onDragObservable: Observable<void>;
  47398. /**
  47399. * Fires each time a drag ends (eg. mouse release after drag)
  47400. */
  47401. onDragEndObservable: Observable<{}>;
  47402. /**
  47403. * 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
  47404. */
  47405. constructor();
  47406. /**
  47407. * The name of the behavior
  47408. */
  47409. get name(): string;
  47410. /**
  47411. * Initializes the behavior
  47412. */
  47413. init(): void;
  47414. /**
  47415. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  47416. */
  47417. private get _pointerCamera();
  47418. /**
  47419. * Attaches the scale behavior the passed in mesh
  47420. * @param ownerNode The mesh that will be scaled around once attached
  47421. */
  47422. attach(ownerNode: Mesh): void;
  47423. /**
  47424. * Detaches the behavior from the mesh
  47425. */
  47426. detach(): void;
  47427. }
  47428. }
  47429. declare module BABYLON {
  47430. /**
  47431. * Class used to apply inverse kinematics to bones
  47432. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  47433. */
  47434. export class BoneIKController {
  47435. private static _tmpVecs;
  47436. private static _tmpQuat;
  47437. private static _tmpMats;
  47438. /**
  47439. * Gets or sets the target mesh
  47440. */
  47441. targetMesh: AbstractMesh;
  47442. /** Gets or sets the mesh used as pole */
  47443. poleTargetMesh: AbstractMesh;
  47444. /**
  47445. * Gets or sets the bone used as pole
  47446. */
  47447. poleTargetBone: Nullable<Bone>;
  47448. /**
  47449. * Gets or sets the target position
  47450. */
  47451. targetPosition: Vector3;
  47452. /**
  47453. * Gets or sets the pole target position
  47454. */
  47455. poleTargetPosition: Vector3;
  47456. /**
  47457. * Gets or sets the pole target local offset
  47458. */
  47459. poleTargetLocalOffset: Vector3;
  47460. /**
  47461. * Gets or sets the pole angle
  47462. */
  47463. poleAngle: number;
  47464. /**
  47465. * Gets or sets the mesh associated with the controller
  47466. */
  47467. mesh: AbstractMesh;
  47468. /**
  47469. * 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)
  47470. */
  47471. slerpAmount: number;
  47472. private _bone1Quat;
  47473. private _bone1Mat;
  47474. private _bone2Ang;
  47475. private _bone1;
  47476. private _bone2;
  47477. private _bone1Length;
  47478. private _bone2Length;
  47479. private _maxAngle;
  47480. private _maxReach;
  47481. private _rightHandedSystem;
  47482. private _bendAxis;
  47483. private _slerping;
  47484. private _adjustRoll;
  47485. /**
  47486. * Gets or sets maximum allowed angle
  47487. */
  47488. get maxAngle(): number;
  47489. set maxAngle(value: number);
  47490. /**
  47491. * Creates a new BoneIKController
  47492. * @param mesh defines the mesh to control
  47493. * @param bone defines the bone to control
  47494. * @param options defines options to set up the controller
  47495. */
  47496. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  47497. targetMesh?: AbstractMesh;
  47498. poleTargetMesh?: AbstractMesh;
  47499. poleTargetBone?: Bone;
  47500. poleTargetLocalOffset?: Vector3;
  47501. poleAngle?: number;
  47502. bendAxis?: Vector3;
  47503. maxAngle?: number;
  47504. slerpAmount?: number;
  47505. });
  47506. private _setMaxAngle;
  47507. /**
  47508. * Force the controller to update the bones
  47509. */
  47510. update(): void;
  47511. }
  47512. }
  47513. declare module BABYLON {
  47514. /**
  47515. * Class used to make a bone look toward a point in space
  47516. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  47517. */
  47518. export class BoneLookController {
  47519. private static _tmpVecs;
  47520. private static _tmpQuat;
  47521. private static _tmpMats;
  47522. /**
  47523. * The target Vector3 that the bone will look at
  47524. */
  47525. target: Vector3;
  47526. /**
  47527. * The mesh that the bone is attached to
  47528. */
  47529. mesh: AbstractMesh;
  47530. /**
  47531. * The bone that will be looking to the target
  47532. */
  47533. bone: Bone;
  47534. /**
  47535. * The up axis of the coordinate system that is used when the bone is rotated
  47536. */
  47537. upAxis: Vector3;
  47538. /**
  47539. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  47540. */
  47541. upAxisSpace: Space;
  47542. /**
  47543. * Used to make an adjustment to the yaw of the bone
  47544. */
  47545. adjustYaw: number;
  47546. /**
  47547. * Used to make an adjustment to the pitch of the bone
  47548. */
  47549. adjustPitch: number;
  47550. /**
  47551. * Used to make an adjustment to the roll of the bone
  47552. */
  47553. adjustRoll: number;
  47554. /**
  47555. * 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)
  47556. */
  47557. slerpAmount: number;
  47558. private _minYaw;
  47559. private _maxYaw;
  47560. private _minPitch;
  47561. private _maxPitch;
  47562. private _minYawSin;
  47563. private _minYawCos;
  47564. private _maxYawSin;
  47565. private _maxYawCos;
  47566. private _midYawConstraint;
  47567. private _minPitchTan;
  47568. private _maxPitchTan;
  47569. private _boneQuat;
  47570. private _slerping;
  47571. private _transformYawPitch;
  47572. private _transformYawPitchInv;
  47573. private _firstFrameSkipped;
  47574. private _yawRange;
  47575. private _fowardAxis;
  47576. /**
  47577. * Gets or sets the minimum yaw angle that the bone can look to
  47578. */
  47579. get minYaw(): number;
  47580. set minYaw(value: number);
  47581. /**
  47582. * Gets or sets the maximum yaw angle that the bone can look to
  47583. */
  47584. get maxYaw(): number;
  47585. set maxYaw(value: number);
  47586. /**
  47587. * Gets or sets the minimum pitch angle that the bone can look to
  47588. */
  47589. get minPitch(): number;
  47590. set minPitch(value: number);
  47591. /**
  47592. * Gets or sets the maximum pitch angle that the bone can look to
  47593. */
  47594. get maxPitch(): number;
  47595. set maxPitch(value: number);
  47596. /**
  47597. * Create a BoneLookController
  47598. * @param mesh the mesh that the bone belongs to
  47599. * @param bone the bone that will be looking to the target
  47600. * @param target the target Vector3 to look at
  47601. * @param options optional settings:
  47602. * * maxYaw: the maximum angle the bone will yaw to
  47603. * * minYaw: the minimum angle the bone will yaw to
  47604. * * maxPitch: the maximum angle the bone will pitch to
  47605. * * minPitch: the minimum angle the bone will yaw to
  47606. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  47607. * * upAxis: the up axis of the coordinate system
  47608. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  47609. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  47610. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  47611. * * adjustYaw: used to make an adjustment to the yaw of the bone
  47612. * * adjustPitch: used to make an adjustment to the pitch of the bone
  47613. * * adjustRoll: used to make an adjustment to the roll of the bone
  47614. **/
  47615. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  47616. maxYaw?: number;
  47617. minYaw?: number;
  47618. maxPitch?: number;
  47619. minPitch?: number;
  47620. slerpAmount?: number;
  47621. upAxis?: Vector3;
  47622. upAxisSpace?: Space;
  47623. yawAxis?: Vector3;
  47624. pitchAxis?: Vector3;
  47625. adjustYaw?: number;
  47626. adjustPitch?: number;
  47627. adjustRoll?: number;
  47628. });
  47629. /**
  47630. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  47631. */
  47632. update(): void;
  47633. private _getAngleDiff;
  47634. private _getAngleBetween;
  47635. private _isAngleBetween;
  47636. }
  47637. }
  47638. declare module BABYLON {
  47639. /**
  47640. * Manage the gamepad inputs to control an arc rotate camera.
  47641. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47642. */
  47643. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  47644. /**
  47645. * Defines the camera the input is attached to.
  47646. */
  47647. camera: ArcRotateCamera;
  47648. /**
  47649. * Defines the gamepad the input is gathering event from.
  47650. */
  47651. gamepad: Nullable<Gamepad>;
  47652. /**
  47653. * Defines the gamepad rotation sensiblity.
  47654. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47655. */
  47656. gamepadRotationSensibility: number;
  47657. /**
  47658. * Defines the gamepad move sensiblity.
  47659. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47660. */
  47661. gamepadMoveSensibility: number;
  47662. private _yAxisScale;
  47663. /**
  47664. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  47665. */
  47666. get invertYAxis(): boolean;
  47667. set invertYAxis(value: boolean);
  47668. private _onGamepadConnectedObserver;
  47669. private _onGamepadDisconnectedObserver;
  47670. /**
  47671. * Attach the input controls to a specific dom element to get the input from.
  47672. */
  47673. attachControl(): void;
  47674. /**
  47675. * Detach the current controls from the specified dom element.
  47676. */
  47677. detachControl(): void;
  47678. /**
  47679. * Update the current camera state depending on the inputs that have been used this frame.
  47680. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47681. */
  47682. checkInputs(): void;
  47683. /**
  47684. * Gets the class name of the current intput.
  47685. * @returns the class name
  47686. */
  47687. getClassName(): string;
  47688. /**
  47689. * Get the friendly name associated with the input class.
  47690. * @returns the input friendly name
  47691. */
  47692. getSimpleName(): string;
  47693. }
  47694. }
  47695. declare module BABYLON {
  47696. interface ArcRotateCameraInputsManager {
  47697. /**
  47698. * Add orientation input support to the input manager.
  47699. * @returns the current input manager
  47700. */
  47701. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  47702. }
  47703. /**
  47704. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  47705. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47706. */
  47707. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  47708. /**
  47709. * Defines the camera the input is attached to.
  47710. */
  47711. camera: ArcRotateCamera;
  47712. /**
  47713. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  47714. */
  47715. alphaCorrection: number;
  47716. /**
  47717. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  47718. */
  47719. gammaCorrection: number;
  47720. private _alpha;
  47721. private _gamma;
  47722. private _dirty;
  47723. private _deviceOrientationHandler;
  47724. /**
  47725. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  47726. */
  47727. constructor();
  47728. /**
  47729. * Attach the input controls to a specific dom element to get the input from.
  47730. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47731. */
  47732. attachControl(noPreventDefault?: boolean): void;
  47733. /** @hidden */
  47734. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  47735. /**
  47736. * Update the current camera state depending on the inputs that have been used this frame.
  47737. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47738. */
  47739. checkInputs(): void;
  47740. /**
  47741. * Detach the current controls from the specified dom element.
  47742. */
  47743. detachControl(): void;
  47744. /**
  47745. * Gets the class name of the current intput.
  47746. * @returns the class name
  47747. */
  47748. getClassName(): string;
  47749. /**
  47750. * Get the friendly name associated with the input class.
  47751. * @returns the input friendly name
  47752. */
  47753. getSimpleName(): string;
  47754. }
  47755. }
  47756. declare module BABYLON {
  47757. /**
  47758. * Listen to mouse events to control the camera.
  47759. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47760. */
  47761. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  47762. /**
  47763. * Defines the camera the input is attached to.
  47764. */
  47765. camera: FlyCamera;
  47766. /**
  47767. * Defines if touch is enabled. (Default is true.)
  47768. */
  47769. touchEnabled: boolean;
  47770. /**
  47771. * Defines the buttons associated with the input to handle camera rotation.
  47772. */
  47773. buttons: number[];
  47774. /**
  47775. * Assign buttons for Yaw control.
  47776. */
  47777. buttonsYaw: number[];
  47778. /**
  47779. * Assign buttons for Pitch control.
  47780. */
  47781. buttonsPitch: number[];
  47782. /**
  47783. * Assign buttons for Roll control.
  47784. */
  47785. buttonsRoll: number[];
  47786. /**
  47787. * Detect if any button is being pressed while mouse is moved.
  47788. * -1 = Mouse locked.
  47789. * 0 = Left button.
  47790. * 1 = Middle Button.
  47791. * 2 = Right Button.
  47792. */
  47793. activeButton: number;
  47794. /**
  47795. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  47796. * Higher values reduce its sensitivity.
  47797. */
  47798. angularSensibility: number;
  47799. private _observer;
  47800. private _rollObserver;
  47801. private previousPosition;
  47802. private noPreventDefault;
  47803. private element;
  47804. /**
  47805. * Listen to mouse events to control the camera.
  47806. * @param touchEnabled Define if touch is enabled. (Default is true.)
  47807. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47808. */
  47809. constructor(touchEnabled?: boolean);
  47810. /**
  47811. * Attach the mouse control to the HTML DOM element.
  47812. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  47813. */
  47814. attachControl(noPreventDefault?: boolean): void;
  47815. /**
  47816. * Detach the current controls from the specified dom element.
  47817. */
  47818. detachControl(): void;
  47819. /**
  47820. * Gets the class name of the current input.
  47821. * @returns the class name.
  47822. */
  47823. getClassName(): string;
  47824. /**
  47825. * Get the friendly name associated with the input class.
  47826. * @returns the input's friendly name.
  47827. */
  47828. getSimpleName(): string;
  47829. private _pointerInput;
  47830. private _onMouseMove;
  47831. /**
  47832. * Rotate camera by mouse offset.
  47833. */
  47834. private rotateCamera;
  47835. }
  47836. }
  47837. declare module BABYLON {
  47838. /**
  47839. * Default Inputs manager for the FlyCamera.
  47840. * It groups all the default supported inputs for ease of use.
  47841. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47842. */
  47843. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  47844. /**
  47845. * Instantiates a new FlyCameraInputsManager.
  47846. * @param camera Defines the camera the inputs belong to.
  47847. */
  47848. constructor(camera: FlyCamera);
  47849. /**
  47850. * Add keyboard input support to the input manager.
  47851. * @returns the new FlyCameraKeyboardMoveInput().
  47852. */
  47853. addKeyboard(): FlyCameraInputsManager;
  47854. /**
  47855. * Add mouse input support to the input manager.
  47856. * @param touchEnabled Enable touch screen support.
  47857. * @returns the new FlyCameraMouseInput().
  47858. */
  47859. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  47860. }
  47861. }
  47862. declare module BABYLON {
  47863. /**
  47864. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47865. * such as in a 3D Space Shooter or a Flight Simulator.
  47866. */
  47867. export class FlyCamera extends TargetCamera {
  47868. /**
  47869. * Define the collision ellipsoid of the camera.
  47870. * This is helpful for simulating a camera body, like a player's body.
  47871. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  47872. */
  47873. ellipsoid: Vector3;
  47874. /**
  47875. * Define an offset for the position of the ellipsoid around the camera.
  47876. * This can be helpful if the camera is attached away from the player's body center,
  47877. * such as at its head.
  47878. */
  47879. ellipsoidOffset: Vector3;
  47880. /**
  47881. * Enable or disable collisions of the camera with the rest of the scene objects.
  47882. */
  47883. checkCollisions: boolean;
  47884. /**
  47885. * Enable or disable gravity on the camera.
  47886. */
  47887. applyGravity: boolean;
  47888. /**
  47889. * Define the current direction the camera is moving to.
  47890. */
  47891. cameraDirection: Vector3;
  47892. /**
  47893. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  47894. * This overrides and empties cameraRotation.
  47895. */
  47896. rotationQuaternion: Quaternion;
  47897. /**
  47898. * Track Roll to maintain the wanted Rolling when looking around.
  47899. */
  47900. _trackRoll: number;
  47901. /**
  47902. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  47903. */
  47904. rollCorrect: number;
  47905. /**
  47906. * Mimic a banked turn, Rolling the camera when Yawing.
  47907. * It's recommended to use rollCorrect = 10 for faster banking correction.
  47908. */
  47909. bankedTurn: boolean;
  47910. /**
  47911. * Limit in radians for how much Roll banking will add. (Default: 90°)
  47912. */
  47913. bankedTurnLimit: number;
  47914. /**
  47915. * Value of 0 disables the banked Roll.
  47916. * Value of 1 is equal to the Yaw angle in radians.
  47917. */
  47918. bankedTurnMultiplier: number;
  47919. /**
  47920. * The inputs manager loads all the input sources, such as keyboard and mouse.
  47921. */
  47922. inputs: FlyCameraInputsManager;
  47923. /**
  47924. * Gets the input sensibility for mouse input.
  47925. * Higher values reduce sensitivity.
  47926. */
  47927. get angularSensibility(): number;
  47928. /**
  47929. * Sets the input sensibility for a mouse input.
  47930. * Higher values reduce sensitivity.
  47931. */
  47932. set angularSensibility(value: number);
  47933. /**
  47934. * Get the keys for camera movement forward.
  47935. */
  47936. get keysForward(): number[];
  47937. /**
  47938. * Set the keys for camera movement forward.
  47939. */
  47940. set keysForward(value: number[]);
  47941. /**
  47942. * Get the keys for camera movement backward.
  47943. */
  47944. get keysBackward(): number[];
  47945. set keysBackward(value: number[]);
  47946. /**
  47947. * Get the keys for camera movement up.
  47948. */
  47949. get keysUp(): number[];
  47950. /**
  47951. * Set the keys for camera movement up.
  47952. */
  47953. set keysUp(value: number[]);
  47954. /**
  47955. * Get the keys for camera movement down.
  47956. */
  47957. get keysDown(): number[];
  47958. /**
  47959. * Set the keys for camera movement down.
  47960. */
  47961. set keysDown(value: number[]);
  47962. /**
  47963. * Get the keys for camera movement left.
  47964. */
  47965. get keysLeft(): number[];
  47966. /**
  47967. * Set the keys for camera movement left.
  47968. */
  47969. set keysLeft(value: number[]);
  47970. /**
  47971. * Set the keys for camera movement right.
  47972. */
  47973. get keysRight(): number[];
  47974. /**
  47975. * Set the keys for camera movement right.
  47976. */
  47977. set keysRight(value: number[]);
  47978. /**
  47979. * Event raised when the camera collides with a mesh in the scene.
  47980. */
  47981. onCollide: (collidedMesh: AbstractMesh) => void;
  47982. private _collider;
  47983. private _needMoveForGravity;
  47984. private _oldPosition;
  47985. private _diffPosition;
  47986. private _newPosition;
  47987. /** @hidden */
  47988. _localDirection: Vector3;
  47989. /** @hidden */
  47990. _transformedDirection: Vector3;
  47991. /**
  47992. * Instantiates a FlyCamera.
  47993. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47994. * such as in a 3D Space Shooter or a Flight Simulator.
  47995. * @param name Define the name of the camera in the scene.
  47996. * @param position Define the starting position of the camera in the scene.
  47997. * @param scene Define the scene the camera belongs to.
  47998. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  47999. */
  48000. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  48001. /**
  48002. * Attach the input controls to a specific dom element to get the input from.
  48003. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48004. */
  48005. attachControl(noPreventDefault?: boolean): void;
  48006. /**
  48007. * Detach a control from the HTML DOM element.
  48008. * The camera will stop reacting to that input.
  48009. */
  48010. detachControl(): void;
  48011. private _collisionMask;
  48012. /**
  48013. * Get the mask that the camera ignores in collision events.
  48014. */
  48015. get collisionMask(): number;
  48016. /**
  48017. * Set the mask that the camera ignores in collision events.
  48018. */
  48019. set collisionMask(mask: number);
  48020. /** @hidden */
  48021. _collideWithWorld(displacement: Vector3): void;
  48022. /** @hidden */
  48023. private _onCollisionPositionChange;
  48024. /** @hidden */
  48025. _checkInputs(): void;
  48026. /** @hidden */
  48027. _decideIfNeedsToMove(): boolean;
  48028. /** @hidden */
  48029. _updatePosition(): void;
  48030. /**
  48031. * Restore the Roll to its target value at the rate specified.
  48032. * @param rate - Higher means slower restoring.
  48033. * @hidden
  48034. */
  48035. restoreRoll(rate: number): void;
  48036. /**
  48037. * Destroy the camera and release the current resources held by it.
  48038. */
  48039. dispose(): void;
  48040. /**
  48041. * Get the current object class name.
  48042. * @returns the class name.
  48043. */
  48044. getClassName(): string;
  48045. }
  48046. }
  48047. declare module BABYLON {
  48048. /**
  48049. * Listen to keyboard events to control the camera.
  48050. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48051. */
  48052. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  48053. /**
  48054. * Defines the camera the input is attached to.
  48055. */
  48056. camera: FlyCamera;
  48057. /**
  48058. * The list of keyboard keys used to control the forward move of the camera.
  48059. */
  48060. keysForward: number[];
  48061. /**
  48062. * The list of keyboard keys used to control the backward move of the camera.
  48063. */
  48064. keysBackward: number[];
  48065. /**
  48066. * The list of keyboard keys used to control the forward move of the camera.
  48067. */
  48068. keysUp: number[];
  48069. /**
  48070. * The list of keyboard keys used to control the backward move of the camera.
  48071. */
  48072. keysDown: number[];
  48073. /**
  48074. * The list of keyboard keys used to control the right strafe move of the camera.
  48075. */
  48076. keysRight: number[];
  48077. /**
  48078. * The list of keyboard keys used to control the left strafe move of the camera.
  48079. */
  48080. keysLeft: number[];
  48081. private _keys;
  48082. private _onCanvasBlurObserver;
  48083. private _onKeyboardObserver;
  48084. private _engine;
  48085. private _scene;
  48086. /**
  48087. * Attach the input controls to a specific dom element to get the input from.
  48088. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48089. */
  48090. attachControl(noPreventDefault?: boolean): void;
  48091. /**
  48092. * Detach the current controls from the specified dom element.
  48093. */
  48094. detachControl(): void;
  48095. /**
  48096. * Gets the class name of the current intput.
  48097. * @returns the class name
  48098. */
  48099. getClassName(): string;
  48100. /** @hidden */
  48101. _onLostFocus(e: FocusEvent): void;
  48102. /**
  48103. * Get the friendly name associated with the input class.
  48104. * @returns the input friendly name
  48105. */
  48106. getSimpleName(): string;
  48107. /**
  48108. * Update the current camera state depending on the inputs that have been used this frame.
  48109. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48110. */
  48111. checkInputs(): void;
  48112. }
  48113. }
  48114. declare module BABYLON {
  48115. /**
  48116. * Manage the mouse wheel inputs to control a follow camera.
  48117. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48118. */
  48119. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  48120. /**
  48121. * Defines the camera the input is attached to.
  48122. */
  48123. camera: FollowCamera;
  48124. /**
  48125. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  48126. */
  48127. axisControlRadius: boolean;
  48128. /**
  48129. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  48130. */
  48131. axisControlHeight: boolean;
  48132. /**
  48133. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  48134. */
  48135. axisControlRotation: boolean;
  48136. /**
  48137. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  48138. * relation to mouseWheel events.
  48139. */
  48140. wheelPrecision: number;
  48141. /**
  48142. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  48143. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  48144. */
  48145. wheelDeltaPercentage: number;
  48146. private _wheel;
  48147. private _observer;
  48148. /**
  48149. * Attach the input controls to a specific dom element to get the input from.
  48150. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48151. */
  48152. attachControl(noPreventDefault?: boolean): void;
  48153. /**
  48154. * Detach the current controls from the specified dom element.
  48155. */
  48156. detachControl(): void;
  48157. /**
  48158. * Gets the class name of the current intput.
  48159. * @returns the class name
  48160. */
  48161. getClassName(): string;
  48162. /**
  48163. * Get the friendly name associated with the input class.
  48164. * @returns the input friendly name
  48165. */
  48166. getSimpleName(): string;
  48167. }
  48168. }
  48169. declare module BABYLON {
  48170. /**
  48171. * Manage the pointers inputs to control an follow camera.
  48172. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48173. */
  48174. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  48175. /**
  48176. * Defines the camera the input is attached to.
  48177. */
  48178. camera: FollowCamera;
  48179. /**
  48180. * Gets the class name of the current input.
  48181. * @returns the class name
  48182. */
  48183. getClassName(): string;
  48184. /**
  48185. * Defines the pointer angular sensibility along the X axis or how fast is
  48186. * the camera rotating.
  48187. * A negative number will reverse the axis direction.
  48188. */
  48189. angularSensibilityX: number;
  48190. /**
  48191. * Defines the pointer angular sensibility along the Y axis or how fast is
  48192. * the camera rotating.
  48193. * A negative number will reverse the axis direction.
  48194. */
  48195. angularSensibilityY: number;
  48196. /**
  48197. * Defines the pointer pinch precision or how fast is the camera zooming.
  48198. * A negative number will reverse the axis direction.
  48199. */
  48200. pinchPrecision: number;
  48201. /**
  48202. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  48203. * from 0.
  48204. * It defines the percentage of current camera.radius to use as delta when
  48205. * pinch zoom is used.
  48206. */
  48207. pinchDeltaPercentage: number;
  48208. /**
  48209. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  48210. */
  48211. axisXControlRadius: boolean;
  48212. /**
  48213. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  48214. */
  48215. axisXControlHeight: boolean;
  48216. /**
  48217. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  48218. */
  48219. axisXControlRotation: boolean;
  48220. /**
  48221. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  48222. */
  48223. axisYControlRadius: boolean;
  48224. /**
  48225. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  48226. */
  48227. axisYControlHeight: boolean;
  48228. /**
  48229. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  48230. */
  48231. axisYControlRotation: boolean;
  48232. /**
  48233. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  48234. */
  48235. axisPinchControlRadius: boolean;
  48236. /**
  48237. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  48238. */
  48239. axisPinchControlHeight: boolean;
  48240. /**
  48241. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  48242. */
  48243. axisPinchControlRotation: boolean;
  48244. /**
  48245. * Log error messages if basic misconfiguration has occurred.
  48246. */
  48247. warningEnable: boolean;
  48248. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  48249. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  48250. private _warningCounter;
  48251. private _warning;
  48252. }
  48253. }
  48254. declare module BABYLON {
  48255. /**
  48256. * Default Inputs manager for the FollowCamera.
  48257. * It groups all the default supported inputs for ease of use.
  48258. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48259. */
  48260. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  48261. /**
  48262. * Instantiates a new FollowCameraInputsManager.
  48263. * @param camera Defines the camera the inputs belong to
  48264. */
  48265. constructor(camera: FollowCamera);
  48266. /**
  48267. * Add keyboard input support to the input manager.
  48268. * @returns the current input manager
  48269. */
  48270. addKeyboard(): FollowCameraInputsManager;
  48271. /**
  48272. * Add mouse wheel input support to the input manager.
  48273. * @returns the current input manager
  48274. */
  48275. addMouseWheel(): FollowCameraInputsManager;
  48276. /**
  48277. * Add pointers input support to the input manager.
  48278. * @returns the current input manager
  48279. */
  48280. addPointers(): FollowCameraInputsManager;
  48281. /**
  48282. * Add orientation input support to the input manager.
  48283. * @returns the current input manager
  48284. */
  48285. addVRDeviceOrientation(): FollowCameraInputsManager;
  48286. }
  48287. }
  48288. declare module BABYLON {
  48289. /**
  48290. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  48291. * an arc rotate version arcFollowCamera are available.
  48292. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48293. */
  48294. export class FollowCamera extends TargetCamera {
  48295. /**
  48296. * Distance the follow camera should follow an object at
  48297. */
  48298. radius: number;
  48299. /**
  48300. * Minimum allowed distance of the camera to the axis of rotation
  48301. * (The camera can not get closer).
  48302. * This can help limiting how the Camera is able to move in the scene.
  48303. */
  48304. lowerRadiusLimit: Nullable<number>;
  48305. /**
  48306. * Maximum allowed distance of the camera to the axis of rotation
  48307. * (The camera can not get further).
  48308. * This can help limiting how the Camera is able to move in the scene.
  48309. */
  48310. upperRadiusLimit: Nullable<number>;
  48311. /**
  48312. * Define a rotation offset between the camera and the object it follows
  48313. */
  48314. rotationOffset: number;
  48315. /**
  48316. * Minimum allowed angle to camera position relative to target object.
  48317. * This can help limiting how the Camera is able to move in the scene.
  48318. */
  48319. lowerRotationOffsetLimit: Nullable<number>;
  48320. /**
  48321. * Maximum allowed angle to camera position relative to target object.
  48322. * This can help limiting how the Camera is able to move in the scene.
  48323. */
  48324. upperRotationOffsetLimit: Nullable<number>;
  48325. /**
  48326. * Define a height offset between the camera and the object it follows.
  48327. * It can help following an object from the top (like a car chaing a plane)
  48328. */
  48329. heightOffset: number;
  48330. /**
  48331. * Minimum allowed height of camera position relative to target object.
  48332. * This can help limiting how the Camera is able to move in the scene.
  48333. */
  48334. lowerHeightOffsetLimit: Nullable<number>;
  48335. /**
  48336. * Maximum allowed height of camera position relative to target object.
  48337. * This can help limiting how the Camera is able to move in the scene.
  48338. */
  48339. upperHeightOffsetLimit: Nullable<number>;
  48340. /**
  48341. * Define how fast the camera can accelerate to follow it s target.
  48342. */
  48343. cameraAcceleration: number;
  48344. /**
  48345. * Define the speed limit of the camera following an object.
  48346. */
  48347. maxCameraSpeed: number;
  48348. /**
  48349. * Define the target of the camera.
  48350. */
  48351. lockedTarget: Nullable<AbstractMesh>;
  48352. /**
  48353. * Defines the input associated with the camera.
  48354. */
  48355. inputs: FollowCameraInputsManager;
  48356. /**
  48357. * Instantiates the follow camera.
  48358. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48359. * @param name Define the name of the camera in the scene
  48360. * @param position Define the position of the camera
  48361. * @param scene Define the scene the camera belong to
  48362. * @param lockedTarget Define the target of the camera
  48363. */
  48364. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  48365. private _follow;
  48366. /**
  48367. * Attach the input controls to a specific dom element to get the input from.
  48368. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48369. */
  48370. attachControl(noPreventDefault?: boolean): void;
  48371. /**
  48372. * Detach the current controls from the specified dom element.
  48373. */
  48374. detachControl(): void;
  48375. /** @hidden */
  48376. _checkInputs(): void;
  48377. private _checkLimits;
  48378. /**
  48379. * Gets the camera class name.
  48380. * @returns the class name
  48381. */
  48382. getClassName(): string;
  48383. }
  48384. /**
  48385. * Arc Rotate version of the follow camera.
  48386. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  48387. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48388. */
  48389. export class ArcFollowCamera extends TargetCamera {
  48390. /** The longitudinal angle of the camera */
  48391. alpha: number;
  48392. /** The latitudinal angle of the camera */
  48393. beta: number;
  48394. /** The radius of the camera from its target */
  48395. radius: number;
  48396. private _cartesianCoordinates;
  48397. /** Define the camera target (the mesh it should follow) */
  48398. private _meshTarget;
  48399. /**
  48400. * Instantiates a new ArcFollowCamera
  48401. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48402. * @param name Define the name of the camera
  48403. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  48404. * @param beta Define the rotation angle of the camera around the elevation axis
  48405. * @param radius Define the radius of the camera from its target point
  48406. * @param target Define the target of the camera
  48407. * @param scene Define the scene the camera belongs to
  48408. */
  48409. constructor(name: string,
  48410. /** The longitudinal angle of the camera */
  48411. alpha: number,
  48412. /** The latitudinal angle of the camera */
  48413. beta: number,
  48414. /** The radius of the camera from its target */
  48415. radius: number,
  48416. /** Define the camera target (the mesh it should follow) */
  48417. target: Nullable<AbstractMesh>, scene: Scene);
  48418. private _follow;
  48419. /** @hidden */
  48420. _checkInputs(): void;
  48421. /**
  48422. * Returns the class name of the object.
  48423. * It is mostly used internally for serialization purposes.
  48424. */
  48425. getClassName(): string;
  48426. }
  48427. }
  48428. declare module BABYLON {
  48429. /**
  48430. * Manage the keyboard inputs to control the movement of a follow camera.
  48431. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48432. */
  48433. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  48434. /**
  48435. * Defines the camera the input is attached to.
  48436. */
  48437. camera: FollowCamera;
  48438. /**
  48439. * Defines the list of key codes associated with the up action (increase heightOffset)
  48440. */
  48441. keysHeightOffsetIncr: number[];
  48442. /**
  48443. * Defines the list of key codes associated with the down action (decrease heightOffset)
  48444. */
  48445. keysHeightOffsetDecr: number[];
  48446. /**
  48447. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  48448. */
  48449. keysHeightOffsetModifierAlt: boolean;
  48450. /**
  48451. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  48452. */
  48453. keysHeightOffsetModifierCtrl: boolean;
  48454. /**
  48455. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  48456. */
  48457. keysHeightOffsetModifierShift: boolean;
  48458. /**
  48459. * Defines the list of key codes associated with the left action (increase rotationOffset)
  48460. */
  48461. keysRotationOffsetIncr: number[];
  48462. /**
  48463. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  48464. */
  48465. keysRotationOffsetDecr: number[];
  48466. /**
  48467. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  48468. */
  48469. keysRotationOffsetModifierAlt: boolean;
  48470. /**
  48471. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  48472. */
  48473. keysRotationOffsetModifierCtrl: boolean;
  48474. /**
  48475. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  48476. */
  48477. keysRotationOffsetModifierShift: boolean;
  48478. /**
  48479. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  48480. */
  48481. keysRadiusIncr: number[];
  48482. /**
  48483. * Defines the list of key codes associated with the zoom-out action (increase radius)
  48484. */
  48485. keysRadiusDecr: number[];
  48486. /**
  48487. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  48488. */
  48489. keysRadiusModifierAlt: boolean;
  48490. /**
  48491. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  48492. */
  48493. keysRadiusModifierCtrl: boolean;
  48494. /**
  48495. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  48496. */
  48497. keysRadiusModifierShift: boolean;
  48498. /**
  48499. * Defines the rate of change of heightOffset.
  48500. */
  48501. heightSensibility: number;
  48502. /**
  48503. * Defines the rate of change of rotationOffset.
  48504. */
  48505. rotationSensibility: number;
  48506. /**
  48507. * Defines the rate of change of radius.
  48508. */
  48509. radiusSensibility: number;
  48510. private _keys;
  48511. private _ctrlPressed;
  48512. private _altPressed;
  48513. private _shiftPressed;
  48514. private _onCanvasBlurObserver;
  48515. private _onKeyboardObserver;
  48516. private _engine;
  48517. private _scene;
  48518. /**
  48519. * Attach the input controls to a specific dom element to get the input from.
  48520. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48521. */
  48522. attachControl(noPreventDefault?: boolean): void;
  48523. /**
  48524. * Detach the current controls from the specified dom element.
  48525. */
  48526. detachControl(): void;
  48527. /**
  48528. * Update the current camera state depending on the inputs that have been used this frame.
  48529. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48530. */
  48531. checkInputs(): void;
  48532. /**
  48533. * Gets the class name of the current input.
  48534. * @returns the class name
  48535. */
  48536. getClassName(): string;
  48537. /**
  48538. * Get the friendly name associated with the input class.
  48539. * @returns the input friendly name
  48540. */
  48541. getSimpleName(): string;
  48542. /**
  48543. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48544. * allow modification of the heightOffset value.
  48545. */
  48546. private _modifierHeightOffset;
  48547. /**
  48548. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48549. * allow modification of the rotationOffset value.
  48550. */
  48551. private _modifierRotationOffset;
  48552. /**
  48553. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48554. * allow modification of the radius value.
  48555. */
  48556. private _modifierRadius;
  48557. }
  48558. }
  48559. declare module BABYLON {
  48560. interface FreeCameraInputsManager {
  48561. /**
  48562. * @hidden
  48563. */
  48564. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  48565. /**
  48566. * Add orientation input support to the input manager.
  48567. * @returns the current input manager
  48568. */
  48569. addDeviceOrientation(): FreeCameraInputsManager;
  48570. }
  48571. /**
  48572. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  48573. * Screen rotation is taken into account.
  48574. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48575. */
  48576. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  48577. private _camera;
  48578. private _screenOrientationAngle;
  48579. private _constantTranform;
  48580. private _screenQuaternion;
  48581. private _alpha;
  48582. private _beta;
  48583. private _gamma;
  48584. /**
  48585. * Can be used to detect if a device orientation sensor is available on a device
  48586. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  48587. * @returns a promise that will resolve on orientation change
  48588. */
  48589. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  48590. /**
  48591. * @hidden
  48592. */
  48593. _onDeviceOrientationChangedObservable: Observable<void>;
  48594. /**
  48595. * Instantiates a new input
  48596. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48597. */
  48598. constructor();
  48599. /**
  48600. * Define the camera controlled by the input.
  48601. */
  48602. get camera(): FreeCamera;
  48603. set camera(camera: FreeCamera);
  48604. /**
  48605. * Attach the input controls to a specific dom element to get the input from.
  48606. */
  48607. attachControl(): void;
  48608. private _orientationChanged;
  48609. private _deviceOrientation;
  48610. /**
  48611. * Detach the current controls from the specified dom element.
  48612. */
  48613. detachControl(): void;
  48614. /**
  48615. * Update the current camera state depending on the inputs that have been used this frame.
  48616. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48617. */
  48618. checkInputs(): void;
  48619. /**
  48620. * Gets the class name of the current intput.
  48621. * @returns the class name
  48622. */
  48623. getClassName(): string;
  48624. /**
  48625. * Get the friendly name associated with the input class.
  48626. * @returns the input friendly name
  48627. */
  48628. getSimpleName(): string;
  48629. }
  48630. }
  48631. declare module BABYLON {
  48632. /**
  48633. * Manage the gamepad inputs to control a free camera.
  48634. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48635. */
  48636. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  48637. /**
  48638. * Define the camera the input is attached to.
  48639. */
  48640. camera: FreeCamera;
  48641. /**
  48642. * Define the Gamepad controlling the input
  48643. */
  48644. gamepad: Nullable<Gamepad>;
  48645. /**
  48646. * Defines the gamepad rotation sensiblity.
  48647. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  48648. */
  48649. gamepadAngularSensibility: number;
  48650. /**
  48651. * Defines the gamepad move sensiblity.
  48652. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  48653. */
  48654. gamepadMoveSensibility: number;
  48655. private _yAxisScale;
  48656. /**
  48657. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  48658. */
  48659. get invertYAxis(): boolean;
  48660. set invertYAxis(value: boolean);
  48661. private _onGamepadConnectedObserver;
  48662. private _onGamepadDisconnectedObserver;
  48663. private _cameraTransform;
  48664. private _deltaTransform;
  48665. private _vector3;
  48666. private _vector2;
  48667. /**
  48668. * Attach the input controls to a specific dom element to get the input from.
  48669. */
  48670. attachControl(): void;
  48671. /**
  48672. * Detach the current controls from the specified dom element.
  48673. */
  48674. detachControl(): void;
  48675. /**
  48676. * Update the current camera state depending on the inputs that have been used this frame.
  48677. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48678. */
  48679. checkInputs(): void;
  48680. /**
  48681. * Gets the class name of the current intput.
  48682. * @returns the class name
  48683. */
  48684. getClassName(): string;
  48685. /**
  48686. * Get the friendly name associated with the input class.
  48687. * @returns the input friendly name
  48688. */
  48689. getSimpleName(): string;
  48690. }
  48691. }
  48692. declare module BABYLON {
  48693. /**
  48694. * Defines the potential axis of a Joystick
  48695. */
  48696. export enum JoystickAxis {
  48697. /** X axis */
  48698. X = 0,
  48699. /** Y axis */
  48700. Y = 1,
  48701. /** Z axis */
  48702. Z = 2
  48703. }
  48704. /**
  48705. * Represents the different customization options available
  48706. * for VirtualJoystick
  48707. */
  48708. interface VirtualJoystickCustomizations {
  48709. /**
  48710. * Size of the joystick's puck
  48711. */
  48712. puckSize: number;
  48713. /**
  48714. * Size of the joystick's container
  48715. */
  48716. containerSize: number;
  48717. /**
  48718. * Color of the joystick && puck
  48719. */
  48720. color: string;
  48721. /**
  48722. * Image URL for the joystick's puck
  48723. */
  48724. puckImage?: string;
  48725. /**
  48726. * Image URL for the joystick's container
  48727. */
  48728. containerImage?: string;
  48729. /**
  48730. * Defines the unmoving position of the joystick container
  48731. */
  48732. position?: {
  48733. x: number;
  48734. y: number;
  48735. };
  48736. /**
  48737. * Defines whether or not the joystick container is always visible
  48738. */
  48739. alwaysVisible: boolean;
  48740. /**
  48741. * Defines whether or not to limit the movement of the puck to the joystick's container
  48742. */
  48743. limitToContainer: boolean;
  48744. }
  48745. /**
  48746. * Class used to define virtual joystick (used in touch mode)
  48747. */
  48748. export class VirtualJoystick {
  48749. /**
  48750. * Gets or sets a boolean indicating that left and right values must be inverted
  48751. */
  48752. reverseLeftRight: boolean;
  48753. /**
  48754. * Gets or sets a boolean indicating that up and down values must be inverted
  48755. */
  48756. reverseUpDown: boolean;
  48757. /**
  48758. * Gets the offset value for the position (ie. the change of the position value)
  48759. */
  48760. deltaPosition: Vector3;
  48761. /**
  48762. * Gets a boolean indicating if the virtual joystick was pressed
  48763. */
  48764. pressed: boolean;
  48765. /**
  48766. * Canvas the virtual joystick will render onto, default z-index of this is 5
  48767. */
  48768. static Canvas: Nullable<HTMLCanvasElement>;
  48769. /**
  48770. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  48771. */
  48772. limitToContainer: boolean;
  48773. private static _globalJoystickIndex;
  48774. private static _alwaysVisibleSticks;
  48775. private static vjCanvasContext;
  48776. private static vjCanvasWidth;
  48777. private static vjCanvasHeight;
  48778. private static halfWidth;
  48779. private static _GetDefaultOptions;
  48780. private _action;
  48781. private _axisTargetedByLeftAndRight;
  48782. private _axisTargetedByUpAndDown;
  48783. private _joystickSensibility;
  48784. private _inversedSensibility;
  48785. private _joystickPointerID;
  48786. private _joystickColor;
  48787. private _joystickPointerPos;
  48788. private _joystickPreviousPointerPos;
  48789. private _joystickPointerStartPos;
  48790. private _deltaJoystickVector;
  48791. private _leftJoystick;
  48792. private _touches;
  48793. private _joystickPosition;
  48794. private _alwaysVisible;
  48795. private _puckImage;
  48796. private _containerImage;
  48797. private _joystickPuckSize;
  48798. private _joystickContainerSize;
  48799. private _clearPuckSize;
  48800. private _clearContainerSize;
  48801. private _clearPuckSizeOffset;
  48802. private _clearContainerSizeOffset;
  48803. private _onPointerDownHandlerRef;
  48804. private _onPointerMoveHandlerRef;
  48805. private _onPointerUpHandlerRef;
  48806. private _onResize;
  48807. /**
  48808. * Creates a new virtual joystick
  48809. * @param leftJoystick defines that the joystick is for left hand (false by default)
  48810. * @param customizations Defines the options we want to customize the VirtualJoystick
  48811. */
  48812. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  48813. /**
  48814. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  48815. * @param newJoystickSensibility defines the new sensibility
  48816. */
  48817. setJoystickSensibility(newJoystickSensibility: number): void;
  48818. private _onPointerDown;
  48819. private _onPointerMove;
  48820. private _onPointerUp;
  48821. /**
  48822. * Change the color of the virtual joystick
  48823. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  48824. */
  48825. setJoystickColor(newColor: string): void;
  48826. /**
  48827. * Size of the joystick's container
  48828. */
  48829. set containerSize(newSize: number);
  48830. get containerSize(): number;
  48831. /**
  48832. * Size of the joystick's puck
  48833. */
  48834. set puckSize(newSize: number);
  48835. get puckSize(): number;
  48836. /**
  48837. * Clears the set position of the joystick
  48838. */
  48839. clearPosition(): void;
  48840. /**
  48841. * Defines whether or not the joystick container is always visible
  48842. */
  48843. set alwaysVisible(value: boolean);
  48844. get alwaysVisible(): boolean;
  48845. /**
  48846. * Sets the constant position of the Joystick container
  48847. * @param x X axis coordinate
  48848. * @param y Y axis coordinate
  48849. */
  48850. setPosition(x: number, y: number): void;
  48851. /**
  48852. * Defines a callback to call when the joystick is touched
  48853. * @param action defines the callback
  48854. */
  48855. setActionOnTouch(action: () => any): void;
  48856. /**
  48857. * Defines which axis you'd like to control for left & right
  48858. * @param axis defines the axis to use
  48859. */
  48860. setAxisForLeftRight(axis: JoystickAxis): void;
  48861. /**
  48862. * Defines which axis you'd like to control for up & down
  48863. * @param axis defines the axis to use
  48864. */
  48865. setAxisForUpDown(axis: JoystickAxis): void;
  48866. /**
  48867. * Clears the canvas from the previous puck / container draw
  48868. */
  48869. private _clearPreviousDraw;
  48870. /**
  48871. * Loads `urlPath` to be used for the container's image
  48872. * @param urlPath defines the urlPath of an image to use
  48873. */
  48874. setContainerImage(urlPath: string): void;
  48875. /**
  48876. * Loads `urlPath` to be used for the puck's image
  48877. * @param urlPath defines the urlPath of an image to use
  48878. */
  48879. setPuckImage(urlPath: string): void;
  48880. /**
  48881. * Draws the Virtual Joystick's container
  48882. */
  48883. private _drawContainer;
  48884. /**
  48885. * Draws the Virtual Joystick's puck
  48886. */
  48887. private _drawPuck;
  48888. private _drawVirtualJoystick;
  48889. /**
  48890. * Release internal HTML canvas
  48891. */
  48892. releaseCanvas(): void;
  48893. }
  48894. }
  48895. declare module BABYLON {
  48896. interface FreeCameraInputsManager {
  48897. /**
  48898. * Add virtual joystick input support to the input manager.
  48899. * @returns the current input manager
  48900. */
  48901. addVirtualJoystick(): FreeCameraInputsManager;
  48902. }
  48903. /**
  48904. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  48905. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48906. */
  48907. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  48908. /**
  48909. * Defines the camera the input is attached to.
  48910. */
  48911. camera: FreeCamera;
  48912. private _leftjoystick;
  48913. private _rightjoystick;
  48914. /**
  48915. * Gets the left stick of the virtual joystick.
  48916. * @returns The virtual Joystick
  48917. */
  48918. getLeftJoystick(): VirtualJoystick;
  48919. /**
  48920. * Gets the right stick of the virtual joystick.
  48921. * @returns The virtual Joystick
  48922. */
  48923. getRightJoystick(): VirtualJoystick;
  48924. /**
  48925. * Update the current camera state depending on the inputs that have been used this frame.
  48926. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48927. */
  48928. checkInputs(): void;
  48929. /**
  48930. * Attach the input controls to a specific dom element to get the input from.
  48931. */
  48932. attachControl(): void;
  48933. /**
  48934. * Detach the current controls from the specified dom element.
  48935. */
  48936. detachControl(): void;
  48937. /**
  48938. * Gets the class name of the current intput.
  48939. * @returns the class name
  48940. */
  48941. getClassName(): string;
  48942. /**
  48943. * Get the friendly name associated with the input class.
  48944. * @returns the input friendly name
  48945. */
  48946. getSimpleName(): string;
  48947. }
  48948. }
  48949. declare module BABYLON {
  48950. /**
  48951. * This represents a FPS type of camera controlled by touch.
  48952. * This is like a universal camera minus the Gamepad controls.
  48953. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48954. */
  48955. export class TouchCamera extends FreeCamera {
  48956. /**
  48957. * Defines the touch sensibility for rotation.
  48958. * The higher the faster.
  48959. */
  48960. get touchAngularSensibility(): number;
  48961. set touchAngularSensibility(value: number);
  48962. /**
  48963. * Defines the touch sensibility for move.
  48964. * The higher the faster.
  48965. */
  48966. get touchMoveSensibility(): number;
  48967. set touchMoveSensibility(value: number);
  48968. /**
  48969. * Instantiates a new touch camera.
  48970. * This represents a FPS type of camera controlled by touch.
  48971. * This is like a universal camera minus the Gamepad controls.
  48972. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48973. * @param name Define the name of the camera in the scene
  48974. * @param position Define the start position of the camera in the scene
  48975. * @param scene Define the scene the camera belongs to
  48976. */
  48977. constructor(name: string, position: Vector3, scene: Scene);
  48978. /**
  48979. * Gets the current object class name.
  48980. * @return the class name
  48981. */
  48982. getClassName(): string;
  48983. /** @hidden */
  48984. _setupInputs(): void;
  48985. }
  48986. }
  48987. declare module BABYLON {
  48988. /**
  48989. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  48990. * being tilted forward or back and left or right.
  48991. */
  48992. export class DeviceOrientationCamera extends FreeCamera {
  48993. private _initialQuaternion;
  48994. private _quaternionCache;
  48995. private _tmpDragQuaternion;
  48996. private _disablePointerInputWhenUsingDeviceOrientation;
  48997. /**
  48998. * Creates a new device orientation camera
  48999. * @param name The name of the camera
  49000. * @param position The start position camera
  49001. * @param scene The scene the camera belongs to
  49002. */
  49003. constructor(name: string, position: Vector3, scene: Scene);
  49004. /**
  49005. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  49006. */
  49007. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  49008. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  49009. private _dragFactor;
  49010. /**
  49011. * Enabled turning on the y axis when the orientation sensor is active
  49012. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  49013. */
  49014. enableHorizontalDragging(dragFactor?: number): void;
  49015. /**
  49016. * Gets the current instance class name ("DeviceOrientationCamera").
  49017. * This helps avoiding instanceof at run time.
  49018. * @returns the class name
  49019. */
  49020. getClassName(): string;
  49021. /**
  49022. * @hidden
  49023. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  49024. */
  49025. _checkInputs(): void;
  49026. /**
  49027. * Reset the camera to its default orientation on the specified axis only.
  49028. * @param axis The axis to reset
  49029. */
  49030. resetToCurrentRotation(axis?: Axis): void;
  49031. }
  49032. }
  49033. declare module BABYLON {
  49034. /**
  49035. * Defines supported buttons for XBox360 compatible gamepads
  49036. */
  49037. export enum Xbox360Button {
  49038. /** A */
  49039. A = 0,
  49040. /** B */
  49041. B = 1,
  49042. /** X */
  49043. X = 2,
  49044. /** Y */
  49045. Y = 3,
  49046. /** Left button */
  49047. LB = 4,
  49048. /** Right button */
  49049. RB = 5,
  49050. /** Back */
  49051. Back = 8,
  49052. /** Start */
  49053. Start = 9,
  49054. /** Left stick */
  49055. LeftStick = 10,
  49056. /** Right stick */
  49057. RightStick = 11
  49058. }
  49059. /** Defines values for XBox360 DPad */
  49060. export enum Xbox360Dpad {
  49061. /** Up */
  49062. Up = 12,
  49063. /** Down */
  49064. Down = 13,
  49065. /** Left */
  49066. Left = 14,
  49067. /** Right */
  49068. Right = 15
  49069. }
  49070. /**
  49071. * Defines a XBox360 gamepad
  49072. */
  49073. export class Xbox360Pad extends Gamepad {
  49074. private _leftTrigger;
  49075. private _rightTrigger;
  49076. private _onlefttriggerchanged;
  49077. private _onrighttriggerchanged;
  49078. private _onbuttondown;
  49079. private _onbuttonup;
  49080. private _ondpaddown;
  49081. private _ondpadup;
  49082. /** Observable raised when a button is pressed */
  49083. onButtonDownObservable: Observable<Xbox360Button>;
  49084. /** Observable raised when a button is released */
  49085. onButtonUpObservable: Observable<Xbox360Button>;
  49086. /** Observable raised when a pad is pressed */
  49087. onPadDownObservable: Observable<Xbox360Dpad>;
  49088. /** Observable raised when a pad is released */
  49089. onPadUpObservable: Observable<Xbox360Dpad>;
  49090. private _buttonA;
  49091. private _buttonB;
  49092. private _buttonX;
  49093. private _buttonY;
  49094. private _buttonBack;
  49095. private _buttonStart;
  49096. private _buttonLB;
  49097. private _buttonRB;
  49098. private _buttonLeftStick;
  49099. private _buttonRightStick;
  49100. private _dPadUp;
  49101. private _dPadDown;
  49102. private _dPadLeft;
  49103. private _dPadRight;
  49104. private _isXboxOnePad;
  49105. /**
  49106. * Creates a new XBox360 gamepad object
  49107. * @param id defines the id of this gamepad
  49108. * @param index defines its index
  49109. * @param gamepad defines the internal HTML gamepad object
  49110. * @param xboxOne defines if it is a XBox One gamepad
  49111. */
  49112. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  49113. /**
  49114. * Defines the callback to call when left trigger is pressed
  49115. * @param callback defines the callback to use
  49116. */
  49117. onlefttriggerchanged(callback: (value: number) => void): void;
  49118. /**
  49119. * Defines the callback to call when right trigger is pressed
  49120. * @param callback defines the callback to use
  49121. */
  49122. onrighttriggerchanged(callback: (value: number) => void): void;
  49123. /**
  49124. * Gets the left trigger value
  49125. */
  49126. get leftTrigger(): number;
  49127. /**
  49128. * Sets the left trigger value
  49129. */
  49130. set leftTrigger(newValue: number);
  49131. /**
  49132. * Gets the right trigger value
  49133. */
  49134. get rightTrigger(): number;
  49135. /**
  49136. * Sets the right trigger value
  49137. */
  49138. set rightTrigger(newValue: number);
  49139. /**
  49140. * Defines the callback to call when a button is pressed
  49141. * @param callback defines the callback to use
  49142. */
  49143. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  49144. /**
  49145. * Defines the callback to call when a button is released
  49146. * @param callback defines the callback to use
  49147. */
  49148. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  49149. /**
  49150. * Defines the callback to call when a pad is pressed
  49151. * @param callback defines the callback to use
  49152. */
  49153. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  49154. /**
  49155. * Defines the callback to call when a pad is released
  49156. * @param callback defines the callback to use
  49157. */
  49158. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  49159. private _setButtonValue;
  49160. private _setDPadValue;
  49161. /**
  49162. * Gets the value of the `A` button
  49163. */
  49164. get buttonA(): number;
  49165. /**
  49166. * Sets the value of the `A` button
  49167. */
  49168. set buttonA(value: number);
  49169. /**
  49170. * Gets the value of the `B` button
  49171. */
  49172. get buttonB(): number;
  49173. /**
  49174. * Sets the value of the `B` button
  49175. */
  49176. set buttonB(value: number);
  49177. /**
  49178. * Gets the value of the `X` button
  49179. */
  49180. get buttonX(): number;
  49181. /**
  49182. * Sets the value of the `X` button
  49183. */
  49184. set buttonX(value: number);
  49185. /**
  49186. * Gets the value of the `Y` button
  49187. */
  49188. get buttonY(): number;
  49189. /**
  49190. * Sets the value of the `Y` button
  49191. */
  49192. set buttonY(value: number);
  49193. /**
  49194. * Gets the value of the `Start` button
  49195. */
  49196. get buttonStart(): number;
  49197. /**
  49198. * Sets the value of the `Start` button
  49199. */
  49200. set buttonStart(value: number);
  49201. /**
  49202. * Gets the value of the `Back` button
  49203. */
  49204. get buttonBack(): number;
  49205. /**
  49206. * Sets the value of the `Back` button
  49207. */
  49208. set buttonBack(value: number);
  49209. /**
  49210. * Gets the value of the `Left` button
  49211. */
  49212. get buttonLB(): number;
  49213. /**
  49214. * Sets the value of the `Left` button
  49215. */
  49216. set buttonLB(value: number);
  49217. /**
  49218. * Gets the value of the `Right` button
  49219. */
  49220. get buttonRB(): number;
  49221. /**
  49222. * Sets the value of the `Right` button
  49223. */
  49224. set buttonRB(value: number);
  49225. /**
  49226. * Gets the value of the Left joystick
  49227. */
  49228. get buttonLeftStick(): number;
  49229. /**
  49230. * Sets the value of the Left joystick
  49231. */
  49232. set buttonLeftStick(value: number);
  49233. /**
  49234. * Gets the value of the Right joystick
  49235. */
  49236. get buttonRightStick(): number;
  49237. /**
  49238. * Sets the value of the Right joystick
  49239. */
  49240. set buttonRightStick(value: number);
  49241. /**
  49242. * Gets the value of D-pad up
  49243. */
  49244. get dPadUp(): number;
  49245. /**
  49246. * Sets the value of D-pad up
  49247. */
  49248. set dPadUp(value: number);
  49249. /**
  49250. * Gets the value of D-pad down
  49251. */
  49252. get dPadDown(): number;
  49253. /**
  49254. * Sets the value of D-pad down
  49255. */
  49256. set dPadDown(value: number);
  49257. /**
  49258. * Gets the value of D-pad left
  49259. */
  49260. get dPadLeft(): number;
  49261. /**
  49262. * Sets the value of D-pad left
  49263. */
  49264. set dPadLeft(value: number);
  49265. /**
  49266. * Gets the value of D-pad right
  49267. */
  49268. get dPadRight(): number;
  49269. /**
  49270. * Sets the value of D-pad right
  49271. */
  49272. set dPadRight(value: number);
  49273. /**
  49274. * Force the gamepad to synchronize with device values
  49275. */
  49276. update(): void;
  49277. /**
  49278. * Disposes the gamepad
  49279. */
  49280. dispose(): void;
  49281. }
  49282. }
  49283. declare module BABYLON {
  49284. /**
  49285. * Defines supported buttons for DualShock compatible gamepads
  49286. */
  49287. export enum DualShockButton {
  49288. /** Cross */
  49289. Cross = 0,
  49290. /** Circle */
  49291. Circle = 1,
  49292. /** Square */
  49293. Square = 2,
  49294. /** Triangle */
  49295. Triangle = 3,
  49296. /** L1 */
  49297. L1 = 4,
  49298. /** R1 */
  49299. R1 = 5,
  49300. /** Share */
  49301. Share = 8,
  49302. /** Options */
  49303. Options = 9,
  49304. /** Left stick */
  49305. LeftStick = 10,
  49306. /** Right stick */
  49307. RightStick = 11
  49308. }
  49309. /** Defines values for DualShock DPad */
  49310. export enum DualShockDpad {
  49311. /** Up */
  49312. Up = 12,
  49313. /** Down */
  49314. Down = 13,
  49315. /** Left */
  49316. Left = 14,
  49317. /** Right */
  49318. Right = 15
  49319. }
  49320. /**
  49321. * Defines a DualShock gamepad
  49322. */
  49323. export class DualShockPad extends Gamepad {
  49324. private _leftTrigger;
  49325. private _rightTrigger;
  49326. private _onlefttriggerchanged;
  49327. private _onrighttriggerchanged;
  49328. private _onbuttondown;
  49329. private _onbuttonup;
  49330. private _ondpaddown;
  49331. private _ondpadup;
  49332. /** Observable raised when a button is pressed */
  49333. onButtonDownObservable: Observable<DualShockButton>;
  49334. /** Observable raised when a button is released */
  49335. onButtonUpObservable: Observable<DualShockButton>;
  49336. /** Observable raised when a pad is pressed */
  49337. onPadDownObservable: Observable<DualShockDpad>;
  49338. /** Observable raised when a pad is released */
  49339. onPadUpObservable: Observable<DualShockDpad>;
  49340. private _buttonCross;
  49341. private _buttonCircle;
  49342. private _buttonSquare;
  49343. private _buttonTriangle;
  49344. private _buttonShare;
  49345. private _buttonOptions;
  49346. private _buttonL1;
  49347. private _buttonR1;
  49348. private _buttonLeftStick;
  49349. private _buttonRightStick;
  49350. private _dPadUp;
  49351. private _dPadDown;
  49352. private _dPadLeft;
  49353. private _dPadRight;
  49354. /**
  49355. * Creates a new DualShock gamepad object
  49356. * @param id defines the id of this gamepad
  49357. * @param index defines its index
  49358. * @param gamepad defines the internal HTML gamepad object
  49359. */
  49360. constructor(id: string, index: number, gamepad: any);
  49361. /**
  49362. * Defines the callback to call when left trigger is pressed
  49363. * @param callback defines the callback to use
  49364. */
  49365. onlefttriggerchanged(callback: (value: number) => void): void;
  49366. /**
  49367. * Defines the callback to call when right trigger is pressed
  49368. * @param callback defines the callback to use
  49369. */
  49370. onrighttriggerchanged(callback: (value: number) => void): void;
  49371. /**
  49372. * Gets the left trigger value
  49373. */
  49374. get leftTrigger(): number;
  49375. /**
  49376. * Sets the left trigger value
  49377. */
  49378. set leftTrigger(newValue: number);
  49379. /**
  49380. * Gets the right trigger value
  49381. */
  49382. get rightTrigger(): number;
  49383. /**
  49384. * Sets the right trigger value
  49385. */
  49386. set rightTrigger(newValue: number);
  49387. /**
  49388. * Defines the callback to call when a button is pressed
  49389. * @param callback defines the callback to use
  49390. */
  49391. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  49392. /**
  49393. * Defines the callback to call when a button is released
  49394. * @param callback defines the callback to use
  49395. */
  49396. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  49397. /**
  49398. * Defines the callback to call when a pad is pressed
  49399. * @param callback defines the callback to use
  49400. */
  49401. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  49402. /**
  49403. * Defines the callback to call when a pad is released
  49404. * @param callback defines the callback to use
  49405. */
  49406. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  49407. private _setButtonValue;
  49408. private _setDPadValue;
  49409. /**
  49410. * Gets the value of the `Cross` button
  49411. */
  49412. get buttonCross(): number;
  49413. /**
  49414. * Sets the value of the `Cross` button
  49415. */
  49416. set buttonCross(value: number);
  49417. /**
  49418. * Gets the value of the `Circle` button
  49419. */
  49420. get buttonCircle(): number;
  49421. /**
  49422. * Sets the value of the `Circle` button
  49423. */
  49424. set buttonCircle(value: number);
  49425. /**
  49426. * Gets the value of the `Square` button
  49427. */
  49428. get buttonSquare(): number;
  49429. /**
  49430. * Sets the value of the `Square` button
  49431. */
  49432. set buttonSquare(value: number);
  49433. /**
  49434. * Gets the value of the `Triangle` button
  49435. */
  49436. get buttonTriangle(): number;
  49437. /**
  49438. * Sets the value of the `Triangle` button
  49439. */
  49440. set buttonTriangle(value: number);
  49441. /**
  49442. * Gets the value of the `Options` button
  49443. */
  49444. get buttonOptions(): number;
  49445. /**
  49446. * Sets the value of the `Options` button
  49447. */
  49448. set buttonOptions(value: number);
  49449. /**
  49450. * Gets the value of the `Share` button
  49451. */
  49452. get buttonShare(): number;
  49453. /**
  49454. * Sets the value of the `Share` button
  49455. */
  49456. set buttonShare(value: number);
  49457. /**
  49458. * Gets the value of the `L1` button
  49459. */
  49460. get buttonL1(): number;
  49461. /**
  49462. * Sets the value of the `L1` button
  49463. */
  49464. set buttonL1(value: number);
  49465. /**
  49466. * Gets the value of the `R1` button
  49467. */
  49468. get buttonR1(): number;
  49469. /**
  49470. * Sets the value of the `R1` button
  49471. */
  49472. set buttonR1(value: number);
  49473. /**
  49474. * Gets the value of the Left joystick
  49475. */
  49476. get buttonLeftStick(): number;
  49477. /**
  49478. * Sets the value of the Left joystick
  49479. */
  49480. set buttonLeftStick(value: number);
  49481. /**
  49482. * Gets the value of the Right joystick
  49483. */
  49484. get buttonRightStick(): number;
  49485. /**
  49486. * Sets the value of the Right joystick
  49487. */
  49488. set buttonRightStick(value: number);
  49489. /**
  49490. * Gets the value of D-pad up
  49491. */
  49492. get dPadUp(): number;
  49493. /**
  49494. * Sets the value of D-pad up
  49495. */
  49496. set dPadUp(value: number);
  49497. /**
  49498. * Gets the value of D-pad down
  49499. */
  49500. get dPadDown(): number;
  49501. /**
  49502. * Sets the value of D-pad down
  49503. */
  49504. set dPadDown(value: number);
  49505. /**
  49506. * Gets the value of D-pad left
  49507. */
  49508. get dPadLeft(): number;
  49509. /**
  49510. * Sets the value of D-pad left
  49511. */
  49512. set dPadLeft(value: number);
  49513. /**
  49514. * Gets the value of D-pad right
  49515. */
  49516. get dPadRight(): number;
  49517. /**
  49518. * Sets the value of D-pad right
  49519. */
  49520. set dPadRight(value: number);
  49521. /**
  49522. * Force the gamepad to synchronize with device values
  49523. */
  49524. update(): void;
  49525. /**
  49526. * Disposes the gamepad
  49527. */
  49528. dispose(): void;
  49529. }
  49530. }
  49531. declare module BABYLON {
  49532. /**
  49533. * Manager for handling gamepads
  49534. */
  49535. export class GamepadManager {
  49536. private _scene?;
  49537. private _babylonGamepads;
  49538. private _oneGamepadConnected;
  49539. /** @hidden */
  49540. _isMonitoring: boolean;
  49541. private _gamepadEventSupported;
  49542. private _gamepadSupport?;
  49543. /**
  49544. * observable to be triggered when the gamepad controller has been connected
  49545. */
  49546. onGamepadConnectedObservable: Observable<Gamepad>;
  49547. /**
  49548. * observable to be triggered when the gamepad controller has been disconnected
  49549. */
  49550. onGamepadDisconnectedObservable: Observable<Gamepad>;
  49551. private _onGamepadConnectedEvent;
  49552. private _onGamepadDisconnectedEvent;
  49553. /**
  49554. * Initializes the gamepad manager
  49555. * @param _scene BabylonJS scene
  49556. */
  49557. constructor(_scene?: Scene | undefined);
  49558. /**
  49559. * The gamepads in the game pad manager
  49560. */
  49561. get gamepads(): Gamepad[];
  49562. /**
  49563. * Get the gamepad controllers based on type
  49564. * @param type The type of gamepad controller
  49565. * @returns Nullable gamepad
  49566. */
  49567. getGamepadByType(type?: number): Nullable<Gamepad>;
  49568. /**
  49569. * Disposes the gamepad manager
  49570. */
  49571. dispose(): void;
  49572. private _addNewGamepad;
  49573. private _startMonitoringGamepads;
  49574. private _stopMonitoringGamepads;
  49575. /** @hidden */
  49576. _checkGamepadsStatus(): void;
  49577. private _updateGamepadObjects;
  49578. }
  49579. }
  49580. declare module BABYLON {
  49581. interface Scene {
  49582. /** @hidden */
  49583. _gamepadManager: Nullable<GamepadManager>;
  49584. /**
  49585. * Gets the gamepad manager associated with the scene
  49586. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  49587. */
  49588. gamepadManager: GamepadManager;
  49589. }
  49590. /**
  49591. * Interface representing a free camera inputs manager
  49592. */
  49593. interface FreeCameraInputsManager {
  49594. /**
  49595. * Adds gamepad input support to the FreeCameraInputsManager.
  49596. * @returns the FreeCameraInputsManager
  49597. */
  49598. addGamepad(): FreeCameraInputsManager;
  49599. }
  49600. /**
  49601. * Interface representing an arc rotate camera inputs manager
  49602. */
  49603. interface ArcRotateCameraInputsManager {
  49604. /**
  49605. * Adds gamepad input support to the ArcRotateCamera InputManager.
  49606. * @returns the camera inputs manager
  49607. */
  49608. addGamepad(): ArcRotateCameraInputsManager;
  49609. }
  49610. /**
  49611. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  49612. */
  49613. export class GamepadSystemSceneComponent implements ISceneComponent {
  49614. /**
  49615. * The component name helpfull to identify the component in the list of scene components.
  49616. */
  49617. readonly name: string;
  49618. /**
  49619. * The scene the component belongs to.
  49620. */
  49621. scene: Scene;
  49622. /**
  49623. * Creates a new instance of the component for the given scene
  49624. * @param scene Defines the scene to register the component in
  49625. */
  49626. constructor(scene: Scene);
  49627. /**
  49628. * Registers the component in a given scene
  49629. */
  49630. register(): void;
  49631. /**
  49632. * Rebuilds the elements related to this component in case of
  49633. * context lost for instance.
  49634. */
  49635. rebuild(): void;
  49636. /**
  49637. * Disposes the component and the associated ressources
  49638. */
  49639. dispose(): void;
  49640. private _beforeCameraUpdate;
  49641. }
  49642. }
  49643. declare module BABYLON {
  49644. /**
  49645. * 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,
  49646. * which still works and will still be found in many Playgrounds.
  49647. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49648. */
  49649. export class UniversalCamera extends TouchCamera {
  49650. /**
  49651. * Defines the gamepad rotation sensiblity.
  49652. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  49653. */
  49654. get gamepadAngularSensibility(): number;
  49655. set gamepadAngularSensibility(value: number);
  49656. /**
  49657. * Defines the gamepad move sensiblity.
  49658. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  49659. */
  49660. get gamepadMoveSensibility(): number;
  49661. set gamepadMoveSensibility(value: number);
  49662. /**
  49663. * 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,
  49664. * which still works and will still be found in many Playgrounds.
  49665. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49666. * @param name Define the name of the camera in the scene
  49667. * @param position Define the start position of the camera in the scene
  49668. * @param scene Define the scene the camera belongs to
  49669. */
  49670. constructor(name: string, position: Vector3, scene: Scene);
  49671. /**
  49672. * Gets the current object class name.
  49673. * @return the class name
  49674. */
  49675. getClassName(): string;
  49676. }
  49677. }
  49678. declare module BABYLON {
  49679. /**
  49680. * This represents a FPS type of camera. This is only here for back compat purpose.
  49681. * Please use the UniversalCamera instead as both are identical.
  49682. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49683. */
  49684. export class GamepadCamera extends UniversalCamera {
  49685. /**
  49686. * Instantiates a new Gamepad Camera
  49687. * This represents a FPS type of camera. This is only here for back compat purpose.
  49688. * Please use the UniversalCamera instead as both are identical.
  49689. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49690. * @param name Define the name of the camera in the scene
  49691. * @param position Define the start position of the camera in the scene
  49692. * @param scene Define the scene the camera belongs to
  49693. */
  49694. constructor(name: string, position: Vector3, scene: Scene);
  49695. /**
  49696. * Gets the current object class name.
  49697. * @return the class name
  49698. */
  49699. getClassName(): string;
  49700. }
  49701. }
  49702. declare module BABYLON {
  49703. /** @hidden */
  49704. export var passPixelShader: {
  49705. name: string;
  49706. shader: string;
  49707. };
  49708. }
  49709. declare module BABYLON {
  49710. /** @hidden */
  49711. export var passCubePixelShader: {
  49712. name: string;
  49713. shader: string;
  49714. };
  49715. }
  49716. declare module BABYLON {
  49717. /**
  49718. * PassPostProcess which produces an output the same as it's input
  49719. */
  49720. export class PassPostProcess extends PostProcess {
  49721. /**
  49722. * Gets a string identifying the name of the class
  49723. * @returns "PassPostProcess" string
  49724. */
  49725. getClassName(): string;
  49726. /**
  49727. * Creates the PassPostProcess
  49728. * @param name The name of the effect.
  49729. * @param options The required width/height ratio to downsize to before computing the render pass.
  49730. * @param camera The camera to apply the render pass to.
  49731. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49732. * @param engine The engine which the post process will be applied. (default: current engine)
  49733. * @param reusable If the post process can be reused on the same frame. (default: false)
  49734. * @param textureType The type of texture to be used when performing the post processing.
  49735. * @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)
  49736. */
  49737. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49738. /** @hidden */
  49739. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  49740. }
  49741. /**
  49742. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  49743. */
  49744. export class PassCubePostProcess extends PostProcess {
  49745. private _face;
  49746. /**
  49747. * Gets or sets the cube face to display.
  49748. * * 0 is +X
  49749. * * 1 is -X
  49750. * * 2 is +Y
  49751. * * 3 is -Y
  49752. * * 4 is +Z
  49753. * * 5 is -Z
  49754. */
  49755. get face(): number;
  49756. set face(value: number);
  49757. /**
  49758. * Gets a string identifying the name of the class
  49759. * @returns "PassCubePostProcess" string
  49760. */
  49761. getClassName(): string;
  49762. /**
  49763. * Creates the PassCubePostProcess
  49764. * @param name The name of the effect.
  49765. * @param options The required width/height ratio to downsize to before computing the render pass.
  49766. * @param camera The camera to apply the render pass to.
  49767. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49768. * @param engine The engine which the post process will be applied. (default: current engine)
  49769. * @param reusable If the post process can be reused on the same frame. (default: false)
  49770. * @param textureType The type of texture to be used when performing the post processing.
  49771. * @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)
  49772. */
  49773. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49774. /** @hidden */
  49775. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  49776. }
  49777. }
  49778. declare module BABYLON {
  49779. /** @hidden */
  49780. export var anaglyphPixelShader: {
  49781. name: string;
  49782. shader: string;
  49783. };
  49784. }
  49785. declare module BABYLON {
  49786. /**
  49787. * Postprocess used to generate anaglyphic rendering
  49788. */
  49789. export class AnaglyphPostProcess extends PostProcess {
  49790. private _passedProcess;
  49791. /**
  49792. * Gets a string identifying the name of the class
  49793. * @returns "AnaglyphPostProcess" string
  49794. */
  49795. getClassName(): string;
  49796. /**
  49797. * Creates a new AnaglyphPostProcess
  49798. * @param name defines postprocess name
  49799. * @param options defines creation options or target ratio scale
  49800. * @param rigCameras defines cameras using this postprocess
  49801. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  49802. * @param engine defines hosting engine
  49803. * @param reusable defines if the postprocess will be reused multiple times per frame
  49804. */
  49805. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  49806. }
  49807. }
  49808. declare module BABYLON {
  49809. /**
  49810. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  49811. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49812. */
  49813. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  49814. /**
  49815. * Creates a new AnaglyphArcRotateCamera
  49816. * @param name defines camera name
  49817. * @param alpha defines alpha angle (in radians)
  49818. * @param beta defines beta angle (in radians)
  49819. * @param radius defines radius
  49820. * @param target defines camera target
  49821. * @param interaxialDistance defines distance between each color axis
  49822. * @param scene defines the hosting scene
  49823. */
  49824. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  49825. /**
  49826. * Gets camera class name
  49827. * @returns AnaglyphArcRotateCamera
  49828. */
  49829. getClassName(): string;
  49830. }
  49831. }
  49832. declare module BABYLON {
  49833. /**
  49834. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  49835. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49836. */
  49837. export class AnaglyphFreeCamera extends FreeCamera {
  49838. /**
  49839. * Creates a new AnaglyphFreeCamera
  49840. * @param name defines camera name
  49841. * @param position defines initial position
  49842. * @param interaxialDistance defines distance between each color axis
  49843. * @param scene defines the hosting scene
  49844. */
  49845. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49846. /**
  49847. * Gets camera class name
  49848. * @returns AnaglyphFreeCamera
  49849. */
  49850. getClassName(): string;
  49851. }
  49852. }
  49853. declare module BABYLON {
  49854. /**
  49855. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  49856. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49857. */
  49858. export class AnaglyphGamepadCamera extends GamepadCamera {
  49859. /**
  49860. * Creates a new AnaglyphGamepadCamera
  49861. * @param name defines camera name
  49862. * @param position defines initial position
  49863. * @param interaxialDistance defines distance between each color axis
  49864. * @param scene defines the hosting scene
  49865. */
  49866. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49867. /**
  49868. * Gets camera class name
  49869. * @returns AnaglyphGamepadCamera
  49870. */
  49871. getClassName(): string;
  49872. }
  49873. }
  49874. declare module BABYLON {
  49875. /**
  49876. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  49877. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49878. */
  49879. export class AnaglyphUniversalCamera extends UniversalCamera {
  49880. /**
  49881. * Creates a new AnaglyphUniversalCamera
  49882. * @param name defines camera name
  49883. * @param position defines initial position
  49884. * @param interaxialDistance defines distance between each color axis
  49885. * @param scene defines the hosting scene
  49886. */
  49887. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49888. /**
  49889. * Gets camera class name
  49890. * @returns AnaglyphUniversalCamera
  49891. */
  49892. getClassName(): string;
  49893. }
  49894. }
  49895. declare module BABYLON {
  49896. /**
  49897. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  49898. * @see https://doc.babylonjs.com/features/cameras
  49899. */
  49900. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  49901. /**
  49902. * Creates a new StereoscopicArcRotateCamera
  49903. * @param name defines camera name
  49904. * @param alpha defines alpha angle (in radians)
  49905. * @param beta defines beta angle (in radians)
  49906. * @param radius defines radius
  49907. * @param target defines camera target
  49908. * @param interaxialDistance defines distance between each color axis
  49909. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49910. * @param scene defines the hosting scene
  49911. */
  49912. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49913. /**
  49914. * Gets camera class name
  49915. * @returns StereoscopicArcRotateCamera
  49916. */
  49917. getClassName(): string;
  49918. }
  49919. }
  49920. declare module BABYLON {
  49921. /**
  49922. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  49923. * @see https://doc.babylonjs.com/features/cameras
  49924. */
  49925. export class StereoscopicFreeCamera extends FreeCamera {
  49926. /**
  49927. * Creates a new StereoscopicFreeCamera
  49928. * @param name defines camera name
  49929. * @param position defines initial position
  49930. * @param interaxialDistance defines distance between each color axis
  49931. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49932. * @param scene defines the hosting scene
  49933. */
  49934. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49935. /**
  49936. * Gets camera class name
  49937. * @returns StereoscopicFreeCamera
  49938. */
  49939. getClassName(): string;
  49940. }
  49941. }
  49942. declare module BABYLON {
  49943. /**
  49944. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  49945. * @see https://doc.babylonjs.com/features/cameras
  49946. */
  49947. export class StereoscopicGamepadCamera extends GamepadCamera {
  49948. /**
  49949. * Creates a new StereoscopicGamepadCamera
  49950. * @param name defines camera name
  49951. * @param position defines initial position
  49952. * @param interaxialDistance defines distance between each color axis
  49953. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49954. * @param scene defines the hosting scene
  49955. */
  49956. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49957. /**
  49958. * Gets camera class name
  49959. * @returns StereoscopicGamepadCamera
  49960. */
  49961. getClassName(): string;
  49962. }
  49963. }
  49964. declare module BABYLON {
  49965. /**
  49966. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  49967. * @see https://doc.babylonjs.com/features/cameras
  49968. */
  49969. export class StereoscopicUniversalCamera extends UniversalCamera {
  49970. /**
  49971. * Creates a new StereoscopicUniversalCamera
  49972. * @param name defines camera name
  49973. * @param position defines initial position
  49974. * @param interaxialDistance defines distance between each color axis
  49975. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49976. * @param scene defines the hosting scene
  49977. */
  49978. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49979. /**
  49980. * Gets camera class name
  49981. * @returns StereoscopicUniversalCamera
  49982. */
  49983. getClassName(): string;
  49984. }
  49985. }
  49986. declare module BABYLON {
  49987. /**
  49988. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  49989. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  49990. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  49991. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  49992. */
  49993. export class VirtualJoysticksCamera extends FreeCamera {
  49994. /**
  49995. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  49996. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  49997. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  49998. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  49999. * @param name Define the name of the camera in the scene
  50000. * @param position Define the start position of the camera in the scene
  50001. * @param scene Define the scene the camera belongs to
  50002. */
  50003. constructor(name: string, position: Vector3, scene: Scene);
  50004. /**
  50005. * Gets the current object class name.
  50006. * @return the class name
  50007. */
  50008. getClassName(): string;
  50009. }
  50010. }
  50011. declare module BABYLON {
  50012. /**
  50013. * This represents all the required metrics to create a VR camera.
  50014. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  50015. */
  50016. export class VRCameraMetrics {
  50017. /**
  50018. * Define the horizontal resolution off the screen.
  50019. */
  50020. hResolution: number;
  50021. /**
  50022. * Define the vertical resolution off the screen.
  50023. */
  50024. vResolution: number;
  50025. /**
  50026. * Define the horizontal screen size.
  50027. */
  50028. hScreenSize: number;
  50029. /**
  50030. * Define the vertical screen size.
  50031. */
  50032. vScreenSize: number;
  50033. /**
  50034. * Define the vertical screen center position.
  50035. */
  50036. vScreenCenter: number;
  50037. /**
  50038. * Define the distance of the eyes to the screen.
  50039. */
  50040. eyeToScreenDistance: number;
  50041. /**
  50042. * Define the distance between both lenses
  50043. */
  50044. lensSeparationDistance: number;
  50045. /**
  50046. * Define the distance between both viewer's eyes.
  50047. */
  50048. interpupillaryDistance: number;
  50049. /**
  50050. * Define the distortion factor of the VR postprocess.
  50051. * Please, touch with care.
  50052. */
  50053. distortionK: number[];
  50054. /**
  50055. * Define the chromatic aberration correction factors for the VR post process.
  50056. */
  50057. chromaAbCorrection: number[];
  50058. /**
  50059. * Define the scale factor of the post process.
  50060. * The smaller the better but the slower.
  50061. */
  50062. postProcessScaleFactor: number;
  50063. /**
  50064. * Define an offset for the lens center.
  50065. */
  50066. lensCenterOffset: number;
  50067. /**
  50068. * Define if the current vr camera should compensate the distortion of the lense or not.
  50069. */
  50070. compensateDistortion: boolean;
  50071. /**
  50072. * Defines if multiview should be enabled when rendering (Default: false)
  50073. */
  50074. multiviewEnabled: boolean;
  50075. /**
  50076. * Gets the rendering aspect ratio based on the provided resolutions.
  50077. */
  50078. get aspectRatio(): number;
  50079. /**
  50080. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  50081. */
  50082. get aspectRatioFov(): number;
  50083. /**
  50084. * @hidden
  50085. */
  50086. get leftHMatrix(): Matrix;
  50087. /**
  50088. * @hidden
  50089. */
  50090. get rightHMatrix(): Matrix;
  50091. /**
  50092. * @hidden
  50093. */
  50094. get leftPreViewMatrix(): Matrix;
  50095. /**
  50096. * @hidden
  50097. */
  50098. get rightPreViewMatrix(): Matrix;
  50099. /**
  50100. * Get the default VRMetrics based on the most generic setup.
  50101. * @returns the default vr metrics
  50102. */
  50103. static GetDefault(): VRCameraMetrics;
  50104. }
  50105. }
  50106. declare module BABYLON {
  50107. /** @hidden */
  50108. export var vrDistortionCorrectionPixelShader: {
  50109. name: string;
  50110. shader: string;
  50111. };
  50112. }
  50113. declare module BABYLON {
  50114. /**
  50115. * VRDistortionCorrectionPostProcess used for mobile VR
  50116. */
  50117. export class VRDistortionCorrectionPostProcess extends PostProcess {
  50118. private _isRightEye;
  50119. private _distortionFactors;
  50120. private _postProcessScaleFactor;
  50121. private _lensCenterOffset;
  50122. private _scaleIn;
  50123. private _scaleFactor;
  50124. private _lensCenter;
  50125. /**
  50126. * Gets a string identifying the name of the class
  50127. * @returns "VRDistortionCorrectionPostProcess" string
  50128. */
  50129. getClassName(): string;
  50130. /**
  50131. * Initializes the VRDistortionCorrectionPostProcess
  50132. * @param name The name of the effect.
  50133. * @param camera The camera to apply the render pass to.
  50134. * @param isRightEye If this is for the right eye distortion
  50135. * @param vrMetrics All the required metrics for the VR camera
  50136. */
  50137. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  50138. }
  50139. }
  50140. declare module BABYLON {
  50141. /**
  50142. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  50143. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  50144. */
  50145. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  50146. /**
  50147. * Creates a new VRDeviceOrientationArcRotateCamera
  50148. * @param name defines camera name
  50149. * @param alpha defines the camera rotation along the logitudinal axis
  50150. * @param beta defines the camera rotation along the latitudinal axis
  50151. * @param radius defines the camera distance from its target
  50152. * @param target defines the camera target
  50153. * @param scene defines the scene the camera belongs to
  50154. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  50155. * @param vrCameraMetrics defines the vr metrics associated to the camera
  50156. */
  50157. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  50158. /**
  50159. * Gets camera class name
  50160. * @returns VRDeviceOrientationArcRotateCamera
  50161. */
  50162. getClassName(): string;
  50163. }
  50164. }
  50165. declare module BABYLON {
  50166. /**
  50167. * Camera used to simulate VR rendering (based on FreeCamera)
  50168. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  50169. */
  50170. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  50171. /**
  50172. * Creates a new VRDeviceOrientationFreeCamera
  50173. * @param name defines camera name
  50174. * @param position defines the start position of the camera
  50175. * @param scene defines the scene the camera belongs to
  50176. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  50177. * @param vrCameraMetrics defines the vr metrics associated to the camera
  50178. */
  50179. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  50180. /**
  50181. * Gets camera class name
  50182. * @returns VRDeviceOrientationFreeCamera
  50183. */
  50184. getClassName(): string;
  50185. }
  50186. }
  50187. declare module BABYLON {
  50188. /**
  50189. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  50190. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  50191. */
  50192. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  50193. /**
  50194. * Creates a new VRDeviceOrientationGamepadCamera
  50195. * @param name defines camera name
  50196. * @param position defines the start position of the camera
  50197. * @param scene defines the scene the camera belongs to
  50198. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  50199. * @param vrCameraMetrics defines the vr metrics associated to the camera
  50200. */
  50201. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  50202. /**
  50203. * Gets camera class name
  50204. * @returns VRDeviceOrientationGamepadCamera
  50205. */
  50206. getClassName(): string;
  50207. }
  50208. }
  50209. declare module BABYLON {
  50210. /**
  50211. * A class extending Texture allowing drawing on a texture
  50212. * @see https://doc.babylonjs.com/how_to/dynamictexture
  50213. */
  50214. export class DynamicTexture extends Texture {
  50215. private _generateMipMaps;
  50216. private _canvas;
  50217. private _context;
  50218. /**
  50219. * Creates a DynamicTexture
  50220. * @param name defines the name of the texture
  50221. * @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
  50222. * @param scene defines the scene where you want the texture
  50223. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  50224. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  50225. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  50226. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  50227. */
  50228. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  50229. /**
  50230. * Get the current class name of the texture useful for serialization or dynamic coding.
  50231. * @returns "DynamicTexture"
  50232. */
  50233. getClassName(): string;
  50234. /**
  50235. * Gets the current state of canRescale
  50236. */
  50237. get canRescale(): boolean;
  50238. private _recreate;
  50239. /**
  50240. * Scales the texture
  50241. * @param ratio the scale factor to apply to both width and height
  50242. */
  50243. scale(ratio: number): void;
  50244. /**
  50245. * Resizes the texture
  50246. * @param width the new width
  50247. * @param height the new height
  50248. */
  50249. scaleTo(width: number, height: number): void;
  50250. /**
  50251. * Gets the context of the canvas used by the texture
  50252. * @returns the canvas context of the dynamic texture
  50253. */
  50254. getContext(): CanvasRenderingContext2D;
  50255. /**
  50256. * Clears the texture
  50257. */
  50258. clear(): void;
  50259. /**
  50260. * Updates the texture
  50261. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  50262. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  50263. */
  50264. update(invertY?: boolean, premulAlpha?: boolean): void;
  50265. /**
  50266. * Draws text onto the texture
  50267. * @param text defines the text to be drawn
  50268. * @param x defines the placement of the text from the left
  50269. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  50270. * @param font defines the font to be used with font-style, font-size, font-name
  50271. * @param color defines the color used for the text
  50272. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  50273. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  50274. * @param update defines whether texture is immediately update (default is true)
  50275. */
  50276. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  50277. /**
  50278. * Clones the texture
  50279. * @returns the clone of the texture.
  50280. */
  50281. clone(): DynamicTexture;
  50282. /**
  50283. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  50284. * @returns a serialized dynamic texture object
  50285. */
  50286. serialize(): any;
  50287. private _IsCanvasElement;
  50288. /** @hidden */
  50289. _rebuild(): void;
  50290. }
  50291. }
  50292. declare module BABYLON {
  50293. /**
  50294. * Class containing static functions to help procedurally build meshes
  50295. */
  50296. export class GroundBuilder {
  50297. /**
  50298. * Creates a ground mesh
  50299. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  50300. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  50301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50302. * @param name defines the name of the mesh
  50303. * @param options defines the options used to create the mesh
  50304. * @param scene defines the hosting scene
  50305. * @returns the ground mesh
  50306. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  50307. */
  50308. static CreateGround(name: string, options: {
  50309. width?: number;
  50310. height?: number;
  50311. subdivisions?: number;
  50312. subdivisionsX?: number;
  50313. subdivisionsY?: number;
  50314. updatable?: boolean;
  50315. }, scene: any): Mesh;
  50316. /**
  50317. * Creates a tiled ground mesh
  50318. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50319. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50320. * * 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
  50321. * * 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
  50322. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50323. * @param name defines the name of the mesh
  50324. * @param options defines the options used to create the mesh
  50325. * @param scene defines the hosting scene
  50326. * @returns the tiled ground mesh
  50327. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50328. */
  50329. static CreateTiledGround(name: string, options: {
  50330. xmin: number;
  50331. zmin: number;
  50332. xmax: number;
  50333. zmax: number;
  50334. subdivisions?: {
  50335. w: number;
  50336. h: number;
  50337. };
  50338. precision?: {
  50339. w: number;
  50340. h: number;
  50341. };
  50342. updatable?: boolean;
  50343. }, scene?: Nullable<Scene>): Mesh;
  50344. /**
  50345. * Creates a ground mesh from a height map
  50346. * * The parameter `url` sets the URL of the height map image resource.
  50347. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50348. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50349. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50350. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50351. * * 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.
  50352. * * 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).
  50353. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50354. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50355. * @param name defines the name of the mesh
  50356. * @param url defines the url to the height map
  50357. * @param options defines the options used to create the mesh
  50358. * @param scene defines the hosting scene
  50359. * @returns the ground mesh
  50360. * @see https://doc.babylonjs.com/babylon101/height_map
  50361. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50362. */
  50363. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50364. width?: number;
  50365. height?: number;
  50366. subdivisions?: number;
  50367. minHeight?: number;
  50368. maxHeight?: number;
  50369. colorFilter?: Color3;
  50370. alphaFilter?: number;
  50371. updatable?: boolean;
  50372. onReady?: (mesh: GroundMesh) => void;
  50373. }, scene?: Nullable<Scene>): GroundMesh;
  50374. }
  50375. }
  50376. declare module BABYLON {
  50377. /**
  50378. * Class containing static functions to help procedurally build meshes
  50379. */
  50380. export class TorusBuilder {
  50381. /**
  50382. * Creates a torus mesh
  50383. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  50384. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  50385. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  50386. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50387. * * 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
  50388. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50389. * @param name defines the name of the mesh
  50390. * @param options defines the options used to create the mesh
  50391. * @param scene defines the hosting scene
  50392. * @returns the torus mesh
  50393. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  50394. */
  50395. static CreateTorus(name: string, options: {
  50396. diameter?: number;
  50397. thickness?: number;
  50398. tessellation?: number;
  50399. updatable?: boolean;
  50400. sideOrientation?: number;
  50401. frontUVs?: Vector4;
  50402. backUVs?: Vector4;
  50403. }, scene: any): Mesh;
  50404. }
  50405. }
  50406. declare module BABYLON {
  50407. /**
  50408. * Class containing static functions to help procedurally build meshes
  50409. */
  50410. export class CylinderBuilder {
  50411. /**
  50412. * Creates a cylinder or a cone mesh
  50413. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  50414. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  50415. * * 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.
  50416. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  50417. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50418. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  50419. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  50420. * * 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).
  50421. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  50422. * * 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).
  50423. * * 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
  50424. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  50425. * * 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
  50426. * * 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.
  50427. * * If `enclose` is false, a ring surface is one element.
  50428. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  50429. * * 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
  50430. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50431. * * 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
  50432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50433. * @param name defines the name of the mesh
  50434. * @param options defines the options used to create the mesh
  50435. * @param scene defines the hosting scene
  50436. * @returns the cylinder mesh
  50437. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  50438. */
  50439. static CreateCylinder(name: string, options: {
  50440. height?: number;
  50441. diameterTop?: number;
  50442. diameterBottom?: number;
  50443. diameter?: number;
  50444. tessellation?: number;
  50445. subdivisions?: number;
  50446. arc?: number;
  50447. faceColors?: Color4[];
  50448. faceUV?: Vector4[];
  50449. updatable?: boolean;
  50450. hasRings?: boolean;
  50451. enclose?: boolean;
  50452. cap?: number;
  50453. sideOrientation?: number;
  50454. frontUVs?: Vector4;
  50455. backUVs?: Vector4;
  50456. }, scene: any): Mesh;
  50457. }
  50458. }
  50459. declare module BABYLON {
  50460. /**
  50461. * States of the webXR experience
  50462. */
  50463. export enum WebXRState {
  50464. /**
  50465. * Transitioning to being in XR mode
  50466. */
  50467. ENTERING_XR = 0,
  50468. /**
  50469. * Transitioning to non XR mode
  50470. */
  50471. EXITING_XR = 1,
  50472. /**
  50473. * In XR mode and presenting
  50474. */
  50475. IN_XR = 2,
  50476. /**
  50477. * Not entered XR mode
  50478. */
  50479. NOT_IN_XR = 3
  50480. }
  50481. /**
  50482. * The state of the XR camera's tracking
  50483. */
  50484. export enum WebXRTrackingState {
  50485. /**
  50486. * No transformation received, device is not being tracked
  50487. */
  50488. NOT_TRACKING = 0,
  50489. /**
  50490. * Tracking lost - using emulated position
  50491. */
  50492. TRACKING_LOST = 1,
  50493. /**
  50494. * Transformation tracking works normally
  50495. */
  50496. TRACKING = 2
  50497. }
  50498. /**
  50499. * Abstraction of the XR render target
  50500. */
  50501. export interface WebXRRenderTarget extends IDisposable {
  50502. /**
  50503. * xrpresent context of the canvas which can be used to display/mirror xr content
  50504. */
  50505. canvasContext: WebGLRenderingContext;
  50506. /**
  50507. * xr layer for the canvas
  50508. */
  50509. xrLayer: Nullable<XRWebGLLayer>;
  50510. /**
  50511. * Initializes the xr layer for the session
  50512. * @param xrSession xr session
  50513. * @returns a promise that will resolve once the XR Layer has been created
  50514. */
  50515. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  50516. }
  50517. }
  50518. declare module BABYLON {
  50519. /**
  50520. * COnfiguration object for WebXR output canvas
  50521. */
  50522. export class WebXRManagedOutputCanvasOptions {
  50523. /**
  50524. * An optional canvas in case you wish to create it yourself and provide it here.
  50525. * If not provided, a new canvas will be created
  50526. */
  50527. canvasElement?: HTMLCanvasElement;
  50528. /**
  50529. * Options for this XR Layer output
  50530. */
  50531. canvasOptions?: XRWebGLLayerInit;
  50532. /**
  50533. * CSS styling for a newly created canvas (if not provided)
  50534. */
  50535. newCanvasCssStyle?: string;
  50536. /**
  50537. * Get the default values of the configuration object
  50538. * @param engine defines the engine to use (can be null)
  50539. * @returns default values of this configuration object
  50540. */
  50541. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  50542. }
  50543. /**
  50544. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  50545. */
  50546. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  50547. private _options;
  50548. private _canvas;
  50549. private _engine;
  50550. private _originalCanvasSize;
  50551. /**
  50552. * Rendering context of the canvas which can be used to display/mirror xr content
  50553. */
  50554. canvasContext: WebGLRenderingContext;
  50555. /**
  50556. * xr layer for the canvas
  50557. */
  50558. xrLayer: Nullable<XRWebGLLayer>;
  50559. /**
  50560. * Obseervers registered here will be triggered when the xr layer was initialized
  50561. */
  50562. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  50563. /**
  50564. * Initializes the canvas to be added/removed upon entering/exiting xr
  50565. * @param _xrSessionManager The XR Session manager
  50566. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  50567. */
  50568. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  50569. /**
  50570. * Disposes of the object
  50571. */
  50572. dispose(): void;
  50573. /**
  50574. * Initializes the xr layer for the session
  50575. * @param xrSession xr session
  50576. * @returns a promise that will resolve once the XR Layer has been created
  50577. */
  50578. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  50579. private _addCanvas;
  50580. private _removeCanvas;
  50581. private _setCanvasSize;
  50582. private _setManagedOutputCanvas;
  50583. }
  50584. }
  50585. declare module BABYLON {
  50586. /**
  50587. * Manages an XRSession to work with Babylon's engine
  50588. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  50589. */
  50590. export class WebXRSessionManager implements IDisposable {
  50591. /** The scene which the session should be created for */
  50592. scene: Scene;
  50593. private _referenceSpace;
  50594. private _rttProvider;
  50595. private _sessionEnded;
  50596. private _xrNavigator;
  50597. private baseLayer;
  50598. /**
  50599. * The base reference space from which the session started. good if you want to reset your
  50600. * reference space
  50601. */
  50602. baseReferenceSpace: XRReferenceSpace;
  50603. /**
  50604. * Current XR frame
  50605. */
  50606. currentFrame: Nullable<XRFrame>;
  50607. /** WebXR timestamp updated every frame */
  50608. currentTimestamp: number;
  50609. /**
  50610. * Used just in case of a failure to initialize an immersive session.
  50611. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  50612. */
  50613. defaultHeightCompensation: number;
  50614. /**
  50615. * Fires every time a new xrFrame arrives which can be used to update the camera
  50616. */
  50617. onXRFrameObservable: Observable<XRFrame>;
  50618. /**
  50619. * Fires when the reference space changed
  50620. */
  50621. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  50622. /**
  50623. * Fires when the xr session is ended either by the device or manually done
  50624. */
  50625. onXRSessionEnded: Observable<any>;
  50626. /**
  50627. * Fires when the xr session is ended either by the device or manually done
  50628. */
  50629. onXRSessionInit: Observable<XRSession>;
  50630. /**
  50631. * Underlying xr session
  50632. */
  50633. session: XRSession;
  50634. /**
  50635. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  50636. * or get the offset the player is currently at.
  50637. */
  50638. viewerReferenceSpace: XRReferenceSpace;
  50639. /**
  50640. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  50641. * @param scene The scene which the session should be created for
  50642. */
  50643. constructor(
  50644. /** The scene which the session should be created for */
  50645. scene: Scene);
  50646. /**
  50647. * The current reference space used in this session. This reference space can constantly change!
  50648. * It is mainly used to offset the camera's position.
  50649. */
  50650. get referenceSpace(): XRReferenceSpace;
  50651. /**
  50652. * Set a new reference space and triggers the observable
  50653. */
  50654. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  50655. /**
  50656. * Disposes of the session manager
  50657. */
  50658. dispose(): void;
  50659. /**
  50660. * Stops the xrSession and restores the render loop
  50661. * @returns Promise which resolves after it exits XR
  50662. */
  50663. exitXRAsync(): Promise<void>;
  50664. /**
  50665. * Gets the correct render target texture to be rendered this frame for this eye
  50666. * @param eye the eye for which to get the render target
  50667. * @returns the render target for the specified eye
  50668. */
  50669. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  50670. /**
  50671. * Creates a WebXRRenderTarget object for the XR session
  50672. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  50673. * @param options optional options to provide when creating a new render target
  50674. * @returns a WebXR render target to which the session can render
  50675. */
  50676. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  50677. /**
  50678. * Initializes the manager
  50679. * After initialization enterXR can be called to start an XR session
  50680. * @returns Promise which resolves after it is initialized
  50681. */
  50682. initializeAsync(): Promise<void>;
  50683. /**
  50684. * Initializes an xr session
  50685. * @param xrSessionMode mode to initialize
  50686. * @param xrSessionInit defines optional and required values to pass to the session builder
  50687. * @returns a promise which will resolve once the session has been initialized
  50688. */
  50689. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  50690. /**
  50691. * Checks if a session would be supported for the creation options specified
  50692. * @param sessionMode session mode to check if supported eg. immersive-vr
  50693. * @returns A Promise that resolves to true if supported and false if not
  50694. */
  50695. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50696. /**
  50697. * Resets the reference space to the one started the session
  50698. */
  50699. resetReferenceSpace(): void;
  50700. /**
  50701. * Starts rendering to the xr layer
  50702. */
  50703. runXRRenderLoop(): void;
  50704. /**
  50705. * Sets the reference space on the xr session
  50706. * @param referenceSpaceType space to set
  50707. * @returns a promise that will resolve once the reference space has been set
  50708. */
  50709. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  50710. /**
  50711. * Updates the render state of the session
  50712. * @param state state to set
  50713. * @returns a promise that resolves once the render state has been updated
  50714. */
  50715. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  50716. /**
  50717. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  50718. * @param sessionMode defines the session to test
  50719. * @returns a promise with boolean as final value
  50720. */
  50721. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50722. private _createRenderTargetTexture;
  50723. }
  50724. }
  50725. declare module BABYLON {
  50726. /**
  50727. * WebXR Camera which holds the views for the xrSession
  50728. * @see https://doc.babylonjs.com/how_to/webxr_camera
  50729. */
  50730. export class WebXRCamera extends FreeCamera {
  50731. private _xrSessionManager;
  50732. private _firstFrame;
  50733. private _referenceQuaternion;
  50734. private _referencedPosition;
  50735. private _xrInvPositionCache;
  50736. private _xrInvQuaternionCache;
  50737. private _trackingState;
  50738. /**
  50739. * Observable raised before camera teleportation
  50740. */
  50741. onBeforeCameraTeleport: Observable<Vector3>;
  50742. /**
  50743. * Observable raised after camera teleportation
  50744. */
  50745. onAfterCameraTeleport: Observable<Vector3>;
  50746. /**
  50747. * Notifies when the camera's tracking state has changed.
  50748. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  50749. */
  50750. onTrackingStateChanged: Observable<WebXRTrackingState>;
  50751. /**
  50752. * Should position compensation execute on first frame.
  50753. * This is used when copying the position from a native (non XR) camera
  50754. */
  50755. compensateOnFirstFrame: boolean;
  50756. /**
  50757. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  50758. * @param name the name of the camera
  50759. * @param scene the scene to add the camera to
  50760. * @param _xrSessionManager a constructed xr session manager
  50761. */
  50762. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  50763. /**
  50764. * Get the current XR tracking state of the camera
  50765. */
  50766. get trackingState(): WebXRTrackingState;
  50767. private _setTrackingState;
  50768. /**
  50769. * Return the user's height, unrelated to the current ground.
  50770. * This will be the y position of this camera, when ground level is 0.
  50771. */
  50772. get realWorldHeight(): number;
  50773. /** @hidden */
  50774. _updateForDualEyeDebugging(): void;
  50775. /**
  50776. * Sets this camera's transformation based on a non-vr camera
  50777. * @param otherCamera the non-vr camera to copy the transformation from
  50778. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  50779. */
  50780. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  50781. /**
  50782. * Gets the current instance class name ("WebXRCamera").
  50783. * @returns the class name
  50784. */
  50785. getClassName(): string;
  50786. private _rotate180;
  50787. private _updateFromXRSession;
  50788. private _updateNumberOfRigCameras;
  50789. private _updateReferenceSpace;
  50790. private _updateReferenceSpaceOffset;
  50791. }
  50792. }
  50793. declare module BABYLON {
  50794. /**
  50795. * Defining the interface required for a (webxr) feature
  50796. */
  50797. export interface IWebXRFeature extends IDisposable {
  50798. /**
  50799. * Is this feature attached
  50800. */
  50801. attached: boolean;
  50802. /**
  50803. * Should auto-attach be disabled?
  50804. */
  50805. disableAutoAttach: boolean;
  50806. /**
  50807. * Attach the feature to the session
  50808. * Will usually be called by the features manager
  50809. *
  50810. * @param force should attachment be forced (even when already attached)
  50811. * @returns true if successful.
  50812. */
  50813. attach(force?: boolean): boolean;
  50814. /**
  50815. * Detach the feature from the session
  50816. * Will usually be called by the features manager
  50817. *
  50818. * @returns true if successful.
  50819. */
  50820. detach(): boolean;
  50821. /**
  50822. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50823. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50824. *
  50825. * @returns whether or not the feature is compatible in this environment
  50826. */
  50827. isCompatible(): boolean;
  50828. /**
  50829. * Was this feature disposed;
  50830. */
  50831. isDisposed: boolean;
  50832. /**
  50833. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  50834. */
  50835. xrNativeFeatureName?: string;
  50836. /**
  50837. * A list of (Babylon WebXR) features this feature depends on
  50838. */
  50839. dependsOn?: string[];
  50840. }
  50841. /**
  50842. * A list of the currently available features without referencing them
  50843. */
  50844. export class WebXRFeatureName {
  50845. /**
  50846. * The name of the anchor system feature
  50847. */
  50848. static readonly ANCHOR_SYSTEM: string;
  50849. /**
  50850. * The name of the background remover feature
  50851. */
  50852. static readonly BACKGROUND_REMOVER: string;
  50853. /**
  50854. * The name of the hit test feature
  50855. */
  50856. static readonly HIT_TEST: string;
  50857. /**
  50858. * physics impostors for xr controllers feature
  50859. */
  50860. static readonly PHYSICS_CONTROLLERS: string;
  50861. /**
  50862. * The name of the plane detection feature
  50863. */
  50864. static readonly PLANE_DETECTION: string;
  50865. /**
  50866. * The name of the pointer selection feature
  50867. */
  50868. static readonly POINTER_SELECTION: string;
  50869. /**
  50870. * The name of the teleportation feature
  50871. */
  50872. static readonly TELEPORTATION: string;
  50873. /**
  50874. * The name of the feature points feature.
  50875. */
  50876. static readonly FEATURE_POINTS: string;
  50877. /**
  50878. * The name of the hand tracking feature.
  50879. */
  50880. static readonly HAND_TRACKING: string;
  50881. }
  50882. /**
  50883. * Defining the constructor of a feature. Used to register the modules.
  50884. */
  50885. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  50886. /**
  50887. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  50888. * It is mainly used in AR sessions.
  50889. *
  50890. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  50891. */
  50892. export class WebXRFeaturesManager implements IDisposable {
  50893. private _xrSessionManager;
  50894. private static readonly _AvailableFeatures;
  50895. private _features;
  50896. /**
  50897. * constructs a new features manages.
  50898. *
  50899. * @param _xrSessionManager an instance of WebXRSessionManager
  50900. */
  50901. constructor(_xrSessionManager: WebXRSessionManager);
  50902. /**
  50903. * Used to register a module. After calling this function a developer can use this feature in the scene.
  50904. * Mainly used internally.
  50905. *
  50906. * @param featureName the name of the feature to register
  50907. * @param constructorFunction the function used to construct the module
  50908. * @param version the (babylon) version of the module
  50909. * @param stable is that a stable version of this module
  50910. */
  50911. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  50912. /**
  50913. * Returns a constructor of a specific feature.
  50914. *
  50915. * @param featureName the name of the feature to construct
  50916. * @param version the version of the feature to load
  50917. * @param xrSessionManager the xrSessionManager. Used to construct the module
  50918. * @param options optional options provided to the module.
  50919. * @returns a function that, when called, will return a new instance of this feature
  50920. */
  50921. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  50922. /**
  50923. * Can be used to return the list of features currently registered
  50924. *
  50925. * @returns an Array of available features
  50926. */
  50927. static GetAvailableFeatures(): string[];
  50928. /**
  50929. * Gets the versions available for a specific feature
  50930. * @param featureName the name of the feature
  50931. * @returns an array with the available versions
  50932. */
  50933. static GetAvailableVersions(featureName: string): string[];
  50934. /**
  50935. * Return the latest unstable version of this feature
  50936. * @param featureName the name of the feature to search
  50937. * @returns the version number. if not found will return -1
  50938. */
  50939. static GetLatestVersionOfFeature(featureName: string): number;
  50940. /**
  50941. * Return the latest stable version of this feature
  50942. * @param featureName the name of the feature to search
  50943. * @returns the version number. if not found will return -1
  50944. */
  50945. static GetStableVersionOfFeature(featureName: string): number;
  50946. /**
  50947. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  50948. * Can be used during a session to start a feature
  50949. * @param featureName the name of feature to attach
  50950. */
  50951. attachFeature(featureName: string): void;
  50952. /**
  50953. * Can be used inside a session or when the session ends to detach a specific feature
  50954. * @param featureName the name of the feature to detach
  50955. */
  50956. detachFeature(featureName: string): void;
  50957. /**
  50958. * Used to disable an already-enabled feature
  50959. * The feature will be disposed and will be recreated once enabled.
  50960. * @param featureName the feature to disable
  50961. * @returns true if disable was successful
  50962. */
  50963. disableFeature(featureName: string | {
  50964. Name: string;
  50965. }): boolean;
  50966. /**
  50967. * dispose this features manager
  50968. */
  50969. dispose(): void;
  50970. /**
  50971. * Enable a feature using its name and a version. This will enable it in the scene, and will be responsible to attach it when the session starts.
  50972. * If used twice, the old version will be disposed and a new one will be constructed. This way you can re-enable with different configuration.
  50973. *
  50974. * @param featureName the name of the feature to load or the class of the feature
  50975. * @param version optional version to load. if not provided the latest version will be enabled
  50976. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  50977. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  50978. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  50979. * @returns a new constructed feature or throws an error if feature not found.
  50980. */
  50981. enableFeature(featureName: string | {
  50982. Name: string;
  50983. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  50984. /**
  50985. * get the implementation of an enabled feature.
  50986. * @param featureName the name of the feature to load
  50987. * @returns the feature class, if found
  50988. */
  50989. getEnabledFeature(featureName: string): IWebXRFeature;
  50990. /**
  50991. * Get the list of enabled features
  50992. * @returns an array of enabled features
  50993. */
  50994. getEnabledFeatures(): string[];
  50995. /**
  50996. * This function will exten the session creation configuration object with enabled features.
  50997. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  50998. * according to the defined "required" variable, provided during enableFeature call
  50999. * @param xrSessionInit the xr Session init object to extend
  51000. *
  51001. * @returns an extended XRSessionInit object
  51002. */
  51003. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  51004. }
  51005. }
  51006. declare module BABYLON {
  51007. /**
  51008. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  51009. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  51010. */
  51011. export class WebXRExperienceHelper implements IDisposable {
  51012. private scene;
  51013. private _nonVRCamera;
  51014. private _originalSceneAutoClear;
  51015. private _supported;
  51016. /**
  51017. * Camera used to render xr content
  51018. */
  51019. camera: WebXRCamera;
  51020. /** A features manager for this xr session */
  51021. featuresManager: WebXRFeaturesManager;
  51022. /**
  51023. * Observers registered here will be triggered after the camera's initial transformation is set
  51024. * This can be used to set a different ground level or an extra rotation.
  51025. *
  51026. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  51027. * to the position set after this observable is done executing.
  51028. */
  51029. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  51030. /**
  51031. * Fires when the state of the experience helper has changed
  51032. */
  51033. onStateChangedObservable: Observable<WebXRState>;
  51034. /** Session manager used to keep track of xr session */
  51035. sessionManager: WebXRSessionManager;
  51036. /**
  51037. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  51038. */
  51039. state: WebXRState;
  51040. /**
  51041. * Creates a WebXRExperienceHelper
  51042. * @param scene The scene the helper should be created in
  51043. */
  51044. private constructor();
  51045. /**
  51046. * Creates the experience helper
  51047. * @param scene the scene to attach the experience helper to
  51048. * @returns a promise for the experience helper
  51049. */
  51050. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  51051. /**
  51052. * Disposes of the experience helper
  51053. */
  51054. dispose(): void;
  51055. /**
  51056. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  51057. * @param sessionMode options for the XR session
  51058. * @param referenceSpaceType frame of reference of the XR session
  51059. * @param renderTarget the output canvas that will be used to enter XR mode
  51060. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  51061. * @returns promise that resolves after xr mode has entered
  51062. */
  51063. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  51064. /**
  51065. * Exits XR mode and returns the scene to its original state
  51066. * @returns promise that resolves after xr mode has exited
  51067. */
  51068. exitXRAsync(): Promise<void>;
  51069. private _nonXRToXRCamera;
  51070. private _setState;
  51071. }
  51072. }
  51073. declare module BABYLON {
  51074. /**
  51075. * X-Y values for axes in WebXR
  51076. */
  51077. export interface IWebXRMotionControllerAxesValue {
  51078. /**
  51079. * The value of the x axis
  51080. */
  51081. x: number;
  51082. /**
  51083. * The value of the y-axis
  51084. */
  51085. y: number;
  51086. }
  51087. /**
  51088. * changed / previous values for the values of this component
  51089. */
  51090. export interface IWebXRMotionControllerComponentChangesValues<T> {
  51091. /**
  51092. * current (this frame) value
  51093. */
  51094. current: T;
  51095. /**
  51096. * previous (last change) value
  51097. */
  51098. previous: T;
  51099. }
  51100. /**
  51101. * Represents changes in the component between current frame and last values recorded
  51102. */
  51103. export interface IWebXRMotionControllerComponentChanges {
  51104. /**
  51105. * will be populated with previous and current values if axes changed
  51106. */
  51107. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  51108. /**
  51109. * will be populated with previous and current values if pressed changed
  51110. */
  51111. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  51112. /**
  51113. * will be populated with previous and current values if touched changed
  51114. */
  51115. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  51116. /**
  51117. * will be populated with previous and current values if value changed
  51118. */
  51119. value?: IWebXRMotionControllerComponentChangesValues<number>;
  51120. }
  51121. /**
  51122. * This class represents a single component (for example button or thumbstick) of a motion controller
  51123. */
  51124. export class WebXRControllerComponent implements IDisposable {
  51125. /**
  51126. * the id of this component
  51127. */
  51128. id: string;
  51129. /**
  51130. * the type of the component
  51131. */
  51132. type: MotionControllerComponentType;
  51133. private _buttonIndex;
  51134. private _axesIndices;
  51135. private _axes;
  51136. private _changes;
  51137. private _currentValue;
  51138. private _hasChanges;
  51139. private _pressed;
  51140. private _touched;
  51141. /**
  51142. * button component type
  51143. */
  51144. static BUTTON_TYPE: MotionControllerComponentType;
  51145. /**
  51146. * squeeze component type
  51147. */
  51148. static SQUEEZE_TYPE: MotionControllerComponentType;
  51149. /**
  51150. * Thumbstick component type
  51151. */
  51152. static THUMBSTICK_TYPE: MotionControllerComponentType;
  51153. /**
  51154. * Touchpad component type
  51155. */
  51156. static TOUCHPAD_TYPE: MotionControllerComponentType;
  51157. /**
  51158. * trigger component type
  51159. */
  51160. static TRIGGER_TYPE: MotionControllerComponentType;
  51161. /**
  51162. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  51163. * the axes data changes
  51164. */
  51165. onAxisValueChangedObservable: Observable<{
  51166. x: number;
  51167. y: number;
  51168. }>;
  51169. /**
  51170. * Observers registered here will be triggered when the state of a button changes
  51171. * State change is either pressed / touched / value
  51172. */
  51173. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  51174. /**
  51175. * Creates a new component for a motion controller.
  51176. * It is created by the motion controller itself
  51177. *
  51178. * @param id the id of this component
  51179. * @param type the type of the component
  51180. * @param _buttonIndex index in the buttons array of the gamepad
  51181. * @param _axesIndices indices of the values in the axes array of the gamepad
  51182. */
  51183. constructor(
  51184. /**
  51185. * the id of this component
  51186. */
  51187. id: string,
  51188. /**
  51189. * the type of the component
  51190. */
  51191. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  51192. /**
  51193. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  51194. */
  51195. get axes(): IWebXRMotionControllerAxesValue;
  51196. /**
  51197. * Get the changes. Elements will be populated only if they changed with their previous and current value
  51198. */
  51199. get changes(): IWebXRMotionControllerComponentChanges;
  51200. /**
  51201. * Return whether or not the component changed the last frame
  51202. */
  51203. get hasChanges(): boolean;
  51204. /**
  51205. * is the button currently pressed
  51206. */
  51207. get pressed(): boolean;
  51208. /**
  51209. * is the button currently touched
  51210. */
  51211. get touched(): boolean;
  51212. /**
  51213. * Get the current value of this component
  51214. */
  51215. get value(): number;
  51216. /**
  51217. * Dispose this component
  51218. */
  51219. dispose(): void;
  51220. /**
  51221. * Are there axes correlating to this component
  51222. * @return true is axes data is available
  51223. */
  51224. isAxes(): boolean;
  51225. /**
  51226. * Is this component a button (hence - pressable)
  51227. * @returns true if can be pressed
  51228. */
  51229. isButton(): boolean;
  51230. /**
  51231. * update this component using the gamepad object it is in. Called on every frame
  51232. * @param nativeController the native gamepad controller object
  51233. */
  51234. update(nativeController: IMinimalMotionControllerObject): void;
  51235. }
  51236. }
  51237. declare module BABYLON {
  51238. /**
  51239. * Type used for the success callback of ImportMesh
  51240. */
  51241. export type SceneLoaderSuccessCallback = (meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[], transformNodes: TransformNode[], geometries: Geometry[], lights: Light[]) => void;
  51242. /**
  51243. * Interface used for the result of ImportMeshAsync
  51244. */
  51245. export interface ISceneLoaderAsyncResult {
  51246. /**
  51247. * The array of loaded meshes
  51248. */
  51249. readonly meshes: AbstractMesh[];
  51250. /**
  51251. * The array of loaded particle systems
  51252. */
  51253. readonly particleSystems: IParticleSystem[];
  51254. /**
  51255. * The array of loaded skeletons
  51256. */
  51257. readonly skeletons: Skeleton[];
  51258. /**
  51259. * The array of loaded animation groups
  51260. */
  51261. readonly animationGroups: AnimationGroup[];
  51262. /**
  51263. * The array of loaded transform nodes
  51264. */
  51265. readonly transformNodes: TransformNode[];
  51266. /**
  51267. * The array of loaded geometries
  51268. */
  51269. readonly geometries: Geometry[];
  51270. /**
  51271. * The array of loaded lights
  51272. */
  51273. readonly lights: Light[];
  51274. }
  51275. /**
  51276. * Interface used to represent data loading progression
  51277. */
  51278. export interface ISceneLoaderProgressEvent {
  51279. /**
  51280. * Defines if data length to load can be evaluated
  51281. */
  51282. readonly lengthComputable: boolean;
  51283. /**
  51284. * Defines the loaded data length
  51285. */
  51286. readonly loaded: number;
  51287. /**
  51288. * Defines the data length to load
  51289. */
  51290. readonly total: number;
  51291. }
  51292. /**
  51293. * Interface used by SceneLoader plugins to define supported file extensions
  51294. */
  51295. export interface ISceneLoaderPluginExtensions {
  51296. /**
  51297. * Defines the list of supported extensions
  51298. */
  51299. [extension: string]: {
  51300. isBinary: boolean;
  51301. };
  51302. }
  51303. /**
  51304. * Interface used by SceneLoader plugin factory
  51305. */
  51306. export interface ISceneLoaderPluginFactory {
  51307. /**
  51308. * Defines the name of the factory
  51309. */
  51310. name: string;
  51311. /**
  51312. * Function called to create a new plugin
  51313. * @return the new plugin
  51314. */
  51315. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  51316. /**
  51317. * The callback that returns true if the data can be directly loaded.
  51318. * @param data string containing the file data
  51319. * @returns if the data can be loaded directly
  51320. */
  51321. canDirectLoad?(data: string): boolean;
  51322. }
  51323. /**
  51324. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  51325. */
  51326. export interface ISceneLoaderPluginBase {
  51327. /**
  51328. * The friendly name of this plugin.
  51329. */
  51330. name: string;
  51331. /**
  51332. * The file extensions supported by this plugin.
  51333. */
  51334. extensions: string | ISceneLoaderPluginExtensions;
  51335. /**
  51336. * The callback called when loading from a url.
  51337. * @param scene scene loading this url
  51338. * @param url url to load
  51339. * @param onSuccess callback called when the file successfully loads
  51340. * @param onProgress callback called while file is loading (if the server supports this mode)
  51341. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  51342. * @param onError callback called when the file fails to load
  51343. * @returns a file request object
  51344. */
  51345. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  51346. /**
  51347. * The callback called when loading from a file object.
  51348. * @param scene scene loading this file
  51349. * @param file defines the file to load
  51350. * @param onSuccess defines the callback to call when data is loaded
  51351. * @param onProgress defines the callback to call during loading process
  51352. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  51353. * @param onError defines the callback to call when an error occurs
  51354. * @returns a file request object
  51355. */
  51356. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  51357. /**
  51358. * The callback that returns true if the data can be directly loaded.
  51359. * @param data string containing the file data
  51360. * @returns if the data can be loaded directly
  51361. */
  51362. canDirectLoad?(data: string): boolean;
  51363. /**
  51364. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  51365. * @param scene scene loading this data
  51366. * @param data string containing the data
  51367. * @returns data to pass to the plugin
  51368. */
  51369. directLoad?(scene: Scene, data: string): any;
  51370. /**
  51371. * The callback that allows custom handling of the root url based on the response url.
  51372. * @param rootUrl the original root url
  51373. * @param responseURL the response url if available
  51374. * @returns the new root url
  51375. */
  51376. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  51377. }
  51378. /**
  51379. * Interface used to define a SceneLoader plugin
  51380. */
  51381. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  51382. /**
  51383. * Import meshes into a scene.
  51384. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51385. * @param scene The scene to import into
  51386. * @param data The data to import
  51387. * @param rootUrl The root url for scene and resources
  51388. * @param meshes The meshes array to import into
  51389. * @param particleSystems The particle systems array to import into
  51390. * @param skeletons The skeletons array to import into
  51391. * @param onError The callback when import fails
  51392. * @returns True if successful or false otherwise
  51393. */
  51394. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  51395. /**
  51396. * Load into a scene.
  51397. * @param scene The scene to load into
  51398. * @param data The data to import
  51399. * @param rootUrl The root url for scene and resources
  51400. * @param onError The callback when import fails
  51401. * @returns True if successful or false otherwise
  51402. */
  51403. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  51404. /**
  51405. * Load into an asset container.
  51406. * @param scene The scene to load into
  51407. * @param data The data to import
  51408. * @param rootUrl The root url for scene and resources
  51409. * @param onError The callback when import fails
  51410. * @returns The loaded asset container
  51411. */
  51412. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  51413. }
  51414. /**
  51415. * Interface used to define an async SceneLoader plugin
  51416. */
  51417. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  51418. /**
  51419. * Import meshes into a scene.
  51420. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51421. * @param scene The scene to import into
  51422. * @param data The data to import
  51423. * @param rootUrl The root url for scene and resources
  51424. * @param onProgress The callback when the load progresses
  51425. * @param fileName Defines the name of the file to load
  51426. * @returns The loaded objects (e.g. meshes, particle systems, skeletons, animation groups, etc.)
  51427. */
  51428. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  51429. /**
  51430. * Load into a scene.
  51431. * @param scene The scene to load into
  51432. * @param data The data to import
  51433. * @param rootUrl The root url for scene and resources
  51434. * @param onProgress The callback when the load progresses
  51435. * @param fileName Defines the name of the file to load
  51436. * @returns Nothing
  51437. */
  51438. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  51439. /**
  51440. * Load into an asset container.
  51441. * @param scene The scene to load into
  51442. * @param data The data to import
  51443. * @param rootUrl The root url for scene and resources
  51444. * @param onProgress The callback when the load progresses
  51445. * @param fileName Defines the name of the file to load
  51446. * @returns The loaded asset container
  51447. */
  51448. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  51449. }
  51450. /**
  51451. * Mode that determines how to handle old animation groups before loading new ones.
  51452. */
  51453. export enum SceneLoaderAnimationGroupLoadingMode {
  51454. /**
  51455. * Reset all old animations to initial state then dispose them.
  51456. */
  51457. Clean = 0,
  51458. /**
  51459. * Stop all old animations.
  51460. */
  51461. Stop = 1,
  51462. /**
  51463. * Restart old animations from first frame.
  51464. */
  51465. Sync = 2,
  51466. /**
  51467. * Old animations remains untouched.
  51468. */
  51469. NoSync = 3
  51470. }
  51471. /**
  51472. * Defines a plugin registered by the SceneLoader
  51473. */
  51474. interface IRegisteredPlugin {
  51475. /**
  51476. * Defines the plugin to use
  51477. */
  51478. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  51479. /**
  51480. * Defines if the plugin supports binary data
  51481. */
  51482. isBinary: boolean;
  51483. }
  51484. /**
  51485. * Class used to load scene from various file formats using registered plugins
  51486. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  51487. */
  51488. export class SceneLoader {
  51489. /**
  51490. * No logging while loading
  51491. */
  51492. static readonly NO_LOGGING: number;
  51493. /**
  51494. * Minimal logging while loading
  51495. */
  51496. static readonly MINIMAL_LOGGING: number;
  51497. /**
  51498. * Summary logging while loading
  51499. */
  51500. static readonly SUMMARY_LOGGING: number;
  51501. /**
  51502. * Detailled logging while loading
  51503. */
  51504. static readonly DETAILED_LOGGING: number;
  51505. /**
  51506. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  51507. */
  51508. static get ForceFullSceneLoadingForIncremental(): boolean;
  51509. static set ForceFullSceneLoadingForIncremental(value: boolean);
  51510. /**
  51511. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  51512. */
  51513. static get ShowLoadingScreen(): boolean;
  51514. static set ShowLoadingScreen(value: boolean);
  51515. /**
  51516. * Defines the current logging level (while loading the scene)
  51517. * @ignorenaming
  51518. */
  51519. static get loggingLevel(): number;
  51520. static set loggingLevel(value: number);
  51521. /**
  51522. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  51523. */
  51524. static get CleanBoneMatrixWeights(): boolean;
  51525. static set CleanBoneMatrixWeights(value: boolean);
  51526. /**
  51527. * Event raised when a plugin is used to load a scene
  51528. */
  51529. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  51530. private static _registeredPlugins;
  51531. private static _showingLoadingScreen;
  51532. /**
  51533. * Gets the default plugin (used to load Babylon files)
  51534. * @returns the .babylon plugin
  51535. */
  51536. static GetDefaultPlugin(): IRegisteredPlugin;
  51537. private static _GetPluginForExtension;
  51538. private static _GetPluginForDirectLoad;
  51539. private static _GetPluginForFilename;
  51540. private static _GetDirectLoad;
  51541. private static _LoadData;
  51542. private static _GetFileInfo;
  51543. /**
  51544. * Gets a plugin that can load the given extension
  51545. * @param extension defines the extension to load
  51546. * @returns a plugin or null if none works
  51547. */
  51548. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  51549. /**
  51550. * Gets a boolean indicating that the given extension can be loaded
  51551. * @param extension defines the extension to load
  51552. * @returns true if the extension is supported
  51553. */
  51554. static IsPluginForExtensionAvailable(extension: string): boolean;
  51555. /**
  51556. * Adds a new plugin to the list of registered plugins
  51557. * @param plugin defines the plugin to add
  51558. */
  51559. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  51560. /**
  51561. * Import meshes into a scene
  51562. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51563. * @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)
  51564. * @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)
  51565. * @param scene the instance of BABYLON.Scene to append to
  51566. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  51567. * @param onProgress a callback with a progress event for each file being loaded
  51568. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51569. * @param pluginExtension the extension used to determine the plugin
  51570. * @returns The loaded plugin
  51571. */
  51572. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<SceneLoaderSuccessCallback>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  51573. /**
  51574. * Import meshes into a scene
  51575. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51576. * @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)
  51577. * @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)
  51578. * @param scene the instance of BABYLON.Scene to append to
  51579. * @param onProgress a callback with a progress event for each file being loaded
  51580. * @param pluginExtension the extension used to determine the plugin
  51581. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  51582. */
  51583. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<ISceneLoaderAsyncResult>;
  51584. /**
  51585. * Load a scene
  51586. * @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)
  51587. * @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)
  51588. * @param engine is the instance of BABYLON.Engine to use to create the scene
  51589. * @param onSuccess a callback with the scene when import succeeds
  51590. * @param onProgress a callback with a progress event for each file being loaded
  51591. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51592. * @param pluginExtension the extension used to determine the plugin
  51593. * @returns The loaded plugin
  51594. */
  51595. static Load(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  51596. /**
  51597. * Load a scene
  51598. * @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)
  51599. * @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)
  51600. * @param engine is the instance of BABYLON.Engine to use to create the scene
  51601. * @param onProgress a callback with a progress event for each file being loaded
  51602. * @param pluginExtension the extension used to determine the plugin
  51603. * @returns The loaded scene
  51604. */
  51605. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  51606. /**
  51607. * Append a scene
  51608. * @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)
  51609. * @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)
  51610. * @param scene is the instance of BABYLON.Scene to append to
  51611. * @param onSuccess a callback with the scene when import succeeds
  51612. * @param onProgress a callback with a progress event for each file being loaded
  51613. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51614. * @param pluginExtension the extension used to determine the plugin
  51615. * @returns The loaded plugin
  51616. */
  51617. static Append(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  51618. /**
  51619. * Append a scene
  51620. * @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)
  51621. * @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)
  51622. * @param scene is the instance of BABYLON.Scene to append to
  51623. * @param onProgress a callback with a progress event for each file being loaded
  51624. * @param pluginExtension the extension used to determine the plugin
  51625. * @returns The given scene
  51626. */
  51627. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  51628. /**
  51629. * Load a scene into an asset container
  51630. * @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)
  51631. * @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)
  51632. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51633. * @param onSuccess a callback with the scene when import succeeds
  51634. * @param onProgress a callback with a progress event for each file being loaded
  51635. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51636. * @param pluginExtension the extension used to determine the plugin
  51637. * @returns The loaded plugin
  51638. */
  51639. static LoadAssetContainer(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  51640. /**
  51641. * Load a scene into an asset container
  51642. * @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)
  51643. * @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)
  51644. * @param scene is the instance of Scene to append to
  51645. * @param onProgress a callback with a progress event for each file being loaded
  51646. * @param pluginExtension the extension used to determine the plugin
  51647. * @returns The loaded asset container
  51648. */
  51649. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  51650. /**
  51651. * Import animations from a file into a scene
  51652. * @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)
  51653. * @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)
  51654. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51655. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  51656. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  51657. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  51658. * @param onSuccess a callback with the scene when import succeeds
  51659. * @param onProgress a callback with a progress event for each file being loaded
  51660. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51661. * @param pluginExtension the extension used to determine the plugin
  51662. */
  51663. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): void;
  51664. /**
  51665. * Import animations from a file into a scene
  51666. * @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)
  51667. * @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)
  51668. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51669. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  51670. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  51671. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  51672. * @param onSuccess a callback with the scene when import succeeds
  51673. * @param onProgress a callback with a progress event for each file being loaded
  51674. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51675. * @param pluginExtension the extension used to determine the plugin
  51676. * @returns the updated scene with imported animations
  51677. */
  51678. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  51679. }
  51680. }
  51681. declare module BABYLON {
  51682. /**
  51683. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  51684. */
  51685. export type MotionControllerHandedness = "none" | "left" | "right";
  51686. /**
  51687. * The type of components available in motion controllers.
  51688. * This is not the name of the component.
  51689. */
  51690. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  51691. /**
  51692. * The state of a controller component
  51693. */
  51694. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  51695. /**
  51696. * The schema of motion controller layout.
  51697. * No object will be initialized using this interface
  51698. * This is used just to define the profile.
  51699. */
  51700. export interface IMotionControllerLayout {
  51701. /**
  51702. * Path to load the assets. Usually relative to the base path
  51703. */
  51704. assetPath: string;
  51705. /**
  51706. * Available components (unsorted)
  51707. */
  51708. components: {
  51709. /**
  51710. * A map of component Ids
  51711. */
  51712. [componentId: string]: {
  51713. /**
  51714. * The type of input the component outputs
  51715. */
  51716. type: MotionControllerComponentType;
  51717. /**
  51718. * The indices of this component in the gamepad object
  51719. */
  51720. gamepadIndices: {
  51721. /**
  51722. * Index of button
  51723. */
  51724. button?: number;
  51725. /**
  51726. * If available, index of x-axis
  51727. */
  51728. xAxis?: number;
  51729. /**
  51730. * If available, index of y-axis
  51731. */
  51732. yAxis?: number;
  51733. };
  51734. /**
  51735. * The mesh's root node name
  51736. */
  51737. rootNodeName: string;
  51738. /**
  51739. * Animation definitions for this model
  51740. */
  51741. visualResponses: {
  51742. [stateKey: string]: {
  51743. /**
  51744. * What property will be animated
  51745. */
  51746. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  51747. /**
  51748. * What states influence this visual response
  51749. */
  51750. states: MotionControllerComponentStateType[];
  51751. /**
  51752. * Type of animation - movement or visibility
  51753. */
  51754. valueNodeProperty: "transform" | "visibility";
  51755. /**
  51756. * Base node name to move. Its position will be calculated according to the min and max nodes
  51757. */
  51758. valueNodeName?: string;
  51759. /**
  51760. * Minimum movement node
  51761. */
  51762. minNodeName?: string;
  51763. /**
  51764. * Max movement node
  51765. */
  51766. maxNodeName?: string;
  51767. };
  51768. };
  51769. /**
  51770. * If touch enabled, what is the name of node to display user feedback
  51771. */
  51772. touchPointNodeName?: string;
  51773. };
  51774. };
  51775. /**
  51776. * Is it xr standard mapping or not
  51777. */
  51778. gamepadMapping: "" | "xr-standard";
  51779. /**
  51780. * Base root node of this entire model
  51781. */
  51782. rootNodeName: string;
  51783. /**
  51784. * Defines the main button component id
  51785. */
  51786. selectComponentId: string;
  51787. }
  51788. /**
  51789. * A definition for the layout map in the input profile
  51790. */
  51791. export interface IMotionControllerLayoutMap {
  51792. /**
  51793. * Layouts with handedness type as a key
  51794. */
  51795. [handedness: string]: IMotionControllerLayout;
  51796. }
  51797. /**
  51798. * The XR Input profile schema
  51799. * Profiles can be found here:
  51800. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  51801. */
  51802. export interface IMotionControllerProfile {
  51803. /**
  51804. * fallback profiles for this profileId
  51805. */
  51806. fallbackProfileIds: string[];
  51807. /**
  51808. * The layout map, with handedness as key
  51809. */
  51810. layouts: IMotionControllerLayoutMap;
  51811. /**
  51812. * The id of this profile
  51813. * correlates to the profile(s) in the xrInput.profiles array
  51814. */
  51815. profileId: string;
  51816. }
  51817. /**
  51818. * A helper-interface for the 3 meshes needed for controller button animation
  51819. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  51820. */
  51821. export interface IMotionControllerButtonMeshMap {
  51822. /**
  51823. * the mesh that defines the pressed value mesh position.
  51824. * This is used to find the max-position of this button
  51825. */
  51826. pressedMesh: AbstractMesh;
  51827. /**
  51828. * the mesh that defines the unpressed value mesh position.
  51829. * This is used to find the min (or initial) position of this button
  51830. */
  51831. unpressedMesh: AbstractMesh;
  51832. /**
  51833. * The mesh that will be changed when value changes
  51834. */
  51835. valueMesh: AbstractMesh;
  51836. }
  51837. /**
  51838. * A helper-interface for the 3 meshes needed for controller axis animation.
  51839. * This will be expanded when touchpad animations are fully supported
  51840. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  51841. */
  51842. export interface IMotionControllerMeshMap {
  51843. /**
  51844. * the mesh that defines the maximum value mesh position.
  51845. */
  51846. maxMesh?: AbstractMesh;
  51847. /**
  51848. * the mesh that defines the minimum value mesh position.
  51849. */
  51850. minMesh?: AbstractMesh;
  51851. /**
  51852. * The mesh that will be changed when axis value changes
  51853. */
  51854. valueMesh?: AbstractMesh;
  51855. }
  51856. /**
  51857. * The elements needed for change-detection of the gamepad objects in motion controllers
  51858. */
  51859. export interface IMinimalMotionControllerObject {
  51860. /**
  51861. * Available axes of this controller
  51862. */
  51863. axes: number[];
  51864. /**
  51865. * An array of available buttons
  51866. */
  51867. buttons: Array<{
  51868. /**
  51869. * Value of the button/trigger
  51870. */
  51871. value: number;
  51872. /**
  51873. * If the button/trigger is currently touched
  51874. */
  51875. touched: boolean;
  51876. /**
  51877. * If the button/trigger is currently pressed
  51878. */
  51879. pressed: boolean;
  51880. }>;
  51881. /**
  51882. * EXPERIMENTAL haptic support.
  51883. */
  51884. hapticActuators?: Array<{
  51885. pulse: (value: number, duration: number) => Promise<boolean>;
  51886. }>;
  51887. }
  51888. /**
  51889. * An Abstract Motion controller
  51890. * This class receives an xrInput and a profile layout and uses those to initialize the components
  51891. * Each component has an observable to check for changes in value and state
  51892. */
  51893. export abstract class WebXRAbstractMotionController implements IDisposable {
  51894. protected scene: Scene;
  51895. protected layout: IMotionControllerLayout;
  51896. /**
  51897. * The gamepad object correlating to this controller
  51898. */
  51899. gamepadObject: IMinimalMotionControllerObject;
  51900. /**
  51901. * handedness (left/right/none) of this controller
  51902. */
  51903. handedness: MotionControllerHandedness;
  51904. private _initComponent;
  51905. private _modelReady;
  51906. /**
  51907. * A map of components (WebXRControllerComponent) in this motion controller
  51908. * Components have a ComponentType and can also have both button and axis definitions
  51909. */
  51910. readonly components: {
  51911. [id: string]: WebXRControllerComponent;
  51912. };
  51913. /**
  51914. * Disable the model's animation. Can be set at any time.
  51915. */
  51916. disableAnimation: boolean;
  51917. /**
  51918. * Observers registered here will be triggered when the model of this controller is done loading
  51919. */
  51920. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  51921. /**
  51922. * The profile id of this motion controller
  51923. */
  51924. abstract profileId: string;
  51925. /**
  51926. * The root mesh of the model. It is null if the model was not yet initialized
  51927. */
  51928. rootMesh: Nullable<AbstractMesh>;
  51929. /**
  51930. * constructs a new abstract motion controller
  51931. * @param scene the scene to which the model of the controller will be added
  51932. * @param layout The profile layout to load
  51933. * @param gamepadObject The gamepad object correlating to this controller
  51934. * @param handedness handedness (left/right/none) of this controller
  51935. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  51936. */
  51937. constructor(scene: Scene, layout: IMotionControllerLayout,
  51938. /**
  51939. * The gamepad object correlating to this controller
  51940. */
  51941. gamepadObject: IMinimalMotionControllerObject,
  51942. /**
  51943. * handedness (left/right/none) of this controller
  51944. */
  51945. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  51946. /**
  51947. * Dispose this controller, the model mesh and all its components
  51948. */
  51949. dispose(): void;
  51950. /**
  51951. * Returns all components of specific type
  51952. * @param type the type to search for
  51953. * @return an array of components with this type
  51954. */
  51955. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  51956. /**
  51957. * get a component based an its component id as defined in layout.components
  51958. * @param id the id of the component
  51959. * @returns the component correlates to the id or undefined if not found
  51960. */
  51961. getComponent(id: string): WebXRControllerComponent;
  51962. /**
  51963. * Get the list of components available in this motion controller
  51964. * @returns an array of strings correlating to available components
  51965. */
  51966. getComponentIds(): string[];
  51967. /**
  51968. * Get the first component of specific type
  51969. * @param type type of component to find
  51970. * @return a controller component or null if not found
  51971. */
  51972. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  51973. /**
  51974. * Get the main (Select) component of this controller as defined in the layout
  51975. * @returns the main component of this controller
  51976. */
  51977. getMainComponent(): WebXRControllerComponent;
  51978. /**
  51979. * Loads the model correlating to this controller
  51980. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  51981. * @returns A promise fulfilled with the result of the model loading
  51982. */
  51983. loadModel(): Promise<boolean>;
  51984. /**
  51985. * Update this model using the current XRFrame
  51986. * @param xrFrame the current xr frame to use and update the model
  51987. */
  51988. updateFromXRFrame(xrFrame: XRFrame): void;
  51989. /**
  51990. * Backwards compatibility due to a deeply-integrated typo
  51991. */
  51992. get handness(): XREye;
  51993. /**
  51994. * Pulse (vibrate) this controller
  51995. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  51996. * Consecutive calls to this function will cancel the last pulse call
  51997. *
  51998. * @param value the strength of the pulse in 0.0...1.0 range
  51999. * @param duration Duration of the pulse in milliseconds
  52000. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  52001. * @returns a promise that will send true when the pulse has ended and false if the device doesn't support pulse or an error accrued
  52002. */
  52003. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  52004. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  52005. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  52006. /**
  52007. * Moves the axis on the controller mesh based on its current state
  52008. * @param axis the index of the axis
  52009. * @param axisValue the value of the axis which determines the meshes new position
  52010. * @hidden
  52011. */
  52012. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  52013. /**
  52014. * Update the model itself with the current frame data
  52015. * @param xrFrame the frame to use for updating the model mesh
  52016. */
  52017. protected updateModel(xrFrame: XRFrame): void;
  52018. /**
  52019. * Get the filename and path for this controller's model
  52020. * @returns a map of filename and path
  52021. */
  52022. protected abstract _getFilenameAndPath(): {
  52023. filename: string;
  52024. path: string;
  52025. };
  52026. /**
  52027. * This function is called before the mesh is loaded. It checks for loading constraints.
  52028. * For example, this function can check if the GLB loader is available
  52029. * If this function returns false, the generic controller will be loaded instead
  52030. * @returns Is the client ready to load the mesh
  52031. */
  52032. protected abstract _getModelLoadingConstraints(): boolean;
  52033. /**
  52034. * This function will be called after the model was successfully loaded and can be used
  52035. * for mesh transformations before it is available for the user
  52036. * @param meshes the loaded meshes
  52037. */
  52038. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  52039. /**
  52040. * Set the root mesh for this controller. Important for the WebXR controller class
  52041. * @param meshes the loaded meshes
  52042. */
  52043. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  52044. /**
  52045. * A function executed each frame that updates the mesh (if needed)
  52046. * @param xrFrame the current xrFrame
  52047. */
  52048. protected abstract _updateModel(xrFrame: XRFrame): void;
  52049. private _getGenericFilenameAndPath;
  52050. private _getGenericParentMesh;
  52051. }
  52052. }
  52053. declare module BABYLON {
  52054. /**
  52055. * A generic trigger-only motion controller for WebXR
  52056. */
  52057. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  52058. /**
  52059. * Static version of the profile id of this controller
  52060. */
  52061. static ProfileId: string;
  52062. profileId: string;
  52063. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  52064. protected _getFilenameAndPath(): {
  52065. filename: string;
  52066. path: string;
  52067. };
  52068. protected _getModelLoadingConstraints(): boolean;
  52069. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  52070. protected _setRootMesh(meshes: AbstractMesh[]): void;
  52071. protected _updateModel(): void;
  52072. }
  52073. }
  52074. declare module BABYLON {
  52075. /**
  52076. * Class containing static functions to help procedurally build meshes
  52077. */
  52078. export class SphereBuilder {
  52079. /**
  52080. * Creates a sphere mesh
  52081. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  52082. * * 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`)
  52083. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  52084. * * 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
  52085. * * 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)
  52086. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52087. * * 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
  52088. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52089. * @param name defines the name of the mesh
  52090. * @param options defines the options used to create the mesh
  52091. * @param scene defines the hosting scene
  52092. * @returns the sphere mesh
  52093. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  52094. */
  52095. static CreateSphere(name: string, options: {
  52096. segments?: number;
  52097. diameter?: number;
  52098. diameterX?: number;
  52099. diameterY?: number;
  52100. diameterZ?: number;
  52101. arc?: number;
  52102. slice?: number;
  52103. sideOrientation?: number;
  52104. frontUVs?: Vector4;
  52105. backUVs?: Vector4;
  52106. updatable?: boolean;
  52107. }, scene?: Nullable<Scene>): Mesh;
  52108. }
  52109. }
  52110. declare module BABYLON {
  52111. /**
  52112. * A profiled motion controller has its profile loaded from an online repository.
  52113. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  52114. */
  52115. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  52116. private _repositoryUrl;
  52117. private _buttonMeshMapping;
  52118. private _touchDots;
  52119. /**
  52120. * The profile ID of this controller. Will be populated when the controller initializes.
  52121. */
  52122. profileId: string;
  52123. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  52124. dispose(): void;
  52125. protected _getFilenameAndPath(): {
  52126. filename: string;
  52127. path: string;
  52128. };
  52129. protected _getModelLoadingConstraints(): boolean;
  52130. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  52131. protected _setRootMesh(meshes: AbstractMesh[]): void;
  52132. protected _updateModel(_xrFrame: XRFrame): void;
  52133. }
  52134. }
  52135. declare module BABYLON {
  52136. /**
  52137. * A construction function type to create a new controller based on an xrInput object
  52138. */
  52139. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  52140. /**
  52141. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  52142. *
  52143. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  52144. * it should be replaced with auto-loaded controllers.
  52145. *
  52146. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  52147. */
  52148. export class WebXRMotionControllerManager {
  52149. private static _AvailableControllers;
  52150. private static _Fallbacks;
  52151. private static _ProfileLoadingPromises;
  52152. private static _ProfilesList;
  52153. /**
  52154. * The base URL of the online controller repository. Can be changed at any time.
  52155. */
  52156. static BaseRepositoryUrl: string;
  52157. /**
  52158. * Which repository gets priority - local or online
  52159. */
  52160. static PrioritizeOnlineRepository: boolean;
  52161. /**
  52162. * Use the online repository, or use only locally-defined controllers
  52163. */
  52164. static UseOnlineRepository: boolean;
  52165. /**
  52166. * Clear the cache used for profile loading and reload when requested again
  52167. */
  52168. static ClearProfilesCache(): void;
  52169. /**
  52170. * Register the default fallbacks.
  52171. * This function is called automatically when this file is imported.
  52172. */
  52173. static DefaultFallbacks(): void;
  52174. /**
  52175. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  52176. * @param profileId the profile to which a fallback needs to be found
  52177. * @return an array with corresponding fallback profiles
  52178. */
  52179. static FindFallbackWithProfileId(profileId: string): string[];
  52180. /**
  52181. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  52182. * The order of search:
  52183. *
  52184. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  52185. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  52186. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  52187. * 4) return the generic trigger controller if none were found
  52188. *
  52189. * @param xrInput the xrInput to which a new controller is initialized
  52190. * @param scene the scene to which the model will be added
  52191. * @param forceProfile force a certain profile for this controller
  52192. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  52193. */
  52194. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  52195. /**
  52196. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  52197. *
  52198. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  52199. *
  52200. * @param type the profile type to register
  52201. * @param constructFunction the function to be called when loading this profile
  52202. */
  52203. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  52204. /**
  52205. * Register a fallback to a specific profile.
  52206. * @param profileId the profileId that will receive the fallbacks
  52207. * @param fallbacks A list of fallback profiles
  52208. */
  52209. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  52210. /**
  52211. * Will update the list of profiles available in the repository
  52212. * @return a promise that resolves to a map of profiles available online
  52213. */
  52214. static UpdateProfilesList(): Promise<{
  52215. [profile: string]: string;
  52216. }>;
  52217. private static _LoadProfileFromRepository;
  52218. private static _LoadProfilesFromAvailableControllers;
  52219. }
  52220. }
  52221. declare module BABYLON {
  52222. /**
  52223. * Configuration options for the WebXR controller creation
  52224. */
  52225. export interface IWebXRControllerOptions {
  52226. /**
  52227. * Should the controller mesh be animated when a user interacts with it
  52228. * The pressed buttons / thumbstick and touchpad animations will be disabled
  52229. */
  52230. disableMotionControllerAnimation?: boolean;
  52231. /**
  52232. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  52233. */
  52234. doNotLoadControllerMesh?: boolean;
  52235. /**
  52236. * Force a specific controller type for this controller.
  52237. * This can be used when creating your own profile or when testing different controllers
  52238. */
  52239. forceControllerProfile?: string;
  52240. /**
  52241. * Defines a rendering group ID for meshes that will be loaded.
  52242. * This is for the default controllers only.
  52243. */
  52244. renderingGroupId?: number;
  52245. }
  52246. /**
  52247. * Represents an XR controller
  52248. */
  52249. export class WebXRInputSource {
  52250. private _scene;
  52251. /** The underlying input source for the controller */
  52252. inputSource: XRInputSource;
  52253. private _options;
  52254. private _tmpVector;
  52255. private _uniqueId;
  52256. private _disposed;
  52257. /**
  52258. * 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
  52259. */
  52260. grip?: AbstractMesh;
  52261. /**
  52262. * If available, this is the gamepad object related to this controller.
  52263. * Using this object it is possible to get click events and trackpad changes of the
  52264. * webxr controller that is currently being used.
  52265. */
  52266. motionController?: WebXRAbstractMotionController;
  52267. /**
  52268. * Event that fires when the controller is removed/disposed.
  52269. * The object provided as event data is this controller, after associated assets were disposed.
  52270. * uniqueId is still available.
  52271. */
  52272. onDisposeObservable: Observable<WebXRInputSource>;
  52273. /**
  52274. * Will be triggered when the mesh associated with the motion controller is done loading.
  52275. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  52276. * A shortened version of controller -> motion controller -> on mesh loaded.
  52277. */
  52278. onMeshLoadedObservable: Observable<AbstractMesh>;
  52279. /**
  52280. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  52281. */
  52282. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  52283. /**
  52284. * Pointer which can be used to select objects or attach a visible laser to
  52285. */
  52286. pointer: AbstractMesh;
  52287. /**
  52288. * Creates the input source object
  52289. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  52290. * @param _scene the scene which the controller should be associated to
  52291. * @param inputSource the underlying input source for the controller
  52292. * @param _options options for this controller creation
  52293. */
  52294. constructor(_scene: Scene,
  52295. /** The underlying input source for the controller */
  52296. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  52297. /**
  52298. * Get this controllers unique id
  52299. */
  52300. get uniqueId(): string;
  52301. /**
  52302. * Disposes of the object
  52303. */
  52304. dispose(): void;
  52305. /**
  52306. * Gets a world space ray coming from the pointer or grip
  52307. * @param result the resulting ray
  52308. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  52309. */
  52310. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  52311. /**
  52312. * Updates the controller pose based on the given XRFrame
  52313. * @param xrFrame xr frame to update the pose with
  52314. * @param referenceSpace reference space to use
  52315. */
  52316. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  52317. }
  52318. }
  52319. declare module BABYLON {
  52320. /**
  52321. * The schema for initialization options of the XR Input class
  52322. */
  52323. export interface IWebXRInputOptions {
  52324. /**
  52325. * If set to true no model will be automatically loaded
  52326. */
  52327. doNotLoadControllerMeshes?: boolean;
  52328. /**
  52329. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  52330. * If not found, the xr input profile data will be used.
  52331. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  52332. */
  52333. forceInputProfile?: string;
  52334. /**
  52335. * Do not send a request to the controller repository to load the profile.
  52336. *
  52337. * Instead, use the controllers available in babylon itself.
  52338. */
  52339. disableOnlineControllerRepository?: boolean;
  52340. /**
  52341. * A custom URL for the controllers repository
  52342. */
  52343. customControllersRepositoryURL?: string;
  52344. /**
  52345. * Should the controller model's components not move according to the user input
  52346. */
  52347. disableControllerAnimation?: boolean;
  52348. /**
  52349. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  52350. */
  52351. controllerOptions?: IWebXRControllerOptions;
  52352. }
  52353. /**
  52354. * XR input used to track XR inputs such as controllers/rays
  52355. */
  52356. export class WebXRInput implements IDisposable {
  52357. /**
  52358. * the xr session manager for this session
  52359. */
  52360. xrSessionManager: WebXRSessionManager;
  52361. /**
  52362. * the WebXR camera for this session. Mainly used for teleportation
  52363. */
  52364. xrCamera: WebXRCamera;
  52365. private readonly options;
  52366. /**
  52367. * XR controllers being tracked
  52368. */
  52369. controllers: Array<WebXRInputSource>;
  52370. private _frameObserver;
  52371. private _sessionEndedObserver;
  52372. private _sessionInitObserver;
  52373. /**
  52374. * Event when a controller has been connected/added
  52375. */
  52376. onControllerAddedObservable: Observable<WebXRInputSource>;
  52377. /**
  52378. * Event when a controller has been removed/disconnected
  52379. */
  52380. onControllerRemovedObservable: Observable<WebXRInputSource>;
  52381. /**
  52382. * Initializes the WebXRInput
  52383. * @param xrSessionManager the xr session manager for this session
  52384. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  52385. * @param options = initialization options for this xr input
  52386. */
  52387. constructor(
  52388. /**
  52389. * the xr session manager for this session
  52390. */
  52391. xrSessionManager: WebXRSessionManager,
  52392. /**
  52393. * the WebXR camera for this session. Mainly used for teleportation
  52394. */
  52395. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  52396. private _onInputSourcesChange;
  52397. private _addAndRemoveControllers;
  52398. /**
  52399. * Disposes of the object
  52400. */
  52401. dispose(): void;
  52402. }
  52403. }
  52404. declare module BABYLON {
  52405. /**
  52406. * This is the base class for all WebXR features.
  52407. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  52408. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  52409. */
  52410. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  52411. protected _xrSessionManager: WebXRSessionManager;
  52412. private _attached;
  52413. private _removeOnDetach;
  52414. /**
  52415. * Is this feature disposed?
  52416. */
  52417. isDisposed: boolean;
  52418. /**
  52419. * Should auto-attach be disabled?
  52420. */
  52421. disableAutoAttach: boolean;
  52422. /**
  52423. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  52424. */
  52425. xrNativeFeatureName: string;
  52426. /**
  52427. * Construct a new (abstract) WebXR feature
  52428. * @param _xrSessionManager the xr session manager for this feature
  52429. */
  52430. constructor(_xrSessionManager: WebXRSessionManager);
  52431. /**
  52432. * Is this feature attached
  52433. */
  52434. get attached(): boolean;
  52435. /**
  52436. * attach this feature
  52437. *
  52438. * @param force should attachment be forced (even when already attached)
  52439. * @returns true if successful, false is failed or already attached
  52440. */
  52441. attach(force?: boolean): boolean;
  52442. /**
  52443. * detach this feature.
  52444. *
  52445. * @returns true if successful, false if failed or already detached
  52446. */
  52447. detach(): boolean;
  52448. /**
  52449. * Dispose this feature and all of the resources attached
  52450. */
  52451. dispose(): void;
  52452. /**
  52453. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  52454. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  52455. *
  52456. * @returns whether or not the feature is compatible in this environment
  52457. */
  52458. isCompatible(): boolean;
  52459. /**
  52460. * This is used to register callbacks that will automatically be removed when detach is called.
  52461. * @param observable the observable to which the observer will be attached
  52462. * @param callback the callback to register
  52463. */
  52464. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  52465. /**
  52466. * Code in this function will be executed on each xrFrame received from the browser.
  52467. * This function will not execute after the feature is detached.
  52468. * @param _xrFrame the current frame
  52469. */
  52470. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  52471. }
  52472. }
  52473. declare module BABYLON {
  52474. /**
  52475. * Renders a layer on top of an existing scene
  52476. */
  52477. export class UtilityLayerRenderer implements IDisposable {
  52478. /** the original scene that will be rendered on top of */
  52479. originalScene: Scene;
  52480. private _pointerCaptures;
  52481. private _lastPointerEvents;
  52482. private static _DefaultUtilityLayer;
  52483. private static _DefaultKeepDepthUtilityLayer;
  52484. private _sharedGizmoLight;
  52485. private _renderCamera;
  52486. /**
  52487. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  52488. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  52489. * @returns the camera that is used when rendering the utility layer
  52490. */
  52491. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  52492. /**
  52493. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  52494. * @param cam the camera that should be used when rendering the utility layer
  52495. */
  52496. setRenderCamera(cam: Nullable<Camera>): void;
  52497. /**
  52498. * @hidden
  52499. * Light which used by gizmos to get light shading
  52500. */
  52501. _getSharedGizmoLight(): HemisphericLight;
  52502. /**
  52503. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  52504. */
  52505. pickUtilitySceneFirst: boolean;
  52506. /**
  52507. * 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)
  52508. */
  52509. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  52510. /**
  52511. * 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)
  52512. */
  52513. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  52514. /**
  52515. * The scene that is rendered on top of the original scene
  52516. */
  52517. utilityLayerScene: Scene;
  52518. /**
  52519. * If the utility layer should automatically be rendered on top of existing scene
  52520. */
  52521. shouldRender: boolean;
  52522. /**
  52523. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  52524. */
  52525. onlyCheckPointerDownEvents: boolean;
  52526. /**
  52527. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  52528. */
  52529. processAllEvents: boolean;
  52530. /**
  52531. * Observable raised when the pointer move from the utility layer scene to the main scene
  52532. */
  52533. onPointerOutObservable: Observable<number>;
  52534. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  52535. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  52536. private _afterRenderObserver;
  52537. private _sceneDisposeObserver;
  52538. private _originalPointerObserver;
  52539. /**
  52540. * Instantiates a UtilityLayerRenderer
  52541. * @param originalScene the original scene that will be rendered on top of
  52542. * @param handleEvents boolean indicating if the utility layer should handle events
  52543. */
  52544. constructor(
  52545. /** the original scene that will be rendered on top of */
  52546. originalScene: Scene, handleEvents?: boolean);
  52547. private _notifyObservers;
  52548. /**
  52549. * Renders the utility layers scene on top of the original scene
  52550. */
  52551. render(): void;
  52552. /**
  52553. * Disposes of the renderer
  52554. */
  52555. dispose(): void;
  52556. private _updateCamera;
  52557. }
  52558. }
  52559. declare module BABYLON {
  52560. /**
  52561. * Options interface for the pointer selection module
  52562. */
  52563. export interface IWebXRControllerPointerSelectionOptions {
  52564. /**
  52565. * if provided, this scene will be used to render meshes.
  52566. */
  52567. customUtilityLayerScene?: Scene;
  52568. /**
  52569. * Disable the pointer up event when the xr controller in screen and gaze mode is disposed (meaning - when the user removed the finger from the screen)
  52570. * If not disabled, the last picked point will be used to execute a pointer up event
  52571. * If disabled, pointer up event will be triggered right after the pointer down event.
  52572. * Used in screen and gaze target ray mode only
  52573. */
  52574. disablePointerUpOnTouchOut: boolean;
  52575. /**
  52576. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  52577. */
  52578. forceGazeMode: boolean;
  52579. /**
  52580. * Factor to be applied to the pointer-moved function in the gaze mode. How sensitive should the gaze mode be when checking if the pointer moved
  52581. * to start a new countdown to the pointer down event.
  52582. * Defaults to 1.
  52583. */
  52584. gazeModePointerMovedFactor?: number;
  52585. /**
  52586. * Different button type to use instead of the main component
  52587. */
  52588. overrideButtonId?: string;
  52589. /**
  52590. * use this rendering group id for the meshes (optional)
  52591. */
  52592. renderingGroupId?: number;
  52593. /**
  52594. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  52595. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  52596. * 3000 means 3 seconds between pointing at something and selecting it
  52597. */
  52598. timeToSelect?: number;
  52599. /**
  52600. * Should meshes created here be added to a utility layer or the main scene
  52601. */
  52602. useUtilityLayer?: boolean;
  52603. /**
  52604. * Optional WebXR camera to be used for gaze selection
  52605. */
  52606. gazeCamera?: WebXRCamera;
  52607. /**
  52608. * the xr input to use with this pointer selection
  52609. */
  52610. xrInput: WebXRInput;
  52611. /**
  52612. * Should the scene pointerX and pointerY update be disabled
  52613. * This is required for fullscreen AR GUI, but might slow down other experiences.
  52614. * Disable in VR, if not needed.
  52615. * The first rig camera (left eye) will be used to calculate the projection
  52616. */
  52617. disableScenePointerVectorUpdate: boolean;
  52618. /**
  52619. * Enable pointer selection on all controllers instead of switching between them
  52620. */
  52621. enablePointerSelectionOnAllControllers?: boolean;
  52622. /**
  52623. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  52624. * If switch is enabled, it will still allow the user to switch between the different controllers
  52625. */
  52626. preferredHandedness?: XRHandedness;
  52627. /**
  52628. * Disable switching the pointer selection from one controller to the other.
  52629. * If the preferred hand is set it will be fixed on this hand, and if not it will be fixed on the first controller added to the scene
  52630. */
  52631. disableSwitchOnClick?: boolean;
  52632. /**
  52633. * The maximum distance of the pointer selection feature. Defaults to 100.
  52634. */
  52635. maxPointerDistance?: number;
  52636. }
  52637. /**
  52638. * A module that will enable pointer selection for motion controllers of XR Input Sources
  52639. */
  52640. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  52641. private readonly _options;
  52642. private static _idCounter;
  52643. private _attachController;
  52644. private _controllers;
  52645. private _scene;
  52646. private _tmpVectorForPickCompare;
  52647. private _attachedController;
  52648. /**
  52649. * The module's name
  52650. */
  52651. static readonly Name: string;
  52652. /**
  52653. * The (Babylon) version of this module.
  52654. * This is an integer representing the implementation version.
  52655. * This number does not correspond to the WebXR specs version
  52656. */
  52657. static readonly Version: number;
  52658. /**
  52659. * Disable lighting on the laser pointer (so it will always be visible)
  52660. */
  52661. disablePointerLighting: boolean;
  52662. /**
  52663. * Disable lighting on the selection mesh (so it will always be visible)
  52664. */
  52665. disableSelectionMeshLighting: boolean;
  52666. /**
  52667. * Should the laser pointer be displayed
  52668. */
  52669. displayLaserPointer: boolean;
  52670. /**
  52671. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  52672. */
  52673. displaySelectionMesh: boolean;
  52674. /**
  52675. * This color will be set to the laser pointer when selection is triggered
  52676. */
  52677. laserPointerPickedColor: Color3;
  52678. /**
  52679. * Default color of the laser pointer
  52680. */
  52681. laserPointerDefaultColor: Color3;
  52682. /**
  52683. * default color of the selection ring
  52684. */
  52685. selectionMeshDefaultColor: Color3;
  52686. /**
  52687. * This color will be applied to the selection ring when selection is triggered
  52688. */
  52689. selectionMeshPickedColor: Color3;
  52690. /**
  52691. * Optional filter to be used for ray selection. This predicate shares behavior with
  52692. * scene.pointerMovePredicate which takes priority if it is also assigned.
  52693. */
  52694. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  52695. /**
  52696. * constructs a new background remover module
  52697. * @param _xrSessionManager the session manager for this module
  52698. * @param _options read-only options to be used in this module
  52699. */
  52700. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  52701. /**
  52702. * attach this feature
  52703. * Will usually be called by the features manager
  52704. *
  52705. * @returns true if successful.
  52706. */
  52707. attach(): boolean;
  52708. /**
  52709. * detach this feature.
  52710. * Will usually be called by the features manager
  52711. *
  52712. * @returns true if successful.
  52713. */
  52714. detach(): boolean;
  52715. /**
  52716. * Will get the mesh under a specific pointer.
  52717. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  52718. * @param controllerId the controllerId to check
  52719. * @returns The mesh under pointer or null if no mesh is under the pointer
  52720. */
  52721. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  52722. /**
  52723. * Get the xr controller that correlates to the pointer id in the pointer event
  52724. *
  52725. * @param id the pointer id to search for
  52726. * @returns the controller that correlates to this id or null if not found
  52727. */
  52728. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  52729. private _identityMatrix;
  52730. private _screenCoordinatesRef;
  52731. private _viewportRef;
  52732. protected _onXRFrame(_xrFrame: XRFrame): void;
  52733. private _attachGazeMode;
  52734. private _attachScreenRayMode;
  52735. private _attachTrackedPointerRayMode;
  52736. private _convertNormalToDirectionOfRay;
  52737. private _detachController;
  52738. private _generateNewMeshPair;
  52739. private _pickingMoved;
  52740. private _updatePointerDistance;
  52741. /** @hidden */
  52742. get lasterPointerDefaultColor(): Color3;
  52743. }
  52744. }
  52745. declare module BABYLON {
  52746. /**
  52747. * Button which can be used to enter a different mode of XR
  52748. */
  52749. export class WebXREnterExitUIButton {
  52750. /** button element */
  52751. element: HTMLElement;
  52752. /** XR initialization options for the button */
  52753. sessionMode: XRSessionMode;
  52754. /** Reference space type */
  52755. referenceSpaceType: XRReferenceSpaceType;
  52756. /**
  52757. * Creates a WebXREnterExitUIButton
  52758. * @param element button element
  52759. * @param sessionMode XR initialization session mode
  52760. * @param referenceSpaceType the type of reference space to be used
  52761. */
  52762. constructor(
  52763. /** button element */
  52764. element: HTMLElement,
  52765. /** XR initialization options for the button */
  52766. sessionMode: XRSessionMode,
  52767. /** Reference space type */
  52768. referenceSpaceType: XRReferenceSpaceType);
  52769. /**
  52770. * Extendable function which can be used to update the button's visuals when the state changes
  52771. * @param activeButton the current active button in the UI
  52772. */
  52773. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  52774. }
  52775. /**
  52776. * Options to create the webXR UI
  52777. */
  52778. export class WebXREnterExitUIOptions {
  52779. /**
  52780. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  52781. */
  52782. customButtons?: Array<WebXREnterExitUIButton>;
  52783. /**
  52784. * A reference space type to use when creating the default button.
  52785. * Default is local-floor
  52786. */
  52787. referenceSpaceType?: XRReferenceSpaceType;
  52788. /**
  52789. * Context to enter xr with
  52790. */
  52791. renderTarget?: Nullable<WebXRRenderTarget>;
  52792. /**
  52793. * A session mode to use when creating the default button.
  52794. * Default is immersive-vr
  52795. */
  52796. sessionMode?: XRSessionMode;
  52797. /**
  52798. * A list of optional features to init the session with
  52799. */
  52800. optionalFeatures?: string[];
  52801. /**
  52802. * A list of optional features to init the session with
  52803. */
  52804. requiredFeatures?: string[];
  52805. /**
  52806. * If defined, this function will be executed if the UI encounters an error when entering XR
  52807. */
  52808. onError?: (error: any) => void;
  52809. }
  52810. /**
  52811. * UI to allow the user to enter/exit XR mode
  52812. */
  52813. export class WebXREnterExitUI implements IDisposable {
  52814. private scene;
  52815. /** version of the options passed to this UI */
  52816. options: WebXREnterExitUIOptions;
  52817. private _activeButton;
  52818. private _buttons;
  52819. /**
  52820. * The HTML Div Element to which buttons are added.
  52821. */
  52822. readonly overlay: HTMLDivElement;
  52823. /**
  52824. * Fired every time the active button is changed.
  52825. *
  52826. * When xr is entered via a button that launches xr that button will be the callback parameter
  52827. *
  52828. * When exiting xr the callback parameter will be null)
  52829. */
  52830. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  52831. /**
  52832. *
  52833. * @param scene babylon scene object to use
  52834. * @param options (read-only) version of the options passed to this UI
  52835. */
  52836. private constructor();
  52837. /**
  52838. * Creates UI to allow the user to enter/exit XR mode
  52839. * @param scene the scene to add the ui to
  52840. * @param helper the xr experience helper to enter/exit xr with
  52841. * @param options options to configure the UI
  52842. * @returns the created ui
  52843. */
  52844. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  52845. /**
  52846. * Disposes of the XR UI component
  52847. */
  52848. dispose(): void;
  52849. private _updateButtons;
  52850. }
  52851. }
  52852. declare module BABYLON {
  52853. /**
  52854. * Class containing static functions to help procedurally build meshes
  52855. */
  52856. export class LinesBuilder {
  52857. /**
  52858. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52859. * * 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
  52860. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52861. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52862. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52863. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52864. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52865. * * 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
  52866. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52868. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52869. * @param name defines the name of the new line system
  52870. * @param options defines the options used to create the line system
  52871. * @param scene defines the hosting scene
  52872. * @returns a new line system mesh
  52873. */
  52874. static CreateLineSystem(name: string, options: {
  52875. lines: Vector3[][];
  52876. updatable?: boolean;
  52877. instance?: Nullable<LinesMesh>;
  52878. colors?: Nullable<Color4[][]>;
  52879. useVertexAlpha?: boolean;
  52880. }, scene: Nullable<Scene>): LinesMesh;
  52881. /**
  52882. * Creates a line mesh
  52883. * 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
  52884. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52885. * * The parameter `points` is an array successive Vector3
  52886. * * 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
  52887. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52888. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52889. * * When updating an instance, remember that only point positions can change, not the number of points
  52890. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52891. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52892. * @param name defines the name of the new line system
  52893. * @param options defines the options used to create the line system
  52894. * @param scene defines the hosting scene
  52895. * @returns a new line mesh
  52896. */
  52897. static CreateLines(name: string, options: {
  52898. points: Vector3[];
  52899. updatable?: boolean;
  52900. instance?: Nullable<LinesMesh>;
  52901. colors?: Color4[];
  52902. useVertexAlpha?: boolean;
  52903. }, scene?: Nullable<Scene>): LinesMesh;
  52904. /**
  52905. * Creates a dashed line mesh
  52906. * * 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
  52907. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52908. * * The parameter `points` is an array successive Vector3
  52909. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52910. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52911. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52912. * * 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
  52913. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52914. * * When updating an instance, remember that only point positions can change, not the number of points
  52915. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52916. * @param name defines the name of the mesh
  52917. * @param options defines the options used to create the mesh
  52918. * @param scene defines the hosting scene
  52919. * @returns the dashed line mesh
  52920. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52921. */
  52922. static CreateDashedLines(name: string, options: {
  52923. points: Vector3[];
  52924. dashSize?: number;
  52925. gapSize?: number;
  52926. dashNb?: number;
  52927. updatable?: boolean;
  52928. instance?: LinesMesh;
  52929. useVertexAlpha?: boolean;
  52930. }, scene?: Nullable<Scene>): LinesMesh;
  52931. }
  52932. }
  52933. declare module BABYLON {
  52934. /**
  52935. * Construction options for a timer
  52936. */
  52937. export interface ITimerOptions<T> {
  52938. /**
  52939. * Time-to-end
  52940. */
  52941. timeout: number;
  52942. /**
  52943. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  52944. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  52945. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  52946. */
  52947. contextObservable: Observable<T>;
  52948. /**
  52949. * Optional parameters when adding an observer to the observable
  52950. */
  52951. observableParameters?: {
  52952. mask?: number;
  52953. insertFirst?: boolean;
  52954. scope?: any;
  52955. };
  52956. /**
  52957. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  52958. */
  52959. breakCondition?: (data?: ITimerData<T>) => boolean;
  52960. /**
  52961. * Will be triggered when the time condition has met
  52962. */
  52963. onEnded?: (data: ITimerData<any>) => void;
  52964. /**
  52965. * Will be triggered when the break condition has met (prematurely ended)
  52966. */
  52967. onAborted?: (data: ITimerData<any>) => void;
  52968. /**
  52969. * Optional function to execute on each tick (or count)
  52970. */
  52971. onTick?: (data: ITimerData<any>) => void;
  52972. }
  52973. /**
  52974. * An interface defining the data sent by the timer
  52975. */
  52976. export interface ITimerData<T> {
  52977. /**
  52978. * When did it start
  52979. */
  52980. startTime: number;
  52981. /**
  52982. * Time now
  52983. */
  52984. currentTime: number;
  52985. /**
  52986. * Time passed since started
  52987. */
  52988. deltaTime: number;
  52989. /**
  52990. * How much is completed, in [0.0...1.0].
  52991. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  52992. */
  52993. completeRate: number;
  52994. /**
  52995. * What the registered observable sent in the last count
  52996. */
  52997. payload: T;
  52998. }
  52999. /**
  53000. * The current state of the timer
  53001. */
  53002. export enum TimerState {
  53003. /**
  53004. * Timer initialized, not yet started
  53005. */
  53006. INIT = 0,
  53007. /**
  53008. * Timer started and counting
  53009. */
  53010. STARTED = 1,
  53011. /**
  53012. * Timer ended (whether aborted or time reached)
  53013. */
  53014. ENDED = 2
  53015. }
  53016. /**
  53017. * A simple version of the timer. Will take options and start the timer immediately after calling it
  53018. *
  53019. * @param options options with which to initialize this timer
  53020. */
  53021. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  53022. /**
  53023. * An advanced implementation of a timer class
  53024. */
  53025. export class AdvancedTimer<T = any> implements IDisposable {
  53026. /**
  53027. * Will notify each time the timer calculates the remaining time
  53028. */
  53029. onEachCountObservable: Observable<ITimerData<T>>;
  53030. /**
  53031. * Will trigger when the timer was aborted due to the break condition
  53032. */
  53033. onTimerAbortedObservable: Observable<ITimerData<T>>;
  53034. /**
  53035. * Will trigger when the timer ended successfully
  53036. */
  53037. onTimerEndedObservable: Observable<ITimerData<T>>;
  53038. /**
  53039. * Will trigger when the timer state has changed
  53040. */
  53041. onStateChangedObservable: Observable<TimerState>;
  53042. private _observer;
  53043. private _contextObservable;
  53044. private _observableParameters;
  53045. private _startTime;
  53046. private _timer;
  53047. private _state;
  53048. private _breakCondition;
  53049. private _timeToEnd;
  53050. private _breakOnNextTick;
  53051. /**
  53052. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  53053. * @param options construction options for this advanced timer
  53054. */
  53055. constructor(options: ITimerOptions<T>);
  53056. /**
  53057. * set a breaking condition for this timer. Default is to never break during count
  53058. * @param predicate the new break condition. Returns true to break, false otherwise
  53059. */
  53060. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  53061. /**
  53062. * Reset ALL associated observables in this advanced timer
  53063. */
  53064. clearObservables(): void;
  53065. /**
  53066. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  53067. *
  53068. * @param timeToEnd how much time to measure until timer ended
  53069. */
  53070. start(timeToEnd?: number): void;
  53071. /**
  53072. * Will force a stop on the next tick.
  53073. */
  53074. stop(): void;
  53075. /**
  53076. * Dispose this timer, clearing all resources
  53077. */
  53078. dispose(): void;
  53079. private _setState;
  53080. private _tick;
  53081. private _stop;
  53082. }
  53083. }
  53084. declare module BABYLON {
  53085. /**
  53086. * The options container for the teleportation module
  53087. */
  53088. export interface IWebXRTeleportationOptions {
  53089. /**
  53090. * if provided, this scene will be used to render meshes.
  53091. */
  53092. customUtilityLayerScene?: Scene;
  53093. /**
  53094. * Values to configure the default target mesh
  53095. */
  53096. defaultTargetMeshOptions?: {
  53097. /**
  53098. * Fill color of the teleportation area
  53099. */
  53100. teleportationFillColor?: string;
  53101. /**
  53102. * Border color for the teleportation area
  53103. */
  53104. teleportationBorderColor?: string;
  53105. /**
  53106. * Disable the mesh's animation sequence
  53107. */
  53108. disableAnimation?: boolean;
  53109. /**
  53110. * Disable lighting on the material or the ring and arrow
  53111. */
  53112. disableLighting?: boolean;
  53113. /**
  53114. * Override the default material of the torus and arrow
  53115. */
  53116. torusArrowMaterial?: Material;
  53117. };
  53118. /**
  53119. * A list of meshes to use as floor meshes.
  53120. * Meshes can be added and removed after initializing the feature using the
  53121. * addFloorMesh and removeFloorMesh functions
  53122. * If empty, rotation will still work
  53123. */
  53124. floorMeshes?: AbstractMesh[];
  53125. /**
  53126. * use this rendering group id for the meshes (optional)
  53127. */
  53128. renderingGroupId?: number;
  53129. /**
  53130. * Should teleportation move only to snap points
  53131. */
  53132. snapPointsOnly?: boolean;
  53133. /**
  53134. * An array of points to which the teleportation will snap to.
  53135. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  53136. */
  53137. snapPositions?: Vector3[];
  53138. /**
  53139. * How close should the teleportation ray be in order to snap to position.
  53140. * Default to 0.8 units (meters)
  53141. */
  53142. snapToPositionRadius?: number;
  53143. /**
  53144. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  53145. * If you want to support rotation, make sure your mesh has a direction indicator.
  53146. *
  53147. * When left untouched, the default mesh will be initialized.
  53148. */
  53149. teleportationTargetMesh?: AbstractMesh;
  53150. /**
  53151. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  53152. */
  53153. timeToTeleport?: number;
  53154. /**
  53155. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  53156. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  53157. */
  53158. useMainComponentOnly?: boolean;
  53159. /**
  53160. * Should meshes created here be added to a utility layer or the main scene
  53161. */
  53162. useUtilityLayer?: boolean;
  53163. /**
  53164. * Babylon XR Input class for controller
  53165. */
  53166. xrInput: WebXRInput;
  53167. /**
  53168. * Meshes that the teleportation ray cannot go through
  53169. */
  53170. pickBlockerMeshes?: AbstractMesh[];
  53171. /**
  53172. * Should teleport work only on a specific hand?
  53173. */
  53174. forceHandedness?: XRHandedness;
  53175. /**
  53176. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  53177. */
  53178. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  53179. }
  53180. /**
  53181. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  53182. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  53183. * the input of the attached controllers.
  53184. */
  53185. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  53186. private _options;
  53187. private _controllers;
  53188. private _currentTeleportationControllerId;
  53189. private _floorMeshes;
  53190. private _quadraticBezierCurve;
  53191. private _selectionFeature;
  53192. private _snapToPositions;
  53193. private _snappedToPoint;
  53194. private _teleportationRingMaterial?;
  53195. private _tmpRay;
  53196. private _tmpVector;
  53197. private _tmpQuaternion;
  53198. /**
  53199. * The module's name
  53200. */
  53201. static readonly Name: string;
  53202. /**
  53203. * The (Babylon) version of this module.
  53204. * This is an integer representing the implementation version.
  53205. * This number does not correspond to the webxr specs version
  53206. */
  53207. static readonly Version: number;
  53208. /**
  53209. * Is movement backwards enabled
  53210. */
  53211. backwardsMovementEnabled: boolean;
  53212. /**
  53213. * Distance to travel when moving backwards
  53214. */
  53215. backwardsTeleportationDistance: number;
  53216. /**
  53217. * The distance from the user to the inspection point in the direction of the controller
  53218. * A higher number will allow the user to move further
  53219. * defaults to 5 (meters, in xr units)
  53220. */
  53221. parabolicCheckRadius: number;
  53222. /**
  53223. * Should the module support parabolic ray on top of direct ray
  53224. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  53225. * Very helpful when moving between floors / different heights
  53226. */
  53227. parabolicRayEnabled: boolean;
  53228. /**
  53229. * The second type of ray - straight line.
  53230. * Should it be enabled or should the parabolic line be the only one.
  53231. */
  53232. straightRayEnabled: boolean;
  53233. /**
  53234. * How much rotation should be applied when rotating right and left
  53235. */
  53236. rotationAngle: number;
  53237. private _rotationEnabled;
  53238. /**
  53239. * Is rotation enabled when moving forward?
  53240. * Disabling this feature will prevent the user from deciding the direction when teleporting
  53241. */
  53242. get rotationEnabled(): boolean;
  53243. /**
  53244. * Sets wether rotation is enabled or not
  53245. * @param enabled is rotation enabled when teleportation is shown
  53246. */
  53247. set rotationEnabled(enabled: boolean);
  53248. /**
  53249. * Exposes the currently set teleportation target mesh.
  53250. */
  53251. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  53252. /**
  53253. * constructs a new anchor system
  53254. * @param _xrSessionManager an instance of WebXRSessionManager
  53255. * @param _options configuration object for this feature
  53256. */
  53257. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  53258. /**
  53259. * Get the snapPointsOnly flag
  53260. */
  53261. get snapPointsOnly(): boolean;
  53262. /**
  53263. * Sets the snapPointsOnly flag
  53264. * @param snapToPoints should teleportation be exclusively to snap points
  53265. */
  53266. set snapPointsOnly(snapToPoints: boolean);
  53267. /**
  53268. * Add a new mesh to the floor meshes array
  53269. * @param mesh the mesh to use as floor mesh
  53270. */
  53271. addFloorMesh(mesh: AbstractMesh): void;
  53272. /**
  53273. * Add a new snap-to point to fix teleportation to this position
  53274. * @param newSnapPoint The new Snap-To point
  53275. */
  53276. addSnapPoint(newSnapPoint: Vector3): void;
  53277. attach(): boolean;
  53278. detach(): boolean;
  53279. dispose(): void;
  53280. /**
  53281. * Remove a mesh from the floor meshes array
  53282. * @param mesh the mesh to remove
  53283. */
  53284. removeFloorMesh(mesh: AbstractMesh): void;
  53285. /**
  53286. * Remove a mesh from the floor meshes array using its name
  53287. * @param name the mesh name to remove
  53288. */
  53289. removeFloorMeshByName(name: string): void;
  53290. /**
  53291. * This function will iterate through the array, searching for this point or equal to it. It will then remove it from the snap-to array
  53292. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  53293. * @returns was the point found and removed or not
  53294. */
  53295. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  53296. /**
  53297. * This function sets a selection feature that will be disabled when
  53298. * the forward ray is shown and will be reattached when hidden.
  53299. * This is used to remove the selection rays when moving.
  53300. * @param selectionFeature the feature to disable when forward movement is enabled
  53301. */
  53302. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  53303. protected _onXRFrame(_xrFrame: XRFrame): void;
  53304. private _attachController;
  53305. private _createDefaultTargetMesh;
  53306. private _detachController;
  53307. private _findClosestSnapPointWithRadius;
  53308. private _setTargetMeshPosition;
  53309. private _setTargetMeshVisibility;
  53310. private _showParabolicPath;
  53311. private _teleportForward;
  53312. }
  53313. }
  53314. declare module BABYLON {
  53315. /**
  53316. * Options for the default xr helper
  53317. */
  53318. export class WebXRDefaultExperienceOptions {
  53319. /**
  53320. * Enable or disable default UI to enter XR
  53321. */
  53322. disableDefaultUI?: boolean;
  53323. /**
  53324. * Should teleportation not initialize. defaults to false.
  53325. */
  53326. disableTeleportation?: boolean;
  53327. /**
  53328. * Floor meshes that will be used for teleport
  53329. */
  53330. floorMeshes?: Array<AbstractMesh>;
  53331. /**
  53332. * If set to true, the first frame will not be used to reset position
  53333. * The first frame is mainly used when copying transformation from the old camera
  53334. * Mainly used in AR
  53335. */
  53336. ignoreNativeCameraTransformation?: boolean;
  53337. /**
  53338. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  53339. */
  53340. inputOptions?: IWebXRInputOptions;
  53341. /**
  53342. * optional configuration for the output canvas
  53343. */
  53344. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  53345. /**
  53346. * optional UI options. This can be used among other to change session mode and reference space type
  53347. */
  53348. uiOptions?: WebXREnterExitUIOptions;
  53349. /**
  53350. * When loading teleportation and pointer select, use stable versions instead of latest.
  53351. */
  53352. useStablePlugins?: boolean;
  53353. /**
  53354. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  53355. */
  53356. renderingGroupId?: number;
  53357. /**
  53358. * A list of optional features to init the session with
  53359. * If set to true, all features we support will be added
  53360. */
  53361. optionalFeatures?: boolean | string[];
  53362. }
  53363. /**
  53364. * Default experience which provides a similar setup to the previous webVRExperience
  53365. */
  53366. export class WebXRDefaultExperience {
  53367. /**
  53368. * Base experience
  53369. */
  53370. baseExperience: WebXRExperienceHelper;
  53371. /**
  53372. * Enables ui for entering/exiting xr
  53373. */
  53374. enterExitUI: WebXREnterExitUI;
  53375. /**
  53376. * Input experience extension
  53377. */
  53378. input: WebXRInput;
  53379. /**
  53380. * Enables laser pointer and selection
  53381. */
  53382. pointerSelection: WebXRControllerPointerSelection;
  53383. /**
  53384. * Default target xr should render to
  53385. */
  53386. renderTarget: WebXRRenderTarget;
  53387. /**
  53388. * Enables teleportation
  53389. */
  53390. teleportation: WebXRMotionControllerTeleportation;
  53391. private constructor();
  53392. /**
  53393. * Creates the default xr experience
  53394. * @param scene scene
  53395. * @param options options for basic configuration
  53396. * @returns resulting WebXRDefaultExperience
  53397. */
  53398. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  53399. /**
  53400. * DIsposes of the experience helper
  53401. */
  53402. dispose(): void;
  53403. }
  53404. }
  53405. declare module BABYLON {
  53406. /**
  53407. * Options to modify the vr teleportation behavior.
  53408. */
  53409. export interface VRTeleportationOptions {
  53410. /**
  53411. * The name of the mesh which should be used as the teleportation floor. (default: null)
  53412. */
  53413. floorMeshName?: string;
  53414. /**
  53415. * A list of meshes to be used as the teleportation floor. (default: empty)
  53416. */
  53417. floorMeshes?: Mesh[];
  53418. /**
  53419. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  53420. */
  53421. teleportationMode?: number;
  53422. /**
  53423. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  53424. */
  53425. teleportationTime?: number;
  53426. /**
  53427. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  53428. */
  53429. teleportationSpeed?: number;
  53430. /**
  53431. * The easing function used in the animation or null for Linear. (default CircleEase)
  53432. */
  53433. easingFunction?: EasingFunction;
  53434. }
  53435. /**
  53436. * Options to modify the vr experience helper's behavior.
  53437. */
  53438. export interface VRExperienceHelperOptions extends WebVROptions {
  53439. /**
  53440. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  53441. */
  53442. createDeviceOrientationCamera?: boolean;
  53443. /**
  53444. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  53445. */
  53446. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  53447. /**
  53448. * Uses the main button on the controller to toggle the laser casted. (default: true)
  53449. */
  53450. laserToggle?: boolean;
  53451. /**
  53452. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  53453. */
  53454. floorMeshes?: Mesh[];
  53455. /**
  53456. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  53457. */
  53458. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  53459. /**
  53460. * Defines if WebXR should be used instead of WebVR (if available)
  53461. */
  53462. useXR?: boolean;
  53463. }
  53464. /**
  53465. * Event containing information after VR has been entered
  53466. */
  53467. export class OnAfterEnteringVRObservableEvent {
  53468. /**
  53469. * If entering vr was successful
  53470. */
  53471. success: boolean;
  53472. }
  53473. /**
  53474. * Helps to quickly add VR support to an existing scene.
  53475. * See https://doc.babylonjs.com/how_to/webvr_helper
  53476. */
  53477. export class VRExperienceHelper {
  53478. /** Options to modify the vr experience helper's behavior. */
  53479. webVROptions: VRExperienceHelperOptions;
  53480. private _scene;
  53481. private _position;
  53482. private _btnVR;
  53483. private _btnVRDisplayed;
  53484. private _webVRsupported;
  53485. private _webVRready;
  53486. private _webVRrequesting;
  53487. private _webVRpresenting;
  53488. private _hasEnteredVR;
  53489. private _fullscreenVRpresenting;
  53490. private _inputElement;
  53491. private _webVRCamera;
  53492. private _vrDeviceOrientationCamera;
  53493. private _deviceOrientationCamera;
  53494. private _existingCamera;
  53495. private _onKeyDown;
  53496. private _onVrDisplayPresentChange;
  53497. private _onVRDisplayChanged;
  53498. private _onVRRequestPresentStart;
  53499. private _onVRRequestPresentComplete;
  53500. /**
  53501. * 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)
  53502. */
  53503. enableGazeEvenWhenNoPointerLock: boolean;
  53504. /**
  53505. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  53506. */
  53507. exitVROnDoubleTap: boolean;
  53508. /**
  53509. * Observable raised right before entering VR.
  53510. */
  53511. onEnteringVRObservable: Observable<VRExperienceHelper>;
  53512. /**
  53513. * Observable raised when entering VR has completed.
  53514. */
  53515. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  53516. /**
  53517. * Observable raised when exiting VR.
  53518. */
  53519. onExitingVRObservable: Observable<VRExperienceHelper>;
  53520. /**
  53521. * Observable raised when controller mesh is loaded.
  53522. */
  53523. onControllerMeshLoadedObservable: Observable<WebVRController>;
  53524. /** Return this.onEnteringVRObservable
  53525. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  53526. */
  53527. get onEnteringVR(): Observable<VRExperienceHelper>;
  53528. /** Return this.onExitingVRObservable
  53529. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  53530. */
  53531. get onExitingVR(): Observable<VRExperienceHelper>;
  53532. /** Return this.onControllerMeshLoadedObservable
  53533. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  53534. */
  53535. get onControllerMeshLoaded(): Observable<WebVRController>;
  53536. private _rayLength;
  53537. private _useCustomVRButton;
  53538. private _teleportationRequested;
  53539. private _teleportActive;
  53540. private _floorMeshName;
  53541. private _floorMeshesCollection;
  53542. private _teleportationMode;
  53543. private _teleportationTime;
  53544. private _teleportationSpeed;
  53545. private _teleportationEasing;
  53546. private _rotationAllowed;
  53547. private _teleportBackwardsVector;
  53548. private _teleportationTarget;
  53549. private _isDefaultTeleportationTarget;
  53550. private _postProcessMove;
  53551. private _teleportationFillColor;
  53552. private _teleportationBorderColor;
  53553. private _rotationAngle;
  53554. private _haloCenter;
  53555. private _cameraGazer;
  53556. private _padSensibilityUp;
  53557. private _padSensibilityDown;
  53558. private _leftController;
  53559. private _rightController;
  53560. private _gazeColor;
  53561. private _laserColor;
  53562. private _pickedLaserColor;
  53563. private _pickedGazeColor;
  53564. /**
  53565. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  53566. */
  53567. onNewMeshSelected: Observable<AbstractMesh>;
  53568. /**
  53569. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  53570. * This observable will provide the mesh and the controller used to select the mesh
  53571. */
  53572. onMeshSelectedWithController: Observable<{
  53573. mesh: AbstractMesh;
  53574. controller: WebVRController;
  53575. }>;
  53576. /**
  53577. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  53578. */
  53579. onNewMeshPicked: Observable<PickingInfo>;
  53580. private _circleEase;
  53581. /**
  53582. * Observable raised before camera teleportation
  53583. */
  53584. onBeforeCameraTeleport: Observable<Vector3>;
  53585. /**
  53586. * Observable raised after camera teleportation
  53587. */
  53588. onAfterCameraTeleport: Observable<Vector3>;
  53589. /**
  53590. * Observable raised when current selected mesh gets unselected
  53591. */
  53592. onSelectedMeshUnselected: Observable<AbstractMesh>;
  53593. private _raySelectionPredicate;
  53594. /**
  53595. * To be optionaly changed by user to define custom ray selection
  53596. */
  53597. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  53598. /**
  53599. * To be optionaly changed by user to define custom selection logic (after ray selection)
  53600. */
  53601. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53602. /**
  53603. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  53604. */
  53605. teleportationEnabled: boolean;
  53606. private _defaultHeight;
  53607. private _teleportationInitialized;
  53608. private _interactionsEnabled;
  53609. private _interactionsRequested;
  53610. private _displayGaze;
  53611. private _displayLaserPointer;
  53612. /**
  53613. * The mesh used to display where the user is going to teleport.
  53614. */
  53615. get teleportationTarget(): Mesh;
  53616. /**
  53617. * Sets the mesh to be used to display where the user is going to teleport.
  53618. */
  53619. set teleportationTarget(value: Mesh);
  53620. /**
  53621. * 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
  53622. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  53623. * See https://doc.babylonjs.com/resources/baking_transformations
  53624. */
  53625. get gazeTrackerMesh(): Mesh;
  53626. set gazeTrackerMesh(value: Mesh);
  53627. /**
  53628. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  53629. */
  53630. updateGazeTrackerScale: boolean;
  53631. /**
  53632. * If the gaze trackers color should be updated when selecting meshes
  53633. */
  53634. updateGazeTrackerColor: boolean;
  53635. /**
  53636. * If the controller laser color should be updated when selecting meshes
  53637. */
  53638. updateControllerLaserColor: boolean;
  53639. /**
  53640. * The gaze tracking mesh corresponding to the left controller
  53641. */
  53642. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  53643. /**
  53644. * The gaze tracking mesh corresponding to the right controller
  53645. */
  53646. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  53647. /**
  53648. * If the ray of the gaze should be displayed.
  53649. */
  53650. get displayGaze(): boolean;
  53651. /**
  53652. * Sets if the ray of the gaze should be displayed.
  53653. */
  53654. set displayGaze(value: boolean);
  53655. /**
  53656. * If the ray of the LaserPointer should be displayed.
  53657. */
  53658. get displayLaserPointer(): boolean;
  53659. /**
  53660. * Sets if the ray of the LaserPointer should be displayed.
  53661. */
  53662. set displayLaserPointer(value: boolean);
  53663. /**
  53664. * The deviceOrientationCamera used as the camera when not in VR.
  53665. */
  53666. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  53667. /**
  53668. * Based on the current WebVR support, returns the current VR camera used.
  53669. */
  53670. get currentVRCamera(): Nullable<Camera>;
  53671. /**
  53672. * The webVRCamera which is used when in VR.
  53673. */
  53674. get webVRCamera(): WebVRFreeCamera;
  53675. /**
  53676. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  53677. */
  53678. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  53679. /**
  53680. * The html button that is used to trigger entering into VR.
  53681. */
  53682. get vrButton(): Nullable<HTMLButtonElement>;
  53683. private get _teleportationRequestInitiated();
  53684. /**
  53685. * Defines whether or not Pointer lock should be requested when switching to
  53686. * full screen.
  53687. */
  53688. requestPointerLockOnFullScreen: boolean;
  53689. /**
  53690. * If asking to force XR, this will be populated with the default xr experience
  53691. */
  53692. xr: WebXRDefaultExperience;
  53693. /**
  53694. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  53695. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  53696. */
  53697. xrTestDone: boolean;
  53698. /**
  53699. * Instantiates a VRExperienceHelper.
  53700. * Helps to quickly add VR support to an existing scene.
  53701. * @param scene The scene the VRExperienceHelper belongs to.
  53702. * @param webVROptions Options to modify the vr experience helper's behavior.
  53703. */
  53704. constructor(scene: Scene,
  53705. /** Options to modify the vr experience helper's behavior. */
  53706. webVROptions?: VRExperienceHelperOptions);
  53707. private completeVRInit;
  53708. private _onDefaultMeshLoaded;
  53709. private _onResize;
  53710. private _onFullscreenChange;
  53711. /**
  53712. * Gets a value indicating if we are currently in VR mode.
  53713. */
  53714. get isInVRMode(): boolean;
  53715. private onVrDisplayPresentChange;
  53716. private onVRDisplayChanged;
  53717. private moveButtonToBottomRight;
  53718. private displayVRButton;
  53719. private updateButtonVisibility;
  53720. private _cachedAngularSensibility;
  53721. /**
  53722. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  53723. * Otherwise, will use the fullscreen API.
  53724. */
  53725. enterVR(): void;
  53726. /**
  53727. * Attempt to exit VR, or fullscreen.
  53728. */
  53729. exitVR(): void;
  53730. /**
  53731. * The position of the vr experience helper.
  53732. */
  53733. get position(): Vector3;
  53734. /**
  53735. * Sets the position of the vr experience helper.
  53736. */
  53737. set position(value: Vector3);
  53738. /**
  53739. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  53740. */
  53741. enableInteractions(): void;
  53742. private get _noControllerIsActive();
  53743. private beforeRender;
  53744. private _isTeleportationFloor;
  53745. /**
  53746. * Adds a floor mesh to be used for teleportation.
  53747. * @param floorMesh the mesh to be used for teleportation.
  53748. */
  53749. addFloorMesh(floorMesh: Mesh): void;
  53750. /**
  53751. * Removes a floor mesh from being used for teleportation.
  53752. * @param floorMesh the mesh to be removed.
  53753. */
  53754. removeFloorMesh(floorMesh: Mesh): void;
  53755. /**
  53756. * Enables interactions and teleportation using the VR controllers and gaze.
  53757. * @param vrTeleportationOptions options to modify teleportation behavior.
  53758. */
  53759. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  53760. private _onNewGamepadConnected;
  53761. private _tryEnableInteractionOnController;
  53762. private _onNewGamepadDisconnected;
  53763. private _enableInteractionOnController;
  53764. private _checkTeleportWithRay;
  53765. private _checkRotate;
  53766. private _checkTeleportBackwards;
  53767. private _enableTeleportationOnController;
  53768. private _createTeleportationCircles;
  53769. private _displayTeleportationTarget;
  53770. private _hideTeleportationTarget;
  53771. private _rotateCamera;
  53772. private _moveTeleportationSelectorTo;
  53773. private _workingVector;
  53774. private _workingQuaternion;
  53775. private _workingMatrix;
  53776. /**
  53777. * Time Constant Teleportation Mode
  53778. */
  53779. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  53780. /**
  53781. * Speed Constant Teleportation Mode
  53782. */
  53783. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  53784. /**
  53785. * Teleports the users feet to the desired location
  53786. * @param location The location where the user's feet should be placed
  53787. */
  53788. teleportCamera(location: Vector3): void;
  53789. private _convertNormalToDirectionOfRay;
  53790. private _castRayAndSelectObject;
  53791. private _notifySelectedMeshUnselected;
  53792. /**
  53793. * Permanently set new colors for the laser pointer
  53794. * @param color the new laser color
  53795. * @param pickedColor the new laser color when picked mesh detected
  53796. */
  53797. setLaserColor(color: Color3, pickedColor?: Color3): void;
  53798. /**
  53799. * Set lighting enabled / disabled on the laser pointer of both controllers
  53800. * @param enabled should the lighting be enabled on the laser pointer
  53801. */
  53802. setLaserLightingState(enabled?: boolean): void;
  53803. /**
  53804. * Permanently set new colors for the gaze pointer
  53805. * @param color the new gaze color
  53806. * @param pickedColor the new gaze color when picked mesh detected
  53807. */
  53808. setGazeColor(color: Color3, pickedColor?: Color3): void;
  53809. /**
  53810. * Sets the color of the laser ray from the vr controllers.
  53811. * @param color new color for the ray.
  53812. */
  53813. changeLaserColor(color: Color3): void;
  53814. /**
  53815. * Sets the color of the ray from the vr headsets gaze.
  53816. * @param color new color for the ray.
  53817. */
  53818. changeGazeColor(color: Color3): void;
  53819. /**
  53820. * Exits VR and disposes of the vr experience helper
  53821. */
  53822. dispose(): void;
  53823. /**
  53824. * Gets the name of the VRExperienceHelper class
  53825. * @returns "VRExperienceHelper"
  53826. */
  53827. getClassName(): string;
  53828. }
  53829. }
  53830. declare module BABYLON {
  53831. /**
  53832. * Contains an array of blocks representing the octree
  53833. */
  53834. export interface IOctreeContainer<T> {
  53835. /**
  53836. * Blocks within the octree
  53837. */
  53838. blocks: Array<OctreeBlock<T>>;
  53839. }
  53840. /**
  53841. * Class used to store a cell in an octree
  53842. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53843. */
  53844. export class OctreeBlock<T> {
  53845. /**
  53846. * Gets the content of the current block
  53847. */
  53848. entries: T[];
  53849. /**
  53850. * Gets the list of block children
  53851. */
  53852. blocks: Array<OctreeBlock<T>>;
  53853. private _depth;
  53854. private _maxDepth;
  53855. private _capacity;
  53856. private _minPoint;
  53857. private _maxPoint;
  53858. private _boundingVectors;
  53859. private _creationFunc;
  53860. /**
  53861. * Creates a new block
  53862. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  53863. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  53864. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53865. * @param depth defines the current depth of this block in the octree
  53866. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  53867. * @param creationFunc defines a callback to call when an element is added to the block
  53868. */
  53869. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  53870. /**
  53871. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53872. */
  53873. get capacity(): number;
  53874. /**
  53875. * Gets the minimum vector (in world space) of the block's bounding box
  53876. */
  53877. get minPoint(): Vector3;
  53878. /**
  53879. * Gets the maximum vector (in world space) of the block's bounding box
  53880. */
  53881. get maxPoint(): Vector3;
  53882. /**
  53883. * Add a new element to this block
  53884. * @param entry defines the element to add
  53885. */
  53886. addEntry(entry: T): void;
  53887. /**
  53888. * Remove an element from this block
  53889. * @param entry defines the element to remove
  53890. */
  53891. removeEntry(entry: T): void;
  53892. /**
  53893. * Add an array of elements to this block
  53894. * @param entries defines the array of elements to add
  53895. */
  53896. addEntries(entries: T[]): void;
  53897. /**
  53898. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  53899. * @param frustumPlanes defines the frustum planes to test
  53900. * @param selection defines the array to store current content if selection is positive
  53901. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53902. */
  53903. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53904. /**
  53905. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  53906. * @param sphereCenter defines the bounding sphere center
  53907. * @param sphereRadius defines the bounding sphere radius
  53908. * @param selection defines the array to store current content if selection is positive
  53909. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53910. */
  53911. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53912. /**
  53913. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  53914. * @param ray defines the ray to test with
  53915. * @param selection defines the array to store current content if selection is positive
  53916. */
  53917. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  53918. /**
  53919. * Subdivide the content into child blocks (this block will then be empty)
  53920. */
  53921. createInnerBlocks(): void;
  53922. /**
  53923. * @hidden
  53924. */
  53925. 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;
  53926. }
  53927. }
  53928. declare module BABYLON {
  53929. /**
  53930. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  53931. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53932. */
  53933. export class Octree<T> {
  53934. /** 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.) */
  53935. maxDepth: number;
  53936. /**
  53937. * Blocks within the octree containing objects
  53938. */
  53939. blocks: Array<OctreeBlock<T>>;
  53940. /**
  53941. * Content stored in the octree
  53942. */
  53943. dynamicContent: T[];
  53944. private _maxBlockCapacity;
  53945. private _selectionContent;
  53946. private _creationFunc;
  53947. /**
  53948. * Creates a octree
  53949. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53950. * @param creationFunc function to be used to instatiate the octree
  53951. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  53952. * @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.)
  53953. */
  53954. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  53955. /** 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.) */
  53956. maxDepth?: number);
  53957. /**
  53958. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  53959. * @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);
  53960. * @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);
  53961. * @param entries meshes to be added to the octree blocks
  53962. */
  53963. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  53964. /**
  53965. * Adds a mesh to the octree
  53966. * @param entry Mesh to add to the octree
  53967. */
  53968. addMesh(entry: T): void;
  53969. /**
  53970. * Remove an element from the octree
  53971. * @param entry defines the element to remove
  53972. */
  53973. removeMesh(entry: T): void;
  53974. /**
  53975. * Selects an array of meshes within the frustum
  53976. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  53977. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  53978. * @returns array of meshes within the frustum
  53979. */
  53980. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  53981. /**
  53982. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  53983. * @param sphereCenter defines the bounding sphere center
  53984. * @param sphereRadius defines the bounding sphere radius
  53985. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53986. * @returns an array of objects that intersect the sphere
  53987. */
  53988. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  53989. /**
  53990. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  53991. * @param ray defines the ray to test with
  53992. * @returns array of intersected objects
  53993. */
  53994. intersectsRay(ray: Ray): SmartArray<T>;
  53995. /**
  53996. * Adds a mesh into the octree block if it intersects the block
  53997. */
  53998. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  53999. /**
  54000. * Adds a submesh into the octree block if it intersects the block
  54001. */
  54002. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  54003. }
  54004. }
  54005. declare module BABYLON {
  54006. interface Scene {
  54007. /**
  54008. * @hidden
  54009. * Backing Filed
  54010. */
  54011. _selectionOctree: Octree<AbstractMesh>;
  54012. /**
  54013. * Gets the octree used to boost mesh selection (picking)
  54014. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  54015. */
  54016. selectionOctree: Octree<AbstractMesh>;
  54017. /**
  54018. * Creates or updates the octree used to boost selection (picking)
  54019. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  54020. * @param maxCapacity defines the maximum capacity per leaf
  54021. * @param maxDepth defines the maximum depth of the octree
  54022. * @returns an octree of AbstractMesh
  54023. */
  54024. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  54025. }
  54026. interface AbstractMesh {
  54027. /**
  54028. * @hidden
  54029. * Backing Field
  54030. */
  54031. _submeshesOctree: Octree<SubMesh>;
  54032. /**
  54033. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  54034. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  54035. * @param maxCapacity defines the maximum size of each block (64 by default)
  54036. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  54037. * @returns the new octree
  54038. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  54039. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  54040. */
  54041. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  54042. }
  54043. /**
  54044. * Defines the octree scene component responsible to manage any octrees
  54045. * in a given scene.
  54046. */
  54047. export class OctreeSceneComponent {
  54048. /**
  54049. * The component name help to identify the component in the list of scene components.
  54050. */
  54051. readonly name: string;
  54052. /**
  54053. * The scene the component belongs to.
  54054. */
  54055. scene: Scene;
  54056. /**
  54057. * Indicates if the meshes have been checked to make sure they are isEnabled()
  54058. */
  54059. readonly checksIsEnabled: boolean;
  54060. /**
  54061. * Creates a new instance of the component for the given scene
  54062. * @param scene Defines the scene to register the component in
  54063. */
  54064. constructor(scene: Scene);
  54065. /**
  54066. * Registers the component in a given scene
  54067. */
  54068. register(): void;
  54069. /**
  54070. * Return the list of active meshes
  54071. * @returns the list of active meshes
  54072. */
  54073. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  54074. /**
  54075. * Return the list of active sub meshes
  54076. * @param mesh The mesh to get the candidates sub meshes from
  54077. * @returns the list of active sub meshes
  54078. */
  54079. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  54080. private _tempRay;
  54081. /**
  54082. * Return the list of sub meshes intersecting with a given local ray
  54083. * @param mesh defines the mesh to find the submesh for
  54084. * @param localRay defines the ray in local space
  54085. * @returns the list of intersecting sub meshes
  54086. */
  54087. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  54088. /**
  54089. * Return the list of sub meshes colliding with a collider
  54090. * @param mesh defines the mesh to find the submesh for
  54091. * @param collider defines the collider to evaluate the collision against
  54092. * @returns the list of colliding sub meshes
  54093. */
  54094. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  54095. /**
  54096. * Rebuilds the elements related to this component in case of
  54097. * context lost for instance.
  54098. */
  54099. rebuild(): void;
  54100. /**
  54101. * Disposes the component and the associated ressources.
  54102. */
  54103. dispose(): void;
  54104. }
  54105. }
  54106. declare module BABYLON {
  54107. /**
  54108. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  54109. */
  54110. export interface GizmoAxisCache {
  54111. /** Mesh used to runder the Gizmo */
  54112. gizmoMeshes: Mesh[];
  54113. /** Mesh used to detect user interaction with Gizmo */
  54114. colliderMeshes: Mesh[];
  54115. /** Material used to inicate color of gizmo mesh */
  54116. material: StandardMaterial;
  54117. /** Material used to inicate hover state of the Gizmo */
  54118. hoverMaterial: StandardMaterial;
  54119. /** Material used to inicate disabled state of the Gizmo */
  54120. disableMaterial: StandardMaterial;
  54121. /** Used to indicate Active state of the Gizmo */
  54122. active: boolean;
  54123. }
  54124. /**
  54125. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  54126. */
  54127. export class Gizmo implements IDisposable {
  54128. /** The utility layer the gizmo will be added to */
  54129. gizmoLayer: UtilityLayerRenderer;
  54130. /**
  54131. * The root mesh of the gizmo
  54132. */
  54133. _rootMesh: Mesh;
  54134. private _attachedMesh;
  54135. private _attachedNode;
  54136. /**
  54137. * Ratio for the scale of the gizmo (Default: 1)
  54138. */
  54139. protected _scaleRatio: number;
  54140. /**
  54141. * boolean updated by pointermove when a gizmo mesh is hovered
  54142. */
  54143. protected _isHovered: boolean;
  54144. /**
  54145. * Ratio for the scale of the gizmo (Default: 1)
  54146. */
  54147. set scaleRatio(value: number);
  54148. get scaleRatio(): number;
  54149. /**
  54150. * True when the mouse pointer is hovered a gizmo mesh
  54151. */
  54152. get isHovered(): boolean;
  54153. /**
  54154. * If a custom mesh has been set (Default: false)
  54155. */
  54156. protected _customMeshSet: boolean;
  54157. /**
  54158. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  54159. * * When set, interactions will be enabled
  54160. */
  54161. get attachedMesh(): Nullable<AbstractMesh>;
  54162. set attachedMesh(value: Nullable<AbstractMesh>);
  54163. /**
  54164. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  54165. * * When set, interactions will be enabled
  54166. */
  54167. get attachedNode(): Nullable<Node>;
  54168. set attachedNode(value: Nullable<Node>);
  54169. /**
  54170. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  54171. * @param mesh The mesh to replace the default mesh of the gizmo
  54172. */
  54173. setCustomMesh(mesh: Mesh): void;
  54174. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  54175. /**
  54176. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  54177. */
  54178. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54179. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54180. /**
  54181. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  54182. */
  54183. updateGizmoPositionToMatchAttachedMesh: boolean;
  54184. /**
  54185. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  54186. */
  54187. updateScale: boolean;
  54188. protected _interactionsEnabled: boolean;
  54189. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54190. private _beforeRenderObserver;
  54191. private _tempQuaternion;
  54192. private _tempVector;
  54193. private _tempVector2;
  54194. private _tempMatrix1;
  54195. private _tempMatrix2;
  54196. private _rightHandtoLeftHandMatrix;
  54197. /**
  54198. * Creates a gizmo
  54199. * @param gizmoLayer The utility layer the gizmo will be added to
  54200. */
  54201. constructor(
  54202. /** The utility layer the gizmo will be added to */
  54203. gizmoLayer?: UtilityLayerRenderer);
  54204. /**
  54205. * Updates the gizmo to match the attached mesh's position/rotation
  54206. */
  54207. protected _update(): void;
  54208. /**
  54209. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  54210. * @param value Node, TransformNode or mesh
  54211. */
  54212. protected _matrixChanged(): void;
  54213. /**
  54214. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  54215. * @param gizmoLayer The utility layer the gizmo will be added to
  54216. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  54217. * @returns {Observer<PointerInfo>} pointerObserver
  54218. */
  54219. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  54220. /**
  54221. * Disposes of the gizmo
  54222. */
  54223. dispose(): void;
  54224. }
  54225. }
  54226. declare module BABYLON {
  54227. /**
  54228. * Single plane drag gizmo
  54229. */
  54230. export class PlaneDragGizmo extends Gizmo {
  54231. /**
  54232. * Drag behavior responsible for the gizmos dragging interactions
  54233. */
  54234. dragBehavior: PointerDragBehavior;
  54235. private _pointerObserver;
  54236. /**
  54237. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54238. */
  54239. snapDistance: number;
  54240. /**
  54241. * Event that fires each time the gizmo snaps to a new location.
  54242. * * snapDistance is the the change in distance
  54243. */
  54244. onSnapObservable: Observable<{
  54245. snapDistance: number;
  54246. }>;
  54247. private _gizmoMesh;
  54248. private _coloredMaterial;
  54249. private _hoverMaterial;
  54250. private _disableMaterial;
  54251. private _isEnabled;
  54252. private _parent;
  54253. private _dragging;
  54254. /** @hidden */
  54255. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  54256. /**
  54257. * Creates a PlaneDragGizmo
  54258. * @param gizmoLayer The utility layer the gizmo will be added to
  54259. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  54260. * @param color The color of the gizmo
  54261. */
  54262. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  54263. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54264. /**
  54265. * If the gizmo is enabled
  54266. */
  54267. set isEnabled(value: boolean);
  54268. get isEnabled(): boolean;
  54269. /**
  54270. * Disposes of the gizmo
  54271. */
  54272. dispose(): void;
  54273. }
  54274. }
  54275. declare module BABYLON {
  54276. /**
  54277. * Single plane rotation gizmo
  54278. */
  54279. export class PlaneRotationGizmo extends Gizmo {
  54280. /**
  54281. * Drag behavior responsible for the gizmos dragging interactions
  54282. */
  54283. dragBehavior: PointerDragBehavior;
  54284. private _pointerObserver;
  54285. /**
  54286. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  54287. */
  54288. snapDistance: number;
  54289. /**
  54290. * Event that fires each time the gizmo snaps to a new location.
  54291. * * snapDistance is the the change in distance
  54292. */
  54293. onSnapObservable: Observable<{
  54294. snapDistance: number;
  54295. }>;
  54296. private _isEnabled;
  54297. private _parent;
  54298. private _coloredMaterial;
  54299. private _hoverMaterial;
  54300. private _disableMaterial;
  54301. private _gizmoMesh;
  54302. private _rotationCircle;
  54303. private _dragging;
  54304. private static _CircleConstants;
  54305. /**
  54306. * Creates a PlaneRotationGizmo
  54307. * @param gizmoLayer The utility layer the gizmo will be added to
  54308. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  54309. * @param color The color of the gizmo
  54310. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54311. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54312. * @param thickness display gizmo axis thickness
  54313. */
  54314. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  54315. /** Create Geometry for Gizmo */
  54316. private _createGizmoMesh;
  54317. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54318. private setupRotationCircle;
  54319. private updateRotationPath;
  54320. private updateRotationCircle;
  54321. /**
  54322. * If the gizmo is enabled
  54323. */
  54324. set isEnabled(value: boolean);
  54325. get isEnabled(): boolean;
  54326. /**
  54327. * Disposes of the gizmo
  54328. */
  54329. dispose(): void;
  54330. }
  54331. }
  54332. declare module BABYLON {
  54333. /**
  54334. * Gizmo that enables rotating a mesh along 3 axis
  54335. */
  54336. export class RotationGizmo extends Gizmo {
  54337. /**
  54338. * Internal gizmo used for interactions on the x axis
  54339. */
  54340. xGizmo: PlaneRotationGizmo;
  54341. /**
  54342. * Internal gizmo used for interactions on the y axis
  54343. */
  54344. yGizmo: PlaneRotationGizmo;
  54345. /**
  54346. * Internal gizmo used for interactions on the z axis
  54347. */
  54348. zGizmo: PlaneRotationGizmo;
  54349. /** Fires an event when any of it's sub gizmos are dragged */
  54350. onDragStartObservable: Observable<unknown>;
  54351. /** Fires an event when any of it's sub gizmos are released from dragging */
  54352. onDragEndObservable: Observable<unknown>;
  54353. private _meshAttached;
  54354. private _nodeAttached;
  54355. private _observables;
  54356. /** Node Caching for quick lookup */
  54357. private _gizmoAxisCache;
  54358. get attachedMesh(): Nullable<AbstractMesh>;
  54359. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54360. get attachedNode(): Nullable<Node>;
  54361. set attachedNode(node: Nullable<Node>);
  54362. protected _checkBillboardTransform(): void;
  54363. /**
  54364. * True when the mouse pointer is hovering a gizmo mesh
  54365. */
  54366. get isHovered(): boolean;
  54367. /**
  54368. * Creates a RotationGizmo
  54369. * @param gizmoLayer The utility layer the gizmo will be added to
  54370. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54371. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54372. * @param thickness display gizmo axis thickness
  54373. */
  54374. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  54375. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54376. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54377. /**
  54378. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54379. */
  54380. set snapDistance(value: number);
  54381. get snapDistance(): number;
  54382. /**
  54383. * Ratio for the scale of the gizmo (Default: 1)
  54384. */
  54385. set scaleRatio(value: number);
  54386. get scaleRatio(): number;
  54387. /**
  54388. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  54389. * @param mesh Axis gizmo mesh
  54390. * @param cache Gizmo axis definition used for reactive gizmo UI
  54391. */
  54392. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  54393. /**
  54394. * Disposes of the gizmo
  54395. */
  54396. dispose(): void;
  54397. /**
  54398. * CustomMeshes are not supported by this gizmo
  54399. * @param mesh The mesh to replace the default mesh of the gizmo
  54400. */
  54401. setCustomMesh(mesh: Mesh): void;
  54402. }
  54403. }
  54404. declare module BABYLON {
  54405. /**
  54406. * Class containing static functions to help procedurally build meshes
  54407. */
  54408. export class PolyhedronBuilder {
  54409. /**
  54410. * Creates a polyhedron mesh
  54411. * * 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
  54412. * * The parameter `size` (positive float, default 1) sets the polygon size
  54413. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  54414. * * 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`
  54415. * * 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
  54416. * * 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)`)
  54417. * * 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
  54418. * * 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
  54419. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54420. * * 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
  54421. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54422. * @param name defines the name of the mesh
  54423. * @param options defines the options used to create the mesh
  54424. * @param scene defines the hosting scene
  54425. * @returns the polyhedron mesh
  54426. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  54427. */
  54428. static CreatePolyhedron(name: string, options: {
  54429. type?: number;
  54430. size?: number;
  54431. sizeX?: number;
  54432. sizeY?: number;
  54433. sizeZ?: number;
  54434. custom?: any;
  54435. faceUV?: Vector4[];
  54436. faceColors?: Color4[];
  54437. flat?: boolean;
  54438. updatable?: boolean;
  54439. sideOrientation?: number;
  54440. frontUVs?: Vector4;
  54441. backUVs?: Vector4;
  54442. }, scene?: Nullable<Scene>): Mesh;
  54443. }
  54444. }
  54445. declare module BABYLON {
  54446. /**
  54447. * Class containing static functions to help procedurally build meshes
  54448. */
  54449. export class BoxBuilder {
  54450. /**
  54451. * Creates a box mesh
  54452. * * The parameter `size` sets the size (float) of each box side (default 1)
  54453. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  54454. * * 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)
  54455. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54456. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54457. * * 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
  54458. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54459. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54460. * @param name defines the name of the mesh
  54461. * @param options defines the options used to create the mesh
  54462. * @param scene defines the hosting scene
  54463. * @returns the box mesh
  54464. */
  54465. static CreateBox(name: string, options: {
  54466. size?: number;
  54467. width?: number;
  54468. height?: number;
  54469. depth?: number;
  54470. faceUV?: Vector4[];
  54471. faceColors?: Color4[];
  54472. sideOrientation?: number;
  54473. frontUVs?: Vector4;
  54474. backUVs?: Vector4;
  54475. wrap?: boolean;
  54476. topBaseAt?: number;
  54477. bottomBaseAt?: number;
  54478. updatable?: boolean;
  54479. }, scene?: Nullable<Scene>): Mesh;
  54480. }
  54481. }
  54482. declare module BABYLON {
  54483. /**
  54484. * Single axis scale gizmo
  54485. */
  54486. export class AxisScaleGizmo extends Gizmo {
  54487. /**
  54488. * Drag behavior responsible for the gizmos dragging interactions
  54489. */
  54490. dragBehavior: PointerDragBehavior;
  54491. private _pointerObserver;
  54492. /**
  54493. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54494. */
  54495. snapDistance: number;
  54496. /**
  54497. * Event that fires each time the gizmo snaps to a new location.
  54498. * * snapDistance is the the change in distance
  54499. */
  54500. onSnapObservable: Observable<{
  54501. snapDistance: number;
  54502. }>;
  54503. /**
  54504. * If the scaling operation should be done on all axis (default: false)
  54505. */
  54506. uniformScaling: boolean;
  54507. /**
  54508. * Custom sensitivity value for the drag strength
  54509. */
  54510. sensitivity: number;
  54511. private _isEnabled;
  54512. private _parent;
  54513. private _gizmoMesh;
  54514. private _coloredMaterial;
  54515. private _hoverMaterial;
  54516. private _disableMaterial;
  54517. private _dragging;
  54518. private _tmpVector;
  54519. private _tmpMatrix;
  54520. private _tmpMatrix2;
  54521. /**
  54522. * Creates an AxisScaleGizmo
  54523. * @param gizmoLayer The utility layer the gizmo will be added to
  54524. * @param dragAxis The axis which the gizmo will be able to scale on
  54525. * @param color The color of the gizmo
  54526. * @param thickness display gizmo axis thickness
  54527. */
  54528. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  54529. /** Create Geometry for Gizmo */
  54530. private _createGizmoMesh;
  54531. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54532. /**
  54533. * If the gizmo is enabled
  54534. */
  54535. set isEnabled(value: boolean);
  54536. get isEnabled(): boolean;
  54537. /**
  54538. * Disposes of the gizmo
  54539. */
  54540. dispose(): void;
  54541. /**
  54542. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  54543. * @param mesh The mesh to replace the default mesh of the gizmo
  54544. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  54545. */
  54546. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  54547. }
  54548. }
  54549. declare module BABYLON {
  54550. /**
  54551. * Gizmo that enables scaling a mesh along 3 axis
  54552. */
  54553. export class ScaleGizmo extends Gizmo {
  54554. /**
  54555. * Internal gizmo used for interactions on the x axis
  54556. */
  54557. xGizmo: AxisScaleGizmo;
  54558. /**
  54559. * Internal gizmo used for interactions on the y axis
  54560. */
  54561. yGizmo: AxisScaleGizmo;
  54562. /**
  54563. * Internal gizmo used for interactions on the z axis
  54564. */
  54565. zGizmo: AxisScaleGizmo;
  54566. /**
  54567. * Internal gizmo used to scale all axis equally
  54568. */
  54569. uniformScaleGizmo: AxisScaleGizmo;
  54570. private _meshAttached;
  54571. private _nodeAttached;
  54572. private _snapDistance;
  54573. private _uniformScalingMesh;
  54574. private _octahedron;
  54575. private _sensitivity;
  54576. private _coloredMaterial;
  54577. private _hoverMaterial;
  54578. private _disableMaterial;
  54579. private _observables;
  54580. /** Node Caching for quick lookup */
  54581. private _gizmoAxisCache;
  54582. /** Fires an event when any of it's sub gizmos are dragged */
  54583. onDragStartObservable: Observable<unknown>;
  54584. /** Fires an event when any of it's sub gizmos are released from dragging */
  54585. onDragEndObservable: Observable<unknown>;
  54586. get attachedMesh(): Nullable<AbstractMesh>;
  54587. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54588. get attachedNode(): Nullable<Node>;
  54589. set attachedNode(node: Nullable<Node>);
  54590. /**
  54591. * True when the mouse pointer is hovering a gizmo mesh
  54592. */
  54593. get isHovered(): boolean;
  54594. /**
  54595. * Creates a ScaleGizmo
  54596. * @param gizmoLayer The utility layer the gizmo will be added to
  54597. * @param thickness display gizmo axis thickness
  54598. */
  54599. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  54600. /** Create Geometry for Gizmo */
  54601. private _createUniformScaleMesh;
  54602. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54603. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54604. /**
  54605. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54606. */
  54607. set snapDistance(value: number);
  54608. get snapDistance(): number;
  54609. /**
  54610. * Ratio for the scale of the gizmo (Default: 1)
  54611. */
  54612. set scaleRatio(value: number);
  54613. get scaleRatio(): number;
  54614. /**
  54615. * Sensitivity factor for dragging (Default: 1)
  54616. */
  54617. set sensitivity(value: number);
  54618. get sensitivity(): number;
  54619. /**
  54620. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  54621. * @param mesh Axis gizmo mesh
  54622. * @param cache Gizmo axis definition used for reactive gizmo UI
  54623. */
  54624. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  54625. /**
  54626. * Disposes of the gizmo
  54627. */
  54628. dispose(): void;
  54629. }
  54630. }
  54631. declare module BABYLON {
  54632. /**
  54633. * Bounding box gizmo
  54634. */
  54635. export class BoundingBoxGizmo extends Gizmo {
  54636. private _lineBoundingBox;
  54637. private _rotateSpheresParent;
  54638. private _scaleBoxesParent;
  54639. private _boundingDimensions;
  54640. private _renderObserver;
  54641. private _pointerObserver;
  54642. private _scaleDragSpeed;
  54643. private _tmpQuaternion;
  54644. private _tmpVector;
  54645. private _tmpRotationMatrix;
  54646. /**
  54647. * 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)
  54648. */
  54649. ignoreChildren: boolean;
  54650. /**
  54651. * 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)
  54652. */
  54653. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  54654. /**
  54655. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  54656. */
  54657. rotationSphereSize: number;
  54658. /**
  54659. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  54660. */
  54661. scaleBoxSize: number;
  54662. /**
  54663. * 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)
  54664. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  54665. */
  54666. fixedDragMeshScreenSize: boolean;
  54667. /**
  54668. * If set, the rotation spheres and scale boxes will increase in size based on the size of the bounding box
  54669. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  54670. */
  54671. fixedDragMeshBoundsSize: boolean;
  54672. /**
  54673. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  54674. */
  54675. fixedDragMeshScreenSizeDistanceFactor: number;
  54676. /**
  54677. * Fired when a rotation sphere or scale box is dragged
  54678. */
  54679. onDragStartObservable: Observable<{}>;
  54680. /**
  54681. * Fired when a scale box is dragged
  54682. */
  54683. onScaleBoxDragObservable: Observable<{}>;
  54684. /**
  54685. * Fired when a scale box drag is ended
  54686. */
  54687. onScaleBoxDragEndObservable: Observable<{}>;
  54688. /**
  54689. * Fired when a rotation sphere is dragged
  54690. */
  54691. onRotationSphereDragObservable: Observable<{}>;
  54692. /**
  54693. * Fired when a rotation sphere drag is ended
  54694. */
  54695. onRotationSphereDragEndObservable: Observable<{}>;
  54696. /**
  54697. * Relative bounding box pivot used when scaling the attached node. 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)
  54698. */
  54699. scalePivot: Nullable<Vector3>;
  54700. /**
  54701. * Mesh used as a pivot to rotate the attached node
  54702. */
  54703. private _anchorMesh;
  54704. private _existingMeshScale;
  54705. private _dragMesh;
  54706. private pointerDragBehavior;
  54707. private coloredMaterial;
  54708. private hoverColoredMaterial;
  54709. /**
  54710. * Sets the color of the bounding box gizmo
  54711. * @param color the color to set
  54712. */
  54713. setColor(color: Color3): void;
  54714. /**
  54715. * Creates an BoundingBoxGizmo
  54716. * @param gizmoLayer The utility layer the gizmo will be added to
  54717. * @param color The color of the gizmo
  54718. */
  54719. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  54720. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  54721. private _selectNode;
  54722. /**
  54723. * Updates the bounding box information for the Gizmo
  54724. */
  54725. updateBoundingBox(): void;
  54726. private _updateRotationSpheres;
  54727. private _updateScaleBoxes;
  54728. /**
  54729. * Enables rotation on the specified axis and disables rotation on the others
  54730. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  54731. */
  54732. setEnabledRotationAxis(axis: string): void;
  54733. /**
  54734. * Enables/disables scaling
  54735. * @param enable if scaling should be enabled
  54736. * @param homogeneousScaling defines if scaling should only be homogeneous
  54737. */
  54738. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  54739. private _updateDummy;
  54740. /**
  54741. * Enables a pointer drag behavior on the bounding box of the gizmo
  54742. */
  54743. enableDragBehavior(): void;
  54744. /**
  54745. * Disposes of the gizmo
  54746. */
  54747. dispose(): void;
  54748. /**
  54749. * 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)
  54750. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  54751. * @returns the bounding box mesh with the passed in mesh as a child
  54752. */
  54753. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  54754. /**
  54755. * CustomMeshes are not supported by this gizmo
  54756. * @param mesh The mesh to replace the default mesh of the gizmo
  54757. */
  54758. setCustomMesh(mesh: Mesh): void;
  54759. }
  54760. }
  54761. declare module BABYLON {
  54762. /**
  54763. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  54764. */
  54765. export class GizmoManager implements IDisposable {
  54766. private scene;
  54767. /**
  54768. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  54769. */
  54770. gizmos: {
  54771. positionGizmo: Nullable<PositionGizmo>;
  54772. rotationGizmo: Nullable<RotationGizmo>;
  54773. scaleGizmo: Nullable<ScaleGizmo>;
  54774. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  54775. };
  54776. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  54777. clearGizmoOnEmptyPointerEvent: boolean;
  54778. /** Fires an event when the manager is attached to a mesh */
  54779. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  54780. /** Fires an event when the manager is attached to a node */
  54781. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  54782. private _gizmosEnabled;
  54783. private _pointerObservers;
  54784. private _attachedMesh;
  54785. private _attachedNode;
  54786. private _boundingBoxColor;
  54787. private _defaultUtilityLayer;
  54788. private _defaultKeepDepthUtilityLayer;
  54789. private _thickness;
  54790. /** Node Caching for quick lookup */
  54791. private _gizmoAxisCache;
  54792. /**
  54793. * When bounding box gizmo is enabled, this can be used to track drag/end events
  54794. */
  54795. boundingBoxDragBehavior: SixDofDragBehavior;
  54796. /**
  54797. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  54798. */
  54799. attachableMeshes: Nullable<Array<AbstractMesh>>;
  54800. /**
  54801. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  54802. */
  54803. attachableNodes: Nullable<Array<Node>>;
  54804. /**
  54805. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  54806. */
  54807. usePointerToAttachGizmos: boolean;
  54808. /**
  54809. * Utility layer that the bounding box gizmo belongs to
  54810. */
  54811. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  54812. /**
  54813. * Utility layer that all gizmos besides bounding box belong to
  54814. */
  54815. get utilityLayer(): UtilityLayerRenderer;
  54816. /**
  54817. * True when the mouse pointer is hovering a gizmo mesh
  54818. */
  54819. get isHovered(): boolean;
  54820. /**
  54821. * Instatiates a gizmo manager
  54822. * @param scene the scene to overlay the gizmos on top of
  54823. * @param thickness display gizmo axis thickness
  54824. * @param utilityLayer the layer where gizmos are rendered
  54825. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  54826. */
  54827. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  54828. /**
  54829. * Subscribes to pointer down events, for attaching and detaching mesh
  54830. * @param scene The sceme layer the observer will be added to
  54831. */
  54832. private _attachToMeshPointerObserver;
  54833. /**
  54834. * Attaches a set of gizmos to the specified mesh
  54835. * @param mesh The mesh the gizmo's should be attached to
  54836. */
  54837. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54838. /**
  54839. * Attaches a set of gizmos to the specified node
  54840. * @param node The node the gizmo's should be attached to
  54841. */
  54842. attachToNode(node: Nullable<Node>): void;
  54843. /**
  54844. * If the position gizmo is enabled
  54845. */
  54846. set positionGizmoEnabled(value: boolean);
  54847. get positionGizmoEnabled(): boolean;
  54848. /**
  54849. * If the rotation gizmo is enabled
  54850. */
  54851. set rotationGizmoEnabled(value: boolean);
  54852. get rotationGizmoEnabled(): boolean;
  54853. /**
  54854. * If the scale gizmo is enabled
  54855. */
  54856. set scaleGizmoEnabled(value: boolean);
  54857. get scaleGizmoEnabled(): boolean;
  54858. /**
  54859. * If the boundingBox gizmo is enabled
  54860. */
  54861. set boundingBoxGizmoEnabled(value: boolean);
  54862. get boundingBoxGizmoEnabled(): boolean;
  54863. /**
  54864. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  54865. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  54866. */
  54867. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  54868. /**
  54869. * Disposes of the gizmo manager
  54870. */
  54871. dispose(): void;
  54872. }
  54873. }
  54874. declare module BABYLON {
  54875. /**
  54876. * Gizmo that enables dragging a mesh along 3 axis
  54877. */
  54878. export class PositionGizmo extends Gizmo {
  54879. /**
  54880. * Internal gizmo used for interactions on the x axis
  54881. */
  54882. xGizmo: AxisDragGizmo;
  54883. /**
  54884. * Internal gizmo used for interactions on the y axis
  54885. */
  54886. yGizmo: AxisDragGizmo;
  54887. /**
  54888. * Internal gizmo used for interactions on the z axis
  54889. */
  54890. zGizmo: AxisDragGizmo;
  54891. /**
  54892. * Internal gizmo used for interactions on the yz plane
  54893. */
  54894. xPlaneGizmo: PlaneDragGizmo;
  54895. /**
  54896. * Internal gizmo used for interactions on the xz plane
  54897. */
  54898. yPlaneGizmo: PlaneDragGizmo;
  54899. /**
  54900. * Internal gizmo used for interactions on the xy plane
  54901. */
  54902. zPlaneGizmo: PlaneDragGizmo;
  54903. /**
  54904. * private variables
  54905. */
  54906. private _meshAttached;
  54907. private _nodeAttached;
  54908. private _snapDistance;
  54909. private _observables;
  54910. /** Node Caching for quick lookup */
  54911. private _gizmoAxisCache;
  54912. /** Fires an event when any of it's sub gizmos are dragged */
  54913. onDragStartObservable: Observable<unknown>;
  54914. /** Fires an event when any of it's sub gizmos are released from dragging */
  54915. onDragEndObservable: Observable<unknown>;
  54916. /**
  54917. * If set to true, planar drag is enabled
  54918. */
  54919. private _planarGizmoEnabled;
  54920. get attachedMesh(): Nullable<AbstractMesh>;
  54921. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54922. get attachedNode(): Nullable<Node>;
  54923. set attachedNode(node: Nullable<Node>);
  54924. /**
  54925. * True when the mouse pointer is hovering a gizmo mesh
  54926. */
  54927. get isHovered(): boolean;
  54928. /**
  54929. * Creates a PositionGizmo
  54930. * @param gizmoLayer The utility layer the gizmo will be added to
  54931. @param thickness display gizmo axis thickness
  54932. */
  54933. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  54934. /**
  54935. * If the planar drag gizmo is enabled
  54936. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  54937. */
  54938. set planarGizmoEnabled(value: boolean);
  54939. get planarGizmoEnabled(): boolean;
  54940. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54941. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54942. /**
  54943. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54944. */
  54945. set snapDistance(value: number);
  54946. get snapDistance(): number;
  54947. /**
  54948. * Ratio for the scale of the gizmo (Default: 1)
  54949. */
  54950. set scaleRatio(value: number);
  54951. get scaleRatio(): number;
  54952. /**
  54953. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  54954. * @param mesh Axis gizmo mesh
  54955. * @param cache Gizmo axis definition used for reactive gizmo UI
  54956. */
  54957. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  54958. /**
  54959. * Disposes of the gizmo
  54960. */
  54961. dispose(): void;
  54962. /**
  54963. * CustomMeshes are not supported by this gizmo
  54964. * @param mesh The mesh to replace the default mesh of the gizmo
  54965. */
  54966. setCustomMesh(mesh: Mesh): void;
  54967. }
  54968. }
  54969. declare module BABYLON {
  54970. /**
  54971. * Single axis drag gizmo
  54972. */
  54973. export class AxisDragGizmo extends Gizmo {
  54974. /**
  54975. * Drag behavior responsible for the gizmos dragging interactions
  54976. */
  54977. dragBehavior: PointerDragBehavior;
  54978. private _pointerObserver;
  54979. /**
  54980. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54981. */
  54982. snapDistance: number;
  54983. /**
  54984. * Event that fires each time the gizmo snaps to a new location.
  54985. * * snapDistance is the the change in distance
  54986. */
  54987. onSnapObservable: Observable<{
  54988. snapDistance: number;
  54989. }>;
  54990. private _isEnabled;
  54991. private _parent;
  54992. private _gizmoMesh;
  54993. private _coloredMaterial;
  54994. private _hoverMaterial;
  54995. private _disableMaterial;
  54996. private _dragging;
  54997. /** @hidden */
  54998. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  54999. /** @hidden */
  55000. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  55001. /**
  55002. * Creates an AxisDragGizmo
  55003. * @param gizmoLayer The utility layer the gizmo will be added to
  55004. * @param dragAxis The axis which the gizmo will be able to drag on
  55005. * @param color The color of the gizmo
  55006. * @param thickness display gizmo axis thickness
  55007. */
  55008. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  55009. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55010. /**
  55011. * If the gizmo is enabled
  55012. */
  55013. set isEnabled(value: boolean);
  55014. get isEnabled(): boolean;
  55015. /**
  55016. * Disposes of the gizmo
  55017. */
  55018. dispose(): void;
  55019. }
  55020. }
  55021. declare module BABYLON.Debug {
  55022. /**
  55023. * The Axes viewer will show 3 axes in a specific point in space
  55024. */
  55025. export class AxesViewer {
  55026. private _xAxis;
  55027. private _yAxis;
  55028. private _zAxis;
  55029. private _scaleLinesFactor;
  55030. private _instanced;
  55031. /**
  55032. * Gets the hosting scene
  55033. */
  55034. scene: Nullable<Scene>;
  55035. /**
  55036. * Gets or sets a number used to scale line length
  55037. */
  55038. scaleLines: number;
  55039. /** Gets the node hierarchy used to render x-axis */
  55040. get xAxis(): TransformNode;
  55041. /** Gets the node hierarchy used to render y-axis */
  55042. get yAxis(): TransformNode;
  55043. /** Gets the node hierarchy used to render z-axis */
  55044. get zAxis(): TransformNode;
  55045. /**
  55046. * Creates a new AxesViewer
  55047. * @param scene defines the hosting scene
  55048. * @param scaleLines defines a number used to scale line length (1 by default)
  55049. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  55050. * @param xAxis defines the node hierarchy used to render the x-axis
  55051. * @param yAxis defines the node hierarchy used to render the y-axis
  55052. * @param zAxis defines the node hierarchy used to render the z-axis
  55053. */
  55054. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  55055. /**
  55056. * Force the viewer to update
  55057. * @param position defines the position of the viewer
  55058. * @param xaxis defines the x axis of the viewer
  55059. * @param yaxis defines the y axis of the viewer
  55060. * @param zaxis defines the z axis of the viewer
  55061. */
  55062. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  55063. /**
  55064. * Creates an instance of this axes viewer.
  55065. * @returns a new axes viewer with instanced meshes
  55066. */
  55067. createInstance(): AxesViewer;
  55068. /** Releases resources */
  55069. dispose(): void;
  55070. private static _SetRenderingGroupId;
  55071. }
  55072. }
  55073. declare module BABYLON.Debug {
  55074. /**
  55075. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  55076. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  55077. */
  55078. export class BoneAxesViewer extends AxesViewer {
  55079. /**
  55080. * Gets or sets the target mesh where to display the axes viewer
  55081. */
  55082. mesh: Nullable<Mesh>;
  55083. /**
  55084. * Gets or sets the target bone where to display the axes viewer
  55085. */
  55086. bone: Nullable<Bone>;
  55087. /** Gets current position */
  55088. pos: Vector3;
  55089. /** Gets direction of X axis */
  55090. xaxis: Vector3;
  55091. /** Gets direction of Y axis */
  55092. yaxis: Vector3;
  55093. /** Gets direction of Z axis */
  55094. zaxis: Vector3;
  55095. /**
  55096. * Creates a new BoneAxesViewer
  55097. * @param scene defines the hosting scene
  55098. * @param bone defines the target bone
  55099. * @param mesh defines the target mesh
  55100. * @param scaleLines defines a scaling factor for line length (1 by default)
  55101. */
  55102. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  55103. /**
  55104. * Force the viewer to update
  55105. */
  55106. update(): void;
  55107. /** Releases resources */
  55108. dispose(): void;
  55109. }
  55110. }
  55111. declare module BABYLON {
  55112. /**
  55113. * Interface used to define scene explorer extensibility option
  55114. */
  55115. export interface IExplorerExtensibilityOption {
  55116. /**
  55117. * Define the option label
  55118. */
  55119. label: string;
  55120. /**
  55121. * Defines the action to execute on click
  55122. */
  55123. action: (entity: any) => void;
  55124. }
  55125. /**
  55126. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  55127. */
  55128. export interface IExplorerExtensibilityGroup {
  55129. /**
  55130. * Defines a predicate to test if a given type mut be extended
  55131. */
  55132. predicate: (entity: any) => boolean;
  55133. /**
  55134. * Gets the list of options added to a type
  55135. */
  55136. entries: IExplorerExtensibilityOption[];
  55137. }
  55138. /**
  55139. * Interface used to define the options to use to create the Inspector
  55140. */
  55141. export interface IInspectorOptions {
  55142. /**
  55143. * Display in overlay mode (default: false)
  55144. */
  55145. overlay?: boolean;
  55146. /**
  55147. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  55148. */
  55149. globalRoot?: HTMLElement;
  55150. /**
  55151. * Display the Scene explorer
  55152. */
  55153. showExplorer?: boolean;
  55154. /**
  55155. * Display the property inspector
  55156. */
  55157. showInspector?: boolean;
  55158. /**
  55159. * Display in embed mode (both panes on the right)
  55160. */
  55161. embedMode?: boolean;
  55162. /**
  55163. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  55164. */
  55165. handleResize?: boolean;
  55166. /**
  55167. * Allow the panes to popup (default: true)
  55168. */
  55169. enablePopup?: boolean;
  55170. /**
  55171. * Allow the panes to be closed by users (default: true)
  55172. */
  55173. enableClose?: boolean;
  55174. /**
  55175. * Optional list of extensibility entries
  55176. */
  55177. explorerExtensibility?: IExplorerExtensibilityGroup[];
  55178. /**
  55179. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  55180. */
  55181. inspectorURL?: string;
  55182. /**
  55183. * Optional initial tab (default to DebugLayerTab.Properties)
  55184. */
  55185. initialTab?: DebugLayerTab;
  55186. }
  55187. interface Scene {
  55188. /**
  55189. * @hidden
  55190. * Backing field
  55191. */
  55192. _debugLayer: DebugLayer;
  55193. /**
  55194. * Gets the debug layer (aka Inspector) associated with the scene
  55195. * @see https://doc.babylonjs.com/features/playground_debuglayer
  55196. */
  55197. debugLayer: DebugLayer;
  55198. }
  55199. /**
  55200. * Enum of inspector action tab
  55201. */
  55202. export enum DebugLayerTab {
  55203. /**
  55204. * Properties tag (default)
  55205. */
  55206. Properties = 0,
  55207. /**
  55208. * Debug tab
  55209. */
  55210. Debug = 1,
  55211. /**
  55212. * Statistics tab
  55213. */
  55214. Statistics = 2,
  55215. /**
  55216. * Tools tab
  55217. */
  55218. Tools = 3,
  55219. /**
  55220. * Settings tab
  55221. */
  55222. Settings = 4
  55223. }
  55224. /**
  55225. * The debug layer (aka Inspector) is the go to tool in order to better understand
  55226. * what is happening in your scene
  55227. * @see https://doc.babylonjs.com/features/playground_debuglayer
  55228. */
  55229. export class DebugLayer {
  55230. /**
  55231. * Define the url to get the inspector script from.
  55232. * By default it uses the babylonjs CDN.
  55233. * @ignoreNaming
  55234. */
  55235. static InspectorURL: string;
  55236. private _scene;
  55237. private BJSINSPECTOR;
  55238. private _onPropertyChangedObservable?;
  55239. /**
  55240. * Observable triggered when a property is changed through the inspector.
  55241. */
  55242. get onPropertyChangedObservable(): any;
  55243. /**
  55244. * Instantiates a new debug layer.
  55245. * The debug layer (aka Inspector) is the go to tool in order to better understand
  55246. * what is happening in your scene
  55247. * @see https://doc.babylonjs.com/features/playground_debuglayer
  55248. * @param scene Defines the scene to inspect
  55249. */
  55250. constructor(scene: Scene);
  55251. /** Creates the inspector window. */
  55252. private _createInspector;
  55253. /**
  55254. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  55255. * @param entity defines the entity to select
  55256. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  55257. */
  55258. select(entity: any, lineContainerTitles?: string | string[]): void;
  55259. /** Get the inspector from bundle or global */
  55260. private _getGlobalInspector;
  55261. /**
  55262. * Get if the inspector is visible or not.
  55263. * @returns true if visible otherwise, false
  55264. */
  55265. isVisible(): boolean;
  55266. /**
  55267. * Hide the inspector and close its window.
  55268. */
  55269. hide(): void;
  55270. /**
  55271. * Update the scene in the inspector
  55272. */
  55273. setAsActiveScene(): void;
  55274. /**
  55275. * Launch the debugLayer.
  55276. * @param config Define the configuration of the inspector
  55277. * @return a promise fulfilled when the debug layer is visible
  55278. */
  55279. show(config?: IInspectorOptions): Promise<DebugLayer>;
  55280. }
  55281. }
  55282. declare module BABYLON.Debug {
  55283. /**
  55284. * Used to show the physics impostor around the specific mesh
  55285. */
  55286. export class PhysicsViewer {
  55287. /** @hidden */
  55288. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  55289. /** @hidden */
  55290. protected _meshes: Array<Nullable<AbstractMesh>>;
  55291. /** @hidden */
  55292. protected _scene: Nullable<Scene>;
  55293. /** @hidden */
  55294. protected _numMeshes: number;
  55295. /** @hidden */
  55296. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  55297. private _renderFunction;
  55298. private _utilityLayer;
  55299. private _debugBoxMesh;
  55300. private _debugSphereMesh;
  55301. private _debugCylinderMesh;
  55302. private _debugMaterial;
  55303. private _debugMeshMeshes;
  55304. /**
  55305. * Creates a new PhysicsViewer
  55306. * @param scene defines the hosting scene
  55307. */
  55308. constructor(scene: Scene);
  55309. /** @hidden */
  55310. protected _updateDebugMeshes(): void;
  55311. /**
  55312. * Renders a specified physic impostor
  55313. * @param impostor defines the impostor to render
  55314. * @param targetMesh defines the mesh represented by the impostor
  55315. * @returns the new debug mesh used to render the impostor
  55316. */
  55317. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  55318. /**
  55319. * Hides a specified physic impostor
  55320. * @param impostor defines the impostor to hide
  55321. */
  55322. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  55323. private _getDebugMaterial;
  55324. private _getDebugBoxMesh;
  55325. private _getDebugSphereMesh;
  55326. private _getDebugCylinderMesh;
  55327. private _getDebugMeshMesh;
  55328. private _getDebugMesh;
  55329. /** Releases all resources */
  55330. dispose(): void;
  55331. }
  55332. }
  55333. declare module BABYLON {
  55334. /**
  55335. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  55336. * in order to better appreciate the issue one might have.
  55337. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  55338. */
  55339. export class RayHelper {
  55340. /**
  55341. * Defines the ray we are currently tryin to visualize.
  55342. */
  55343. ray: Nullable<Ray>;
  55344. private _renderPoints;
  55345. private _renderLine;
  55346. private _renderFunction;
  55347. private _scene;
  55348. private _onAfterRenderObserver;
  55349. private _onAfterStepObserver;
  55350. private _attachedToMesh;
  55351. private _meshSpaceDirection;
  55352. private _meshSpaceOrigin;
  55353. /**
  55354. * Helper function to create a colored helper in a scene in one line.
  55355. * @param ray Defines the ray we are currently tryin to visualize
  55356. * @param scene Defines the scene the ray is used in
  55357. * @param color Defines the color we want to see the ray in
  55358. * @returns The newly created ray helper.
  55359. */
  55360. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  55361. /**
  55362. * Instantiate a new ray helper.
  55363. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  55364. * in order to better appreciate the issue one might have.
  55365. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  55366. * @param ray Defines the ray we are currently tryin to visualize
  55367. */
  55368. constructor(ray: Ray);
  55369. /**
  55370. * Shows the ray we are willing to debug.
  55371. * @param scene Defines the scene the ray needs to be rendered in
  55372. * @param color Defines the color the ray needs to be rendered in
  55373. */
  55374. show(scene: Scene, color?: Color3): void;
  55375. /**
  55376. * Hides the ray we are debugging.
  55377. */
  55378. hide(): void;
  55379. private _render;
  55380. /**
  55381. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  55382. * @param mesh Defines the mesh we want the helper attached to
  55383. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  55384. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  55385. * @param length Defines the length of the ray
  55386. */
  55387. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  55388. /**
  55389. * Detach the ray helper from the mesh it has previously been attached to.
  55390. */
  55391. detachFromMesh(): void;
  55392. private _updateToMesh;
  55393. /**
  55394. * Dispose the helper and release its associated resources.
  55395. */
  55396. dispose(): void;
  55397. }
  55398. }
  55399. declare module BABYLON {
  55400. /**
  55401. * Defines the options associated with the creation of a SkeletonViewer.
  55402. */
  55403. export interface ISkeletonViewerOptions {
  55404. /** Should the system pause animations before building the Viewer? */
  55405. pauseAnimations: boolean;
  55406. /** Should the system return the skeleton to rest before building? */
  55407. returnToRest: boolean;
  55408. /** public Display Mode of the Viewer */
  55409. displayMode: number;
  55410. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  55411. displayOptions: ISkeletonViewerDisplayOptions;
  55412. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  55413. computeBonesUsingShaders: boolean;
  55414. /** Flag ignore non weighted bones */
  55415. useAllBones: boolean;
  55416. }
  55417. /**
  55418. * Defines how to display the various bone meshes for the viewer.
  55419. */
  55420. export interface ISkeletonViewerDisplayOptions {
  55421. /** How far down to start tapering the bone spurs */
  55422. midStep?: number;
  55423. /** How big is the midStep? */
  55424. midStepFactor?: number;
  55425. /** Base for the Sphere Size */
  55426. sphereBaseSize?: number;
  55427. /** The ratio of the sphere to the longest bone in units */
  55428. sphereScaleUnit?: number;
  55429. /** Ratio for the Sphere Size */
  55430. sphereFactor?: number;
  55431. /** Whether a spur should attach its far end to the child bone position */
  55432. spurFollowsChild?: boolean;
  55433. /** Whether to show local axes or not */
  55434. showLocalAxes?: boolean;
  55435. /** Length of each local axis */
  55436. localAxesSize?: number;
  55437. }
  55438. /**
  55439. * Defines the constructor options for the BoneWeight Shader.
  55440. */
  55441. export interface IBoneWeightShaderOptions {
  55442. /** Skeleton to Map */
  55443. skeleton: Skeleton;
  55444. /** Colors for Uninfluenced bones */
  55445. colorBase?: Color3;
  55446. /** Colors for 0.0-0.25 Weight bones */
  55447. colorZero?: Color3;
  55448. /** Color for 0.25-0.5 Weight Influence */
  55449. colorQuarter?: Color3;
  55450. /** Color for 0.5-0.75 Weight Influence */
  55451. colorHalf?: Color3;
  55452. /** Color for 0.75-1 Weight Influence */
  55453. colorFull?: Color3;
  55454. /** Color for Zero Weight Influence */
  55455. targetBoneIndex?: number;
  55456. }
  55457. /**
  55458. * Simple structure of the gradient steps for the Color Map.
  55459. */
  55460. export interface ISkeletonMapShaderColorMapKnot {
  55461. /** Color of the Knot */
  55462. color: Color3;
  55463. /** Location of the Knot */
  55464. location: number;
  55465. }
  55466. /**
  55467. * Defines the constructor options for the SkeletonMap Shader.
  55468. */
  55469. export interface ISkeletonMapShaderOptions {
  55470. /** Skeleton to Map */
  55471. skeleton: Skeleton;
  55472. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  55473. colorMap?: ISkeletonMapShaderColorMapKnot[];
  55474. }
  55475. }
  55476. declare module BABYLON {
  55477. /**
  55478. * Class containing static functions to help procedurally build meshes
  55479. */
  55480. export class RibbonBuilder {
  55481. /**
  55482. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55483. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55484. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55485. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55486. * * 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
  55487. * * 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
  55488. * * 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
  55489. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55490. * * 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
  55491. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55492. * * 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
  55493. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55494. * * 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
  55495. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55496. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55497. * @param name defines the name of the mesh
  55498. * @param options defines the options used to create the mesh
  55499. * @param scene defines the hosting scene
  55500. * @returns the ribbon mesh
  55501. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55502. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55503. */
  55504. static CreateRibbon(name: string, options: {
  55505. pathArray: Vector3[][];
  55506. closeArray?: boolean;
  55507. closePath?: boolean;
  55508. offset?: number;
  55509. updatable?: boolean;
  55510. sideOrientation?: number;
  55511. frontUVs?: Vector4;
  55512. backUVs?: Vector4;
  55513. instance?: Mesh;
  55514. invertUV?: boolean;
  55515. uvs?: Vector2[];
  55516. colors?: Color4[];
  55517. }, scene?: Nullable<Scene>): Mesh;
  55518. }
  55519. }
  55520. declare module BABYLON {
  55521. /**
  55522. * Class containing static functions to help procedurally build meshes
  55523. */
  55524. export class ShapeBuilder {
  55525. /**
  55526. * 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.
  55527. * * 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.
  55528. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55529. * * 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.
  55530. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55531. * * 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
  55532. * * 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
  55533. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55534. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55535. * * 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
  55536. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55537. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55538. * @param name defines the name of the mesh
  55539. * @param options defines the options used to create the mesh
  55540. * @param scene defines the hosting scene
  55541. * @returns the extruded shape mesh
  55542. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55543. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55544. */
  55545. static ExtrudeShape(name: string, options: {
  55546. shape: Vector3[];
  55547. path: Vector3[];
  55548. scale?: number;
  55549. rotation?: number;
  55550. cap?: number;
  55551. updatable?: boolean;
  55552. sideOrientation?: number;
  55553. frontUVs?: Vector4;
  55554. backUVs?: Vector4;
  55555. instance?: Mesh;
  55556. invertUV?: boolean;
  55557. }, scene?: Nullable<Scene>): Mesh;
  55558. /**
  55559. * Creates an custom extruded shape mesh.
  55560. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55561. * * 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.
  55562. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55563. * * 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
  55564. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55565. * * 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
  55566. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55567. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55568. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55569. * * 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
  55570. * * 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
  55571. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55572. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55573. * * 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
  55574. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55575. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55576. * @param name defines the name of the mesh
  55577. * @param options defines the options used to create the mesh
  55578. * @param scene defines the hosting scene
  55579. * @returns the custom extruded shape mesh
  55580. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55581. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55582. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55583. */
  55584. static ExtrudeShapeCustom(name: string, options: {
  55585. shape: Vector3[];
  55586. path: Vector3[];
  55587. scaleFunction?: any;
  55588. rotationFunction?: any;
  55589. ribbonCloseArray?: boolean;
  55590. ribbonClosePath?: boolean;
  55591. cap?: number;
  55592. updatable?: boolean;
  55593. sideOrientation?: number;
  55594. frontUVs?: Vector4;
  55595. backUVs?: Vector4;
  55596. instance?: Mesh;
  55597. invertUV?: boolean;
  55598. }, scene?: Nullable<Scene>): Mesh;
  55599. private static _ExtrudeShapeGeneric;
  55600. }
  55601. }
  55602. declare module BABYLON.Debug {
  55603. /**
  55604. * Class used to render a debug view of a given skeleton
  55605. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  55606. */
  55607. export class SkeletonViewer {
  55608. /** defines the skeleton to render */
  55609. skeleton: Skeleton;
  55610. /** defines the mesh attached to the skeleton */
  55611. mesh: AbstractMesh;
  55612. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  55613. autoUpdateBonesMatrices: boolean;
  55614. /** defines the rendering group id to use with the viewer */
  55615. renderingGroupId: number;
  55616. /** is the options for the viewer */
  55617. options: Partial<ISkeletonViewerOptions>;
  55618. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  55619. static readonly DISPLAY_LINES: number;
  55620. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  55621. static readonly DISPLAY_SPHERES: number;
  55622. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  55623. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  55624. /** public static method to create a BoneWeight Shader
  55625. * @param options The constructor options
  55626. * @param scene The scene that the shader is scoped to
  55627. * @returns The created ShaderMaterial
  55628. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  55629. */
  55630. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  55631. /** public static method to create a BoneWeight Shader
  55632. * @param options The constructor options
  55633. * @param scene The scene that the shader is scoped to
  55634. * @returns The created ShaderMaterial
  55635. */
  55636. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  55637. /** private static method to create a BoneWeight Shader
  55638. * @param size The size of the buffer to create (usually the bone count)
  55639. * @param colorMap The gradient data to generate
  55640. * @param scene The scene that the shader is scoped to
  55641. * @returns an Array of floats from the color gradient values
  55642. */
  55643. private static _CreateBoneMapColorBuffer;
  55644. /** If SkeletonViewer scene scope. */
  55645. private _scene;
  55646. /** Gets or sets the color used to render the skeleton */
  55647. color: Color3;
  55648. /** Array of the points of the skeleton fo the line view. */
  55649. private _debugLines;
  55650. /** The SkeletonViewers Mesh. */
  55651. private _debugMesh;
  55652. /** The local axes Meshes. */
  55653. private _localAxes;
  55654. /** If SkeletonViewer is enabled. */
  55655. private _isEnabled;
  55656. /** If SkeletonViewer is ready. */
  55657. private _ready;
  55658. /** SkeletonViewer render observable. */
  55659. private _obs;
  55660. /** The Utility Layer to render the gizmos in. */
  55661. private _utilityLayer;
  55662. private _boneIndices;
  55663. /** Gets the Scene. */
  55664. get scene(): Scene;
  55665. /** Gets the utilityLayer. */
  55666. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  55667. /** Checks Ready Status. */
  55668. get isReady(): Boolean;
  55669. /** Sets Ready Status. */
  55670. set ready(value: boolean);
  55671. /** Gets the debugMesh */
  55672. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  55673. /** Sets the debugMesh */
  55674. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  55675. /** Gets the displayMode */
  55676. get displayMode(): number;
  55677. /** Sets the displayMode */
  55678. set displayMode(value: number);
  55679. /**
  55680. * Creates a new SkeletonViewer
  55681. * @param skeleton defines the skeleton to render
  55682. * @param mesh defines the mesh attached to the skeleton
  55683. * @param scene defines the hosting scene
  55684. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  55685. * @param renderingGroupId defines the rendering group id to use with the viewer
  55686. * @param options All of the extra constructor options for the SkeletonViewer
  55687. */
  55688. constructor(
  55689. /** defines the skeleton to render */
  55690. skeleton: Skeleton,
  55691. /** defines the mesh attached to the skeleton */
  55692. mesh: AbstractMesh,
  55693. /** The Scene scope*/
  55694. scene: Scene,
  55695. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  55696. autoUpdateBonesMatrices?: boolean,
  55697. /** defines the rendering group id to use with the viewer */
  55698. renderingGroupId?: number,
  55699. /** is the options for the viewer */
  55700. options?: Partial<ISkeletonViewerOptions>);
  55701. /** The Dynamic bindings for the update functions */
  55702. private _bindObs;
  55703. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  55704. update(): void;
  55705. /** Gets or sets a boolean indicating if the viewer is enabled */
  55706. set isEnabled(value: boolean);
  55707. get isEnabled(): boolean;
  55708. private _getBonePosition;
  55709. private _getLinesForBonesWithLength;
  55710. private _getLinesForBonesNoLength;
  55711. /** function to revert the mesh and scene back to the initial state. */
  55712. private _revert;
  55713. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  55714. private _getAbsoluteBindPoseToRef;
  55715. /** function to build and bind sphere joint points and spur bone representations. */
  55716. private _buildSpheresAndSpurs;
  55717. private _buildLocalAxes;
  55718. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  55719. private _displayLinesUpdate;
  55720. /** Changes the displayMode of the skeleton viewer
  55721. * @param mode The displayMode numerical value
  55722. */
  55723. changeDisplayMode(mode: number): void;
  55724. /** Sets a display option of the skeleton viewer
  55725. *
  55726. * | Option | Type | Default | Description |
  55727. * | ---------------- | ------- | ------- | ----------- |
  55728. * | midStep | float | 0.235 | A percentage between a bone and its child that determines the widest part of a spur. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  55729. * | midStepFactor | float | 0.15 | Mid step width expressed as a factor of the length. A value of 0.5 makes the spur width half of the spur length. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  55730. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  55731. * | sphereScaleUnit | float | 0.865 | Sphere scale factor used to scale spheres in relation to the longest bone. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  55732. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  55733. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  55734. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  55735. *
  55736. * @param option String of the option name
  55737. * @param value The numerical option value
  55738. */
  55739. changeDisplayOptions(option: string, value: number): void;
  55740. /** Release associated resources */
  55741. dispose(): void;
  55742. }
  55743. }
  55744. declare module BABYLON {
  55745. /**
  55746. * Enum for Device Types
  55747. */
  55748. export enum DeviceType {
  55749. /** Generic */
  55750. Generic = 0,
  55751. /** Keyboard */
  55752. Keyboard = 1,
  55753. /** Mouse */
  55754. Mouse = 2,
  55755. /** Touch Pointers */
  55756. Touch = 3,
  55757. /** PS4 Dual Shock */
  55758. DualShock = 4,
  55759. /** Xbox */
  55760. Xbox = 5,
  55761. /** Switch Controller */
  55762. Switch = 6
  55763. }
  55764. /**
  55765. * Enum for All Pointers (Touch/Mouse)
  55766. */
  55767. export enum PointerInput {
  55768. /** Horizontal Axis */
  55769. Horizontal = 0,
  55770. /** Vertical Axis */
  55771. Vertical = 1,
  55772. /** Left Click or Touch */
  55773. LeftClick = 2,
  55774. /** Middle Click */
  55775. MiddleClick = 3,
  55776. /** Right Click */
  55777. RightClick = 4,
  55778. /** Browser Back */
  55779. BrowserBack = 5,
  55780. /** Browser Forward */
  55781. BrowserForward = 6
  55782. }
  55783. /**
  55784. * Enum for Dual Shock Gamepad
  55785. */
  55786. export enum DualShockInput {
  55787. /** Cross */
  55788. Cross = 0,
  55789. /** Circle */
  55790. Circle = 1,
  55791. /** Square */
  55792. Square = 2,
  55793. /** Triangle */
  55794. Triangle = 3,
  55795. /** L1 */
  55796. L1 = 4,
  55797. /** R1 */
  55798. R1 = 5,
  55799. /** L2 */
  55800. L2 = 6,
  55801. /** R2 */
  55802. R2 = 7,
  55803. /** Share */
  55804. Share = 8,
  55805. /** Options */
  55806. Options = 9,
  55807. /** L3 */
  55808. L3 = 10,
  55809. /** R3 */
  55810. R3 = 11,
  55811. /** DPadUp */
  55812. DPadUp = 12,
  55813. /** DPadDown */
  55814. DPadDown = 13,
  55815. /** DPadLeft */
  55816. DPadLeft = 14,
  55817. /** DRight */
  55818. DPadRight = 15,
  55819. /** Home */
  55820. Home = 16,
  55821. /** TouchPad */
  55822. TouchPad = 17,
  55823. /** LStickXAxis */
  55824. LStickXAxis = 18,
  55825. /** LStickYAxis */
  55826. LStickYAxis = 19,
  55827. /** RStickXAxis */
  55828. RStickXAxis = 20,
  55829. /** RStickYAxis */
  55830. RStickYAxis = 21
  55831. }
  55832. /**
  55833. * Enum for Xbox Gamepad
  55834. */
  55835. export enum XboxInput {
  55836. /** A */
  55837. A = 0,
  55838. /** B */
  55839. B = 1,
  55840. /** X */
  55841. X = 2,
  55842. /** Y */
  55843. Y = 3,
  55844. /** LB */
  55845. LB = 4,
  55846. /** RB */
  55847. RB = 5,
  55848. /** LT */
  55849. LT = 6,
  55850. /** RT */
  55851. RT = 7,
  55852. /** Back */
  55853. Back = 8,
  55854. /** Start */
  55855. Start = 9,
  55856. /** LS */
  55857. LS = 10,
  55858. /** RS */
  55859. RS = 11,
  55860. /** DPadUp */
  55861. DPadUp = 12,
  55862. /** DPadDown */
  55863. DPadDown = 13,
  55864. /** DPadLeft */
  55865. DPadLeft = 14,
  55866. /** DRight */
  55867. DPadRight = 15,
  55868. /** Home */
  55869. Home = 16,
  55870. /** LStickXAxis */
  55871. LStickXAxis = 17,
  55872. /** LStickYAxis */
  55873. LStickYAxis = 18,
  55874. /** RStickXAxis */
  55875. RStickXAxis = 19,
  55876. /** RStickYAxis */
  55877. RStickYAxis = 20
  55878. }
  55879. /**
  55880. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  55881. */
  55882. export enum SwitchInput {
  55883. /** B */
  55884. B = 0,
  55885. /** A */
  55886. A = 1,
  55887. /** Y */
  55888. Y = 2,
  55889. /** X */
  55890. X = 3,
  55891. /** L */
  55892. L = 4,
  55893. /** R */
  55894. R = 5,
  55895. /** ZL */
  55896. ZL = 6,
  55897. /** ZR */
  55898. ZR = 7,
  55899. /** Minus */
  55900. Minus = 8,
  55901. /** Plus */
  55902. Plus = 9,
  55903. /** LS */
  55904. LS = 10,
  55905. /** RS */
  55906. RS = 11,
  55907. /** DPadUp */
  55908. DPadUp = 12,
  55909. /** DPadDown */
  55910. DPadDown = 13,
  55911. /** DPadLeft */
  55912. DPadLeft = 14,
  55913. /** DRight */
  55914. DPadRight = 15,
  55915. /** Home */
  55916. Home = 16,
  55917. /** Capture */
  55918. Capture = 17,
  55919. /** LStickXAxis */
  55920. LStickXAxis = 18,
  55921. /** LStickYAxis */
  55922. LStickYAxis = 19,
  55923. /** RStickXAxis */
  55924. RStickXAxis = 20,
  55925. /** RStickYAxis */
  55926. RStickYAxis = 21
  55927. }
  55928. }
  55929. declare module BABYLON {
  55930. /**
  55931. * This class will take all inputs from Keyboard, Pointer, and
  55932. * any Gamepads and provide a polling system that all devices
  55933. * will use. This class assumes that there will only be one
  55934. * pointer device and one keyboard.
  55935. */
  55936. export class DeviceInputSystem implements IDisposable {
  55937. /**
  55938. * Returns onDeviceConnected callback property
  55939. * @returns Callback with function to execute when a device is connected
  55940. */
  55941. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  55942. /**
  55943. * Sets callback function when a device is connected and executes against all connected devices
  55944. * @param callback Function to execute when a device is connected
  55945. */
  55946. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  55947. /**
  55948. * Callback to be triggered when a device is disconnected
  55949. */
  55950. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  55951. /**
  55952. * Callback to be triggered when event driven input is updated
  55953. */
  55954. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  55955. private _inputs;
  55956. private _gamepads;
  55957. private _keyboardActive;
  55958. private _pointerActive;
  55959. private _elementToAttachTo;
  55960. private _keyboardDownEvent;
  55961. private _keyboardUpEvent;
  55962. private _pointerMoveEvent;
  55963. private _pointerDownEvent;
  55964. private _pointerUpEvent;
  55965. private _gamepadConnectedEvent;
  55966. private _gamepadDisconnectedEvent;
  55967. private _onDeviceConnected;
  55968. private static _MAX_KEYCODES;
  55969. private static _MAX_POINTER_INPUTS;
  55970. private constructor();
  55971. /**
  55972. * Creates a new DeviceInputSystem instance
  55973. * @param engine Engine to pull input element from
  55974. * @returns The new instance
  55975. */
  55976. static Create(engine: Engine): DeviceInputSystem;
  55977. /**
  55978. * Checks for current device input value, given an id and input index
  55979. * @param deviceName Id of connected device
  55980. * @param inputIndex Index of device input
  55981. * @returns Current value of input
  55982. */
  55983. /**
  55984. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  55985. * @param deviceType Enum specifiying device type
  55986. * @param deviceSlot "Slot" or index that device is referenced in
  55987. * @param inputIndex Id of input to be checked
  55988. * @returns Current value of input
  55989. */
  55990. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  55991. /**
  55992. * Dispose of all the eventlisteners
  55993. */
  55994. dispose(): void;
  55995. /**
  55996. * Checks for existing connections to devices and register them, if necessary
  55997. * Currently handles gamepads and mouse
  55998. */
  55999. private _checkForConnectedDevices;
  56000. /**
  56001. * Add a gamepad to the DeviceInputSystem
  56002. * @param gamepad A single DOM Gamepad object
  56003. */
  56004. private _addGamePad;
  56005. /**
  56006. * Add pointer device to DeviceInputSystem
  56007. * @param deviceType Type of Pointer to add
  56008. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  56009. * @param currentX Current X at point of adding
  56010. * @param currentY Current Y at point of adding
  56011. */
  56012. private _addPointerDevice;
  56013. /**
  56014. * Add device and inputs to device array
  56015. * @param deviceType Enum specifiying device type
  56016. * @param deviceSlot "Slot" or index that device is referenced in
  56017. * @param numberOfInputs Number of input entries to create for given device
  56018. */
  56019. private _registerDevice;
  56020. /**
  56021. * Given a specific device name, remove that device from the device map
  56022. * @param deviceType Enum specifiying device type
  56023. * @param deviceSlot "Slot" or index that device is referenced in
  56024. */
  56025. private _unregisterDevice;
  56026. /**
  56027. * Handle all actions that come from keyboard interaction
  56028. */
  56029. private _handleKeyActions;
  56030. /**
  56031. * Handle all actions that come from pointer interaction
  56032. */
  56033. private _handlePointerActions;
  56034. /**
  56035. * Handle all actions that come from gamepad interaction
  56036. */
  56037. private _handleGamepadActions;
  56038. /**
  56039. * Update all non-event based devices with each frame
  56040. * @param deviceType Enum specifiying device type
  56041. * @param deviceSlot "Slot" or index that device is referenced in
  56042. * @param inputIndex Id of input to be checked
  56043. */
  56044. private _updateDevice;
  56045. /**
  56046. * Gets DeviceType from the device name
  56047. * @param deviceName Name of Device from DeviceInputSystem
  56048. * @returns DeviceType enum value
  56049. */
  56050. private _getGamepadDeviceType;
  56051. }
  56052. }
  56053. declare module BABYLON {
  56054. /**
  56055. * Type to handle enforcement of inputs
  56056. */
  56057. export type DeviceInput<T extends DeviceType> = T extends DeviceType.Keyboard | DeviceType.Generic ? number : T extends DeviceType.Mouse | DeviceType.Touch ? PointerInput : T extends DeviceType.DualShock ? DualShockInput : T extends DeviceType.Xbox ? XboxInput : T extends DeviceType.Switch ? SwitchInput : never;
  56058. }
  56059. declare module BABYLON {
  56060. /**
  56061. * Class that handles all input for a specific device
  56062. */
  56063. export class DeviceSource<T extends DeviceType> {
  56064. /** Type of device */
  56065. readonly deviceType: DeviceType;
  56066. /** "Slot" or index that device is referenced in */
  56067. readonly deviceSlot: number;
  56068. /**
  56069. * Observable to handle device input changes per device
  56070. */
  56071. readonly onInputChangedObservable: Observable<{
  56072. inputIndex: DeviceInput<T>;
  56073. previousState: Nullable<number>;
  56074. currentState: Nullable<number>;
  56075. }>;
  56076. private readonly _deviceInputSystem;
  56077. /**
  56078. * Default Constructor
  56079. * @param deviceInputSystem Reference to DeviceInputSystem
  56080. * @param deviceType Type of device
  56081. * @param deviceSlot "Slot" or index that device is referenced in
  56082. */
  56083. constructor(deviceInputSystem: DeviceInputSystem,
  56084. /** Type of device */
  56085. deviceType: DeviceType,
  56086. /** "Slot" or index that device is referenced in */
  56087. deviceSlot?: number);
  56088. /**
  56089. * Get input for specific input
  56090. * @param inputIndex index of specific input on device
  56091. * @returns Input value from DeviceInputSystem
  56092. */
  56093. getInput(inputIndex: DeviceInput<T>): number;
  56094. }
  56095. /**
  56096. * Class to keep track of devices
  56097. */
  56098. export class DeviceSourceManager implements IDisposable {
  56099. /**
  56100. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  56101. */
  56102. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  56103. /**
  56104. * Observable to be triggered when after a device is disconnected
  56105. */
  56106. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  56107. private readonly _devices;
  56108. private readonly _firstDevice;
  56109. private readonly _deviceInputSystem;
  56110. /**
  56111. * Default Constructor
  56112. * @param engine engine to pull input element from
  56113. */
  56114. constructor(engine: Engine);
  56115. /**
  56116. * Gets a DeviceSource, given a type and slot
  56117. * @param deviceType Enum specifying device type
  56118. * @param deviceSlot "Slot" or index that device is referenced in
  56119. * @returns DeviceSource object
  56120. */
  56121. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  56122. /**
  56123. * Gets an array of DeviceSource objects for a given device type
  56124. * @param deviceType Enum specifying device type
  56125. * @returns Array of DeviceSource objects
  56126. */
  56127. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  56128. /**
  56129. * Returns a read-only list of all available devices
  56130. * @returns Read-only array with active devices
  56131. */
  56132. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  56133. /**
  56134. * Dispose of DeviceInputSystem and other parts
  56135. */
  56136. dispose(): void;
  56137. /**
  56138. * Function to add device name to device list
  56139. * @param deviceType Enum specifying device type
  56140. * @param deviceSlot "Slot" or index that device is referenced in
  56141. */
  56142. private _addDevice;
  56143. /**
  56144. * Function to remove device name to device list
  56145. * @param deviceType Enum specifying device type
  56146. * @param deviceSlot "Slot" or index that device is referenced in
  56147. */
  56148. private _removeDevice;
  56149. /**
  56150. * Updates array storing first connected device of each type
  56151. * @param type Type of Device
  56152. */
  56153. private _updateFirstDevices;
  56154. }
  56155. }
  56156. declare module BABYLON {
  56157. /**
  56158. * Options to create the null engine
  56159. */
  56160. export class NullEngineOptions {
  56161. /**
  56162. * Render width (Default: 512)
  56163. */
  56164. renderWidth: number;
  56165. /**
  56166. * Render height (Default: 256)
  56167. */
  56168. renderHeight: number;
  56169. /**
  56170. * Texture size (Default: 512)
  56171. */
  56172. textureSize: number;
  56173. /**
  56174. * If delta time between frames should be constant
  56175. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  56176. */
  56177. deterministicLockstep: boolean;
  56178. /**
  56179. * Maximum about of steps between frames (Default: 4)
  56180. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  56181. */
  56182. lockstepMaxSteps: number;
  56183. /**
  56184. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  56185. */
  56186. useHighPrecisionMatrix?: boolean;
  56187. }
  56188. /**
  56189. * The null engine class provides support for headless version of babylon.js.
  56190. * This can be used in server side scenario or for testing purposes
  56191. */
  56192. export class NullEngine extends Engine {
  56193. private _options;
  56194. /**
  56195. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  56196. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  56197. * @returns true if engine is in deterministic lock step mode
  56198. */
  56199. isDeterministicLockStep(): boolean;
  56200. /**
  56201. * Gets the max steps when engine is running in deterministic lock step
  56202. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  56203. * @returns the max steps
  56204. */
  56205. getLockstepMaxSteps(): number;
  56206. /**
  56207. * Gets the current hardware scaling level.
  56208. * By default the hardware scaling level is computed from the window device ratio.
  56209. * 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.
  56210. * @returns a number indicating the current hardware scaling level
  56211. */
  56212. getHardwareScalingLevel(): number;
  56213. constructor(options?: NullEngineOptions);
  56214. /**
  56215. * Creates a vertex buffer
  56216. * @param vertices the data for the vertex buffer
  56217. * @returns the new WebGL static buffer
  56218. */
  56219. createVertexBuffer(vertices: FloatArray): DataBuffer;
  56220. /**
  56221. * Creates a new index buffer
  56222. * @param indices defines the content of the index buffer
  56223. * @param updatable defines if the index buffer must be updatable
  56224. * @returns a new webGL buffer
  56225. */
  56226. createIndexBuffer(indices: IndicesArray): DataBuffer;
  56227. /**
  56228. * Clear the current render buffer or the current render target (if any is set up)
  56229. * @param color defines the color to use
  56230. * @param backBuffer defines if the back buffer must be cleared
  56231. * @param depth defines if the depth buffer must be cleared
  56232. * @param stencil defines if the stencil buffer must be cleared
  56233. */
  56234. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  56235. /**
  56236. * Gets the current render width
  56237. * @param useScreen defines if screen size must be used (or the current render target if any)
  56238. * @returns a number defining the current render width
  56239. */
  56240. getRenderWidth(useScreen?: boolean): number;
  56241. /**
  56242. * Gets the current render height
  56243. * @param useScreen defines if screen size must be used (or the current render target if any)
  56244. * @returns a number defining the current render height
  56245. */
  56246. getRenderHeight(useScreen?: boolean): number;
  56247. /**
  56248. * Set the WebGL's viewport
  56249. * @param viewport defines the viewport element to be used
  56250. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  56251. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  56252. */
  56253. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  56254. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  56255. /**
  56256. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  56257. * @param pipelineContext defines the pipeline context to use
  56258. * @param uniformsNames defines the list of uniform names
  56259. * @returns an array of webGL uniform locations
  56260. */
  56261. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  56262. /**
  56263. * Gets the lsit of active attributes for a given webGL program
  56264. * @param pipelineContext defines the pipeline context to use
  56265. * @param attributesNames defines the list of attribute names to get
  56266. * @returns an array of indices indicating the offset of each attribute
  56267. */
  56268. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  56269. /**
  56270. * Binds an effect to the webGL context
  56271. * @param effect defines the effect to bind
  56272. */
  56273. bindSamplers(effect: Effect): void;
  56274. /**
  56275. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  56276. * @param effect defines the effect to activate
  56277. */
  56278. enableEffect(effect: Effect): void;
  56279. /**
  56280. * Set various states to the webGL context
  56281. * @param culling defines backface culling state
  56282. * @param zOffset defines the value to apply to zOffset (0 by default)
  56283. * @param force defines if states must be applied even if cache is up to date
  56284. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  56285. */
  56286. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  56287. /**
  56288. * Set the value of an uniform to an array of int32
  56289. * @param uniform defines the webGL uniform location where to store the value
  56290. * @param array defines the array of int32 to store
  56291. * @returns true if value was set
  56292. */
  56293. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56294. /**
  56295. * Set the value of an uniform to an array of int32 (stored as vec2)
  56296. * @param uniform defines the webGL uniform location where to store the value
  56297. * @param array defines the array of int32 to store
  56298. * @returns true if value was set
  56299. */
  56300. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56301. /**
  56302. * Set the value of an uniform to an array of int32 (stored as vec3)
  56303. * @param uniform defines the webGL uniform location where to store the value
  56304. * @param array defines the array of int32 to store
  56305. * @returns true if value was set
  56306. */
  56307. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56308. /**
  56309. * Set the value of an uniform to an array of int32 (stored as vec4)
  56310. * @param uniform defines the webGL uniform location where to store the value
  56311. * @param array defines the array of int32 to store
  56312. * @returns true if value was set
  56313. */
  56314. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56315. /**
  56316. * Set the value of an uniform to an array of float32
  56317. * @param uniform defines the webGL uniform location where to store the value
  56318. * @param array defines the array of float32 to store
  56319. * @returns true if value was set
  56320. */
  56321. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56322. /**
  56323. * Set the value of an uniform to an array of float32 (stored as vec2)
  56324. * @param uniform defines the webGL uniform location where to store the value
  56325. * @param array defines the array of float32 to store
  56326. * @returns true if value was set
  56327. */
  56328. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56329. /**
  56330. * Set the value of an uniform to an array of float32 (stored as vec3)
  56331. * @param uniform defines the webGL uniform location where to store the value
  56332. * @param array defines the array of float32 to store
  56333. * @returns true if value was set
  56334. */
  56335. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56336. /**
  56337. * Set the value of an uniform to an array of float32 (stored as vec4)
  56338. * @param uniform defines the webGL uniform location where to store the value
  56339. * @param array defines the array of float32 to store
  56340. * @returns true if value was set
  56341. */
  56342. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56343. /**
  56344. * Set the value of an uniform to an array of number
  56345. * @param uniform defines the webGL uniform location where to store the value
  56346. * @param array defines the array of number to store
  56347. * @returns true if value was set
  56348. */
  56349. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  56350. /**
  56351. * Set the value of an uniform to an array of number (stored as vec2)
  56352. * @param uniform defines the webGL uniform location where to store the value
  56353. * @param array defines the array of number to store
  56354. * @returns true if value was set
  56355. */
  56356. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  56357. /**
  56358. * Set the value of an uniform to an array of number (stored as vec3)
  56359. * @param uniform defines the webGL uniform location where to store the value
  56360. * @param array defines the array of number to store
  56361. * @returns true if value was set
  56362. */
  56363. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  56364. /**
  56365. * Set the value of an uniform to an array of number (stored as vec4)
  56366. * @param uniform defines the webGL uniform location where to store the value
  56367. * @param array defines the array of number to store
  56368. * @returns true if value was set
  56369. */
  56370. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  56371. /**
  56372. * Set the value of an uniform to an array of float32 (stored as matrices)
  56373. * @param uniform defines the webGL uniform location where to store the value
  56374. * @param matrices defines the array of float32 to store
  56375. * @returns true if value was set
  56376. */
  56377. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  56378. /**
  56379. * Set the value of an uniform to a matrix (3x3)
  56380. * @param uniform defines the webGL uniform location where to store the value
  56381. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  56382. * @returns true if value was set
  56383. */
  56384. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  56385. /**
  56386. * Set the value of an uniform to a matrix (2x2)
  56387. * @param uniform defines the webGL uniform location where to store the value
  56388. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  56389. * @returns true if value was set
  56390. */
  56391. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  56392. /**
  56393. * Set the value of an uniform to a number (float)
  56394. * @param uniform defines the webGL uniform location where to store the value
  56395. * @param value defines the float number to store
  56396. * @returns true if value was set
  56397. */
  56398. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  56399. /**
  56400. * Set the value of an uniform to a vec2
  56401. * @param uniform defines the webGL uniform location where to store the value
  56402. * @param x defines the 1st component of the value
  56403. * @param y defines the 2nd component of the value
  56404. * @returns true if value was set
  56405. */
  56406. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  56407. /**
  56408. * Set the value of an uniform to a vec3
  56409. * @param uniform defines the webGL uniform location where to store the value
  56410. * @param x defines the 1st component of the value
  56411. * @param y defines the 2nd component of the value
  56412. * @param z defines the 3rd component of the value
  56413. * @returns true if value was set
  56414. */
  56415. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  56416. /**
  56417. * Set the value of an uniform to a boolean
  56418. * @param uniform defines the webGL uniform location where to store the value
  56419. * @param bool defines the boolean to store
  56420. * @returns true if value was set
  56421. */
  56422. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  56423. /**
  56424. * Set the value of an uniform to a vec4
  56425. * @param uniform defines the webGL uniform location where to store the value
  56426. * @param x defines the 1st component of the value
  56427. * @param y defines the 2nd component of the value
  56428. * @param z defines the 3rd component of the value
  56429. * @param w defines the 4th component of the value
  56430. * @returns true if value was set
  56431. */
  56432. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  56433. /**
  56434. * Sets the current alpha mode
  56435. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  56436. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  56437. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  56438. */
  56439. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  56440. /**
  56441. * Bind webGl buffers directly to the webGL context
  56442. * @param vertexBuffers defines the vertex buffer to bind
  56443. * @param indexBuffer defines the index buffer to bind
  56444. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  56445. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  56446. * @param effect defines the effect associated with the vertex buffer
  56447. */
  56448. bindBuffers(vertexBuffers: {
  56449. [key: string]: VertexBuffer;
  56450. }, indexBuffer: DataBuffer, effect: Effect): void;
  56451. /**
  56452. * Force the entire cache to be cleared
  56453. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  56454. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  56455. */
  56456. wipeCaches(bruteForce?: boolean): void;
  56457. /**
  56458. * Send a draw order
  56459. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  56460. * @param indexStart defines the starting index
  56461. * @param indexCount defines the number of index to draw
  56462. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56463. */
  56464. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  56465. /**
  56466. * Draw a list of indexed primitives
  56467. * @param fillMode defines the primitive to use
  56468. * @param indexStart defines the starting index
  56469. * @param indexCount defines the number of index to draw
  56470. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56471. */
  56472. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  56473. /**
  56474. * Draw a list of unindexed primitives
  56475. * @param fillMode defines the primitive to use
  56476. * @param verticesStart defines the index of first vertex to draw
  56477. * @param verticesCount defines the count of vertices to draw
  56478. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56479. */
  56480. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  56481. /** @hidden */
  56482. _createTexture(): WebGLTexture;
  56483. /** @hidden */
  56484. _releaseTexture(texture: InternalTexture): void;
  56485. /**
  56486. * Usually called from Texture.ts.
  56487. * Passed information to create a WebGLTexture
  56488. * @param urlArg defines a value which contains one of the following:
  56489. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  56490. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  56491. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  56492. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  56493. * @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)
  56494. * @param scene needed for loading to the correct scene
  56495. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  56496. * @param onLoad optional callback to be called upon successful completion
  56497. * @param onError optional callback to be called upon failure
  56498. * @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
  56499. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  56500. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  56501. * @param forcedExtension defines the extension to use to pick the right loader
  56502. * @param mimeType defines an optional mime type
  56503. * @returns a InternalTexture for assignment back into BABYLON.Texture
  56504. */
  56505. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  56506. /**
  56507. * Creates a new render target texture
  56508. * @param size defines the size of the texture
  56509. * @param options defines the options used to create the texture
  56510. * @returns a new render target texture stored in an InternalTexture
  56511. */
  56512. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  56513. /**
  56514. * Update the sampling mode of a given texture
  56515. * @param samplingMode defines the required sampling mode
  56516. * @param texture defines the texture to update
  56517. */
  56518. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  56519. /**
  56520. * Binds the frame buffer to the specified texture.
  56521. * @param texture The texture to render to or null for the default canvas
  56522. * @param faceIndex The face of the texture to render to in case of cube texture
  56523. * @param requiredWidth The width of the target to render to
  56524. * @param requiredHeight The height of the target to render to
  56525. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  56526. * @param lodLevel defines le lod level to bind to the frame buffer
  56527. */
  56528. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  56529. /**
  56530. * Unbind the current render target texture from the webGL context
  56531. * @param texture defines the render target texture to unbind
  56532. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  56533. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  56534. */
  56535. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  56536. /**
  56537. * Creates a dynamic vertex buffer
  56538. * @param vertices the data for the dynamic vertex buffer
  56539. * @returns the new WebGL dynamic buffer
  56540. */
  56541. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  56542. /**
  56543. * Update the content of a dynamic texture
  56544. * @param texture defines the texture to update
  56545. * @param canvas defines the canvas containing the source
  56546. * @param invertY defines if data must be stored with Y axis inverted
  56547. * @param premulAlpha defines if alpha is stored as premultiplied
  56548. * @param format defines the format of the data
  56549. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  56550. */
  56551. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  56552. /**
  56553. * Gets a boolean indicating if all created effects are ready
  56554. * @returns true if all effects are ready
  56555. */
  56556. areAllEffectsReady(): boolean;
  56557. /**
  56558. * @hidden
  56559. * Get the current error code of the webGL context
  56560. * @returns the error code
  56561. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  56562. */
  56563. getError(): number;
  56564. /** @hidden */
  56565. _getUnpackAlignement(): number;
  56566. /** @hidden */
  56567. _unpackFlipY(value: boolean): void;
  56568. /**
  56569. * Update a dynamic index buffer
  56570. * @param indexBuffer defines the target index buffer
  56571. * @param indices defines the data to update
  56572. * @param offset defines the offset in the target index buffer where update should start
  56573. */
  56574. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  56575. /**
  56576. * Updates a dynamic vertex buffer.
  56577. * @param vertexBuffer the vertex buffer to update
  56578. * @param vertices the data used to update the vertex buffer
  56579. * @param byteOffset the byte offset of the data (optional)
  56580. * @param byteLength the byte length of the data (optional)
  56581. */
  56582. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  56583. /** @hidden */
  56584. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  56585. /** @hidden */
  56586. _bindTexture(channel: number, texture: InternalTexture): void;
  56587. protected _deleteBuffer(buffer: WebGLBuffer): void;
  56588. /**
  56589. * 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
  56590. */
  56591. releaseEffects(): void;
  56592. displayLoadingUI(): void;
  56593. hideLoadingUI(): void;
  56594. /** @hidden */
  56595. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56596. /** @hidden */
  56597. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56598. /** @hidden */
  56599. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56600. /** @hidden */
  56601. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  56602. }
  56603. }
  56604. declare module BABYLON {
  56605. /**
  56606. * @hidden
  56607. **/
  56608. export class _TimeToken {
  56609. _startTimeQuery: Nullable<WebGLQuery>;
  56610. _endTimeQuery: Nullable<WebGLQuery>;
  56611. _timeElapsedQuery: Nullable<WebGLQuery>;
  56612. _timeElapsedQueryEnded: boolean;
  56613. }
  56614. }
  56615. declare module BABYLON {
  56616. /** @hidden */
  56617. export class _OcclusionDataStorage {
  56618. /** @hidden */
  56619. occlusionInternalRetryCounter: number;
  56620. /** @hidden */
  56621. isOcclusionQueryInProgress: boolean;
  56622. /** @hidden */
  56623. isOccluded: boolean;
  56624. /** @hidden */
  56625. occlusionRetryCount: number;
  56626. /** @hidden */
  56627. occlusionType: number;
  56628. /** @hidden */
  56629. occlusionQueryAlgorithmType: number;
  56630. }
  56631. interface Engine {
  56632. /**
  56633. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  56634. * @return the new query
  56635. */
  56636. createQuery(): WebGLQuery;
  56637. /**
  56638. * Delete and release a webGL query
  56639. * @param query defines the query to delete
  56640. * @return the current engine
  56641. */
  56642. deleteQuery(query: WebGLQuery): Engine;
  56643. /**
  56644. * Check if a given query has resolved and got its value
  56645. * @param query defines the query to check
  56646. * @returns true if the query got its value
  56647. */
  56648. isQueryResultAvailable(query: WebGLQuery): boolean;
  56649. /**
  56650. * Gets the value of a given query
  56651. * @param query defines the query to check
  56652. * @returns the value of the query
  56653. */
  56654. getQueryResult(query: WebGLQuery): number;
  56655. /**
  56656. * Initiates an occlusion query
  56657. * @param algorithmType defines the algorithm to use
  56658. * @param query defines the query to use
  56659. * @returns the current engine
  56660. * @see https://doc.babylonjs.com/features/occlusionquery
  56661. */
  56662. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  56663. /**
  56664. * Ends an occlusion query
  56665. * @see https://doc.babylonjs.com/features/occlusionquery
  56666. * @param algorithmType defines the algorithm to use
  56667. * @returns the current engine
  56668. */
  56669. endOcclusionQuery(algorithmType: number): Engine;
  56670. /**
  56671. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  56672. * Please note that only one query can be issued at a time
  56673. * @returns a time token used to track the time span
  56674. */
  56675. startTimeQuery(): Nullable<_TimeToken>;
  56676. /**
  56677. * Ends a time query
  56678. * @param token defines the token used to measure the time span
  56679. * @returns the time spent (in ns)
  56680. */
  56681. endTimeQuery(token: _TimeToken): int;
  56682. /** @hidden */
  56683. _currentNonTimestampToken: Nullable<_TimeToken>;
  56684. /** @hidden */
  56685. _createTimeQuery(): WebGLQuery;
  56686. /** @hidden */
  56687. _deleteTimeQuery(query: WebGLQuery): void;
  56688. /** @hidden */
  56689. _getGlAlgorithmType(algorithmType: number): number;
  56690. /** @hidden */
  56691. _getTimeQueryResult(query: WebGLQuery): any;
  56692. /** @hidden */
  56693. _getTimeQueryAvailability(query: WebGLQuery): any;
  56694. }
  56695. interface AbstractMesh {
  56696. /**
  56697. * Backing filed
  56698. * @hidden
  56699. */
  56700. __occlusionDataStorage: _OcclusionDataStorage;
  56701. /**
  56702. * Access property
  56703. * @hidden
  56704. */
  56705. _occlusionDataStorage: _OcclusionDataStorage;
  56706. /**
  56707. * 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.
  56708. * The default value is -1 which means don't break the query and wait till the result
  56709. * @see https://doc.babylonjs.com/features/occlusionquery
  56710. */
  56711. occlusionRetryCount: number;
  56712. /**
  56713. * 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:
  56714. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  56715. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  56716. * * 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.
  56717. * @see https://doc.babylonjs.com/features/occlusionquery
  56718. */
  56719. occlusionType: number;
  56720. /**
  56721. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  56722. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  56723. * * 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.
  56724. * @see https://doc.babylonjs.com/features/occlusionquery
  56725. */
  56726. occlusionQueryAlgorithmType: number;
  56727. /**
  56728. * 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
  56729. * @see https://doc.babylonjs.com/features/occlusionquery
  56730. */
  56731. isOccluded: boolean;
  56732. /**
  56733. * Flag to check the progress status of the query
  56734. * @see https://doc.babylonjs.com/features/occlusionquery
  56735. */
  56736. isOcclusionQueryInProgress: boolean;
  56737. }
  56738. }
  56739. declare module BABYLON {
  56740. /** @hidden */
  56741. export var _forceTransformFeedbackToBundle: boolean;
  56742. interface Engine {
  56743. /**
  56744. * Creates a webGL transform feedback object
  56745. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  56746. * @returns the webGL transform feedback object
  56747. */
  56748. createTransformFeedback(): WebGLTransformFeedback;
  56749. /**
  56750. * Delete a webGL transform feedback object
  56751. * @param value defines the webGL transform feedback object to delete
  56752. */
  56753. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  56754. /**
  56755. * Bind a webGL transform feedback object to the webgl context
  56756. * @param value defines the webGL transform feedback object to bind
  56757. */
  56758. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  56759. /**
  56760. * Begins a transform feedback operation
  56761. * @param usePoints defines if points or triangles must be used
  56762. */
  56763. beginTransformFeedback(usePoints: boolean): void;
  56764. /**
  56765. * Ends a transform feedback operation
  56766. */
  56767. endTransformFeedback(): void;
  56768. /**
  56769. * Specify the varyings to use with transform feedback
  56770. * @param program defines the associated webGL program
  56771. * @param value defines the list of strings representing the varying names
  56772. */
  56773. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  56774. /**
  56775. * Bind a webGL buffer for a transform feedback operation
  56776. * @param value defines the webGL buffer to bind
  56777. */
  56778. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  56779. }
  56780. }
  56781. declare module BABYLON {
  56782. /**
  56783. * Class used to define an additional view for the engine
  56784. * @see https://doc.babylonjs.com/how_to/multi_canvases
  56785. */
  56786. export class EngineView {
  56787. /** Defines the canvas where to render the view */
  56788. target: HTMLCanvasElement;
  56789. /** Defines an optional camera used to render the view (will use active camera else) */
  56790. camera?: Camera;
  56791. }
  56792. interface Engine {
  56793. /**
  56794. * Gets or sets the HTML element to use for attaching events
  56795. */
  56796. inputElement: Nullable<HTMLElement>;
  56797. /**
  56798. * Gets the current engine view
  56799. * @see https://doc.babylonjs.com/how_to/multi_canvases
  56800. */
  56801. activeView: Nullable<EngineView>;
  56802. /** Gets or sets the list of views */
  56803. views: EngineView[];
  56804. /**
  56805. * Register a new child canvas
  56806. * @param canvas defines the canvas to register
  56807. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  56808. * @returns the associated view
  56809. */
  56810. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  56811. /**
  56812. * Remove a registered child canvas
  56813. * @param canvas defines the canvas to remove
  56814. * @returns the current engine
  56815. */
  56816. unRegisterView(canvas: HTMLCanvasElement): Engine;
  56817. }
  56818. }
  56819. declare module BABYLON {
  56820. interface Engine {
  56821. /** @hidden */
  56822. _excludedCompressedTextures: string[];
  56823. /** @hidden */
  56824. _textureFormatInUse: string;
  56825. /**
  56826. * Gets the list of texture formats supported
  56827. */
  56828. readonly texturesSupported: Array<string>;
  56829. /**
  56830. * Gets the texture format in use
  56831. */
  56832. readonly textureFormatInUse: Nullable<string>;
  56833. /**
  56834. * Set the compressed texture extensions or file names to skip.
  56835. *
  56836. * @param skippedFiles defines the list of those texture files you want to skip
  56837. * Example: [".dds", ".env", "myfile.png"]
  56838. */
  56839. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  56840. /**
  56841. * Set the compressed texture format to use, based on the formats you have, and the formats
  56842. * supported by the hardware / browser.
  56843. *
  56844. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  56845. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  56846. * to API arguments needed to compressed textures. This puts the burden on the container
  56847. * generator to house the arcane code for determining these for current & future formats.
  56848. *
  56849. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  56850. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  56851. *
  56852. * Note: The result of this call is not taken into account when a texture is base64.
  56853. *
  56854. * @param formatsAvailable defines the list of those format families you have created
  56855. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  56856. *
  56857. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  56858. * @returns The extension selected.
  56859. */
  56860. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  56861. }
  56862. }
  56863. declare module BABYLON {
  56864. /** @hidden */
  56865. export var rgbdEncodePixelShader: {
  56866. name: string;
  56867. shader: string;
  56868. };
  56869. }
  56870. declare module BABYLON {
  56871. /**
  56872. * Raw texture data and descriptor sufficient for WebGL texture upload
  56873. */
  56874. export interface EnvironmentTextureInfo {
  56875. /**
  56876. * Version of the environment map
  56877. */
  56878. version: number;
  56879. /**
  56880. * Width of image
  56881. */
  56882. width: number;
  56883. /**
  56884. * Irradiance information stored in the file.
  56885. */
  56886. irradiance: any;
  56887. /**
  56888. * Specular information stored in the file.
  56889. */
  56890. specular: any;
  56891. }
  56892. /**
  56893. * Defines One Image in the file. It requires only the position in the file
  56894. * as well as the length.
  56895. */
  56896. interface BufferImageData {
  56897. /**
  56898. * Length of the image data.
  56899. */
  56900. length: number;
  56901. /**
  56902. * Position of the data from the null terminator delimiting the end of the JSON.
  56903. */
  56904. position: number;
  56905. }
  56906. /**
  56907. * Defines the specular data enclosed in the file.
  56908. * This corresponds to the version 1 of the data.
  56909. */
  56910. export interface EnvironmentTextureSpecularInfoV1 {
  56911. /**
  56912. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  56913. */
  56914. specularDataPosition?: number;
  56915. /**
  56916. * This contains all the images data needed to reconstruct the cubemap.
  56917. */
  56918. mipmaps: Array<BufferImageData>;
  56919. /**
  56920. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  56921. */
  56922. lodGenerationScale: number;
  56923. }
  56924. /**
  56925. * Sets of helpers addressing the serialization and deserialization of environment texture
  56926. * stored in a BabylonJS env file.
  56927. * Those files are usually stored as .env files.
  56928. */
  56929. export class EnvironmentTextureTools {
  56930. /**
  56931. * Magic number identifying the env file.
  56932. */
  56933. private static _MagicBytes;
  56934. /**
  56935. * Gets the environment info from an env file.
  56936. * @param data The array buffer containing the .env bytes.
  56937. * @returns the environment file info (the json header) if successfully parsed.
  56938. */
  56939. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  56940. /**
  56941. * Creates an environment texture from a loaded cube texture.
  56942. * @param texture defines the cube texture to convert in env file
  56943. * @return a promise containing the environment data if succesfull.
  56944. */
  56945. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  56946. /**
  56947. * Creates a JSON representation of the spherical data.
  56948. * @param texture defines the texture containing the polynomials
  56949. * @return the JSON representation of the spherical info
  56950. */
  56951. private static _CreateEnvTextureIrradiance;
  56952. /**
  56953. * Creates the ArrayBufferViews used for initializing environment texture image data.
  56954. * @param data the image data
  56955. * @param info parameters that determine what views will be created for accessing the underlying buffer
  56956. * @return the views described by info providing access to the underlying buffer
  56957. */
  56958. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  56959. /**
  56960. * Uploads the texture info contained in the env file to the GPU.
  56961. * @param texture defines the internal texture to upload to
  56962. * @param data defines the data to load
  56963. * @param info defines the texture info retrieved through the GetEnvInfo method
  56964. * @returns a promise
  56965. */
  56966. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  56967. private static _OnImageReadyAsync;
  56968. /**
  56969. * Uploads the levels of image data to the GPU.
  56970. * @param texture defines the internal texture to upload to
  56971. * @param imageData defines the array buffer views of image data [mipmap][face]
  56972. * @returns a promise
  56973. */
  56974. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  56975. /**
  56976. * Uploads spherical polynomials information to the texture.
  56977. * @param texture defines the texture we are trying to upload the information to
  56978. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  56979. */
  56980. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  56981. /** @hidden */
  56982. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56983. }
  56984. }
  56985. declare module BABYLON {
  56986. /**
  56987. * Class used to inline functions in shader code
  56988. */
  56989. export class ShaderCodeInliner {
  56990. private static readonly _RegexpFindFunctionNameAndType;
  56991. private _sourceCode;
  56992. private _functionDescr;
  56993. private _numMaxIterations;
  56994. /** Gets or sets the token used to mark the functions to inline */
  56995. inlineToken: string;
  56996. /** Gets or sets the debug mode */
  56997. debug: boolean;
  56998. /** Gets the code after the inlining process */
  56999. get code(): string;
  57000. /**
  57001. * Initializes the inliner
  57002. * @param sourceCode shader code source to inline
  57003. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  57004. */
  57005. constructor(sourceCode: string, numMaxIterations?: number);
  57006. /**
  57007. * Start the processing of the shader code
  57008. */
  57009. processCode(): void;
  57010. private _collectFunctions;
  57011. private _processInlining;
  57012. private _extractBetweenMarkers;
  57013. private _skipWhitespaces;
  57014. private _removeComments;
  57015. private _replaceFunctionCallsByCode;
  57016. private _findBackward;
  57017. private _escapeRegExp;
  57018. private _replaceNames;
  57019. }
  57020. }
  57021. declare module BABYLON {
  57022. /**
  57023. * Container for accessors for natively-stored mesh data buffers.
  57024. */
  57025. class NativeDataBuffer extends DataBuffer {
  57026. /**
  57027. * Accessor value used to identify/retrieve a natively-stored index buffer.
  57028. */
  57029. nativeIndexBuffer?: any;
  57030. /**
  57031. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  57032. */
  57033. nativeVertexBuffer?: any;
  57034. }
  57035. /** @hidden */
  57036. class NativeTexture extends InternalTexture {
  57037. getInternalTexture(): InternalTexture;
  57038. getViewCount(): number;
  57039. }
  57040. /** @hidden */
  57041. export class NativeEngine extends Engine {
  57042. private readonly _native;
  57043. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  57044. private readonly INVALID_HANDLE;
  57045. private _boundBuffersVertexArray;
  57046. private _currentDepthTest;
  57047. getHardwareScalingLevel(): number;
  57048. constructor();
  57049. dispose(): void;
  57050. /**
  57051. * Can be used to override the current requestAnimationFrame requester.
  57052. * @hidden
  57053. */
  57054. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  57055. /**
  57056. * Override default engine behavior.
  57057. * @param color
  57058. * @param backBuffer
  57059. * @param depth
  57060. * @param stencil
  57061. */
  57062. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  57063. /**
  57064. * Gets host document
  57065. * @returns the host document object
  57066. */
  57067. getHostDocument(): Nullable<Document>;
  57068. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  57069. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  57070. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  57071. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  57072. [key: string]: VertexBuffer;
  57073. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  57074. bindBuffers(vertexBuffers: {
  57075. [key: string]: VertexBuffer;
  57076. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  57077. recordVertexArrayObject(vertexBuffers: {
  57078. [key: string]: VertexBuffer;
  57079. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  57080. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  57081. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  57082. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  57083. /**
  57084. * Draw a list of indexed primitives
  57085. * @param fillMode defines the primitive to use
  57086. * @param indexStart defines the starting index
  57087. * @param indexCount defines the number of index to draw
  57088. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57089. */
  57090. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  57091. /**
  57092. * Draw a list of unindexed primitives
  57093. * @param fillMode defines the primitive to use
  57094. * @param verticesStart defines the index of first vertex to draw
  57095. * @param verticesCount defines the count of vertices to draw
  57096. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57097. */
  57098. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  57099. createPipelineContext(): IPipelineContext;
  57100. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  57101. /** @hidden */
  57102. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  57103. /** @hidden */
  57104. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  57105. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  57106. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  57107. protected _setProgram(program: WebGLProgram): void;
  57108. _releaseEffect(effect: Effect): void;
  57109. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  57110. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  57111. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  57112. bindSamplers(effect: Effect): void;
  57113. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  57114. getRenderWidth(useScreen?: boolean): number;
  57115. getRenderHeight(useScreen?: boolean): number;
  57116. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  57117. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  57118. /**
  57119. * Set the z offset to apply to current rendering
  57120. * @param value defines the offset to apply
  57121. */
  57122. setZOffset(value: number): void;
  57123. /**
  57124. * Gets the current value of the zOffset
  57125. * @returns the current zOffset state
  57126. */
  57127. getZOffset(): number;
  57128. /**
  57129. * Enable or disable depth buffering
  57130. * @param enable defines the state to set
  57131. */
  57132. setDepthBuffer(enable: boolean): void;
  57133. /**
  57134. * Gets a boolean indicating if depth writing is enabled
  57135. * @returns the current depth writing state
  57136. */
  57137. getDepthWrite(): boolean;
  57138. setDepthFunctionToGreater(): void;
  57139. setDepthFunctionToGreaterOrEqual(): void;
  57140. setDepthFunctionToLess(): void;
  57141. setDepthFunctionToLessOrEqual(): void;
  57142. /**
  57143. * Enable or disable depth writing
  57144. * @param enable defines the state to set
  57145. */
  57146. setDepthWrite(enable: boolean): void;
  57147. /**
  57148. * Enable or disable color writing
  57149. * @param enable defines the state to set
  57150. */
  57151. setColorWrite(enable: boolean): void;
  57152. /**
  57153. * Gets a boolean indicating if color writing is enabled
  57154. * @returns the current color writing state
  57155. */
  57156. getColorWrite(): boolean;
  57157. /**
  57158. * Sets alpha constants used by some alpha blending modes
  57159. * @param r defines the red component
  57160. * @param g defines the green component
  57161. * @param b defines the blue component
  57162. * @param a defines the alpha component
  57163. */
  57164. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  57165. /**
  57166. * Sets the current alpha mode
  57167. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  57168. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  57169. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  57170. */
  57171. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  57172. /**
  57173. * Gets the current alpha mode
  57174. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  57175. * @returns the current alpha mode
  57176. */
  57177. getAlphaMode(): number;
  57178. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  57179. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57180. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57181. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57182. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57183. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57184. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57185. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57186. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57187. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  57188. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  57189. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  57190. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  57191. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  57192. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57193. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57194. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  57195. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  57196. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  57197. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  57198. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  57199. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  57200. wipeCaches(bruteForce?: boolean): void;
  57201. _createTexture(): WebGLTexture;
  57202. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  57203. /**
  57204. * Update the content of a dynamic texture
  57205. * @param texture defines the texture to update
  57206. * @param canvas defines the canvas containing the source
  57207. * @param invertY defines if data must be stored with Y axis inverted
  57208. * @param premulAlpha defines if alpha is stored as premultiplied
  57209. * @param format defines the format of the data
  57210. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  57211. */
  57212. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  57213. /**
  57214. * Usually called from Texture.ts.
  57215. * Passed information to create a WebGLTexture
  57216. * @param url defines a value which contains one of the following:
  57217. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  57218. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  57219. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  57220. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  57221. * @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)
  57222. * @param scene needed for loading to the correct scene
  57223. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  57224. * @param onLoad optional callback to be called upon successful completion
  57225. * @param onError optional callback to be called upon failure
  57226. * @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
  57227. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  57228. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  57229. * @param forcedExtension defines the extension to use to pick the right loader
  57230. * @param mimeType defines an optional mime type
  57231. * @param loaderOptions options to be passed to the loader
  57232. * @returns a InternalTexture for assignment back into BABYLON.Texture
  57233. */
  57234. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any): InternalTexture;
  57235. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  57236. _releaseFramebufferObjects(texture: InternalTexture): void;
  57237. /**
  57238. * Creates a cube texture
  57239. * @param rootUrl defines the url where the files to load is located
  57240. * @param scene defines the current scene
  57241. * @param files defines the list of files to load (1 per face)
  57242. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  57243. * @param onLoad defines an optional callback raised when the texture is loaded
  57244. * @param onError defines an optional callback raised if there is an issue to load the texture
  57245. * @param format defines the format of the data
  57246. * @param forcedExtension defines the extension to use to pick the right loader
  57247. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  57248. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  57249. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  57250. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  57251. * @returns the cube texture as an InternalTexture
  57252. */
  57253. 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;
  57254. createRenderTargetTexture(size: number | {
  57255. width: number;
  57256. height: number;
  57257. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  57258. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  57259. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  57260. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  57261. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  57262. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  57263. /**
  57264. * Updates a dynamic vertex buffer.
  57265. * @param vertexBuffer the vertex buffer to update
  57266. * @param data the data used to update the vertex buffer
  57267. * @param byteOffset the byte offset of the data (optional)
  57268. * @param byteLength the byte length of the data (optional)
  57269. */
  57270. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  57271. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  57272. private _updateAnisotropicLevel;
  57273. private _getAddressMode;
  57274. /** @hidden */
  57275. _bindTexture(channel: number, texture: InternalTexture): void;
  57276. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  57277. releaseEffects(): void;
  57278. /** @hidden */
  57279. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57280. /** @hidden */
  57281. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57282. /** @hidden */
  57283. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57284. /** @hidden */
  57285. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  57286. private _getNativeSamplingMode;
  57287. private _getNativeTextureFormat;
  57288. private _getNativeAlphaMode;
  57289. private _getNativeAttribType;
  57290. }
  57291. }
  57292. declare module BABYLON {
  57293. /**
  57294. * Gather the list of clipboard event types as constants.
  57295. */
  57296. export class ClipboardEventTypes {
  57297. /**
  57298. * The clipboard event is fired when a copy command is active (pressed).
  57299. */
  57300. static readonly COPY: number;
  57301. /**
  57302. * The clipboard event is fired when a cut command is active (pressed).
  57303. */
  57304. static readonly CUT: number;
  57305. /**
  57306. * The clipboard event is fired when a paste command is active (pressed).
  57307. */
  57308. static readonly PASTE: number;
  57309. }
  57310. /**
  57311. * This class is used to store clipboard related info for the onClipboardObservable event.
  57312. */
  57313. export class ClipboardInfo {
  57314. /**
  57315. * Defines the type of event (BABYLON.ClipboardEventTypes)
  57316. */
  57317. type: number;
  57318. /**
  57319. * Defines the related dom event
  57320. */
  57321. event: ClipboardEvent;
  57322. /**
  57323. *Creates an instance of ClipboardInfo.
  57324. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  57325. * @param event Defines the related dom event
  57326. */
  57327. constructor(
  57328. /**
  57329. * Defines the type of event (BABYLON.ClipboardEventTypes)
  57330. */
  57331. type: number,
  57332. /**
  57333. * Defines the related dom event
  57334. */
  57335. event: ClipboardEvent);
  57336. /**
  57337. * Get the clipboard event's type from the keycode.
  57338. * @param keyCode Defines the keyCode for the current keyboard event.
  57339. * @return {number}
  57340. */
  57341. static GetTypeFromCharacter(keyCode: number): number;
  57342. }
  57343. }
  57344. declare module BABYLON {
  57345. /**
  57346. * Google Daydream controller
  57347. */
  57348. export class DaydreamController extends WebVRController {
  57349. /**
  57350. * Base Url for the controller model.
  57351. */
  57352. static MODEL_BASE_URL: string;
  57353. /**
  57354. * File name for the controller model.
  57355. */
  57356. static MODEL_FILENAME: string;
  57357. /**
  57358. * Gamepad Id prefix used to identify Daydream Controller.
  57359. */
  57360. static readonly GAMEPAD_ID_PREFIX: string;
  57361. /**
  57362. * Creates a new DaydreamController from a gamepad
  57363. * @param vrGamepad the gamepad that the controller should be created from
  57364. */
  57365. constructor(vrGamepad: any);
  57366. /**
  57367. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57368. * @param scene scene in which to add meshes
  57369. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57370. */
  57371. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57372. /**
  57373. * Called once for each button that changed state since the last frame
  57374. * @param buttonIdx Which button index changed
  57375. * @param state New state of the button
  57376. * @param changes Which properties on the state changed since last frame
  57377. */
  57378. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57379. }
  57380. }
  57381. declare module BABYLON {
  57382. /**
  57383. * Gear VR Controller
  57384. */
  57385. export class GearVRController extends WebVRController {
  57386. /**
  57387. * Base Url for the controller model.
  57388. */
  57389. static MODEL_BASE_URL: string;
  57390. /**
  57391. * File name for the controller model.
  57392. */
  57393. static MODEL_FILENAME: string;
  57394. /**
  57395. * Gamepad Id prefix used to identify this controller.
  57396. */
  57397. static readonly GAMEPAD_ID_PREFIX: string;
  57398. private readonly _buttonIndexToObservableNameMap;
  57399. /**
  57400. * Creates a new GearVRController from a gamepad
  57401. * @param vrGamepad the gamepad that the controller should be created from
  57402. */
  57403. constructor(vrGamepad: any);
  57404. /**
  57405. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57406. * @param scene scene in which to add meshes
  57407. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57408. */
  57409. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57410. /**
  57411. * Called once for each button that changed state since the last frame
  57412. * @param buttonIdx Which button index changed
  57413. * @param state New state of the button
  57414. * @param changes Which properties on the state changed since last frame
  57415. */
  57416. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57417. }
  57418. }
  57419. declare module BABYLON {
  57420. /**
  57421. * Generic Controller
  57422. */
  57423. export class GenericController extends WebVRController {
  57424. /**
  57425. * Base Url for the controller model.
  57426. */
  57427. static readonly MODEL_BASE_URL: string;
  57428. /**
  57429. * File name for the controller model.
  57430. */
  57431. static readonly MODEL_FILENAME: string;
  57432. /**
  57433. * Creates a new GenericController from a gamepad
  57434. * @param vrGamepad the gamepad that the controller should be created from
  57435. */
  57436. constructor(vrGamepad: any);
  57437. /**
  57438. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57439. * @param scene scene in which to add meshes
  57440. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57441. */
  57442. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57443. /**
  57444. * Called once for each button that changed state since the last frame
  57445. * @param buttonIdx Which button index changed
  57446. * @param state New state of the button
  57447. * @param changes Which properties on the state changed since last frame
  57448. */
  57449. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57450. }
  57451. }
  57452. declare module BABYLON {
  57453. /**
  57454. * Oculus Touch Controller
  57455. */
  57456. export class OculusTouchController extends WebVRController {
  57457. /**
  57458. * Base Url for the controller model.
  57459. */
  57460. static MODEL_BASE_URL: string;
  57461. /**
  57462. * File name for the left controller model.
  57463. */
  57464. static MODEL_LEFT_FILENAME: string;
  57465. /**
  57466. * File name for the right controller model.
  57467. */
  57468. static MODEL_RIGHT_FILENAME: string;
  57469. /**
  57470. * Base Url for the Quest controller model.
  57471. */
  57472. static QUEST_MODEL_BASE_URL: string;
  57473. /**
  57474. * @hidden
  57475. * If the controllers are running on a device that needs the updated Quest controller models
  57476. */
  57477. static _IsQuest: boolean;
  57478. /**
  57479. * Fired when the secondary trigger on this controller is modified
  57480. */
  57481. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  57482. /**
  57483. * Fired when the thumb rest on this controller is modified
  57484. */
  57485. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  57486. /**
  57487. * Creates a new OculusTouchController from a gamepad
  57488. * @param vrGamepad the gamepad that the controller should be created from
  57489. */
  57490. constructor(vrGamepad: any);
  57491. /**
  57492. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57493. * @param scene scene in which to add meshes
  57494. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57495. */
  57496. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57497. /**
  57498. * Fired when the A button on this controller is modified
  57499. */
  57500. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57501. /**
  57502. * Fired when the B button on this controller is modified
  57503. */
  57504. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57505. /**
  57506. * Fired when the X button on this controller is modified
  57507. */
  57508. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57509. /**
  57510. * Fired when the Y button on this controller is modified
  57511. */
  57512. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57513. /**
  57514. * Called once for each button that changed state since the last frame
  57515. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  57516. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  57517. * 2) secondary trigger (same)
  57518. * 3) A (right) X (left), touch, pressed = value
  57519. * 4) B / Y
  57520. * 5) thumb rest
  57521. * @param buttonIdx Which button index changed
  57522. * @param state New state of the button
  57523. * @param changes Which properties on the state changed since last frame
  57524. */
  57525. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57526. }
  57527. }
  57528. declare module BABYLON {
  57529. /**
  57530. * Vive Controller
  57531. */
  57532. export class ViveController extends WebVRController {
  57533. /**
  57534. * Base Url for the controller model.
  57535. */
  57536. static MODEL_BASE_URL: string;
  57537. /**
  57538. * File name for the controller model.
  57539. */
  57540. static MODEL_FILENAME: string;
  57541. /**
  57542. * Creates a new ViveController from a gamepad
  57543. * @param vrGamepad the gamepad that the controller should be created from
  57544. */
  57545. constructor(vrGamepad: any);
  57546. /**
  57547. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57548. * @param scene scene in which to add meshes
  57549. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57550. */
  57551. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57552. /**
  57553. * Fired when the left button on this controller is modified
  57554. */
  57555. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57556. /**
  57557. * Fired when the right button on this controller is modified
  57558. */
  57559. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57560. /**
  57561. * Fired when the menu button on this controller is modified
  57562. */
  57563. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57564. /**
  57565. * Called once for each button that changed state since the last frame
  57566. * Vive mapping:
  57567. * 0: touchpad
  57568. * 1: trigger
  57569. * 2: left AND right buttons
  57570. * 3: menu button
  57571. * @param buttonIdx Which button index changed
  57572. * @param state New state of the button
  57573. * @param changes Which properties on the state changed since last frame
  57574. */
  57575. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57576. }
  57577. }
  57578. declare module BABYLON {
  57579. /**
  57580. * Defines the WindowsMotionController object that the state of the windows motion controller
  57581. */
  57582. export class WindowsMotionController extends WebVRController {
  57583. /**
  57584. * The base url used to load the left and right controller models
  57585. */
  57586. static MODEL_BASE_URL: string;
  57587. /**
  57588. * The name of the left controller model file
  57589. */
  57590. static MODEL_LEFT_FILENAME: string;
  57591. /**
  57592. * The name of the right controller model file
  57593. */
  57594. static MODEL_RIGHT_FILENAME: string;
  57595. /**
  57596. * The controller name prefix for this controller type
  57597. */
  57598. static readonly GAMEPAD_ID_PREFIX: string;
  57599. /**
  57600. * The controller id pattern for this controller type
  57601. */
  57602. private static readonly GAMEPAD_ID_PATTERN;
  57603. private _loadedMeshInfo;
  57604. protected readonly _mapping: {
  57605. buttons: string[];
  57606. buttonMeshNames: {
  57607. trigger: string;
  57608. menu: string;
  57609. grip: string;
  57610. thumbstick: string;
  57611. trackpad: string;
  57612. };
  57613. buttonObservableNames: {
  57614. trigger: string;
  57615. menu: string;
  57616. grip: string;
  57617. thumbstick: string;
  57618. trackpad: string;
  57619. };
  57620. axisMeshNames: string[];
  57621. pointingPoseMeshName: string;
  57622. };
  57623. /**
  57624. * Fired when the trackpad on this controller is clicked
  57625. */
  57626. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  57627. /**
  57628. * Fired when the trackpad on this controller is modified
  57629. */
  57630. onTrackpadValuesChangedObservable: Observable<StickValues>;
  57631. /**
  57632. * The current x and y values of this controller's trackpad
  57633. */
  57634. trackpad: StickValues;
  57635. /**
  57636. * Creates a new WindowsMotionController from a gamepad
  57637. * @param vrGamepad the gamepad that the controller should be created from
  57638. */
  57639. constructor(vrGamepad: any);
  57640. /**
  57641. * Fired when the trigger on this controller is modified
  57642. */
  57643. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57644. /**
  57645. * Fired when the menu button on this controller is modified
  57646. */
  57647. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57648. /**
  57649. * Fired when the grip button on this controller is modified
  57650. */
  57651. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57652. /**
  57653. * Fired when the thumbstick button on this controller is modified
  57654. */
  57655. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57656. /**
  57657. * Fired when the touchpad button on this controller is modified
  57658. */
  57659. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57660. /**
  57661. * Fired when the touchpad values on this controller are modified
  57662. */
  57663. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  57664. protected _updateTrackpad(): void;
  57665. /**
  57666. * Called once per frame by the engine.
  57667. */
  57668. update(): void;
  57669. /**
  57670. * Called once for each button that changed state since the last frame
  57671. * @param buttonIdx Which button index changed
  57672. * @param state New state of the button
  57673. * @param changes Which properties on the state changed since last frame
  57674. */
  57675. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57676. /**
  57677. * Moves the buttons on the controller mesh based on their current state
  57678. * @param buttonName the name of the button to move
  57679. * @param buttonValue the value of the button which determines the buttons new position
  57680. */
  57681. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  57682. /**
  57683. * Moves the axis on the controller mesh based on its current state
  57684. * @param axis the index of the axis
  57685. * @param axisValue the value of the axis which determines the meshes new position
  57686. * @hidden
  57687. */
  57688. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  57689. /**
  57690. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57691. * @param scene scene in which to add meshes
  57692. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57693. */
  57694. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  57695. /**
  57696. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  57697. * can be transformed by button presses and axes values, based on this._mapping.
  57698. *
  57699. * @param scene scene in which the meshes exist
  57700. * @param meshes list of meshes that make up the controller model to process
  57701. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  57702. */
  57703. private processModel;
  57704. private createMeshInfo;
  57705. /**
  57706. * Gets the ray of the controller in the direction the controller is pointing
  57707. * @param length the length the resulting ray should be
  57708. * @returns a ray in the direction the controller is pointing
  57709. */
  57710. getForwardRay(length?: number): Ray;
  57711. /**
  57712. * Disposes of the controller
  57713. */
  57714. dispose(): void;
  57715. }
  57716. /**
  57717. * This class represents a new windows motion controller in XR.
  57718. */
  57719. export class XRWindowsMotionController extends WindowsMotionController {
  57720. /**
  57721. * Changing the original WIndowsMotionController mapping to fir the new mapping
  57722. */
  57723. protected readonly _mapping: {
  57724. buttons: string[];
  57725. buttonMeshNames: {
  57726. trigger: string;
  57727. menu: string;
  57728. grip: string;
  57729. thumbstick: string;
  57730. trackpad: string;
  57731. };
  57732. buttonObservableNames: {
  57733. trigger: string;
  57734. menu: string;
  57735. grip: string;
  57736. thumbstick: string;
  57737. trackpad: string;
  57738. };
  57739. axisMeshNames: string[];
  57740. pointingPoseMeshName: string;
  57741. };
  57742. /**
  57743. * Construct a new XR-Based windows motion controller
  57744. *
  57745. * @param gamepadInfo the gamepad object from the browser
  57746. */
  57747. constructor(gamepadInfo: any);
  57748. /**
  57749. * holds the thumbstick values (X,Y)
  57750. */
  57751. thumbstickValues: StickValues;
  57752. /**
  57753. * Fired when the thumbstick on this controller is clicked
  57754. */
  57755. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  57756. /**
  57757. * Fired when the thumbstick on this controller is modified
  57758. */
  57759. onThumbstickValuesChangedObservable: Observable<StickValues>;
  57760. /**
  57761. * Fired when the touchpad button on this controller is modified
  57762. */
  57763. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  57764. /**
  57765. * Fired when the touchpad values on this controller are modified
  57766. */
  57767. onTrackpadValuesChangedObservable: Observable<StickValues>;
  57768. /**
  57769. * Fired when the thumbstick button on this controller is modified
  57770. * here to prevent breaking changes
  57771. */
  57772. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57773. /**
  57774. * updating the thumbstick(!) and not the trackpad.
  57775. * This is named this way due to the difference between WebVR and XR and to avoid
  57776. * changing the parent class.
  57777. */
  57778. protected _updateTrackpad(): void;
  57779. /**
  57780. * Disposes the class with joy
  57781. */
  57782. dispose(): void;
  57783. }
  57784. }
  57785. declare module BABYLON {
  57786. /**
  57787. * A directional light is defined by a direction (what a surprise!).
  57788. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  57789. * 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.
  57790. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57791. */
  57792. export class DirectionalLight extends ShadowLight {
  57793. private _shadowFrustumSize;
  57794. /**
  57795. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  57796. */
  57797. get shadowFrustumSize(): number;
  57798. /**
  57799. * Specifies a fix frustum size for the shadow generation.
  57800. */
  57801. set shadowFrustumSize(value: number);
  57802. private _shadowOrthoScale;
  57803. /**
  57804. * Gets the shadow projection scale against the optimal computed one.
  57805. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  57806. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  57807. */
  57808. get shadowOrthoScale(): number;
  57809. /**
  57810. * Sets the shadow projection scale against the optimal computed one.
  57811. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  57812. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  57813. */
  57814. set shadowOrthoScale(value: number);
  57815. /**
  57816. * Automatically compute the projection matrix to best fit (including all the casters)
  57817. * on each frame.
  57818. */
  57819. autoUpdateExtends: boolean;
  57820. /**
  57821. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  57822. * on each frame. autoUpdateExtends must be set to true for this to work
  57823. */
  57824. autoCalcShadowZBounds: boolean;
  57825. private _orthoLeft;
  57826. private _orthoRight;
  57827. private _orthoTop;
  57828. private _orthoBottom;
  57829. /**
  57830. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  57831. * The directional light is emitted from everywhere in the given direction.
  57832. * It can cast shadows.
  57833. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57834. * @param name The friendly name of the light
  57835. * @param direction The direction of the light
  57836. * @param scene The scene the light belongs to
  57837. */
  57838. constructor(name: string, direction: Vector3, scene: Scene);
  57839. /**
  57840. * Returns the string "DirectionalLight".
  57841. * @return The class name
  57842. */
  57843. getClassName(): string;
  57844. /**
  57845. * Returns the integer 1.
  57846. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57847. */
  57848. getTypeID(): number;
  57849. /**
  57850. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  57851. * Returns the DirectionalLight Shadow projection matrix.
  57852. */
  57853. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57854. /**
  57855. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  57856. * Returns the DirectionalLight Shadow projection matrix.
  57857. */
  57858. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  57859. /**
  57860. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  57861. * Returns the DirectionalLight Shadow projection matrix.
  57862. */
  57863. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57864. protected _buildUniformLayout(): void;
  57865. /**
  57866. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  57867. * @param effect The effect to update
  57868. * @param lightIndex The index of the light in the effect to update
  57869. * @returns The directional light
  57870. */
  57871. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  57872. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  57873. /**
  57874. * Gets the minZ used for shadow according to both the scene and the light.
  57875. *
  57876. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  57877. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  57878. * @param activeCamera The camera we are returning the min for
  57879. * @returns the depth min z
  57880. */
  57881. getDepthMinZ(activeCamera: Camera): number;
  57882. /**
  57883. * Gets the maxZ used for shadow according to both the scene and the light.
  57884. *
  57885. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  57886. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  57887. * @param activeCamera The camera we are returning the max for
  57888. * @returns the depth max z
  57889. */
  57890. getDepthMaxZ(activeCamera: Camera): number;
  57891. /**
  57892. * Prepares the list of defines specific to the light type.
  57893. * @param defines the list of defines
  57894. * @param lightIndex defines the index of the light for the effect
  57895. */
  57896. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57897. }
  57898. }
  57899. declare module BABYLON {
  57900. /**
  57901. * Class containing static functions to help procedurally build meshes
  57902. */
  57903. export class HemisphereBuilder {
  57904. /**
  57905. * Creates a hemisphere mesh
  57906. * @param name defines the name of the mesh
  57907. * @param options defines the options used to create the mesh
  57908. * @param scene defines the hosting scene
  57909. * @returns the hemisphere mesh
  57910. */
  57911. static CreateHemisphere(name: string, options: {
  57912. segments?: number;
  57913. diameter?: number;
  57914. sideOrientation?: number;
  57915. }, scene: any): Mesh;
  57916. }
  57917. }
  57918. declare module BABYLON {
  57919. /**
  57920. * A spot light is defined by a position, a direction, an angle, and an exponent.
  57921. * These values define a cone of light starting from the position, emitting toward the direction.
  57922. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  57923. * and the exponent defines the speed of the decay of the light with distance (reach).
  57924. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57925. */
  57926. export class SpotLight extends ShadowLight {
  57927. private _angle;
  57928. private _innerAngle;
  57929. private _cosHalfAngle;
  57930. private _lightAngleScale;
  57931. private _lightAngleOffset;
  57932. /**
  57933. * Gets the cone angle of the spot light in Radians.
  57934. */
  57935. get angle(): number;
  57936. /**
  57937. * Sets the cone angle of the spot light in Radians.
  57938. */
  57939. set angle(value: number);
  57940. /**
  57941. * Only used in gltf falloff mode, this defines the angle where
  57942. * the directional falloff will start before cutting at angle which could be seen
  57943. * as outer angle.
  57944. */
  57945. get innerAngle(): number;
  57946. /**
  57947. * Only used in gltf falloff mode, this defines the angle where
  57948. * the directional falloff will start before cutting at angle which could be seen
  57949. * as outer angle.
  57950. */
  57951. set innerAngle(value: number);
  57952. private _shadowAngleScale;
  57953. /**
  57954. * Allows scaling the angle of the light for shadow generation only.
  57955. */
  57956. get shadowAngleScale(): number;
  57957. /**
  57958. * Allows scaling the angle of the light for shadow generation only.
  57959. */
  57960. set shadowAngleScale(value: number);
  57961. /**
  57962. * The light decay speed with the distance from the emission spot.
  57963. */
  57964. exponent: number;
  57965. private _projectionTextureMatrix;
  57966. /**
  57967. * Allows reading the projecton texture
  57968. */
  57969. get projectionTextureMatrix(): Matrix;
  57970. protected _projectionTextureLightNear: number;
  57971. /**
  57972. * Gets the near clip of the Spotlight for texture projection.
  57973. */
  57974. get projectionTextureLightNear(): number;
  57975. /**
  57976. * Sets the near clip of the Spotlight for texture projection.
  57977. */
  57978. set projectionTextureLightNear(value: number);
  57979. protected _projectionTextureLightFar: number;
  57980. /**
  57981. * Gets the far clip of the Spotlight for texture projection.
  57982. */
  57983. get projectionTextureLightFar(): number;
  57984. /**
  57985. * Sets the far clip of the Spotlight for texture projection.
  57986. */
  57987. set projectionTextureLightFar(value: number);
  57988. protected _projectionTextureUpDirection: Vector3;
  57989. /**
  57990. * Gets the Up vector of the Spotlight for texture projection.
  57991. */
  57992. get projectionTextureUpDirection(): Vector3;
  57993. /**
  57994. * Sets the Up vector of the Spotlight for texture projection.
  57995. */
  57996. set projectionTextureUpDirection(value: Vector3);
  57997. private _projectionTexture;
  57998. /**
  57999. * Gets the projection texture of the light.
  58000. */
  58001. get projectionTexture(): Nullable<BaseTexture>;
  58002. /**
  58003. * Sets the projection texture of the light.
  58004. */
  58005. set projectionTexture(value: Nullable<BaseTexture>);
  58006. private static _IsProceduralTexture;
  58007. private static _IsTexture;
  58008. private _projectionTextureViewLightDirty;
  58009. private _projectionTextureProjectionLightDirty;
  58010. private _projectionTextureDirty;
  58011. private _projectionTextureViewTargetVector;
  58012. private _projectionTextureViewLightMatrix;
  58013. private _projectionTextureProjectionLightMatrix;
  58014. private _projectionTextureScalingMatrix;
  58015. /**
  58016. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  58017. * It can cast shadows.
  58018. * Documentation : https://doc.babylonjs.com/babylon101/lights
  58019. * @param name The light friendly name
  58020. * @param position The position of the spot light in the scene
  58021. * @param direction The direction of the light in the scene
  58022. * @param angle The cone angle of the light in Radians
  58023. * @param exponent The light decay speed with the distance from the emission spot
  58024. * @param scene The scene the lights belongs to
  58025. */
  58026. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  58027. /**
  58028. * Returns the string "SpotLight".
  58029. * @returns the class name
  58030. */
  58031. getClassName(): string;
  58032. /**
  58033. * Returns the integer 2.
  58034. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  58035. */
  58036. getTypeID(): number;
  58037. /**
  58038. * Overrides the direction setter to recompute the projection texture view light Matrix.
  58039. */
  58040. protected _setDirection(value: Vector3): void;
  58041. /**
  58042. * Overrides the position setter to recompute the projection texture view light Matrix.
  58043. */
  58044. protected _setPosition(value: Vector3): void;
  58045. /**
  58046. * 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.
  58047. * Returns the SpotLight.
  58048. */
  58049. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  58050. protected _computeProjectionTextureViewLightMatrix(): void;
  58051. protected _computeProjectionTextureProjectionLightMatrix(): void;
  58052. /**
  58053. * Main function for light texture projection matrix computing.
  58054. */
  58055. protected _computeProjectionTextureMatrix(): void;
  58056. protected _buildUniformLayout(): void;
  58057. private _computeAngleValues;
  58058. /**
  58059. * Sets the passed Effect "effect" with the Light textures.
  58060. * @param effect The effect to update
  58061. * @param lightIndex The index of the light in the effect to update
  58062. * @returns The light
  58063. */
  58064. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  58065. /**
  58066. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  58067. * @param effect The effect to update
  58068. * @param lightIndex The index of the light in the effect to update
  58069. * @returns The spot light
  58070. */
  58071. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  58072. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  58073. /**
  58074. * Disposes the light and the associated resources.
  58075. */
  58076. dispose(): void;
  58077. /**
  58078. * Prepares the list of defines specific to the light type.
  58079. * @param defines the list of defines
  58080. * @param lightIndex defines the index of the light for the effect
  58081. */
  58082. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  58083. }
  58084. }
  58085. declare module BABYLON {
  58086. /**
  58087. * Gizmo that enables viewing a light
  58088. */
  58089. export class LightGizmo extends Gizmo {
  58090. private _lightMesh;
  58091. private _material;
  58092. private _cachedPosition;
  58093. private _cachedForward;
  58094. private _attachedMeshParent;
  58095. private _pointerObserver;
  58096. /**
  58097. * Event that fires each time the gizmo is clicked
  58098. */
  58099. onClickedObservable: Observable<Light>;
  58100. /**
  58101. * Creates a LightGizmo
  58102. * @param gizmoLayer The utility layer the gizmo will be added to
  58103. */
  58104. constructor(gizmoLayer?: UtilityLayerRenderer);
  58105. private _light;
  58106. /**
  58107. * The light that the gizmo is attached to
  58108. */
  58109. set light(light: Nullable<Light>);
  58110. get light(): Nullable<Light>;
  58111. /**
  58112. * Gets the material used to render the light gizmo
  58113. */
  58114. get material(): StandardMaterial;
  58115. /**
  58116. * @hidden
  58117. * Updates the gizmo to match the attached mesh's position/rotation
  58118. */
  58119. protected _update(): void;
  58120. private static _Scale;
  58121. /**
  58122. * Creates the lines for a light mesh
  58123. */
  58124. private static _CreateLightLines;
  58125. /**
  58126. * Disposes of the light gizmo
  58127. */
  58128. dispose(): void;
  58129. private static _CreateHemisphericLightMesh;
  58130. private static _CreatePointLightMesh;
  58131. private static _CreateSpotLightMesh;
  58132. private static _CreateDirectionalLightMesh;
  58133. }
  58134. }
  58135. declare module BABYLON {
  58136. /**
  58137. * Gizmo that enables viewing a camera
  58138. */
  58139. export class CameraGizmo extends Gizmo {
  58140. private _cameraMesh;
  58141. private _cameraLinesMesh;
  58142. private _material;
  58143. private _pointerObserver;
  58144. /**
  58145. * Event that fires each time the gizmo is clicked
  58146. */
  58147. onClickedObservable: Observable<Camera>;
  58148. /**
  58149. * Creates a CameraGizmo
  58150. * @param gizmoLayer The utility layer the gizmo will be added to
  58151. */
  58152. constructor(gizmoLayer?: UtilityLayerRenderer);
  58153. private _camera;
  58154. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  58155. get displayFrustum(): boolean;
  58156. set displayFrustum(value: boolean);
  58157. /**
  58158. * The camera that the gizmo is attached to
  58159. */
  58160. set camera(camera: Nullable<Camera>);
  58161. get camera(): Nullable<Camera>;
  58162. /**
  58163. * Gets the material used to render the camera gizmo
  58164. */
  58165. get material(): StandardMaterial;
  58166. /**
  58167. * @hidden
  58168. * Updates the gizmo to match the attached mesh's position/rotation
  58169. */
  58170. protected _update(): void;
  58171. private static _Scale;
  58172. private _invProjection;
  58173. /**
  58174. * Disposes of the camera gizmo
  58175. */
  58176. dispose(): void;
  58177. private static _CreateCameraMesh;
  58178. private static _CreateCameraFrustum;
  58179. }
  58180. }
  58181. declare module BABYLON {
  58182. /** @hidden */
  58183. export var backgroundFragmentDeclaration: {
  58184. name: string;
  58185. shader: string;
  58186. };
  58187. }
  58188. declare module BABYLON {
  58189. /** @hidden */
  58190. export var backgroundUboDeclaration: {
  58191. name: string;
  58192. shader: string;
  58193. };
  58194. }
  58195. declare module BABYLON {
  58196. /** @hidden */
  58197. export var backgroundPixelShader: {
  58198. name: string;
  58199. shader: string;
  58200. };
  58201. }
  58202. declare module BABYLON {
  58203. /** @hidden */
  58204. export var backgroundVertexDeclaration: {
  58205. name: string;
  58206. shader: string;
  58207. };
  58208. }
  58209. declare module BABYLON {
  58210. /** @hidden */
  58211. export var backgroundVertexShader: {
  58212. name: string;
  58213. shader: string;
  58214. };
  58215. }
  58216. declare module BABYLON {
  58217. /**
  58218. * Background material used to create an efficient environement around your scene.
  58219. */
  58220. export class BackgroundMaterial extends PushMaterial {
  58221. /**
  58222. * Standard reflectance value at parallel view angle.
  58223. */
  58224. static StandardReflectance0: number;
  58225. /**
  58226. * Standard reflectance value at grazing angle.
  58227. */
  58228. static StandardReflectance90: number;
  58229. protected _primaryColor: Color3;
  58230. /**
  58231. * Key light Color (multiply against the environement texture)
  58232. */
  58233. primaryColor: Color3;
  58234. protected __perceptualColor: Nullable<Color3>;
  58235. /**
  58236. * Experimental Internal Use Only.
  58237. *
  58238. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  58239. * This acts as a helper to set the primary color to a more "human friendly" value.
  58240. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  58241. * output color as close as possible from the chosen value.
  58242. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  58243. * part of lighting setup.)
  58244. */
  58245. get _perceptualColor(): Nullable<Color3>;
  58246. set _perceptualColor(value: Nullable<Color3>);
  58247. protected _primaryColorShadowLevel: float;
  58248. /**
  58249. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  58250. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  58251. */
  58252. get primaryColorShadowLevel(): float;
  58253. set primaryColorShadowLevel(value: float);
  58254. protected _primaryColorHighlightLevel: float;
  58255. /**
  58256. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  58257. * The primary color is used at the level chosen to define what the white area would look.
  58258. */
  58259. get primaryColorHighlightLevel(): float;
  58260. set primaryColorHighlightLevel(value: float);
  58261. protected _reflectionTexture: Nullable<BaseTexture>;
  58262. /**
  58263. * Reflection Texture used in the material.
  58264. * Should be author in a specific way for the best result (refer to the documentation).
  58265. */
  58266. reflectionTexture: Nullable<BaseTexture>;
  58267. protected _reflectionBlur: float;
  58268. /**
  58269. * Reflection Texture level of blur.
  58270. *
  58271. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  58272. * texture twice.
  58273. */
  58274. reflectionBlur: float;
  58275. protected _diffuseTexture: Nullable<BaseTexture>;
  58276. /**
  58277. * Diffuse Texture used in the material.
  58278. * Should be author in a specific way for the best result (refer to the documentation).
  58279. */
  58280. diffuseTexture: Nullable<BaseTexture>;
  58281. protected _shadowLights: Nullable<IShadowLight[]>;
  58282. /**
  58283. * Specify the list of lights casting shadow on the material.
  58284. * All scene shadow lights will be included if null.
  58285. */
  58286. shadowLights: Nullable<IShadowLight[]>;
  58287. protected _shadowLevel: float;
  58288. /**
  58289. * Helps adjusting the shadow to a softer level if required.
  58290. * 0 means black shadows and 1 means no shadows.
  58291. */
  58292. shadowLevel: float;
  58293. protected _sceneCenter: Vector3;
  58294. /**
  58295. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  58296. * It is usually zero but might be interesting to modify according to your setup.
  58297. */
  58298. sceneCenter: Vector3;
  58299. protected _opacityFresnel: boolean;
  58300. /**
  58301. * This helps specifying that the material is falling off to the sky box at grazing angle.
  58302. * This helps ensuring a nice transition when the camera goes under the ground.
  58303. */
  58304. opacityFresnel: boolean;
  58305. protected _reflectionFresnel: boolean;
  58306. /**
  58307. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  58308. * This helps adding a mirror texture on the ground.
  58309. */
  58310. reflectionFresnel: boolean;
  58311. protected _reflectionFalloffDistance: number;
  58312. /**
  58313. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  58314. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  58315. */
  58316. reflectionFalloffDistance: number;
  58317. protected _reflectionAmount: number;
  58318. /**
  58319. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  58320. */
  58321. reflectionAmount: number;
  58322. protected _reflectionReflectance0: number;
  58323. /**
  58324. * This specifies the weight of the reflection at grazing angle.
  58325. */
  58326. reflectionReflectance0: number;
  58327. protected _reflectionReflectance90: number;
  58328. /**
  58329. * This specifies the weight of the reflection at a perpendicular point of view.
  58330. */
  58331. reflectionReflectance90: number;
  58332. /**
  58333. * Sets the reflection reflectance fresnel values according to the default standard
  58334. * empirically know to work well :-)
  58335. */
  58336. set reflectionStandardFresnelWeight(value: number);
  58337. protected _useRGBColor: boolean;
  58338. /**
  58339. * Helps to directly use the maps channels instead of their level.
  58340. */
  58341. useRGBColor: boolean;
  58342. protected _enableNoise: boolean;
  58343. /**
  58344. * This helps reducing the banding effect that could occur on the background.
  58345. */
  58346. enableNoise: boolean;
  58347. /**
  58348. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  58349. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  58350. * Recommended to be keep at 1.0 except for special cases.
  58351. */
  58352. get fovMultiplier(): number;
  58353. set fovMultiplier(value: number);
  58354. private _fovMultiplier;
  58355. /**
  58356. * Enable the FOV adjustment feature controlled by fovMultiplier.
  58357. */
  58358. useEquirectangularFOV: boolean;
  58359. private _maxSimultaneousLights;
  58360. /**
  58361. * Number of Simultaneous lights allowed on the material.
  58362. */
  58363. maxSimultaneousLights: int;
  58364. private _shadowOnly;
  58365. /**
  58366. * Make the material only render shadows
  58367. */
  58368. shadowOnly: boolean;
  58369. /**
  58370. * Default configuration related to image processing available in the Background Material.
  58371. */
  58372. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  58373. /**
  58374. * Keep track of the image processing observer to allow dispose and replace.
  58375. */
  58376. private _imageProcessingObserver;
  58377. /**
  58378. * Attaches a new image processing configuration to the PBR Material.
  58379. * @param configuration (if null the scene configuration will be use)
  58380. */
  58381. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  58382. /**
  58383. * Gets the image processing configuration used either in this material.
  58384. */
  58385. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  58386. /**
  58387. * Sets the Default image processing configuration used either in the this material.
  58388. *
  58389. * If sets to null, the scene one is in use.
  58390. */
  58391. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  58392. /**
  58393. * Gets wether the color curves effect is enabled.
  58394. */
  58395. get cameraColorCurvesEnabled(): boolean;
  58396. /**
  58397. * Sets wether the color curves effect is enabled.
  58398. */
  58399. set cameraColorCurvesEnabled(value: boolean);
  58400. /**
  58401. * Gets wether the color grading effect is enabled.
  58402. */
  58403. get cameraColorGradingEnabled(): boolean;
  58404. /**
  58405. * Gets wether the color grading effect is enabled.
  58406. */
  58407. set cameraColorGradingEnabled(value: boolean);
  58408. /**
  58409. * Gets wether tonemapping is enabled or not.
  58410. */
  58411. get cameraToneMappingEnabled(): boolean;
  58412. /**
  58413. * Sets wether tonemapping is enabled or not
  58414. */
  58415. set cameraToneMappingEnabled(value: boolean);
  58416. /**
  58417. * The camera exposure used on this material.
  58418. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58419. * This corresponds to a photographic exposure.
  58420. */
  58421. get cameraExposure(): float;
  58422. /**
  58423. * The camera exposure used on this material.
  58424. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58425. * This corresponds to a photographic exposure.
  58426. */
  58427. set cameraExposure(value: float);
  58428. /**
  58429. * Gets The camera contrast used on this material.
  58430. */
  58431. get cameraContrast(): float;
  58432. /**
  58433. * Sets The camera contrast used on this material.
  58434. */
  58435. set cameraContrast(value: float);
  58436. /**
  58437. * Gets the Color Grading 2D Lookup Texture.
  58438. */
  58439. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  58440. /**
  58441. * Sets the Color Grading 2D Lookup Texture.
  58442. */
  58443. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  58444. /**
  58445. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58446. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58447. * 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;
  58448. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58449. */
  58450. get cameraColorCurves(): Nullable<ColorCurves>;
  58451. /**
  58452. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58453. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58454. * 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;
  58455. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58456. */
  58457. set cameraColorCurves(value: Nullable<ColorCurves>);
  58458. /**
  58459. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  58460. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  58461. */
  58462. switchToBGR: boolean;
  58463. private _renderTargets;
  58464. private _reflectionControls;
  58465. private _white;
  58466. private _primaryShadowColor;
  58467. private _primaryHighlightColor;
  58468. /**
  58469. * Instantiates a Background Material in the given scene
  58470. * @param name The friendly name of the material
  58471. * @param scene The scene to add the material to
  58472. */
  58473. constructor(name: string, scene: Scene);
  58474. /**
  58475. * Gets a boolean indicating that current material needs to register RTT
  58476. */
  58477. get hasRenderTargetTextures(): boolean;
  58478. /**
  58479. * The entire material has been created in order to prevent overdraw.
  58480. * @returns false
  58481. */
  58482. needAlphaTesting(): boolean;
  58483. /**
  58484. * The entire material has been created in order to prevent overdraw.
  58485. * @returns true if blending is enable
  58486. */
  58487. needAlphaBlending(): boolean;
  58488. /**
  58489. * Checks wether the material is ready to be rendered for a given mesh.
  58490. * @param mesh The mesh to render
  58491. * @param subMesh The submesh to check against
  58492. * @param useInstances Specify wether or not the material is used with instances
  58493. * @returns true if all the dependencies are ready (Textures, Effects...)
  58494. */
  58495. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58496. /**
  58497. * Compute the primary color according to the chosen perceptual color.
  58498. */
  58499. private _computePrimaryColorFromPerceptualColor;
  58500. /**
  58501. * Compute the highlights and shadow colors according to their chosen levels.
  58502. */
  58503. private _computePrimaryColors;
  58504. /**
  58505. * Build the uniform buffer used in the material.
  58506. */
  58507. buildUniformLayout(): void;
  58508. /**
  58509. * Unbind the material.
  58510. */
  58511. unbind(): void;
  58512. /**
  58513. * Bind only the world matrix to the material.
  58514. * @param world The world matrix to bind.
  58515. */
  58516. bindOnlyWorldMatrix(world: Matrix): void;
  58517. /**
  58518. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  58519. * @param world The world matrix to bind.
  58520. * @param subMesh The submesh to bind for.
  58521. */
  58522. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58523. /**
  58524. * Checks to see if a texture is used in the material.
  58525. * @param texture - Base texture to use.
  58526. * @returns - Boolean specifying if a texture is used in the material.
  58527. */
  58528. hasTexture(texture: BaseTexture): boolean;
  58529. /**
  58530. * Dispose the material.
  58531. * @param forceDisposeEffect Force disposal of the associated effect.
  58532. * @param forceDisposeTextures Force disposal of the associated textures.
  58533. */
  58534. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  58535. /**
  58536. * Clones the material.
  58537. * @param name The cloned name.
  58538. * @returns The cloned material.
  58539. */
  58540. clone(name: string): BackgroundMaterial;
  58541. /**
  58542. * Serializes the current material to its JSON representation.
  58543. * @returns The JSON representation.
  58544. */
  58545. serialize(): any;
  58546. /**
  58547. * Gets the class name of the material
  58548. * @returns "BackgroundMaterial"
  58549. */
  58550. getClassName(): string;
  58551. /**
  58552. * Parse a JSON input to create back a background material.
  58553. * @param source The JSON data to parse
  58554. * @param scene The scene to create the parsed material in
  58555. * @param rootUrl The root url of the assets the material depends upon
  58556. * @returns the instantiated BackgroundMaterial.
  58557. */
  58558. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  58559. }
  58560. }
  58561. declare module BABYLON {
  58562. /**
  58563. * Represents the different options available during the creation of
  58564. * a Environment helper.
  58565. *
  58566. * This can control the default ground, skybox and image processing setup of your scene.
  58567. */
  58568. export interface IEnvironmentHelperOptions {
  58569. /**
  58570. * Specifies whether or not to create a ground.
  58571. * True by default.
  58572. */
  58573. createGround: boolean;
  58574. /**
  58575. * Specifies the ground size.
  58576. * 15 by default.
  58577. */
  58578. groundSize: number;
  58579. /**
  58580. * The texture used on the ground for the main color.
  58581. * Comes from the BabylonJS CDN by default.
  58582. *
  58583. * Remarks: Can be either a texture or a url.
  58584. */
  58585. groundTexture: string | BaseTexture;
  58586. /**
  58587. * The color mixed in the ground texture by default.
  58588. * BabylonJS clearColor by default.
  58589. */
  58590. groundColor: Color3;
  58591. /**
  58592. * Specifies the ground opacity.
  58593. * 1 by default.
  58594. */
  58595. groundOpacity: number;
  58596. /**
  58597. * Enables the ground to receive shadows.
  58598. * True by default.
  58599. */
  58600. enableGroundShadow: boolean;
  58601. /**
  58602. * Helps preventing the shadow to be fully black on the ground.
  58603. * 0.5 by default.
  58604. */
  58605. groundShadowLevel: number;
  58606. /**
  58607. * Creates a mirror texture attach to the ground.
  58608. * false by default.
  58609. */
  58610. enableGroundMirror: boolean;
  58611. /**
  58612. * Specifies the ground mirror size ratio.
  58613. * 0.3 by default as the default kernel is 64.
  58614. */
  58615. groundMirrorSizeRatio: number;
  58616. /**
  58617. * Specifies the ground mirror blur kernel size.
  58618. * 64 by default.
  58619. */
  58620. groundMirrorBlurKernel: number;
  58621. /**
  58622. * Specifies the ground mirror visibility amount.
  58623. * 1 by default
  58624. */
  58625. groundMirrorAmount: number;
  58626. /**
  58627. * Specifies the ground mirror reflectance weight.
  58628. * This uses the standard weight of the background material to setup the fresnel effect
  58629. * of the mirror.
  58630. * 1 by default.
  58631. */
  58632. groundMirrorFresnelWeight: number;
  58633. /**
  58634. * Specifies the ground mirror Falloff distance.
  58635. * This can helps reducing the size of the reflection.
  58636. * 0 by Default.
  58637. */
  58638. groundMirrorFallOffDistance: number;
  58639. /**
  58640. * Specifies the ground mirror texture type.
  58641. * Unsigned Int by Default.
  58642. */
  58643. groundMirrorTextureType: number;
  58644. /**
  58645. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  58646. * the shown objects.
  58647. */
  58648. groundYBias: number;
  58649. /**
  58650. * Specifies whether or not to create a skybox.
  58651. * True by default.
  58652. */
  58653. createSkybox: boolean;
  58654. /**
  58655. * Specifies the skybox size.
  58656. * 20 by default.
  58657. */
  58658. skyboxSize: number;
  58659. /**
  58660. * The texture used on the skybox for the main color.
  58661. * Comes from the BabylonJS CDN by default.
  58662. *
  58663. * Remarks: Can be either a texture or a url.
  58664. */
  58665. skyboxTexture: string | BaseTexture;
  58666. /**
  58667. * The color mixed in the skybox texture by default.
  58668. * BabylonJS clearColor by default.
  58669. */
  58670. skyboxColor: Color3;
  58671. /**
  58672. * The background rotation around the Y axis of the scene.
  58673. * This helps aligning the key lights of your scene with the background.
  58674. * 0 by default.
  58675. */
  58676. backgroundYRotation: number;
  58677. /**
  58678. * Compute automatically the size of the elements to best fit with the scene.
  58679. */
  58680. sizeAuto: boolean;
  58681. /**
  58682. * Default position of the rootMesh if autoSize is not true.
  58683. */
  58684. rootPosition: Vector3;
  58685. /**
  58686. * Sets up the image processing in the scene.
  58687. * true by default.
  58688. */
  58689. setupImageProcessing: boolean;
  58690. /**
  58691. * The texture used as your environment texture in the scene.
  58692. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  58693. *
  58694. * Remarks: Can be either a texture or a url.
  58695. */
  58696. environmentTexture: string | BaseTexture;
  58697. /**
  58698. * The value of the exposure to apply to the scene.
  58699. * 0.6 by default if setupImageProcessing is true.
  58700. */
  58701. cameraExposure: number;
  58702. /**
  58703. * The value of the contrast to apply to the scene.
  58704. * 1.6 by default if setupImageProcessing is true.
  58705. */
  58706. cameraContrast: number;
  58707. /**
  58708. * Specifies whether or not tonemapping should be enabled in the scene.
  58709. * true by default if setupImageProcessing is true.
  58710. */
  58711. toneMappingEnabled: boolean;
  58712. }
  58713. /**
  58714. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  58715. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  58716. * It also helps with the default setup of your imageProcessing configuration.
  58717. */
  58718. export class EnvironmentHelper {
  58719. /**
  58720. * Default ground texture URL.
  58721. */
  58722. private static _groundTextureCDNUrl;
  58723. /**
  58724. * Default skybox texture URL.
  58725. */
  58726. private static _skyboxTextureCDNUrl;
  58727. /**
  58728. * Default environment texture URL.
  58729. */
  58730. private static _environmentTextureCDNUrl;
  58731. /**
  58732. * Creates the default options for the helper.
  58733. */
  58734. private static _getDefaultOptions;
  58735. private _rootMesh;
  58736. /**
  58737. * Gets the root mesh created by the helper.
  58738. */
  58739. get rootMesh(): Mesh;
  58740. private _skybox;
  58741. /**
  58742. * Gets the skybox created by the helper.
  58743. */
  58744. get skybox(): Nullable<Mesh>;
  58745. private _skyboxTexture;
  58746. /**
  58747. * Gets the skybox texture created by the helper.
  58748. */
  58749. get skyboxTexture(): Nullable<BaseTexture>;
  58750. private _skyboxMaterial;
  58751. /**
  58752. * Gets the skybox material created by the helper.
  58753. */
  58754. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  58755. private _ground;
  58756. /**
  58757. * Gets the ground mesh created by the helper.
  58758. */
  58759. get ground(): Nullable<Mesh>;
  58760. private _groundTexture;
  58761. /**
  58762. * Gets the ground texture created by the helper.
  58763. */
  58764. get groundTexture(): Nullable<BaseTexture>;
  58765. private _groundMirror;
  58766. /**
  58767. * Gets the ground mirror created by the helper.
  58768. */
  58769. get groundMirror(): Nullable<MirrorTexture>;
  58770. /**
  58771. * Gets the ground mirror render list to helps pushing the meshes
  58772. * you wish in the ground reflection.
  58773. */
  58774. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  58775. private _groundMaterial;
  58776. /**
  58777. * Gets the ground material created by the helper.
  58778. */
  58779. get groundMaterial(): Nullable<BackgroundMaterial>;
  58780. /**
  58781. * Stores the creation options.
  58782. */
  58783. private readonly _scene;
  58784. private _options;
  58785. /**
  58786. * This observable will be notified with any error during the creation of the environment,
  58787. * mainly texture creation errors.
  58788. */
  58789. onErrorObservable: Observable<{
  58790. message?: string;
  58791. exception?: any;
  58792. }>;
  58793. /**
  58794. * constructor
  58795. * @param options Defines the options we want to customize the helper
  58796. * @param scene The scene to add the material to
  58797. */
  58798. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  58799. /**
  58800. * Updates the background according to the new options
  58801. * @param options
  58802. */
  58803. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  58804. /**
  58805. * Sets the primary color of all the available elements.
  58806. * @param color the main color to affect to the ground and the background
  58807. */
  58808. setMainColor(color: Color3): void;
  58809. /**
  58810. * Setup the image processing according to the specified options.
  58811. */
  58812. private _setupImageProcessing;
  58813. /**
  58814. * Setup the environment texture according to the specified options.
  58815. */
  58816. private _setupEnvironmentTexture;
  58817. /**
  58818. * Setup the background according to the specified options.
  58819. */
  58820. private _setupBackground;
  58821. /**
  58822. * Get the scene sizes according to the setup.
  58823. */
  58824. private _getSceneSize;
  58825. /**
  58826. * Setup the ground according to the specified options.
  58827. */
  58828. private _setupGround;
  58829. /**
  58830. * Setup the ground material according to the specified options.
  58831. */
  58832. private _setupGroundMaterial;
  58833. /**
  58834. * Setup the ground diffuse texture according to the specified options.
  58835. */
  58836. private _setupGroundDiffuseTexture;
  58837. /**
  58838. * Setup the ground mirror texture according to the specified options.
  58839. */
  58840. private _setupGroundMirrorTexture;
  58841. /**
  58842. * Setup the ground to receive the mirror texture.
  58843. */
  58844. private _setupMirrorInGroundMaterial;
  58845. /**
  58846. * Setup the skybox according to the specified options.
  58847. */
  58848. private _setupSkybox;
  58849. /**
  58850. * Setup the skybox material according to the specified options.
  58851. */
  58852. private _setupSkyboxMaterial;
  58853. /**
  58854. * Setup the skybox reflection texture according to the specified options.
  58855. */
  58856. private _setupSkyboxReflectionTexture;
  58857. private _errorHandler;
  58858. /**
  58859. * Dispose all the elements created by the Helper.
  58860. */
  58861. dispose(): void;
  58862. }
  58863. }
  58864. declare module BABYLON {
  58865. /**
  58866. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  58867. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  58868. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  58869. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58870. */
  58871. export abstract class TextureDome<T extends Texture> extends TransformNode {
  58872. protected onError: Nullable<(message?: string, exception?: any) => void>;
  58873. /**
  58874. * Define the source as a Monoscopic panoramic 360/180.
  58875. */
  58876. static readonly MODE_MONOSCOPIC: number;
  58877. /**
  58878. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  58879. */
  58880. static readonly MODE_TOPBOTTOM: number;
  58881. /**
  58882. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  58883. */
  58884. static readonly MODE_SIDEBYSIDE: number;
  58885. private _halfDome;
  58886. private _crossEye;
  58887. protected _useDirectMapping: boolean;
  58888. /**
  58889. * The texture being displayed on the sphere
  58890. */
  58891. protected _texture: T;
  58892. /**
  58893. * Gets the texture being displayed on the sphere
  58894. */
  58895. get texture(): T;
  58896. /**
  58897. * Sets the texture being displayed on the sphere
  58898. */
  58899. set texture(newTexture: T);
  58900. /**
  58901. * The skybox material
  58902. */
  58903. protected _material: BackgroundMaterial;
  58904. /**
  58905. * The surface used for the dome
  58906. */
  58907. protected _mesh: Mesh;
  58908. /**
  58909. * Gets the mesh used for the dome.
  58910. */
  58911. get mesh(): Mesh;
  58912. /**
  58913. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  58914. */
  58915. private _halfDomeMask;
  58916. /**
  58917. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  58918. * Also see the options.resolution property.
  58919. */
  58920. get fovMultiplier(): number;
  58921. set fovMultiplier(value: number);
  58922. protected _textureMode: number;
  58923. /**
  58924. * Gets or set the current texture mode for the texture. It can be:
  58925. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58926. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58927. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58928. */
  58929. get textureMode(): number;
  58930. /**
  58931. * Sets the current texture mode for the texture. It can be:
  58932. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58933. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58934. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58935. */
  58936. set textureMode(value: number);
  58937. /**
  58938. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  58939. */
  58940. get halfDome(): boolean;
  58941. /**
  58942. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  58943. */
  58944. set halfDome(enabled: boolean);
  58945. /**
  58946. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  58947. */
  58948. set crossEye(enabled: boolean);
  58949. /**
  58950. * Is it a cross-eye texture?
  58951. */
  58952. get crossEye(): boolean;
  58953. /**
  58954. * The background material of this dome.
  58955. */
  58956. get material(): BackgroundMaterial;
  58957. /**
  58958. * Oberserver used in Stereoscopic VR Mode.
  58959. */
  58960. private _onBeforeCameraRenderObserver;
  58961. /**
  58962. * Observable raised when an error occured while loading the 360 image
  58963. */
  58964. onLoadErrorObservable: Observable<string>;
  58965. /**
  58966. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  58967. * @param name Element's name, child elements will append suffixes for their own names.
  58968. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  58969. * @param options An object containing optional or exposed sub element properties
  58970. */
  58971. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  58972. resolution?: number;
  58973. clickToPlay?: boolean;
  58974. autoPlay?: boolean;
  58975. loop?: boolean;
  58976. size?: number;
  58977. poster?: string;
  58978. faceForward?: boolean;
  58979. useDirectMapping?: boolean;
  58980. halfDomeMode?: boolean;
  58981. crossEyeMode?: boolean;
  58982. generateMipMaps?: boolean;
  58983. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  58984. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  58985. protected _changeTextureMode(value: number): void;
  58986. /**
  58987. * Releases resources associated with this node.
  58988. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  58989. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  58990. */
  58991. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  58992. }
  58993. }
  58994. declare module BABYLON {
  58995. /**
  58996. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  58997. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  58998. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  58999. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  59000. */
  59001. export class PhotoDome extends TextureDome<Texture> {
  59002. /**
  59003. * Define the image as a Monoscopic panoramic 360 image.
  59004. */
  59005. static readonly MODE_MONOSCOPIC: number;
  59006. /**
  59007. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  59008. */
  59009. static readonly MODE_TOPBOTTOM: number;
  59010. /**
  59011. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  59012. */
  59013. static readonly MODE_SIDEBYSIDE: number;
  59014. /**
  59015. * Gets or sets the texture being displayed on the sphere
  59016. */
  59017. get photoTexture(): Texture;
  59018. /**
  59019. * sets the texture being displayed on the sphere
  59020. */
  59021. set photoTexture(value: Texture);
  59022. /**
  59023. * Gets the current video mode for the video. It can be:
  59024. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  59025. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  59026. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  59027. */
  59028. get imageMode(): number;
  59029. /**
  59030. * Sets the current video mode for the video. It can be:
  59031. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  59032. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  59033. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  59034. */
  59035. set imageMode(value: number);
  59036. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  59037. }
  59038. }
  59039. declare module BABYLON {
  59040. /**
  59041. * Direct draw surface info
  59042. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  59043. */
  59044. export interface DDSInfo {
  59045. /**
  59046. * Width of the texture
  59047. */
  59048. width: number;
  59049. /**
  59050. * Width of the texture
  59051. */
  59052. height: number;
  59053. /**
  59054. * Number of Mipmaps for the texture
  59055. * @see https://en.wikipedia.org/wiki/Mipmap
  59056. */
  59057. mipmapCount: number;
  59058. /**
  59059. * If the textures format is a known fourCC format
  59060. * @see https://www.fourcc.org/
  59061. */
  59062. isFourCC: boolean;
  59063. /**
  59064. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  59065. */
  59066. isRGB: boolean;
  59067. /**
  59068. * If the texture is a lumincance format
  59069. */
  59070. isLuminance: boolean;
  59071. /**
  59072. * If this is a cube texture
  59073. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  59074. */
  59075. isCube: boolean;
  59076. /**
  59077. * If the texture is a compressed format eg. FOURCC_DXT1
  59078. */
  59079. isCompressed: boolean;
  59080. /**
  59081. * The dxgiFormat of the texture
  59082. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  59083. */
  59084. dxgiFormat: number;
  59085. /**
  59086. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  59087. */
  59088. textureType: number;
  59089. /**
  59090. * Sphericle polynomial created for the dds texture
  59091. */
  59092. sphericalPolynomial?: SphericalPolynomial;
  59093. }
  59094. /**
  59095. * Class used to provide DDS decompression tools
  59096. */
  59097. export class DDSTools {
  59098. /**
  59099. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  59100. */
  59101. static StoreLODInAlphaChannel: boolean;
  59102. /**
  59103. * Gets DDS information from an array buffer
  59104. * @param data defines the array buffer view to read data from
  59105. * @returns the DDS information
  59106. */
  59107. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  59108. private static _FloatView;
  59109. private static _Int32View;
  59110. private static _ToHalfFloat;
  59111. private static _FromHalfFloat;
  59112. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  59113. private static _GetHalfFloatRGBAArrayBuffer;
  59114. private static _GetFloatRGBAArrayBuffer;
  59115. private static _GetFloatAsUIntRGBAArrayBuffer;
  59116. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  59117. private static _GetRGBAArrayBuffer;
  59118. private static _ExtractLongWordOrder;
  59119. private static _GetRGBArrayBuffer;
  59120. private static _GetLuminanceArrayBuffer;
  59121. /**
  59122. * Uploads DDS Levels to a Babylon Texture
  59123. * @hidden
  59124. */
  59125. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  59126. }
  59127. interface ThinEngine {
  59128. /**
  59129. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  59130. * @param rootUrl defines the url where the file to load is located
  59131. * @param scene defines the current scene
  59132. * @param lodScale defines scale to apply to the mip map selection
  59133. * @param lodOffset defines offset to apply to the mip map selection
  59134. * @param onLoad defines an optional callback raised when the texture is loaded
  59135. * @param onError defines an optional callback raised if there is an issue to load the texture
  59136. * @param format defines the format of the data
  59137. * @param forcedExtension defines the extension to use to pick the right loader
  59138. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  59139. * @returns the cube texture as an InternalTexture
  59140. */
  59141. 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;
  59142. }
  59143. }
  59144. declare module BABYLON {
  59145. /**
  59146. * Implementation of the DDS Texture Loader.
  59147. * @hidden
  59148. */
  59149. export class _DDSTextureLoader implements IInternalTextureLoader {
  59150. /**
  59151. * Defines wether the loader supports cascade loading the different faces.
  59152. */
  59153. readonly supportCascades: boolean;
  59154. /**
  59155. * This returns if the loader support the current file information.
  59156. * @param extension defines the file extension of the file being loaded
  59157. * @returns true if the loader can load the specified file
  59158. */
  59159. canLoad(extension: string): boolean;
  59160. /**
  59161. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59162. * @param data contains the texture data
  59163. * @param texture defines the BabylonJS internal texture
  59164. * @param createPolynomials will be true if polynomials have been requested
  59165. * @param onLoad defines the callback to trigger once the texture is ready
  59166. * @param onError defines the callback to trigger in case of error
  59167. */
  59168. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59169. /**
  59170. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59171. * @param data contains the texture data
  59172. * @param texture defines the BabylonJS internal texture
  59173. * @param callback defines the method to call once ready to upload
  59174. */
  59175. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59176. }
  59177. }
  59178. declare module BABYLON {
  59179. /**
  59180. * Implementation of the ENV Texture Loader.
  59181. * @hidden
  59182. */
  59183. export class _ENVTextureLoader implements IInternalTextureLoader {
  59184. /**
  59185. * Defines wether the loader supports cascade loading the different faces.
  59186. */
  59187. readonly supportCascades: boolean;
  59188. /**
  59189. * This returns if the loader support the current file information.
  59190. * @param extension defines the file extension of the file being loaded
  59191. * @returns true if the loader can load the specified file
  59192. */
  59193. canLoad(extension: string): boolean;
  59194. /**
  59195. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59196. * @param data contains the texture data
  59197. * @param texture defines the BabylonJS internal texture
  59198. * @param createPolynomials will be true if polynomials have been requested
  59199. * @param onLoad defines the callback to trigger once the texture is ready
  59200. * @param onError defines the callback to trigger in case of error
  59201. */
  59202. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59203. /**
  59204. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59205. * @param data contains the texture data
  59206. * @param texture defines the BabylonJS internal texture
  59207. * @param callback defines the method to call once ready to upload
  59208. */
  59209. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59210. }
  59211. }
  59212. declare module BABYLON {
  59213. /**
  59214. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  59215. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  59216. */
  59217. export class KhronosTextureContainer {
  59218. /** contents of the KTX container file */
  59219. data: ArrayBufferView;
  59220. private static HEADER_LEN;
  59221. private static COMPRESSED_2D;
  59222. private static COMPRESSED_3D;
  59223. private static TEX_2D;
  59224. private static TEX_3D;
  59225. /**
  59226. * Gets the openGL type
  59227. */
  59228. glType: number;
  59229. /**
  59230. * Gets the openGL type size
  59231. */
  59232. glTypeSize: number;
  59233. /**
  59234. * Gets the openGL format
  59235. */
  59236. glFormat: number;
  59237. /**
  59238. * Gets the openGL internal format
  59239. */
  59240. glInternalFormat: number;
  59241. /**
  59242. * Gets the base internal format
  59243. */
  59244. glBaseInternalFormat: number;
  59245. /**
  59246. * Gets image width in pixel
  59247. */
  59248. pixelWidth: number;
  59249. /**
  59250. * Gets image height in pixel
  59251. */
  59252. pixelHeight: number;
  59253. /**
  59254. * Gets image depth in pixels
  59255. */
  59256. pixelDepth: number;
  59257. /**
  59258. * Gets the number of array elements
  59259. */
  59260. numberOfArrayElements: number;
  59261. /**
  59262. * Gets the number of faces
  59263. */
  59264. numberOfFaces: number;
  59265. /**
  59266. * Gets the number of mipmap levels
  59267. */
  59268. numberOfMipmapLevels: number;
  59269. /**
  59270. * Gets the bytes of key value data
  59271. */
  59272. bytesOfKeyValueData: number;
  59273. /**
  59274. * Gets the load type
  59275. */
  59276. loadType: number;
  59277. /**
  59278. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  59279. */
  59280. isInvalid: boolean;
  59281. /**
  59282. * Creates a new KhronosTextureContainer
  59283. * @param data contents of the KTX container file
  59284. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  59285. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  59286. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  59287. */
  59288. constructor(
  59289. /** contents of the KTX container file */
  59290. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  59291. /**
  59292. * Uploads KTX content to a Babylon Texture.
  59293. * It is assumed that the texture has already been created & is currently bound
  59294. * @hidden
  59295. */
  59296. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  59297. private _upload2DCompressedLevels;
  59298. /**
  59299. * Checks if the given data starts with a KTX file identifier.
  59300. * @param data the data to check
  59301. * @returns true if the data is a KTX file or false otherwise
  59302. */
  59303. static IsValid(data: ArrayBufferView): boolean;
  59304. }
  59305. }
  59306. declare module BABYLON {
  59307. /**
  59308. * Helper class to push actions to a pool of workers.
  59309. */
  59310. export class WorkerPool implements IDisposable {
  59311. private _workerInfos;
  59312. private _pendingActions;
  59313. /**
  59314. * Constructor
  59315. * @param workers Array of workers to use for actions
  59316. */
  59317. constructor(workers: Array<Worker>);
  59318. /**
  59319. * Terminates all workers and clears any pending actions.
  59320. */
  59321. dispose(): void;
  59322. /**
  59323. * Pushes an action to the worker pool. If all the workers are active, the action will be
  59324. * pended until a worker has completed its action.
  59325. * @param action The action to perform. Call onComplete when the action is complete.
  59326. */
  59327. push(action: (worker: Worker, onComplete: () => void) => void): void;
  59328. private _execute;
  59329. }
  59330. }
  59331. declare module BABYLON {
  59332. /**
  59333. * Class for loading KTX2 files
  59334. */
  59335. export class KhronosTextureContainer2 {
  59336. private static _WorkerPoolPromise?;
  59337. private static _Initialized;
  59338. private static _Ktx2Decoder;
  59339. /**
  59340. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  59341. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  59342. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  59343. * Urls you can change:
  59344. * URLConfig.jsDecoderModule
  59345. * URLConfig.wasmUASTCToASTC
  59346. * URLConfig.wasmUASTCToBC7
  59347. * URLConfig.wasmUASTCToRGBA_UNORM
  59348. * URLConfig.wasmUASTCToRGBA_SRGB
  59349. * URLConfig.jsMSCTranscoder
  59350. * URLConfig.wasmMSCTranscoder
  59351. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  59352. */
  59353. static URLConfig: {
  59354. jsDecoderModule: string;
  59355. wasmUASTCToASTC: null;
  59356. wasmUASTCToBC7: null;
  59357. wasmUASTCToRGBA_UNORM: null;
  59358. wasmUASTCToRGBA_SRGB: null;
  59359. jsMSCTranscoder: null;
  59360. wasmMSCTranscoder: null;
  59361. };
  59362. /**
  59363. * Default number of workers used to handle data decoding
  59364. */
  59365. static DefaultNumWorkers: number;
  59366. private static GetDefaultNumWorkers;
  59367. private _engine;
  59368. private static _CreateWorkerPool;
  59369. /**
  59370. * Constructor
  59371. * @param engine The engine to use
  59372. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  59373. */
  59374. constructor(engine: ThinEngine, numWorkers?: number);
  59375. /** @hidden */
  59376. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  59377. /**
  59378. * Stop all async operations and release resources.
  59379. */
  59380. dispose(): void;
  59381. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  59382. /**
  59383. * Checks if the given data starts with a KTX2 file identifier.
  59384. * @param data the data to check
  59385. * @returns true if the data is a KTX2 file or false otherwise
  59386. */
  59387. static IsValid(data: ArrayBufferView): boolean;
  59388. }
  59389. }
  59390. declare module BABYLON {
  59391. /**
  59392. * Implementation of the KTX Texture Loader.
  59393. * @hidden
  59394. */
  59395. export class _KTXTextureLoader implements IInternalTextureLoader {
  59396. /**
  59397. * Defines wether the loader supports cascade loading the different faces.
  59398. */
  59399. readonly supportCascades: boolean;
  59400. /**
  59401. * This returns if the loader support the current file information.
  59402. * @param extension defines the file extension of the file being loaded
  59403. * @param mimeType defines the optional mime type of the file being loaded
  59404. * @returns true if the loader can load the specified file
  59405. */
  59406. canLoad(extension: string, mimeType?: string): boolean;
  59407. /**
  59408. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59409. * @param data contains the texture data
  59410. * @param texture defines the BabylonJS internal texture
  59411. * @param createPolynomials will be true if polynomials have been requested
  59412. * @param onLoad defines the callback to trigger once the texture is ready
  59413. * @param onError defines the callback to trigger in case of error
  59414. */
  59415. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59416. /**
  59417. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59418. * @param data contains the texture data
  59419. * @param texture defines the BabylonJS internal texture
  59420. * @param callback defines the method to call once ready to upload
  59421. */
  59422. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  59423. }
  59424. }
  59425. declare module BABYLON {
  59426. /** @hidden */
  59427. export var _forceSceneHelpersToBundle: boolean;
  59428. interface Scene {
  59429. /**
  59430. * Creates a default light for the scene.
  59431. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  59432. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  59433. */
  59434. createDefaultLight(replace?: boolean): void;
  59435. /**
  59436. * Creates a default camera for the scene.
  59437. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  59438. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59439. * @param replace has default false, when true replaces the active camera in the scene
  59440. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  59441. */
  59442. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59443. /**
  59444. * Creates a default camera and a default light.
  59445. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  59446. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59447. * @param replace has the default false, when true replaces the active camera/light in the scene
  59448. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  59449. */
  59450. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59451. /**
  59452. * Creates a new sky box
  59453. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  59454. * @param environmentTexture defines the texture to use as environment texture
  59455. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  59456. * @param scale defines the overall scale of the skybox
  59457. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  59458. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  59459. * @returns a new mesh holding the sky box
  59460. */
  59461. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  59462. /**
  59463. * Creates a new environment
  59464. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  59465. * @param options defines the options you can use to configure the environment
  59466. * @returns the new EnvironmentHelper
  59467. */
  59468. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  59469. /**
  59470. * Creates a new VREXperienceHelper
  59471. * @see https://doc.babylonjs.com/how_to/webvr_helper
  59472. * @param webVROptions defines the options used to create the new VREXperienceHelper
  59473. * @returns a new VREXperienceHelper
  59474. */
  59475. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  59476. /**
  59477. * Creates a new WebXRDefaultExperience
  59478. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  59479. * @param options experience options
  59480. * @returns a promise for a new WebXRDefaultExperience
  59481. */
  59482. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  59483. }
  59484. }
  59485. declare module BABYLON {
  59486. /**
  59487. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  59488. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  59489. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  59490. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  59491. */
  59492. export class VideoDome extends TextureDome<VideoTexture> {
  59493. /**
  59494. * Define the video source as a Monoscopic panoramic 360 video.
  59495. */
  59496. static readonly MODE_MONOSCOPIC: number;
  59497. /**
  59498. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  59499. */
  59500. static readonly MODE_TOPBOTTOM: number;
  59501. /**
  59502. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  59503. */
  59504. static readonly MODE_SIDEBYSIDE: number;
  59505. /**
  59506. * Get the video texture associated with this video dome
  59507. */
  59508. get videoTexture(): VideoTexture;
  59509. /**
  59510. * Get the video mode of this dome
  59511. */
  59512. get videoMode(): number;
  59513. /**
  59514. * Set the video mode of this dome.
  59515. * @see textureMode
  59516. */
  59517. set videoMode(value: number);
  59518. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  59519. }
  59520. }
  59521. declare module BABYLON {
  59522. /**
  59523. * This class can be used to get instrumentation data from a Babylon engine
  59524. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59525. */
  59526. export class EngineInstrumentation implements IDisposable {
  59527. /**
  59528. * Define the instrumented engine.
  59529. */
  59530. engine: Engine;
  59531. private _captureGPUFrameTime;
  59532. private _gpuFrameTimeToken;
  59533. private _gpuFrameTime;
  59534. private _captureShaderCompilationTime;
  59535. private _shaderCompilationTime;
  59536. private _onBeginFrameObserver;
  59537. private _onEndFrameObserver;
  59538. private _onBeforeShaderCompilationObserver;
  59539. private _onAfterShaderCompilationObserver;
  59540. /**
  59541. * Gets the perf counter used for GPU frame time
  59542. */
  59543. get gpuFrameTimeCounter(): PerfCounter;
  59544. /**
  59545. * Gets the GPU frame time capture status
  59546. */
  59547. get captureGPUFrameTime(): boolean;
  59548. /**
  59549. * Enable or disable the GPU frame time capture
  59550. */
  59551. set captureGPUFrameTime(value: boolean);
  59552. /**
  59553. * Gets the perf counter used for shader compilation time
  59554. */
  59555. get shaderCompilationTimeCounter(): PerfCounter;
  59556. /**
  59557. * Gets the shader compilation time capture status
  59558. */
  59559. get captureShaderCompilationTime(): boolean;
  59560. /**
  59561. * Enable or disable the shader compilation time capture
  59562. */
  59563. set captureShaderCompilationTime(value: boolean);
  59564. /**
  59565. * Instantiates a new engine instrumentation.
  59566. * This class can be used to get instrumentation data from a Babylon engine
  59567. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59568. * @param engine Defines the engine to instrument
  59569. */
  59570. constructor(
  59571. /**
  59572. * Define the instrumented engine.
  59573. */
  59574. engine: Engine);
  59575. /**
  59576. * Dispose and release associated resources.
  59577. */
  59578. dispose(): void;
  59579. }
  59580. }
  59581. declare module BABYLON {
  59582. /**
  59583. * This class can be used to get instrumentation data from a Babylon engine
  59584. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59585. */
  59586. export class SceneInstrumentation implements IDisposable {
  59587. /**
  59588. * Defines the scene to instrument
  59589. */
  59590. scene: Scene;
  59591. private _captureActiveMeshesEvaluationTime;
  59592. private _activeMeshesEvaluationTime;
  59593. private _captureRenderTargetsRenderTime;
  59594. private _renderTargetsRenderTime;
  59595. private _captureFrameTime;
  59596. private _frameTime;
  59597. private _captureRenderTime;
  59598. private _renderTime;
  59599. private _captureInterFrameTime;
  59600. private _interFrameTime;
  59601. private _captureParticlesRenderTime;
  59602. private _particlesRenderTime;
  59603. private _captureSpritesRenderTime;
  59604. private _spritesRenderTime;
  59605. private _capturePhysicsTime;
  59606. private _physicsTime;
  59607. private _captureAnimationsTime;
  59608. private _animationsTime;
  59609. private _captureCameraRenderTime;
  59610. private _cameraRenderTime;
  59611. private _onBeforeActiveMeshesEvaluationObserver;
  59612. private _onAfterActiveMeshesEvaluationObserver;
  59613. private _onBeforeRenderTargetsRenderObserver;
  59614. private _onAfterRenderTargetsRenderObserver;
  59615. private _onAfterRenderObserver;
  59616. private _onBeforeDrawPhaseObserver;
  59617. private _onAfterDrawPhaseObserver;
  59618. private _onBeforeAnimationsObserver;
  59619. private _onBeforeParticlesRenderingObserver;
  59620. private _onAfterParticlesRenderingObserver;
  59621. private _onBeforeSpritesRenderingObserver;
  59622. private _onAfterSpritesRenderingObserver;
  59623. private _onBeforePhysicsObserver;
  59624. private _onAfterPhysicsObserver;
  59625. private _onAfterAnimationsObserver;
  59626. private _onBeforeCameraRenderObserver;
  59627. private _onAfterCameraRenderObserver;
  59628. /**
  59629. * Gets the perf counter used for active meshes evaluation time
  59630. */
  59631. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  59632. /**
  59633. * Gets the active meshes evaluation time capture status
  59634. */
  59635. get captureActiveMeshesEvaluationTime(): boolean;
  59636. /**
  59637. * Enable or disable the active meshes evaluation time capture
  59638. */
  59639. set captureActiveMeshesEvaluationTime(value: boolean);
  59640. /**
  59641. * Gets the perf counter used for render targets render time
  59642. */
  59643. get renderTargetsRenderTimeCounter(): PerfCounter;
  59644. /**
  59645. * Gets the render targets render time capture status
  59646. */
  59647. get captureRenderTargetsRenderTime(): boolean;
  59648. /**
  59649. * Enable or disable the render targets render time capture
  59650. */
  59651. set captureRenderTargetsRenderTime(value: boolean);
  59652. /**
  59653. * Gets the perf counter used for particles render time
  59654. */
  59655. get particlesRenderTimeCounter(): PerfCounter;
  59656. /**
  59657. * Gets the particles render time capture status
  59658. */
  59659. get captureParticlesRenderTime(): boolean;
  59660. /**
  59661. * Enable or disable the particles render time capture
  59662. */
  59663. set captureParticlesRenderTime(value: boolean);
  59664. /**
  59665. * Gets the perf counter used for sprites render time
  59666. */
  59667. get spritesRenderTimeCounter(): PerfCounter;
  59668. /**
  59669. * Gets the sprites render time capture status
  59670. */
  59671. get captureSpritesRenderTime(): boolean;
  59672. /**
  59673. * Enable or disable the sprites render time capture
  59674. */
  59675. set captureSpritesRenderTime(value: boolean);
  59676. /**
  59677. * Gets the perf counter used for physics time
  59678. */
  59679. get physicsTimeCounter(): PerfCounter;
  59680. /**
  59681. * Gets the physics time capture status
  59682. */
  59683. get capturePhysicsTime(): boolean;
  59684. /**
  59685. * Enable or disable the physics time capture
  59686. */
  59687. set capturePhysicsTime(value: boolean);
  59688. /**
  59689. * Gets the perf counter used for animations time
  59690. */
  59691. get animationsTimeCounter(): PerfCounter;
  59692. /**
  59693. * Gets the animations time capture status
  59694. */
  59695. get captureAnimationsTime(): boolean;
  59696. /**
  59697. * Enable or disable the animations time capture
  59698. */
  59699. set captureAnimationsTime(value: boolean);
  59700. /**
  59701. * Gets the perf counter used for frame time capture
  59702. */
  59703. get frameTimeCounter(): PerfCounter;
  59704. /**
  59705. * Gets the frame time capture status
  59706. */
  59707. get captureFrameTime(): boolean;
  59708. /**
  59709. * Enable or disable the frame time capture
  59710. */
  59711. set captureFrameTime(value: boolean);
  59712. /**
  59713. * Gets the perf counter used for inter-frames time capture
  59714. */
  59715. get interFrameTimeCounter(): PerfCounter;
  59716. /**
  59717. * Gets the inter-frames time capture status
  59718. */
  59719. get captureInterFrameTime(): boolean;
  59720. /**
  59721. * Enable or disable the inter-frames time capture
  59722. */
  59723. set captureInterFrameTime(value: boolean);
  59724. /**
  59725. * Gets the perf counter used for render time capture
  59726. */
  59727. get renderTimeCounter(): PerfCounter;
  59728. /**
  59729. * Gets the render time capture status
  59730. */
  59731. get captureRenderTime(): boolean;
  59732. /**
  59733. * Enable or disable the render time capture
  59734. */
  59735. set captureRenderTime(value: boolean);
  59736. /**
  59737. * Gets the perf counter used for camera render time capture
  59738. */
  59739. get cameraRenderTimeCounter(): PerfCounter;
  59740. /**
  59741. * Gets the camera render time capture status
  59742. */
  59743. get captureCameraRenderTime(): boolean;
  59744. /**
  59745. * Enable or disable the camera render time capture
  59746. */
  59747. set captureCameraRenderTime(value: boolean);
  59748. /**
  59749. * Gets the perf counter used for draw calls
  59750. */
  59751. get drawCallsCounter(): PerfCounter;
  59752. /**
  59753. * Instantiates a new scene instrumentation.
  59754. * This class can be used to get instrumentation data from a Babylon engine
  59755. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59756. * @param scene Defines the scene to instrument
  59757. */
  59758. constructor(
  59759. /**
  59760. * Defines the scene to instrument
  59761. */
  59762. scene: Scene);
  59763. /**
  59764. * Dispose and release associated resources.
  59765. */
  59766. dispose(): void;
  59767. }
  59768. }
  59769. declare module BABYLON {
  59770. /** @hidden */
  59771. export var glowMapGenerationPixelShader: {
  59772. name: string;
  59773. shader: string;
  59774. };
  59775. }
  59776. declare module BABYLON {
  59777. /** @hidden */
  59778. export var glowMapGenerationVertexShader: {
  59779. name: string;
  59780. shader: string;
  59781. };
  59782. }
  59783. declare module BABYLON {
  59784. /**
  59785. * Effect layer options. This helps customizing the behaviour
  59786. * of the effect layer.
  59787. */
  59788. export interface IEffectLayerOptions {
  59789. /**
  59790. * Multiplication factor apply to the canvas size to compute the render target size
  59791. * used to generated the objects (the smaller the faster).
  59792. */
  59793. mainTextureRatio: number;
  59794. /**
  59795. * Enforces a fixed size texture to ensure effect stability across devices.
  59796. */
  59797. mainTextureFixedSize?: number;
  59798. /**
  59799. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  59800. */
  59801. alphaBlendingMode: number;
  59802. /**
  59803. * The camera attached to the layer.
  59804. */
  59805. camera: Nullable<Camera>;
  59806. /**
  59807. * The rendering group to draw the layer in.
  59808. */
  59809. renderingGroupId: number;
  59810. }
  59811. /**
  59812. * The effect layer Helps adding post process effect blended with the main pass.
  59813. *
  59814. * This can be for instance use to generate glow or higlight effects on the scene.
  59815. *
  59816. * The effect layer class can not be used directly and is intented to inherited from to be
  59817. * customized per effects.
  59818. */
  59819. export abstract class EffectLayer {
  59820. private _vertexBuffers;
  59821. private _indexBuffer;
  59822. private _cachedDefines;
  59823. private _effectLayerMapGenerationEffect;
  59824. private _effectLayerOptions;
  59825. private _mergeEffect;
  59826. protected _scene: Scene;
  59827. protected _engine: Engine;
  59828. protected _maxSize: number;
  59829. protected _mainTextureDesiredSize: ISize;
  59830. protected _mainTexture: RenderTargetTexture;
  59831. protected _shouldRender: boolean;
  59832. protected _postProcesses: PostProcess[];
  59833. protected _textures: BaseTexture[];
  59834. protected _emissiveTextureAndColor: {
  59835. texture: Nullable<BaseTexture>;
  59836. color: Color4;
  59837. };
  59838. /**
  59839. * The name of the layer
  59840. */
  59841. name: string;
  59842. /**
  59843. * The clear color of the texture used to generate the glow map.
  59844. */
  59845. neutralColor: Color4;
  59846. /**
  59847. * Specifies whether the highlight layer is enabled or not.
  59848. */
  59849. isEnabled: boolean;
  59850. /**
  59851. * Gets the camera attached to the layer.
  59852. */
  59853. get camera(): Nullable<Camera>;
  59854. /**
  59855. * Gets the rendering group id the layer should render in.
  59856. */
  59857. get renderingGroupId(): number;
  59858. set renderingGroupId(renderingGroupId: number);
  59859. /**
  59860. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  59861. */
  59862. disableBoundingBoxesFromEffectLayer: boolean;
  59863. /**
  59864. * An event triggered when the effect layer has been disposed.
  59865. */
  59866. onDisposeObservable: Observable<EffectLayer>;
  59867. /**
  59868. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  59869. */
  59870. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  59871. /**
  59872. * An event triggered when the generated texture is being merged in the scene.
  59873. */
  59874. onBeforeComposeObservable: Observable<EffectLayer>;
  59875. /**
  59876. * An event triggered when the mesh is rendered into the effect render target.
  59877. */
  59878. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  59879. /**
  59880. * An event triggered after the mesh has been rendered into the effect render target.
  59881. */
  59882. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  59883. /**
  59884. * An event triggered when the generated texture has been merged in the scene.
  59885. */
  59886. onAfterComposeObservable: Observable<EffectLayer>;
  59887. /**
  59888. * An event triggered when the efffect layer changes its size.
  59889. */
  59890. onSizeChangedObservable: Observable<EffectLayer>;
  59891. /** @hidden */
  59892. static _SceneComponentInitialization: (scene: Scene) => void;
  59893. /**
  59894. * Instantiates a new effect Layer and references it in the scene.
  59895. * @param name The name of the layer
  59896. * @param scene The scene to use the layer in
  59897. */
  59898. constructor(
  59899. /** The Friendly of the effect in the scene */
  59900. name: string, scene: Scene);
  59901. /**
  59902. * Get the effect name of the layer.
  59903. * @return The effect name
  59904. */
  59905. abstract getEffectName(): string;
  59906. /**
  59907. * Checks for the readiness of the element composing the layer.
  59908. * @param subMesh the mesh to check for
  59909. * @param useInstances specify whether or not to use instances to render the mesh
  59910. * @return true if ready otherwise, false
  59911. */
  59912. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59913. /**
  59914. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59915. * @returns true if the effect requires stencil during the main canvas render pass.
  59916. */
  59917. abstract needStencil(): boolean;
  59918. /**
  59919. * Create the merge effect. This is the shader use to blit the information back
  59920. * to the main canvas at the end of the scene rendering.
  59921. * @returns The effect containing the shader used to merge the effect on the main canvas
  59922. */
  59923. protected abstract _createMergeEffect(): Effect;
  59924. /**
  59925. * Creates the render target textures and post processes used in the effect layer.
  59926. */
  59927. protected abstract _createTextureAndPostProcesses(): void;
  59928. /**
  59929. * Implementation specific of rendering the generating effect on the main canvas.
  59930. * @param effect The effect used to render through
  59931. */
  59932. protected abstract _internalRender(effect: Effect): void;
  59933. /**
  59934. * Sets the required values for both the emissive texture and and the main color.
  59935. */
  59936. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59937. /**
  59938. * Free any resources and references associated to a mesh.
  59939. * Internal use
  59940. * @param mesh The mesh to free.
  59941. */
  59942. abstract _disposeMesh(mesh: Mesh): void;
  59943. /**
  59944. * Serializes this layer (Glow or Highlight for example)
  59945. * @returns a serialized layer object
  59946. */
  59947. abstract serialize?(): any;
  59948. /**
  59949. * Initializes the effect layer with the required options.
  59950. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  59951. */
  59952. protected _init(options: Partial<IEffectLayerOptions>): void;
  59953. /**
  59954. * Generates the index buffer of the full screen quad blending to the main canvas.
  59955. */
  59956. private _generateIndexBuffer;
  59957. /**
  59958. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  59959. */
  59960. private _generateVertexBuffer;
  59961. /**
  59962. * Sets the main texture desired size which is the closest power of two
  59963. * of the engine canvas size.
  59964. */
  59965. private _setMainTextureSize;
  59966. /**
  59967. * Creates the main texture for the effect layer.
  59968. */
  59969. protected _createMainTexture(): void;
  59970. /**
  59971. * Adds specific effects defines.
  59972. * @param defines The defines to add specifics to.
  59973. */
  59974. protected _addCustomEffectDefines(defines: string[]): void;
  59975. /**
  59976. * Checks for the readiness of the element composing the layer.
  59977. * @param subMesh the mesh to check for
  59978. * @param useInstances specify whether or not to use instances to render the mesh
  59979. * @param emissiveTexture the associated emissive texture used to generate the glow
  59980. * @return true if ready otherwise, false
  59981. */
  59982. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  59983. /**
  59984. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  59985. */
  59986. render(): void;
  59987. /**
  59988. * Determine if a given mesh will be used in the current effect.
  59989. * @param mesh mesh to test
  59990. * @returns true if the mesh will be used
  59991. */
  59992. hasMesh(mesh: AbstractMesh): boolean;
  59993. /**
  59994. * Returns true if the layer contains information to display, otherwise false.
  59995. * @returns true if the glow layer should be rendered
  59996. */
  59997. shouldRender(): boolean;
  59998. /**
  59999. * Returns true if the mesh should render, otherwise false.
  60000. * @param mesh The mesh to render
  60001. * @returns true if it should render otherwise false
  60002. */
  60003. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  60004. /**
  60005. * Returns true if the mesh can be rendered, otherwise false.
  60006. * @param mesh The mesh to render
  60007. * @param material The material used on the mesh
  60008. * @returns true if it can be rendered otherwise false
  60009. */
  60010. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60011. /**
  60012. * Returns true if the mesh should render, otherwise false.
  60013. * @param mesh The mesh to render
  60014. * @returns true if it should render otherwise false
  60015. */
  60016. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  60017. /**
  60018. * Renders the submesh passed in parameter to the generation map.
  60019. */
  60020. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  60021. /**
  60022. * Defines whether the current material of the mesh should be use to render the effect.
  60023. * @param mesh defines the current mesh to render
  60024. */
  60025. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  60026. /**
  60027. * Rebuild the required buffers.
  60028. * @hidden Internal use only.
  60029. */
  60030. _rebuild(): void;
  60031. /**
  60032. * Dispose only the render target textures and post process.
  60033. */
  60034. private _disposeTextureAndPostProcesses;
  60035. /**
  60036. * Dispose the highlight layer and free resources.
  60037. */
  60038. dispose(): void;
  60039. /**
  60040. * Gets the class name of the effect layer
  60041. * @returns the string with the class name of the effect layer
  60042. */
  60043. getClassName(): string;
  60044. /**
  60045. * Creates an effect layer from parsed effect layer data
  60046. * @param parsedEffectLayer defines effect layer data
  60047. * @param scene defines the current scene
  60048. * @param rootUrl defines the root URL containing the effect layer information
  60049. * @returns a parsed effect Layer
  60050. */
  60051. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  60052. }
  60053. }
  60054. declare module BABYLON {
  60055. interface AbstractScene {
  60056. /**
  60057. * The list of effect layers (highlights/glow) added to the scene
  60058. * @see https://doc.babylonjs.com/how_to/highlight_layer
  60059. * @see https://doc.babylonjs.com/how_to/glow_layer
  60060. */
  60061. effectLayers: Array<EffectLayer>;
  60062. /**
  60063. * Removes the given effect layer from this scene.
  60064. * @param toRemove defines the effect layer to remove
  60065. * @returns the index of the removed effect layer
  60066. */
  60067. removeEffectLayer(toRemove: EffectLayer): number;
  60068. /**
  60069. * Adds the given effect layer to this scene
  60070. * @param newEffectLayer defines the effect layer to add
  60071. */
  60072. addEffectLayer(newEffectLayer: EffectLayer): void;
  60073. }
  60074. /**
  60075. * Defines the layer scene component responsible to manage any effect layers
  60076. * in a given scene.
  60077. */
  60078. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  60079. /**
  60080. * The component name helpfull to identify the component in the list of scene components.
  60081. */
  60082. readonly name: string;
  60083. /**
  60084. * The scene the component belongs to.
  60085. */
  60086. scene: Scene;
  60087. private _engine;
  60088. private _renderEffects;
  60089. private _needStencil;
  60090. private _previousStencilState;
  60091. /**
  60092. * Creates a new instance of the component for the given scene
  60093. * @param scene Defines the scene to register the component in
  60094. */
  60095. constructor(scene: Scene);
  60096. /**
  60097. * Registers the component in a given scene
  60098. */
  60099. register(): void;
  60100. /**
  60101. * Rebuilds the elements related to this component in case of
  60102. * context lost for instance.
  60103. */
  60104. rebuild(): void;
  60105. /**
  60106. * Serializes the component data to the specified json object
  60107. * @param serializationObject The object to serialize to
  60108. */
  60109. serialize(serializationObject: any): void;
  60110. /**
  60111. * Adds all the elements from the container to the scene
  60112. * @param container the container holding the elements
  60113. */
  60114. addFromContainer(container: AbstractScene): void;
  60115. /**
  60116. * Removes all the elements in the container from the scene
  60117. * @param container contains the elements to remove
  60118. * @param dispose if the removed element should be disposed (default: false)
  60119. */
  60120. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60121. /**
  60122. * Disposes the component and the associated ressources.
  60123. */
  60124. dispose(): void;
  60125. private _isReadyForMesh;
  60126. private _renderMainTexture;
  60127. private _setStencil;
  60128. private _setStencilBack;
  60129. private _draw;
  60130. private _drawCamera;
  60131. private _drawRenderingGroup;
  60132. }
  60133. }
  60134. declare module BABYLON {
  60135. /** @hidden */
  60136. export var glowMapMergePixelShader: {
  60137. name: string;
  60138. shader: string;
  60139. };
  60140. }
  60141. declare module BABYLON {
  60142. /** @hidden */
  60143. export var glowMapMergeVertexShader: {
  60144. name: string;
  60145. shader: string;
  60146. };
  60147. }
  60148. declare module BABYLON {
  60149. interface AbstractScene {
  60150. /**
  60151. * Return a the first highlight layer of the scene with a given name.
  60152. * @param name The name of the highlight layer to look for.
  60153. * @return The highlight layer if found otherwise null.
  60154. */
  60155. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  60156. }
  60157. /**
  60158. * Glow layer options. This helps customizing the behaviour
  60159. * of the glow layer.
  60160. */
  60161. export interface IGlowLayerOptions {
  60162. /**
  60163. * Multiplication factor apply to the canvas size to compute the render target size
  60164. * used to generated the glowing objects (the smaller the faster).
  60165. */
  60166. mainTextureRatio: number;
  60167. /**
  60168. * Enforces a fixed size texture to ensure resize independant blur.
  60169. */
  60170. mainTextureFixedSize?: number;
  60171. /**
  60172. * How big is the kernel of the blur texture.
  60173. */
  60174. blurKernelSize: number;
  60175. /**
  60176. * The camera attached to the layer.
  60177. */
  60178. camera: Nullable<Camera>;
  60179. /**
  60180. * Enable MSAA by chosing the number of samples.
  60181. */
  60182. mainTextureSamples?: number;
  60183. /**
  60184. * The rendering group to draw the layer in.
  60185. */
  60186. renderingGroupId: number;
  60187. }
  60188. /**
  60189. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  60190. *
  60191. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  60192. *
  60193. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  60194. */
  60195. export class GlowLayer extends EffectLayer {
  60196. /**
  60197. * Effect Name of the layer.
  60198. */
  60199. static readonly EffectName: string;
  60200. /**
  60201. * The default blur kernel size used for the glow.
  60202. */
  60203. static DefaultBlurKernelSize: number;
  60204. /**
  60205. * The default texture size ratio used for the glow.
  60206. */
  60207. static DefaultTextureRatio: number;
  60208. /**
  60209. * Sets the kernel size of the blur.
  60210. */
  60211. set blurKernelSize(value: number);
  60212. /**
  60213. * Gets the kernel size of the blur.
  60214. */
  60215. get blurKernelSize(): number;
  60216. /**
  60217. * Sets the glow intensity.
  60218. */
  60219. set intensity(value: number);
  60220. /**
  60221. * Gets the glow intensity.
  60222. */
  60223. get intensity(): number;
  60224. private _options;
  60225. private _intensity;
  60226. private _horizontalBlurPostprocess1;
  60227. private _verticalBlurPostprocess1;
  60228. private _horizontalBlurPostprocess2;
  60229. private _verticalBlurPostprocess2;
  60230. private _blurTexture1;
  60231. private _blurTexture2;
  60232. private _postProcesses1;
  60233. private _postProcesses2;
  60234. private _includedOnlyMeshes;
  60235. private _excludedMeshes;
  60236. private _meshesUsingTheirOwnMaterials;
  60237. /**
  60238. * Callback used to let the user override the color selection on a per mesh basis
  60239. */
  60240. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  60241. /**
  60242. * Callback used to let the user override the texture selection on a per mesh basis
  60243. */
  60244. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  60245. /**
  60246. * Instantiates a new glow Layer and references it to the scene.
  60247. * @param name The name of the layer
  60248. * @param scene The scene to use the layer in
  60249. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  60250. */
  60251. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  60252. /**
  60253. * Get the effect name of the layer.
  60254. * @return The effect name
  60255. */
  60256. getEffectName(): string;
  60257. /**
  60258. * Create the merge effect. This is the shader use to blit the information back
  60259. * to the main canvas at the end of the scene rendering.
  60260. */
  60261. protected _createMergeEffect(): Effect;
  60262. /**
  60263. * Creates the render target textures and post processes used in the glow layer.
  60264. */
  60265. protected _createTextureAndPostProcesses(): void;
  60266. /**
  60267. * Checks for the readiness of the element composing the layer.
  60268. * @param subMesh the mesh to check for
  60269. * @param useInstances specify wether or not to use instances to render the mesh
  60270. * @param emissiveTexture the associated emissive texture used to generate the glow
  60271. * @return true if ready otherwise, false
  60272. */
  60273. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60274. /**
  60275. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  60276. */
  60277. needStencil(): boolean;
  60278. /**
  60279. * Returns true if the mesh can be rendered, otherwise false.
  60280. * @param mesh The mesh to render
  60281. * @param material The material used on the mesh
  60282. * @returns true if it can be rendered otherwise false
  60283. */
  60284. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60285. /**
  60286. * Implementation specific of rendering the generating effect on the main canvas.
  60287. * @param effect The effect used to render through
  60288. */
  60289. protected _internalRender(effect: Effect): void;
  60290. /**
  60291. * Sets the required values for both the emissive texture and and the main color.
  60292. */
  60293. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60294. /**
  60295. * Returns true if the mesh should render, otherwise false.
  60296. * @param mesh The mesh to render
  60297. * @returns true if it should render otherwise false
  60298. */
  60299. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60300. /**
  60301. * Adds specific effects defines.
  60302. * @param defines The defines to add specifics to.
  60303. */
  60304. protected _addCustomEffectDefines(defines: string[]): void;
  60305. /**
  60306. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  60307. * @param mesh The mesh to exclude from the glow layer
  60308. */
  60309. addExcludedMesh(mesh: Mesh): void;
  60310. /**
  60311. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  60312. * @param mesh The mesh to remove
  60313. */
  60314. removeExcludedMesh(mesh: Mesh): void;
  60315. /**
  60316. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  60317. * @param mesh The mesh to include in the glow layer
  60318. */
  60319. addIncludedOnlyMesh(mesh: Mesh): void;
  60320. /**
  60321. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  60322. * @param mesh The mesh to remove
  60323. */
  60324. removeIncludedOnlyMesh(mesh: Mesh): void;
  60325. /**
  60326. * Determine if a given mesh will be used in the glow layer
  60327. * @param mesh The mesh to test
  60328. * @returns true if the mesh will be highlighted by the current glow layer
  60329. */
  60330. hasMesh(mesh: AbstractMesh): boolean;
  60331. /**
  60332. * Defines whether the current material of the mesh should be use to render the effect.
  60333. * @param mesh defines the current mesh to render
  60334. */
  60335. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  60336. /**
  60337. * Add a mesh to be rendered through its own material and not with emissive only.
  60338. * @param mesh The mesh for which we need to use its material
  60339. */
  60340. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  60341. /**
  60342. * Remove a mesh from being rendered through its own material and not with emissive only.
  60343. * @param mesh The mesh for which we need to not use its material
  60344. */
  60345. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  60346. /**
  60347. * Free any resources and references associated to a mesh.
  60348. * Internal use
  60349. * @param mesh The mesh to free.
  60350. * @hidden
  60351. */
  60352. _disposeMesh(mesh: Mesh): void;
  60353. /**
  60354. * Gets the class name of the effect layer
  60355. * @returns the string with the class name of the effect layer
  60356. */
  60357. getClassName(): string;
  60358. /**
  60359. * Serializes this glow layer
  60360. * @returns a serialized glow layer object
  60361. */
  60362. serialize(): any;
  60363. /**
  60364. * Creates a Glow Layer from parsed glow layer data
  60365. * @param parsedGlowLayer defines glow layer data
  60366. * @param scene defines the current scene
  60367. * @param rootUrl defines the root URL containing the glow layer information
  60368. * @returns a parsed Glow Layer
  60369. */
  60370. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  60371. }
  60372. }
  60373. declare module BABYLON {
  60374. /** @hidden */
  60375. export var glowBlurPostProcessPixelShader: {
  60376. name: string;
  60377. shader: string;
  60378. };
  60379. }
  60380. declare module BABYLON {
  60381. interface AbstractScene {
  60382. /**
  60383. * Return a the first highlight layer of the scene with a given name.
  60384. * @param name The name of the highlight layer to look for.
  60385. * @return The highlight layer if found otherwise null.
  60386. */
  60387. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  60388. }
  60389. /**
  60390. * Highlight layer options. This helps customizing the behaviour
  60391. * of the highlight layer.
  60392. */
  60393. export interface IHighlightLayerOptions {
  60394. /**
  60395. * Multiplication factor apply to the canvas size to compute the render target size
  60396. * used to generated the glowing objects (the smaller the faster).
  60397. */
  60398. mainTextureRatio: number;
  60399. /**
  60400. * Enforces a fixed size texture to ensure resize independant blur.
  60401. */
  60402. mainTextureFixedSize?: number;
  60403. /**
  60404. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  60405. * of the picture to blur (the smaller the faster).
  60406. */
  60407. blurTextureSizeRatio: number;
  60408. /**
  60409. * How big in texel of the blur texture is the vertical blur.
  60410. */
  60411. blurVerticalSize: number;
  60412. /**
  60413. * How big in texel of the blur texture is the horizontal blur.
  60414. */
  60415. blurHorizontalSize: number;
  60416. /**
  60417. * Alpha blending mode used to apply the blur. Default is combine.
  60418. */
  60419. alphaBlendingMode: number;
  60420. /**
  60421. * The camera attached to the layer.
  60422. */
  60423. camera: Nullable<Camera>;
  60424. /**
  60425. * Should we display highlight as a solid stroke?
  60426. */
  60427. isStroke?: boolean;
  60428. /**
  60429. * The rendering group to draw the layer in.
  60430. */
  60431. renderingGroupId: number;
  60432. }
  60433. /**
  60434. * The highlight layer Helps adding a glow effect around a mesh.
  60435. *
  60436. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  60437. * glowy meshes to your scene.
  60438. *
  60439. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  60440. */
  60441. export class HighlightLayer extends EffectLayer {
  60442. name: string;
  60443. /**
  60444. * Effect Name of the highlight layer.
  60445. */
  60446. static readonly EffectName: string;
  60447. /**
  60448. * The neutral color used during the preparation of the glow effect.
  60449. * This is black by default as the blend operation is a blend operation.
  60450. */
  60451. static NeutralColor: Color4;
  60452. /**
  60453. * Stencil value used for glowing meshes.
  60454. */
  60455. static GlowingMeshStencilReference: number;
  60456. /**
  60457. * Stencil value used for the other meshes in the scene.
  60458. */
  60459. static NormalMeshStencilReference: number;
  60460. /**
  60461. * Specifies whether or not the inner glow is ACTIVE in the layer.
  60462. */
  60463. innerGlow: boolean;
  60464. /**
  60465. * Specifies whether or not the outer glow is ACTIVE in the layer.
  60466. */
  60467. outerGlow: boolean;
  60468. /**
  60469. * Specifies the horizontal size of the blur.
  60470. */
  60471. set blurHorizontalSize(value: number);
  60472. /**
  60473. * Specifies the vertical size of the blur.
  60474. */
  60475. set blurVerticalSize(value: number);
  60476. /**
  60477. * Gets the horizontal size of the blur.
  60478. */
  60479. get blurHorizontalSize(): number;
  60480. /**
  60481. * Gets the vertical size of the blur.
  60482. */
  60483. get blurVerticalSize(): number;
  60484. /**
  60485. * An event triggered when the highlight layer is being blurred.
  60486. */
  60487. onBeforeBlurObservable: Observable<HighlightLayer>;
  60488. /**
  60489. * An event triggered when the highlight layer has been blurred.
  60490. */
  60491. onAfterBlurObservable: Observable<HighlightLayer>;
  60492. private _instanceGlowingMeshStencilReference;
  60493. private _options;
  60494. private _downSamplePostprocess;
  60495. private _horizontalBlurPostprocess;
  60496. private _verticalBlurPostprocess;
  60497. private _blurTexture;
  60498. private _meshes;
  60499. private _excludedMeshes;
  60500. /**
  60501. * Instantiates a new highlight Layer and references it to the scene..
  60502. * @param name The name of the layer
  60503. * @param scene The scene to use the layer in
  60504. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  60505. */
  60506. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  60507. /**
  60508. * Get the effect name of the layer.
  60509. * @return The effect name
  60510. */
  60511. getEffectName(): string;
  60512. /**
  60513. * Create the merge effect. This is the shader use to blit the information back
  60514. * to the main canvas at the end of the scene rendering.
  60515. */
  60516. protected _createMergeEffect(): Effect;
  60517. /**
  60518. * Creates the render target textures and post processes used in the highlight layer.
  60519. */
  60520. protected _createTextureAndPostProcesses(): void;
  60521. /**
  60522. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  60523. */
  60524. needStencil(): boolean;
  60525. /**
  60526. * Checks for the readiness of the element composing the layer.
  60527. * @param subMesh the mesh to check for
  60528. * @param useInstances specify wether or not to use instances to render the mesh
  60529. * @param emissiveTexture the associated emissive texture used to generate the glow
  60530. * @return true if ready otherwise, false
  60531. */
  60532. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60533. /**
  60534. * Implementation specific of rendering the generating effect on the main canvas.
  60535. * @param effect The effect used to render through
  60536. */
  60537. protected _internalRender(effect: Effect): void;
  60538. /**
  60539. * Returns true if the layer contains information to display, otherwise false.
  60540. */
  60541. shouldRender(): boolean;
  60542. /**
  60543. * Returns true if the mesh should render, otherwise false.
  60544. * @param mesh The mesh to render
  60545. * @returns true if it should render otherwise false
  60546. */
  60547. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60548. /**
  60549. * Returns true if the mesh can be rendered, otherwise false.
  60550. * @param mesh The mesh to render
  60551. * @param material The material used on the mesh
  60552. * @returns true if it can be rendered otherwise false
  60553. */
  60554. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60555. /**
  60556. * Adds specific effects defines.
  60557. * @param defines The defines to add specifics to.
  60558. */
  60559. protected _addCustomEffectDefines(defines: string[]): void;
  60560. /**
  60561. * Sets the required values for both the emissive texture and and the main color.
  60562. */
  60563. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60564. /**
  60565. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  60566. * @param mesh The mesh to exclude from the highlight layer
  60567. */
  60568. addExcludedMesh(mesh: Mesh): void;
  60569. /**
  60570. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  60571. * @param mesh The mesh to highlight
  60572. */
  60573. removeExcludedMesh(mesh: Mesh): void;
  60574. /**
  60575. * Determine if a given mesh will be highlighted by the current HighlightLayer
  60576. * @param mesh mesh to test
  60577. * @returns true if the mesh will be highlighted by the current HighlightLayer
  60578. */
  60579. hasMesh(mesh: AbstractMesh): boolean;
  60580. /**
  60581. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  60582. * @param mesh The mesh to highlight
  60583. * @param color The color of the highlight
  60584. * @param glowEmissiveOnly Extract the glow from the emissive texture
  60585. */
  60586. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  60587. /**
  60588. * Remove a mesh from the highlight layer in order to make it stop glowing.
  60589. * @param mesh The mesh to highlight
  60590. */
  60591. removeMesh(mesh: Mesh): void;
  60592. /**
  60593. * Remove all the meshes currently referenced in the highlight layer
  60594. */
  60595. removeAllMeshes(): void;
  60596. /**
  60597. * Force the stencil to the normal expected value for none glowing parts
  60598. */
  60599. private _defaultStencilReference;
  60600. /**
  60601. * Free any resources and references associated to a mesh.
  60602. * Internal use
  60603. * @param mesh The mesh to free.
  60604. * @hidden
  60605. */
  60606. _disposeMesh(mesh: Mesh): void;
  60607. /**
  60608. * Dispose the highlight layer and free resources.
  60609. */
  60610. dispose(): void;
  60611. /**
  60612. * Gets the class name of the effect layer
  60613. * @returns the string with the class name of the effect layer
  60614. */
  60615. getClassName(): string;
  60616. /**
  60617. * Serializes this Highlight layer
  60618. * @returns a serialized Highlight layer object
  60619. */
  60620. serialize(): any;
  60621. /**
  60622. * Creates a Highlight layer from parsed Highlight layer data
  60623. * @param parsedHightlightLayer defines the Highlight layer data
  60624. * @param scene defines the current scene
  60625. * @param rootUrl defines the root URL containing the Highlight layer information
  60626. * @returns a parsed Highlight layer
  60627. */
  60628. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  60629. }
  60630. }
  60631. declare module BABYLON {
  60632. interface AbstractScene {
  60633. /**
  60634. * The list of layers (background and foreground) of the scene
  60635. */
  60636. layers: Array<Layer>;
  60637. }
  60638. /**
  60639. * Defines the layer scene component responsible to manage any layers
  60640. * in a given scene.
  60641. */
  60642. export class LayerSceneComponent implements ISceneComponent {
  60643. /**
  60644. * The component name helpfull to identify the component in the list of scene components.
  60645. */
  60646. readonly name: string;
  60647. /**
  60648. * The scene the component belongs to.
  60649. */
  60650. scene: Scene;
  60651. private _engine;
  60652. /**
  60653. * Creates a new instance of the component for the given scene
  60654. * @param scene Defines the scene to register the component in
  60655. */
  60656. constructor(scene: Scene);
  60657. /**
  60658. * Registers the component in a given scene
  60659. */
  60660. register(): void;
  60661. /**
  60662. * Rebuilds the elements related to this component in case of
  60663. * context lost for instance.
  60664. */
  60665. rebuild(): void;
  60666. /**
  60667. * Disposes the component and the associated ressources.
  60668. */
  60669. dispose(): void;
  60670. private _draw;
  60671. private _drawCameraPredicate;
  60672. private _drawCameraBackground;
  60673. private _drawCameraForeground;
  60674. private _drawRenderTargetPredicate;
  60675. private _drawRenderTargetBackground;
  60676. private _drawRenderTargetForeground;
  60677. /**
  60678. * Adds all the elements from the container to the scene
  60679. * @param container the container holding the elements
  60680. */
  60681. addFromContainer(container: AbstractScene): void;
  60682. /**
  60683. * Removes all the elements in the container from the scene
  60684. * @param container contains the elements to remove
  60685. * @param dispose if the removed element should be disposed (default: false)
  60686. */
  60687. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60688. }
  60689. }
  60690. declare module BABYLON {
  60691. /** @hidden */
  60692. export var layerPixelShader: {
  60693. name: string;
  60694. shader: string;
  60695. };
  60696. }
  60697. declare module BABYLON {
  60698. /** @hidden */
  60699. export var layerVertexShader: {
  60700. name: string;
  60701. shader: string;
  60702. };
  60703. }
  60704. declare module BABYLON {
  60705. /**
  60706. * This represents a full screen 2d layer.
  60707. * This can be useful to display a picture in the background of your scene for instance.
  60708. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60709. */
  60710. export class Layer {
  60711. /**
  60712. * Define the name of the layer.
  60713. */
  60714. name: string;
  60715. /**
  60716. * Define the texture the layer should display.
  60717. */
  60718. texture: Nullable<Texture>;
  60719. /**
  60720. * Is the layer in background or foreground.
  60721. */
  60722. isBackground: boolean;
  60723. /**
  60724. * Define the color of the layer (instead of texture).
  60725. */
  60726. color: Color4;
  60727. /**
  60728. * Define the scale of the layer in order to zoom in out of the texture.
  60729. */
  60730. scale: Vector2;
  60731. /**
  60732. * Define an offset for the layer in order to shift the texture.
  60733. */
  60734. offset: Vector2;
  60735. /**
  60736. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  60737. */
  60738. alphaBlendingMode: number;
  60739. /**
  60740. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  60741. * Alpha test will not mix with the background color in case of transparency.
  60742. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  60743. */
  60744. alphaTest: boolean;
  60745. /**
  60746. * Define a mask to restrict the layer to only some of the scene cameras.
  60747. */
  60748. layerMask: number;
  60749. /**
  60750. * Define the list of render target the layer is visible into.
  60751. */
  60752. renderTargetTextures: RenderTargetTexture[];
  60753. /**
  60754. * Define if the layer is only used in renderTarget or if it also
  60755. * renders in the main frame buffer of the canvas.
  60756. */
  60757. renderOnlyInRenderTargetTextures: boolean;
  60758. private _scene;
  60759. private _vertexBuffers;
  60760. private _indexBuffer;
  60761. private _effect;
  60762. private _previousDefines;
  60763. /**
  60764. * An event triggered when the layer is disposed.
  60765. */
  60766. onDisposeObservable: Observable<Layer>;
  60767. private _onDisposeObserver;
  60768. /**
  60769. * Back compatibility with callback before the onDisposeObservable existed.
  60770. * The set callback will be triggered when the layer has been disposed.
  60771. */
  60772. set onDispose(callback: () => void);
  60773. /**
  60774. * An event triggered before rendering the scene
  60775. */
  60776. onBeforeRenderObservable: Observable<Layer>;
  60777. private _onBeforeRenderObserver;
  60778. /**
  60779. * Back compatibility with callback before the onBeforeRenderObservable existed.
  60780. * The set callback will be triggered just before rendering the layer.
  60781. */
  60782. set onBeforeRender(callback: () => void);
  60783. /**
  60784. * An event triggered after rendering the scene
  60785. */
  60786. onAfterRenderObservable: Observable<Layer>;
  60787. private _onAfterRenderObserver;
  60788. /**
  60789. * Back compatibility with callback before the onAfterRenderObservable existed.
  60790. * The set callback will be triggered just after rendering the layer.
  60791. */
  60792. set onAfterRender(callback: () => void);
  60793. /**
  60794. * Instantiates a new layer.
  60795. * This represents a full screen 2d layer.
  60796. * This can be useful to display a picture in the background of your scene for instance.
  60797. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60798. * @param name Define the name of the layer in the scene
  60799. * @param imgUrl Define the url of the texture to display in the layer
  60800. * @param scene Define the scene the layer belongs to
  60801. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  60802. * @param color Defines a color for the layer
  60803. */
  60804. constructor(
  60805. /**
  60806. * Define the name of the layer.
  60807. */
  60808. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  60809. private _createIndexBuffer;
  60810. /** @hidden */
  60811. _rebuild(): void;
  60812. /**
  60813. * Renders the layer in the scene.
  60814. */
  60815. render(): void;
  60816. /**
  60817. * Disposes and releases the associated ressources.
  60818. */
  60819. dispose(): void;
  60820. }
  60821. }
  60822. declare module BABYLON {
  60823. /** @hidden */
  60824. export var lensFlarePixelShader: {
  60825. name: string;
  60826. shader: string;
  60827. };
  60828. }
  60829. declare module BABYLON {
  60830. /** @hidden */
  60831. export var lensFlareVertexShader: {
  60832. name: string;
  60833. shader: string;
  60834. };
  60835. }
  60836. declare module BABYLON {
  60837. /**
  60838. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60839. * It is usually composed of several `lensFlare`.
  60840. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60841. */
  60842. export class LensFlareSystem {
  60843. /**
  60844. * Define the name of the lens flare system
  60845. */
  60846. name: string;
  60847. /**
  60848. * List of lens flares used in this system.
  60849. */
  60850. lensFlares: LensFlare[];
  60851. /**
  60852. * Define a limit from the border the lens flare can be visible.
  60853. */
  60854. borderLimit: number;
  60855. /**
  60856. * Define a viewport border we do not want to see the lens flare in.
  60857. */
  60858. viewportBorder: number;
  60859. /**
  60860. * Define a predicate which could limit the list of meshes able to occlude the effect.
  60861. */
  60862. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  60863. /**
  60864. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  60865. */
  60866. layerMask: number;
  60867. /**
  60868. * Define the id of the lens flare system in the scene.
  60869. * (equal to name by default)
  60870. */
  60871. id: string;
  60872. private _scene;
  60873. private _emitter;
  60874. private _vertexBuffers;
  60875. private _indexBuffer;
  60876. private _effect;
  60877. private _positionX;
  60878. private _positionY;
  60879. private _isEnabled;
  60880. /** @hidden */
  60881. static _SceneComponentInitialization: (scene: Scene) => void;
  60882. /**
  60883. * Instantiates a lens flare system.
  60884. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60885. * It is usually composed of several `lensFlare`.
  60886. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60887. * @param name Define the name of the lens flare system in the scene
  60888. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  60889. * @param scene Define the scene the lens flare system belongs to
  60890. */
  60891. constructor(
  60892. /**
  60893. * Define the name of the lens flare system
  60894. */
  60895. name: string, emitter: any, scene: Scene);
  60896. /**
  60897. * Define if the lens flare system is enabled.
  60898. */
  60899. get isEnabled(): boolean;
  60900. set isEnabled(value: boolean);
  60901. /**
  60902. * Get the scene the effects belongs to.
  60903. * @returns the scene holding the lens flare system
  60904. */
  60905. getScene(): Scene;
  60906. /**
  60907. * Get the emitter of the lens flare system.
  60908. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60909. * @returns the emitter of the lens flare system
  60910. */
  60911. getEmitter(): any;
  60912. /**
  60913. * Set the emitter of the lens flare system.
  60914. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60915. * @param newEmitter Define the new emitter of the system
  60916. */
  60917. setEmitter(newEmitter: any): void;
  60918. /**
  60919. * Get the lens flare system emitter position.
  60920. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  60921. * @returns the position
  60922. */
  60923. getEmitterPosition(): Vector3;
  60924. /**
  60925. * @hidden
  60926. */
  60927. computeEffectivePosition(globalViewport: Viewport): boolean;
  60928. /** @hidden */
  60929. _isVisible(): boolean;
  60930. /**
  60931. * @hidden
  60932. */
  60933. render(): boolean;
  60934. /**
  60935. * Dispose and release the lens flare with its associated resources.
  60936. */
  60937. dispose(): void;
  60938. /**
  60939. * Parse a lens flare system from a JSON repressentation
  60940. * @param parsedLensFlareSystem Define the JSON to parse
  60941. * @param scene Define the scene the parsed system should be instantiated in
  60942. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  60943. * @returns the parsed system
  60944. */
  60945. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  60946. /**
  60947. * Serialize the current Lens Flare System into a JSON representation.
  60948. * @returns the serialized JSON
  60949. */
  60950. serialize(): any;
  60951. }
  60952. }
  60953. declare module BABYLON {
  60954. /**
  60955. * This represents one of the lens effect in a `lensFlareSystem`.
  60956. * It controls one of the indiviual texture used in the effect.
  60957. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60958. */
  60959. export class LensFlare {
  60960. /**
  60961. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60962. */
  60963. size: number;
  60964. /**
  60965. * 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.
  60966. */
  60967. position: number;
  60968. /**
  60969. * Define the lens color.
  60970. */
  60971. color: Color3;
  60972. /**
  60973. * Define the lens texture.
  60974. */
  60975. texture: Nullable<Texture>;
  60976. /**
  60977. * Define the alpha mode to render this particular lens.
  60978. */
  60979. alphaMode: number;
  60980. private _system;
  60981. /**
  60982. * Creates a new Lens Flare.
  60983. * This represents one of the lens effect in a `lensFlareSystem`.
  60984. * It controls one of the indiviual texture used in the effect.
  60985. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60986. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  60987. * @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.
  60988. * @param color Define the lens color
  60989. * @param imgUrl Define the lens texture url
  60990. * @param system Define the `lensFlareSystem` this flare is part of
  60991. * @returns The newly created Lens Flare
  60992. */
  60993. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  60994. /**
  60995. * Instantiates a new Lens Flare.
  60996. * This represents one of the lens effect in a `lensFlareSystem`.
  60997. * It controls one of the indiviual texture used in the effect.
  60998. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60999. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  61000. * @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.
  61001. * @param color Define the lens color
  61002. * @param imgUrl Define the lens texture url
  61003. * @param system Define the `lensFlareSystem` this flare is part of
  61004. */
  61005. constructor(
  61006. /**
  61007. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  61008. */
  61009. size: number,
  61010. /**
  61011. * 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.
  61012. */
  61013. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  61014. /**
  61015. * Dispose and release the lens flare with its associated resources.
  61016. */
  61017. dispose(): void;
  61018. }
  61019. }
  61020. declare module BABYLON {
  61021. interface AbstractScene {
  61022. /**
  61023. * The list of lens flare system added to the scene
  61024. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61025. */
  61026. lensFlareSystems: Array<LensFlareSystem>;
  61027. /**
  61028. * Removes the given lens flare system from this scene.
  61029. * @param toRemove The lens flare system to remove
  61030. * @returns The index of the removed lens flare system
  61031. */
  61032. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  61033. /**
  61034. * Adds the given lens flare system to this scene
  61035. * @param newLensFlareSystem The lens flare system to add
  61036. */
  61037. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  61038. /**
  61039. * Gets a lens flare system using its name
  61040. * @param name defines the name to look for
  61041. * @returns the lens flare system or null if not found
  61042. */
  61043. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  61044. /**
  61045. * Gets a lens flare system using its id
  61046. * @param id defines the id to look for
  61047. * @returns the lens flare system or null if not found
  61048. */
  61049. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  61050. }
  61051. /**
  61052. * Defines the lens flare scene component responsible to manage any lens flares
  61053. * in a given scene.
  61054. */
  61055. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  61056. /**
  61057. * The component name helpfull to identify the component in the list of scene components.
  61058. */
  61059. readonly name: string;
  61060. /**
  61061. * The scene the component belongs to.
  61062. */
  61063. scene: Scene;
  61064. /**
  61065. * Creates a new instance of the component for the given scene
  61066. * @param scene Defines the scene to register the component in
  61067. */
  61068. constructor(scene: Scene);
  61069. /**
  61070. * Registers the component in a given scene
  61071. */
  61072. register(): void;
  61073. /**
  61074. * Rebuilds the elements related to this component in case of
  61075. * context lost for instance.
  61076. */
  61077. rebuild(): void;
  61078. /**
  61079. * Adds all the elements from the container to the scene
  61080. * @param container the container holding the elements
  61081. */
  61082. addFromContainer(container: AbstractScene): void;
  61083. /**
  61084. * Removes all the elements in the container from the scene
  61085. * @param container contains the elements to remove
  61086. * @param dispose if the removed element should be disposed (default: false)
  61087. */
  61088. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61089. /**
  61090. * Serializes the component data to the specified json object
  61091. * @param serializationObject The object to serialize to
  61092. */
  61093. serialize(serializationObject: any): void;
  61094. /**
  61095. * Disposes the component and the associated ressources.
  61096. */
  61097. dispose(): void;
  61098. private _draw;
  61099. }
  61100. }
  61101. declare module BABYLON {
  61102. /** @hidden */
  61103. export var depthPixelShader: {
  61104. name: string;
  61105. shader: string;
  61106. };
  61107. }
  61108. declare module BABYLON {
  61109. /** @hidden */
  61110. export var depthVertexShader: {
  61111. name: string;
  61112. shader: string;
  61113. };
  61114. }
  61115. declare module BABYLON {
  61116. /**
  61117. * This represents a depth renderer in Babylon.
  61118. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  61119. */
  61120. export class DepthRenderer {
  61121. private _scene;
  61122. private _depthMap;
  61123. private _effect;
  61124. private readonly _storeNonLinearDepth;
  61125. private readonly _clearColor;
  61126. /** Get if the depth renderer is using packed depth or not */
  61127. readonly isPacked: boolean;
  61128. private _cachedDefines;
  61129. private _camera;
  61130. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  61131. enabled: boolean;
  61132. /**
  61133. * Specifiess that the depth renderer will only be used within
  61134. * the camera it is created for.
  61135. * This can help forcing its rendering during the camera processing.
  61136. */
  61137. useOnlyInActiveCamera: boolean;
  61138. /** @hidden */
  61139. static _SceneComponentInitialization: (scene: Scene) => void;
  61140. /**
  61141. * Instantiates a depth renderer
  61142. * @param scene The scene the renderer belongs to
  61143. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  61144. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  61145. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61146. */
  61147. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  61148. /**
  61149. * Creates the depth rendering effect and checks if the effect is ready.
  61150. * @param subMesh The submesh to be used to render the depth map of
  61151. * @param useInstances If multiple world instances should be used
  61152. * @returns if the depth renderer is ready to render the depth map
  61153. */
  61154. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61155. /**
  61156. * Gets the texture which the depth map will be written to.
  61157. * @returns The depth map texture
  61158. */
  61159. getDepthMap(): RenderTargetTexture;
  61160. /**
  61161. * Disposes of the depth renderer.
  61162. */
  61163. dispose(): void;
  61164. }
  61165. }
  61166. declare module BABYLON {
  61167. /** @hidden */
  61168. export var minmaxReduxPixelShader: {
  61169. name: string;
  61170. shader: string;
  61171. };
  61172. }
  61173. declare module BABYLON {
  61174. /**
  61175. * This class computes a min/max reduction from a texture: it means it computes the minimum
  61176. * and maximum values from all values of the texture.
  61177. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  61178. * The source values are read from the red channel of the texture.
  61179. */
  61180. export class MinMaxReducer {
  61181. /**
  61182. * Observable triggered when the computation has been performed
  61183. */
  61184. onAfterReductionPerformed: Observable<{
  61185. min: number;
  61186. max: number;
  61187. }>;
  61188. protected _camera: Camera;
  61189. protected _sourceTexture: Nullable<RenderTargetTexture>;
  61190. protected _reductionSteps: Nullable<Array<PostProcess>>;
  61191. protected _postProcessManager: PostProcessManager;
  61192. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  61193. protected _forceFullscreenViewport: boolean;
  61194. /**
  61195. * Creates a min/max reducer
  61196. * @param camera The camera to use for the post processes
  61197. */
  61198. constructor(camera: Camera);
  61199. /**
  61200. * Gets the texture used to read the values from.
  61201. */
  61202. get sourceTexture(): Nullable<RenderTargetTexture>;
  61203. /**
  61204. * Sets the source texture to read the values from.
  61205. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  61206. * because in such textures '1' value must not be taken into account to compute the maximum
  61207. * as this value is used to clear the texture.
  61208. * Note that the computation is not activated by calling this function, you must call activate() for that!
  61209. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  61210. * @param depthRedux Indicates if the texture is a depth texture or not
  61211. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  61212. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61213. */
  61214. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61215. /**
  61216. * Defines the refresh rate of the computation.
  61217. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61218. */
  61219. get refreshRate(): number;
  61220. set refreshRate(value: number);
  61221. protected _activated: boolean;
  61222. /**
  61223. * Gets the activation status of the reducer
  61224. */
  61225. get activated(): boolean;
  61226. /**
  61227. * Activates the reduction computation.
  61228. * When activated, the observers registered in onAfterReductionPerformed are
  61229. * called after the compuation is performed
  61230. */
  61231. activate(): void;
  61232. /**
  61233. * Deactivates the reduction computation.
  61234. */
  61235. deactivate(): void;
  61236. /**
  61237. * Disposes the min/max reducer
  61238. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  61239. */
  61240. dispose(disposeAll?: boolean): void;
  61241. }
  61242. }
  61243. declare module BABYLON {
  61244. /**
  61245. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  61246. */
  61247. export class DepthReducer extends MinMaxReducer {
  61248. private _depthRenderer;
  61249. private _depthRendererId;
  61250. /**
  61251. * Gets the depth renderer used for the computation.
  61252. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  61253. */
  61254. get depthRenderer(): Nullable<DepthRenderer>;
  61255. /**
  61256. * Creates a depth reducer
  61257. * @param camera The camera used to render the depth texture
  61258. */
  61259. constructor(camera: Camera);
  61260. /**
  61261. * Sets the depth renderer to use to generate the depth map
  61262. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  61263. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  61264. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61265. */
  61266. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  61267. /** @hidden */
  61268. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61269. /**
  61270. * Activates the reduction computation.
  61271. * When activated, the observers registered in onAfterReductionPerformed are
  61272. * called after the compuation is performed
  61273. */
  61274. activate(): void;
  61275. /**
  61276. * Deactivates the reduction computation.
  61277. */
  61278. deactivate(): void;
  61279. /**
  61280. * Disposes the depth reducer
  61281. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  61282. */
  61283. dispose(disposeAll?: boolean): void;
  61284. }
  61285. }
  61286. declare module BABYLON {
  61287. /**
  61288. * A CSM implementation allowing casting shadows on large scenes.
  61289. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61290. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  61291. */
  61292. export class CascadedShadowGenerator extends ShadowGenerator {
  61293. private static readonly frustumCornersNDCSpace;
  61294. /**
  61295. * Name of the CSM class
  61296. */
  61297. static CLASSNAME: string;
  61298. /**
  61299. * Defines the default number of cascades used by the CSM.
  61300. */
  61301. static readonly DEFAULT_CASCADES_COUNT: number;
  61302. /**
  61303. * Defines the minimum number of cascades used by the CSM.
  61304. */
  61305. static readonly MIN_CASCADES_COUNT: number;
  61306. /**
  61307. * Defines the maximum number of cascades used by the CSM.
  61308. */
  61309. static readonly MAX_CASCADES_COUNT: number;
  61310. protected _validateFilter(filter: number): number;
  61311. /**
  61312. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  61313. */
  61314. penumbraDarkness: number;
  61315. private _numCascades;
  61316. /**
  61317. * Gets or set the number of cascades used by the CSM.
  61318. */
  61319. get numCascades(): number;
  61320. set numCascades(value: number);
  61321. /**
  61322. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  61323. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  61324. */
  61325. stabilizeCascades: boolean;
  61326. private _freezeShadowCastersBoundingInfo;
  61327. private _freezeShadowCastersBoundingInfoObservable;
  61328. /**
  61329. * Enables or disables the shadow casters bounding info computation.
  61330. * If your shadow casters don't move, you can disable this feature.
  61331. * If it is enabled, the bounding box computation is done every frame.
  61332. */
  61333. get freezeShadowCastersBoundingInfo(): boolean;
  61334. set freezeShadowCastersBoundingInfo(freeze: boolean);
  61335. private _scbiMin;
  61336. private _scbiMax;
  61337. protected _computeShadowCastersBoundingInfo(): void;
  61338. protected _shadowCastersBoundingInfo: BoundingInfo;
  61339. /**
  61340. * Gets or sets the shadow casters bounding info.
  61341. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  61342. * so that the system won't overwrite the bounds you provide
  61343. */
  61344. get shadowCastersBoundingInfo(): BoundingInfo;
  61345. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  61346. protected _breaksAreDirty: boolean;
  61347. protected _minDistance: number;
  61348. protected _maxDistance: number;
  61349. /**
  61350. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  61351. *
  61352. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  61353. * If you don't know these values, simply leave them to their defaults and don't call this function.
  61354. * @param min minimal distance for the breaks (default to 0.)
  61355. * @param max maximal distance for the breaks (default to 1.)
  61356. */
  61357. setMinMaxDistance(min: number, max: number): void;
  61358. /** Gets the minimal distance used in the cascade break computation */
  61359. get minDistance(): number;
  61360. /** Gets the maximal distance used in the cascade break computation */
  61361. get maxDistance(): number;
  61362. /**
  61363. * Gets the class name of that object
  61364. * @returns "CascadedShadowGenerator"
  61365. */
  61366. getClassName(): string;
  61367. private _cascadeMinExtents;
  61368. private _cascadeMaxExtents;
  61369. /**
  61370. * Gets a cascade minimum extents
  61371. * @param cascadeIndex index of the cascade
  61372. * @returns the minimum cascade extents
  61373. */
  61374. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  61375. /**
  61376. * Gets a cascade maximum extents
  61377. * @param cascadeIndex index of the cascade
  61378. * @returns the maximum cascade extents
  61379. */
  61380. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  61381. private _cascades;
  61382. private _currentLayer;
  61383. private _viewSpaceFrustumsZ;
  61384. private _viewMatrices;
  61385. private _projectionMatrices;
  61386. private _transformMatrices;
  61387. private _transformMatricesAsArray;
  61388. private _frustumLengths;
  61389. private _lightSizeUVCorrection;
  61390. private _depthCorrection;
  61391. private _frustumCornersWorldSpace;
  61392. private _frustumCenter;
  61393. private _shadowCameraPos;
  61394. private _shadowMaxZ;
  61395. /**
  61396. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  61397. * It defaults to camera.maxZ
  61398. */
  61399. get shadowMaxZ(): number;
  61400. /**
  61401. * Sets the shadow max z distance.
  61402. */
  61403. set shadowMaxZ(value: number);
  61404. protected _debug: boolean;
  61405. /**
  61406. * Gets or sets the debug flag.
  61407. * When enabled, the cascades are materialized by different colors on the screen.
  61408. */
  61409. get debug(): boolean;
  61410. set debug(dbg: boolean);
  61411. private _depthClamp;
  61412. /**
  61413. * Gets or sets the depth clamping value.
  61414. *
  61415. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  61416. * to account for the shadow casters far away.
  61417. *
  61418. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  61419. */
  61420. get depthClamp(): boolean;
  61421. set depthClamp(value: boolean);
  61422. private _cascadeBlendPercentage;
  61423. /**
  61424. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  61425. * It defaults to 0.1 (10% blending).
  61426. */
  61427. get cascadeBlendPercentage(): number;
  61428. set cascadeBlendPercentage(value: number);
  61429. private _lambda;
  61430. /**
  61431. * Gets or set the lambda parameter.
  61432. * This parameter is used to split the camera frustum and create the cascades.
  61433. * It's a value between 0. and 1.: If 0, the split is a uniform split of the frustum, if 1 it is a logarithmic split.
  61434. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  61435. */
  61436. get lambda(): number;
  61437. set lambda(value: number);
  61438. /**
  61439. * Gets the view matrix corresponding to a given cascade
  61440. * @param cascadeNum cascade to retrieve the view matrix from
  61441. * @returns the cascade view matrix
  61442. */
  61443. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  61444. /**
  61445. * Gets the projection matrix corresponding to a given cascade
  61446. * @param cascadeNum cascade to retrieve the projection matrix from
  61447. * @returns the cascade projection matrix
  61448. */
  61449. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  61450. /**
  61451. * Gets the transformation matrix corresponding to a given cascade
  61452. * @param cascadeNum cascade to retrieve the transformation matrix from
  61453. * @returns the cascade transformation matrix
  61454. */
  61455. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  61456. private _depthRenderer;
  61457. /**
  61458. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  61459. *
  61460. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  61461. *
  61462. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  61463. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  61464. * @param depthRenderer The depth renderer to use when autoCalcDepthBounds is enabled. If you pass null or don't call this function at all, a depth renderer will be automatically created
  61465. */
  61466. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  61467. private _depthReducer;
  61468. private _autoCalcDepthBounds;
  61469. /**
  61470. * Gets or sets the autoCalcDepthBounds property.
  61471. *
  61472. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  61473. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  61474. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  61475. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  61476. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  61477. */
  61478. get autoCalcDepthBounds(): boolean;
  61479. set autoCalcDepthBounds(value: boolean);
  61480. /**
  61481. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  61482. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61483. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  61484. * for setting the refresh rate on the renderer yourself!
  61485. */
  61486. get autoCalcDepthBoundsRefreshRate(): number;
  61487. set autoCalcDepthBoundsRefreshRate(value: number);
  61488. /**
  61489. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  61490. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  61491. * you change the camera near/far planes!
  61492. */
  61493. splitFrustum(): void;
  61494. private _splitFrustum;
  61495. private _computeMatrices;
  61496. private _computeFrustumInWorldSpace;
  61497. private _computeCascadeFrustum;
  61498. /**
  61499. * Support test.
  61500. */
  61501. static get IsSupported(): boolean;
  61502. /** @hidden */
  61503. static _SceneComponentInitialization: (scene: Scene) => void;
  61504. /**
  61505. * Creates a Cascaded Shadow Generator object.
  61506. * A ShadowGenerator is the required tool to use the shadows.
  61507. * Each directional light casting shadows needs to use its own ShadowGenerator.
  61508. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61509. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  61510. * @param light The directional light object generating the shadows.
  61511. * @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.
  61512. */
  61513. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  61514. protected _initializeGenerator(): void;
  61515. protected _createTargetRenderTexture(): void;
  61516. protected _initializeShadowMap(): void;
  61517. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  61518. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  61519. /**
  61520. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  61521. * @param defines Defines of the material we want to update
  61522. * @param lightIndex Index of the light in the enabled light list of the material
  61523. */
  61524. prepareDefines(defines: any, lightIndex: number): void;
  61525. /**
  61526. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  61527. * defined in the generator but impacting the effect).
  61528. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  61529. * @param effect The effect we are binfing the information for
  61530. */
  61531. bindShadowLight(lightIndex: string, effect: Effect): void;
  61532. /**
  61533. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  61534. * (eq to view projection * shadow projection matrices)
  61535. * @returns The transform matrix used to create the shadow map
  61536. */
  61537. getTransformMatrix(): Matrix;
  61538. /**
  61539. * Disposes the ShadowGenerator.
  61540. * Returns nothing.
  61541. */
  61542. dispose(): void;
  61543. /**
  61544. * Serializes the shadow generator setup to a json object.
  61545. * @returns The serialized JSON object
  61546. */
  61547. serialize(): any;
  61548. /**
  61549. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  61550. * @param parsedShadowGenerator The JSON object to parse
  61551. * @param scene The scene to create the shadow map for
  61552. * @returns The parsed shadow generator
  61553. */
  61554. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  61555. }
  61556. }
  61557. declare module BABYLON {
  61558. /**
  61559. * Defines the shadow generator component responsible to manage any shadow generators
  61560. * in a given scene.
  61561. */
  61562. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  61563. /**
  61564. * The component name helpfull to identify the component in the list of scene components.
  61565. */
  61566. readonly name: string;
  61567. /**
  61568. * The scene the component belongs to.
  61569. */
  61570. scene: Scene;
  61571. /**
  61572. * Creates a new instance of the component for the given scene
  61573. * @param scene Defines the scene to register the component in
  61574. */
  61575. constructor(scene: Scene);
  61576. /**
  61577. * Registers the component in a given scene
  61578. */
  61579. register(): void;
  61580. /**
  61581. * Rebuilds the elements related to this component in case of
  61582. * context lost for instance.
  61583. */
  61584. rebuild(): void;
  61585. /**
  61586. * Serializes the component data to the specified json object
  61587. * @param serializationObject The object to serialize to
  61588. */
  61589. serialize(serializationObject: any): void;
  61590. /**
  61591. * Adds all the elements from the container to the scene
  61592. * @param container the container holding the elements
  61593. */
  61594. addFromContainer(container: AbstractScene): void;
  61595. /**
  61596. * Removes all the elements in the container from the scene
  61597. * @param container contains the elements to remove
  61598. * @param dispose if the removed element should be disposed (default: false)
  61599. */
  61600. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61601. /**
  61602. * Rebuilds the elements related to this component in case of
  61603. * context lost for instance.
  61604. */
  61605. dispose(): void;
  61606. private _gatherRenderTargets;
  61607. }
  61608. }
  61609. declare module BABYLON {
  61610. /**
  61611. * A point light is a light defined by an unique point in world space.
  61612. * The light is emitted in every direction from this point.
  61613. * A good example of a point light is a standard light bulb.
  61614. * Documentation: https://doc.babylonjs.com/babylon101/lights
  61615. */
  61616. export class PointLight extends ShadowLight {
  61617. private _shadowAngle;
  61618. /**
  61619. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61620. * This specifies what angle the shadow will use to be created.
  61621. *
  61622. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61623. */
  61624. get shadowAngle(): number;
  61625. /**
  61626. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61627. * This specifies what angle the shadow will use to be created.
  61628. *
  61629. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61630. */
  61631. set shadowAngle(value: number);
  61632. /**
  61633. * Gets the direction if it has been set.
  61634. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61635. */
  61636. get direction(): Vector3;
  61637. /**
  61638. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61639. */
  61640. set direction(value: Vector3);
  61641. /**
  61642. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  61643. * A PointLight emits the light in every direction.
  61644. * It can cast shadows.
  61645. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  61646. * ```javascript
  61647. * var pointLight = new PointLight("pl", camera.position, scene);
  61648. * ```
  61649. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61650. * @param name The light friendly name
  61651. * @param position The position of the point light in the scene
  61652. * @param scene The scene the lights belongs to
  61653. */
  61654. constructor(name: string, position: Vector3, scene: Scene);
  61655. /**
  61656. * Returns the string "PointLight"
  61657. * @returns the class name
  61658. */
  61659. getClassName(): string;
  61660. /**
  61661. * Returns the integer 0.
  61662. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61663. */
  61664. getTypeID(): number;
  61665. /**
  61666. * Specifies wether or not the shadowmap should be a cube texture.
  61667. * @returns true if the shadowmap needs to be a cube texture.
  61668. */
  61669. needCube(): boolean;
  61670. /**
  61671. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  61672. * @param faceIndex The index of the face we are computed the direction to generate shadow
  61673. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  61674. */
  61675. getShadowDirection(faceIndex?: number): Vector3;
  61676. /**
  61677. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  61678. * - fov = PI / 2
  61679. * - aspect ratio : 1.0
  61680. * - z-near and far equal to the active camera minZ and maxZ.
  61681. * Returns the PointLight.
  61682. */
  61683. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61684. protected _buildUniformLayout(): void;
  61685. /**
  61686. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  61687. * @param effect The effect to update
  61688. * @param lightIndex The index of the light in the effect to update
  61689. * @returns The point light
  61690. */
  61691. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  61692. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  61693. /**
  61694. * Prepares the list of defines specific to the light type.
  61695. * @param defines the list of defines
  61696. * @param lightIndex defines the index of the light for the effect
  61697. */
  61698. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61699. }
  61700. }
  61701. declare module BABYLON {
  61702. /**
  61703. * Header information of HDR texture files.
  61704. */
  61705. export interface HDRInfo {
  61706. /**
  61707. * The height of the texture in pixels.
  61708. */
  61709. height: number;
  61710. /**
  61711. * The width of the texture in pixels.
  61712. */
  61713. width: number;
  61714. /**
  61715. * The index of the beginning of the data in the binary file.
  61716. */
  61717. dataPosition: number;
  61718. }
  61719. /**
  61720. * This groups tools to convert HDR texture to native colors array.
  61721. */
  61722. export class HDRTools {
  61723. private static Ldexp;
  61724. private static Rgbe2float;
  61725. private static readStringLine;
  61726. /**
  61727. * Reads header information from an RGBE texture stored in a native array.
  61728. * More information on this format are available here:
  61729. * https://en.wikipedia.org/wiki/RGBE_image_format
  61730. *
  61731. * @param uint8array The binary file stored in native array.
  61732. * @return The header information.
  61733. */
  61734. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  61735. /**
  61736. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  61737. * This RGBE texture needs to store the information as a panorama.
  61738. *
  61739. * More information on this format are available here:
  61740. * https://en.wikipedia.org/wiki/RGBE_image_format
  61741. *
  61742. * @param buffer The binary file stored in an array buffer.
  61743. * @param size The expected size of the extracted cubemap.
  61744. * @return The Cube Map information.
  61745. */
  61746. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  61747. /**
  61748. * Returns the pixels data extracted from an RGBE texture.
  61749. * This pixels will be stored left to right up to down in the R G B order in one array.
  61750. *
  61751. * More information on this format are available here:
  61752. * https://en.wikipedia.org/wiki/RGBE_image_format
  61753. *
  61754. * @param uint8array The binary file stored in an array buffer.
  61755. * @param hdrInfo The header information of the file.
  61756. * @return The pixels data in RGB right to left up to down order.
  61757. */
  61758. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  61759. private static RGBE_ReadPixels_RLE;
  61760. private static RGBE_ReadPixels_NOT_RLE;
  61761. }
  61762. }
  61763. declare module BABYLON {
  61764. /**
  61765. * Effect Render Options
  61766. */
  61767. export interface IEffectRendererOptions {
  61768. /**
  61769. * Defines the vertices positions.
  61770. */
  61771. positions?: number[];
  61772. /**
  61773. * Defines the indices.
  61774. */
  61775. indices?: number[];
  61776. }
  61777. /**
  61778. * Helper class to render one or more effects.
  61779. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  61780. */
  61781. export class EffectRenderer {
  61782. private engine;
  61783. private static _DefaultOptions;
  61784. private _vertexBuffers;
  61785. private _indexBuffer;
  61786. private _fullscreenViewport;
  61787. /**
  61788. * Creates an effect renderer
  61789. * @param engine the engine to use for rendering
  61790. * @param options defines the options of the effect renderer
  61791. */
  61792. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61793. /**
  61794. * Sets the current viewport in normalized coordinates 0-1
  61795. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61796. */
  61797. setViewport(viewport?: Viewport): void;
  61798. /**
  61799. * Binds the embedded attributes buffer to the effect.
  61800. * @param effect Defines the effect to bind the attributes for
  61801. */
  61802. bindBuffers(effect: Effect): void;
  61803. /**
  61804. * Sets the current effect wrapper to use during draw.
  61805. * The effect needs to be ready before calling this api.
  61806. * This also sets the default full screen position attribute.
  61807. * @param effectWrapper Defines the effect to draw with
  61808. */
  61809. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61810. /**
  61811. * Restores engine states
  61812. */
  61813. restoreStates(): void;
  61814. /**
  61815. * Draws a full screen quad.
  61816. */
  61817. draw(): void;
  61818. private isRenderTargetTexture;
  61819. /**
  61820. * renders one or more effects to a specified texture
  61821. * @param effectWrapper the effect to renderer
  61822. * @param outputTexture texture to draw to, if null it will render to the screen.
  61823. */
  61824. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  61825. /**
  61826. * Disposes of the effect renderer
  61827. */
  61828. dispose(): void;
  61829. }
  61830. /**
  61831. * Options to create an EffectWrapper
  61832. */
  61833. interface EffectWrapperCreationOptions {
  61834. /**
  61835. * Engine to use to create the effect
  61836. */
  61837. engine: ThinEngine;
  61838. /**
  61839. * Fragment shader for the effect
  61840. */
  61841. fragmentShader: string;
  61842. /**
  61843. * Use the shader store instead of direct source code
  61844. */
  61845. useShaderStore?: boolean;
  61846. /**
  61847. * Vertex shader for the effect
  61848. */
  61849. vertexShader?: string;
  61850. /**
  61851. * Attributes to use in the shader
  61852. */
  61853. attributeNames?: Array<string>;
  61854. /**
  61855. * Uniforms to use in the shader
  61856. */
  61857. uniformNames?: Array<string>;
  61858. /**
  61859. * Texture sampler names to use in the shader
  61860. */
  61861. samplerNames?: Array<string>;
  61862. /**
  61863. * Defines to use in the shader
  61864. */
  61865. defines?: Array<string>;
  61866. /**
  61867. * Callback when effect is compiled
  61868. */
  61869. onCompiled?: Nullable<(effect: Effect) => void>;
  61870. /**
  61871. * The friendly name of the effect displayed in Spector.
  61872. */
  61873. name?: string;
  61874. }
  61875. /**
  61876. * Wraps an effect to be used for rendering
  61877. */
  61878. export class EffectWrapper {
  61879. /**
  61880. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61881. */
  61882. onApplyObservable: Observable<{}>;
  61883. /**
  61884. * The underlying effect
  61885. */
  61886. effect: Effect;
  61887. /**
  61888. * Creates an effect to be renderer
  61889. * @param creationOptions options to create the effect
  61890. */
  61891. constructor(creationOptions: EffectWrapperCreationOptions);
  61892. /**
  61893. * Disposes of the effect wrapper
  61894. */
  61895. dispose(): void;
  61896. }
  61897. }
  61898. declare module BABYLON {
  61899. /** @hidden */
  61900. export var hdrFilteringVertexShader: {
  61901. name: string;
  61902. shader: string;
  61903. };
  61904. }
  61905. declare module BABYLON {
  61906. /** @hidden */
  61907. export var hdrFilteringPixelShader: {
  61908. name: string;
  61909. shader: string;
  61910. };
  61911. }
  61912. declare module BABYLON {
  61913. /**
  61914. * Options for texture filtering
  61915. */
  61916. interface IHDRFilteringOptions {
  61917. /**
  61918. * Scales pixel intensity for the input HDR map.
  61919. */
  61920. hdrScale?: number;
  61921. /**
  61922. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  61923. */
  61924. quality?: number;
  61925. }
  61926. /**
  61927. * Filters HDR maps to get correct renderings of PBR reflections
  61928. */
  61929. export class HDRFiltering {
  61930. private _engine;
  61931. private _effectRenderer;
  61932. private _effectWrapper;
  61933. private _lodGenerationOffset;
  61934. private _lodGenerationScale;
  61935. /**
  61936. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  61937. * you care about baking speed.
  61938. */
  61939. quality: number;
  61940. /**
  61941. * Scales pixel intensity for the input HDR map.
  61942. */
  61943. hdrScale: number;
  61944. /**
  61945. * Instantiates HDR filter for reflection maps
  61946. *
  61947. * @param engine Thin engine
  61948. * @param options Options
  61949. */
  61950. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  61951. private _createRenderTarget;
  61952. private _prefilterInternal;
  61953. private _createEffect;
  61954. /**
  61955. * Get a value indicating if the filter is ready to be used
  61956. * @param texture Texture to filter
  61957. * @returns true if the filter is ready
  61958. */
  61959. isReady(texture: BaseTexture): boolean;
  61960. /**
  61961. * Prefilters a cube texture to have mipmap levels representing roughness values.
  61962. * Prefiltering will be invoked at the end of next rendering pass.
  61963. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  61964. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  61965. * @param texture Texture to filter
  61966. * @param onFinished Callback when filtering is done
  61967. * @return Promise called when prefiltering is done
  61968. */
  61969. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  61970. }
  61971. }
  61972. declare module BABYLON {
  61973. /**
  61974. * This represents a texture coming from an HDR input.
  61975. *
  61976. * The only supported format is currently panorama picture stored in RGBE format.
  61977. * Example of such files can be found on HDRLib: http://hdrlib.com/
  61978. */
  61979. export class HDRCubeTexture extends BaseTexture {
  61980. private static _facesMapping;
  61981. private _generateHarmonics;
  61982. private _noMipmap;
  61983. private _prefilterOnLoad;
  61984. private _textureMatrix;
  61985. private _size;
  61986. private _onLoad;
  61987. private _onError;
  61988. /**
  61989. * The texture URL.
  61990. */
  61991. url: string;
  61992. protected _isBlocking: boolean;
  61993. /**
  61994. * Sets wether or not the texture is blocking during loading.
  61995. */
  61996. set isBlocking(value: boolean);
  61997. /**
  61998. * Gets wether or not the texture is blocking during loading.
  61999. */
  62000. get isBlocking(): boolean;
  62001. protected _rotationY: number;
  62002. /**
  62003. * Sets texture matrix rotation angle around Y axis in radians.
  62004. */
  62005. set rotationY(value: number);
  62006. /**
  62007. * Gets texture matrix rotation angle around Y axis radians.
  62008. */
  62009. get rotationY(): number;
  62010. /**
  62011. * Gets or sets the center of the bounding box associated with the cube texture
  62012. * It must define where the camera used to render the texture was set
  62013. */
  62014. boundingBoxPosition: Vector3;
  62015. private _boundingBoxSize;
  62016. /**
  62017. * Gets or sets the size of the bounding box associated with the cube texture
  62018. * When defined, the cubemap will switch to local mode
  62019. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  62020. * @example https://www.babylonjs-playground.com/#RNASML
  62021. */
  62022. set boundingBoxSize(value: Vector3);
  62023. get boundingBoxSize(): Vector3;
  62024. /**
  62025. * Instantiates an HDRTexture from the following parameters.
  62026. *
  62027. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  62028. * @param sceneOrEngine The scene or engine the texture will be used in
  62029. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  62030. * @param noMipmap Forces to not generate the mipmap if true
  62031. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  62032. * @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)
  62033. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  62034. */
  62035. constructor(url: string, sceneOrEngine: Scene | ThinEngine, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, prefilterOnLoad?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  62036. /**
  62037. * Get the current class name of the texture useful for serialization or dynamic coding.
  62038. * @returns "HDRCubeTexture"
  62039. */
  62040. getClassName(): string;
  62041. /**
  62042. * Occurs when the file is raw .hdr file.
  62043. */
  62044. private loadTexture;
  62045. clone(): HDRCubeTexture;
  62046. delayLoad(): void;
  62047. /**
  62048. * Get the texture reflection matrix used to rotate/transform the reflection.
  62049. * @returns the reflection matrix
  62050. */
  62051. getReflectionTextureMatrix(): Matrix;
  62052. /**
  62053. * Set the texture reflection matrix used to rotate/transform the reflection.
  62054. * @param value Define the reflection matrix to set
  62055. */
  62056. setReflectionTextureMatrix(value: Matrix): void;
  62057. /**
  62058. * Parses a JSON representation of an HDR Texture in order to create the texture
  62059. * @param parsedTexture Define the JSON representation
  62060. * @param scene Define the scene the texture should be created in
  62061. * @param rootUrl Define the root url in case we need to load relative dependencies
  62062. * @returns the newly created texture after parsing
  62063. */
  62064. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  62065. serialize(): any;
  62066. }
  62067. }
  62068. declare module BABYLON {
  62069. /**
  62070. * Class used to control physics engine
  62071. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62072. */
  62073. export class PhysicsEngine implements IPhysicsEngine {
  62074. private _physicsPlugin;
  62075. /**
  62076. * Global value used to control the smallest number supported by the simulation
  62077. */
  62078. static Epsilon: number;
  62079. private _impostors;
  62080. private _joints;
  62081. private _subTimeStep;
  62082. /**
  62083. * Gets the gravity vector used by the simulation
  62084. */
  62085. gravity: Vector3;
  62086. /**
  62087. * Factory used to create the default physics plugin.
  62088. * @returns The default physics plugin
  62089. */
  62090. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  62091. /**
  62092. * Creates a new Physics Engine
  62093. * @param gravity defines the gravity vector used by the simulation
  62094. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  62095. */
  62096. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  62097. /**
  62098. * Sets the gravity vector used by the simulation
  62099. * @param gravity defines the gravity vector to use
  62100. */
  62101. setGravity(gravity: Vector3): void;
  62102. /**
  62103. * Set the time step of the physics engine.
  62104. * Default is 1/60.
  62105. * To slow it down, enter 1/600 for example.
  62106. * To speed it up, 1/30
  62107. * @param newTimeStep defines the new timestep to apply to this world.
  62108. */
  62109. setTimeStep(newTimeStep?: number): void;
  62110. /**
  62111. * Get the time step of the physics engine.
  62112. * @returns the current time step
  62113. */
  62114. getTimeStep(): number;
  62115. /**
  62116. * Set the sub time step of the physics engine.
  62117. * Default is 0 meaning there is no sub steps
  62118. * To increase physics resolution precision, set a small value (like 1 ms)
  62119. * @param subTimeStep defines the new sub timestep used for physics resolution.
  62120. */
  62121. setSubTimeStep(subTimeStep?: number): void;
  62122. /**
  62123. * Get the sub time step of the physics engine.
  62124. * @returns the current sub time step
  62125. */
  62126. getSubTimeStep(): number;
  62127. /**
  62128. * Release all resources
  62129. */
  62130. dispose(): void;
  62131. /**
  62132. * Gets the name of the current physics plugin
  62133. * @returns the name of the plugin
  62134. */
  62135. getPhysicsPluginName(): string;
  62136. /**
  62137. * Adding a new impostor for the impostor tracking.
  62138. * This will be done by the impostor itself.
  62139. * @param impostor the impostor to add
  62140. */
  62141. addImpostor(impostor: PhysicsImpostor): void;
  62142. /**
  62143. * Remove an impostor from the engine.
  62144. * This impostor and its mesh will not longer be updated by the physics engine.
  62145. * @param impostor the impostor to remove
  62146. */
  62147. removeImpostor(impostor: PhysicsImpostor): void;
  62148. /**
  62149. * Add a joint to the physics engine
  62150. * @param mainImpostor defines the main impostor to which the joint is added.
  62151. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  62152. * @param joint defines the joint that will connect both impostors.
  62153. */
  62154. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62155. /**
  62156. * Removes a joint from the simulation
  62157. * @param mainImpostor defines the impostor used with the joint
  62158. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  62159. * @param joint defines the joint to remove
  62160. */
  62161. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62162. /**
  62163. * Called by the scene. No need to call it.
  62164. * @param delta defines the timespam between frames
  62165. */
  62166. _step(delta: number): void;
  62167. /**
  62168. * Gets the current plugin used to run the simulation
  62169. * @returns current plugin
  62170. */
  62171. getPhysicsPlugin(): IPhysicsEnginePlugin;
  62172. /**
  62173. * Gets the list of physic impostors
  62174. * @returns an array of PhysicsImpostor
  62175. */
  62176. getImpostors(): Array<PhysicsImpostor>;
  62177. /**
  62178. * Gets the impostor for a physics enabled object
  62179. * @param object defines the object impersonated by the impostor
  62180. * @returns the PhysicsImpostor or null if not found
  62181. */
  62182. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  62183. /**
  62184. * Gets the impostor for a physics body object
  62185. * @param body defines physics body used by the impostor
  62186. * @returns the PhysicsImpostor or null if not found
  62187. */
  62188. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  62189. /**
  62190. * Does a raycast in the physics world
  62191. * @param from when should the ray start?
  62192. * @param to when should the ray end?
  62193. * @returns PhysicsRaycastResult
  62194. */
  62195. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62196. }
  62197. }
  62198. declare module BABYLON {
  62199. /** @hidden */
  62200. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  62201. private _useDeltaForWorldStep;
  62202. world: any;
  62203. name: string;
  62204. private _physicsMaterials;
  62205. private _fixedTimeStep;
  62206. private _cannonRaycastResult;
  62207. private _raycastResult;
  62208. private _physicsBodysToRemoveAfterStep;
  62209. private _firstFrame;
  62210. BJSCANNON: any;
  62211. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  62212. setGravity(gravity: Vector3): void;
  62213. setTimeStep(timeStep: number): void;
  62214. getTimeStep(): number;
  62215. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62216. private _removeMarkedPhysicsBodiesFromWorld;
  62217. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62218. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62219. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62220. private _processChildMeshes;
  62221. removePhysicsBody(impostor: PhysicsImpostor): void;
  62222. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62223. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62224. private _addMaterial;
  62225. private _checkWithEpsilon;
  62226. private _createShape;
  62227. private _createHeightmap;
  62228. private _minus90X;
  62229. private _plus90X;
  62230. private _tmpPosition;
  62231. private _tmpDeltaPosition;
  62232. private _tmpUnityRotation;
  62233. private _updatePhysicsBodyTransformation;
  62234. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62235. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62236. isSupported(): boolean;
  62237. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62238. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62239. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62240. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62241. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62242. getBodyMass(impostor: PhysicsImpostor): number;
  62243. getBodyFriction(impostor: PhysicsImpostor): number;
  62244. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62245. getBodyRestitution(impostor: PhysicsImpostor): number;
  62246. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62247. sleepBody(impostor: PhysicsImpostor): void;
  62248. wakeUpBody(impostor: PhysicsImpostor): void;
  62249. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  62250. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62251. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62252. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62253. getRadius(impostor: PhysicsImpostor): number;
  62254. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62255. dispose(): void;
  62256. private _extendNamespace;
  62257. /**
  62258. * Does a raycast in the physics world
  62259. * @param from when should the ray start?
  62260. * @param to when should the ray end?
  62261. * @returns PhysicsRaycastResult
  62262. */
  62263. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62264. }
  62265. }
  62266. declare module BABYLON {
  62267. /** @hidden */
  62268. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  62269. private _useDeltaForWorldStep;
  62270. world: any;
  62271. name: string;
  62272. BJSOIMO: any;
  62273. private _raycastResult;
  62274. private _fixedTimeStep;
  62275. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  62276. setGravity(gravity: Vector3): void;
  62277. setTimeStep(timeStep: number): void;
  62278. getTimeStep(): number;
  62279. private _tmpImpostorsArray;
  62280. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62281. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62282. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62283. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62284. private _tmpPositionVector;
  62285. removePhysicsBody(impostor: PhysicsImpostor): void;
  62286. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62287. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62288. isSupported(): boolean;
  62289. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62290. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62291. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62292. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62293. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62294. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62295. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62296. getBodyMass(impostor: PhysicsImpostor): number;
  62297. getBodyFriction(impostor: PhysicsImpostor): number;
  62298. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62299. getBodyRestitution(impostor: PhysicsImpostor): number;
  62300. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62301. sleepBody(impostor: PhysicsImpostor): void;
  62302. wakeUpBody(impostor: PhysicsImpostor): void;
  62303. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62304. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  62305. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  62306. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62307. getRadius(impostor: PhysicsImpostor): number;
  62308. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62309. dispose(): void;
  62310. /**
  62311. * Does a raycast in the physics world
  62312. * @param from when should the ray start?
  62313. * @param to when should the ray end?
  62314. * @returns PhysicsRaycastResult
  62315. */
  62316. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62317. }
  62318. }
  62319. declare module BABYLON {
  62320. /**
  62321. * AmmoJS Physics plugin
  62322. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62323. * @see https://github.com/kripken/ammo.js/
  62324. */
  62325. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  62326. private _useDeltaForWorldStep;
  62327. /**
  62328. * Reference to the Ammo library
  62329. */
  62330. bjsAMMO: any;
  62331. /**
  62332. * Created ammoJS world which physics bodies are added to
  62333. */
  62334. world: any;
  62335. /**
  62336. * Name of the plugin
  62337. */
  62338. name: string;
  62339. private _timeStep;
  62340. private _fixedTimeStep;
  62341. private _maxSteps;
  62342. private _tmpQuaternion;
  62343. private _tmpAmmoTransform;
  62344. private _tmpAmmoQuaternion;
  62345. private _tmpAmmoConcreteContactResultCallback;
  62346. private _collisionConfiguration;
  62347. private _dispatcher;
  62348. private _overlappingPairCache;
  62349. private _solver;
  62350. private _softBodySolver;
  62351. private _tmpAmmoVectorA;
  62352. private _tmpAmmoVectorB;
  62353. private _tmpAmmoVectorC;
  62354. private _tmpAmmoVectorD;
  62355. private _tmpContactCallbackResult;
  62356. private _tmpAmmoVectorRCA;
  62357. private _tmpAmmoVectorRCB;
  62358. private _raycastResult;
  62359. private _tmpContactPoint;
  62360. private static readonly DISABLE_COLLISION_FLAG;
  62361. private static readonly KINEMATIC_FLAG;
  62362. private static readonly DISABLE_DEACTIVATION_FLAG;
  62363. /**
  62364. * Initializes the ammoJS plugin
  62365. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  62366. * @param ammoInjection can be used to inject your own ammo reference
  62367. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  62368. */
  62369. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  62370. /**
  62371. * Sets the gravity of the physics world (m/(s^2))
  62372. * @param gravity Gravity to set
  62373. */
  62374. setGravity(gravity: Vector3): void;
  62375. /**
  62376. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  62377. * @param timeStep timestep to use in seconds
  62378. */
  62379. setTimeStep(timeStep: number): void;
  62380. /**
  62381. * 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)
  62382. * @param fixedTimeStep fixedTimeStep to use in seconds
  62383. */
  62384. setFixedTimeStep(fixedTimeStep: number): void;
  62385. /**
  62386. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  62387. * @param maxSteps the maximum number of steps by the physics engine per frame
  62388. */
  62389. setMaxSteps(maxSteps: number): void;
  62390. /**
  62391. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  62392. * @returns the current timestep in seconds
  62393. */
  62394. getTimeStep(): number;
  62395. /**
  62396. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  62397. */
  62398. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  62399. private _isImpostorInContact;
  62400. private _isImpostorPairInContact;
  62401. private _stepSimulation;
  62402. /**
  62403. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  62404. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  62405. * After the step the babylon meshes are set to the position of the physics imposters
  62406. * @param delta amount of time to step forward
  62407. * @param impostors array of imposters to update before/after the step
  62408. */
  62409. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62410. /**
  62411. * Update babylon mesh to match physics world object
  62412. * @param impostor imposter to match
  62413. */
  62414. private _afterSoftStep;
  62415. /**
  62416. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62417. * @param impostor imposter to match
  62418. */
  62419. private _ropeStep;
  62420. /**
  62421. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62422. * @param impostor imposter to match
  62423. */
  62424. private _softbodyOrClothStep;
  62425. private _tmpMatrix;
  62426. /**
  62427. * Applies an impulse on the imposter
  62428. * @param impostor imposter to apply impulse to
  62429. * @param force amount of force to be applied to the imposter
  62430. * @param contactPoint the location to apply the impulse on the imposter
  62431. */
  62432. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62433. /**
  62434. * Applies a force on the imposter
  62435. * @param impostor imposter to apply force
  62436. * @param force amount of force to be applied to the imposter
  62437. * @param contactPoint the location to apply the force on the imposter
  62438. */
  62439. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62440. /**
  62441. * Creates a physics body using the plugin
  62442. * @param impostor the imposter to create the physics body on
  62443. */
  62444. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62445. /**
  62446. * Removes the physics body from the imposter and disposes of the body's memory
  62447. * @param impostor imposter to remove the physics body from
  62448. */
  62449. removePhysicsBody(impostor: PhysicsImpostor): void;
  62450. /**
  62451. * Generates a joint
  62452. * @param impostorJoint the imposter joint to create the joint with
  62453. */
  62454. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62455. /**
  62456. * Removes a joint
  62457. * @param impostorJoint the imposter joint to remove the joint from
  62458. */
  62459. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62460. private _addMeshVerts;
  62461. /**
  62462. * Initialise the soft body vertices to match its object's (mesh) vertices
  62463. * Softbody vertices (nodes) are in world space and to match this
  62464. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  62465. * @param impostor to create the softbody for
  62466. */
  62467. private _softVertexData;
  62468. /**
  62469. * Create an impostor's soft body
  62470. * @param impostor to create the softbody for
  62471. */
  62472. private _createSoftbody;
  62473. /**
  62474. * Create cloth for an impostor
  62475. * @param impostor to create the softbody for
  62476. */
  62477. private _createCloth;
  62478. /**
  62479. * Create rope for an impostor
  62480. * @param impostor to create the softbody for
  62481. */
  62482. private _createRope;
  62483. /**
  62484. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  62485. * @param impostor to create the custom physics shape for
  62486. */
  62487. private _createCustom;
  62488. private _addHullVerts;
  62489. private _createShape;
  62490. /**
  62491. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  62492. * @param impostor imposter containing the physics body and babylon object
  62493. */
  62494. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62495. /**
  62496. * Sets the babylon object's position/rotation from the physics body's position/rotation
  62497. * @param impostor imposter containing the physics body and babylon object
  62498. * @param newPosition new position
  62499. * @param newRotation new rotation
  62500. */
  62501. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62502. /**
  62503. * If this plugin is supported
  62504. * @returns true if its supported
  62505. */
  62506. isSupported(): boolean;
  62507. /**
  62508. * Sets the linear velocity of the physics body
  62509. * @param impostor imposter to set the velocity on
  62510. * @param velocity velocity to set
  62511. */
  62512. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62513. /**
  62514. * Sets the angular velocity of the physics body
  62515. * @param impostor imposter to set the velocity on
  62516. * @param velocity velocity to set
  62517. */
  62518. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62519. /**
  62520. * gets the linear velocity
  62521. * @param impostor imposter to get linear velocity from
  62522. * @returns linear velocity
  62523. */
  62524. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62525. /**
  62526. * gets the angular velocity
  62527. * @param impostor imposter to get angular velocity from
  62528. * @returns angular velocity
  62529. */
  62530. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62531. /**
  62532. * Sets the mass of physics body
  62533. * @param impostor imposter to set the mass on
  62534. * @param mass mass to set
  62535. */
  62536. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62537. /**
  62538. * Gets the mass of the physics body
  62539. * @param impostor imposter to get the mass from
  62540. * @returns mass
  62541. */
  62542. getBodyMass(impostor: PhysicsImpostor): number;
  62543. /**
  62544. * Gets friction of the impostor
  62545. * @param impostor impostor to get friction from
  62546. * @returns friction value
  62547. */
  62548. getBodyFriction(impostor: PhysicsImpostor): number;
  62549. /**
  62550. * Sets friction of the impostor
  62551. * @param impostor impostor to set friction on
  62552. * @param friction friction value
  62553. */
  62554. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62555. /**
  62556. * Gets restitution of the impostor
  62557. * @param impostor impostor to get restitution from
  62558. * @returns restitution value
  62559. */
  62560. getBodyRestitution(impostor: PhysicsImpostor): number;
  62561. /**
  62562. * Sets resitution of the impostor
  62563. * @param impostor impostor to set resitution on
  62564. * @param restitution resitution value
  62565. */
  62566. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62567. /**
  62568. * Gets pressure inside the impostor
  62569. * @param impostor impostor to get pressure from
  62570. * @returns pressure value
  62571. */
  62572. getBodyPressure(impostor: PhysicsImpostor): number;
  62573. /**
  62574. * Sets pressure inside a soft body impostor
  62575. * Cloth and rope must remain 0 pressure
  62576. * @param impostor impostor to set pressure on
  62577. * @param pressure pressure value
  62578. */
  62579. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  62580. /**
  62581. * Gets stiffness of the impostor
  62582. * @param impostor impostor to get stiffness from
  62583. * @returns pressure value
  62584. */
  62585. getBodyStiffness(impostor: PhysicsImpostor): number;
  62586. /**
  62587. * Sets stiffness of the impostor
  62588. * @param impostor impostor to set stiffness on
  62589. * @param stiffness stiffness value from 0 to 1
  62590. */
  62591. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  62592. /**
  62593. * Gets velocityIterations of the impostor
  62594. * @param impostor impostor to get velocity iterations from
  62595. * @returns velocityIterations value
  62596. */
  62597. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  62598. /**
  62599. * Sets velocityIterations of the impostor
  62600. * @param impostor impostor to set velocity iterations on
  62601. * @param velocityIterations velocityIterations value
  62602. */
  62603. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  62604. /**
  62605. * Gets positionIterations of the impostor
  62606. * @param impostor impostor to get position iterations from
  62607. * @returns positionIterations value
  62608. */
  62609. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  62610. /**
  62611. * Sets positionIterations of the impostor
  62612. * @param impostor impostor to set position on
  62613. * @param positionIterations positionIterations value
  62614. */
  62615. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  62616. /**
  62617. * Append an anchor to a cloth object
  62618. * @param impostor is the cloth impostor to add anchor to
  62619. * @param otherImpostor is the rigid impostor to anchor to
  62620. * @param width ratio across width from 0 to 1
  62621. * @param height ratio up height from 0 to 1
  62622. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  62623. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62624. */
  62625. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62626. /**
  62627. * Append an hook to a rope object
  62628. * @param impostor is the rope impostor to add hook to
  62629. * @param otherImpostor is the rigid impostor to hook to
  62630. * @param length ratio along the rope from 0 to 1
  62631. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  62632. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62633. */
  62634. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62635. /**
  62636. * Sleeps the physics body and stops it from being active
  62637. * @param impostor impostor to sleep
  62638. */
  62639. sleepBody(impostor: PhysicsImpostor): void;
  62640. /**
  62641. * Activates the physics body
  62642. * @param impostor impostor to activate
  62643. */
  62644. wakeUpBody(impostor: PhysicsImpostor): void;
  62645. /**
  62646. * Updates the distance parameters of the joint
  62647. * @param joint joint to update
  62648. * @param maxDistance maximum distance of the joint
  62649. * @param minDistance minimum distance of the joint
  62650. */
  62651. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62652. /**
  62653. * Sets a motor on the joint
  62654. * @param joint joint to set motor on
  62655. * @param speed speed of the motor
  62656. * @param maxForce maximum force of the motor
  62657. * @param motorIndex index of the motor
  62658. */
  62659. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62660. /**
  62661. * Sets the motors limit
  62662. * @param joint joint to set limit on
  62663. * @param upperLimit upper limit
  62664. * @param lowerLimit lower limit
  62665. */
  62666. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62667. /**
  62668. * Syncs the position and rotation of a mesh with the impostor
  62669. * @param mesh mesh to sync
  62670. * @param impostor impostor to update the mesh with
  62671. */
  62672. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62673. /**
  62674. * Gets the radius of the impostor
  62675. * @param impostor impostor to get radius from
  62676. * @returns the radius
  62677. */
  62678. getRadius(impostor: PhysicsImpostor): number;
  62679. /**
  62680. * Gets the box size of the impostor
  62681. * @param impostor impostor to get box size from
  62682. * @param result the resulting box size
  62683. */
  62684. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62685. /**
  62686. * Disposes of the impostor
  62687. */
  62688. dispose(): void;
  62689. /**
  62690. * Does a raycast in the physics world
  62691. * @param from when should the ray start?
  62692. * @param to when should the ray end?
  62693. * @returns PhysicsRaycastResult
  62694. */
  62695. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62696. }
  62697. }
  62698. declare module BABYLON {
  62699. interface AbstractScene {
  62700. /**
  62701. * The list of reflection probes added to the scene
  62702. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62703. */
  62704. reflectionProbes: Array<ReflectionProbe>;
  62705. /**
  62706. * Removes the given reflection probe from this scene.
  62707. * @param toRemove The reflection probe to remove
  62708. * @returns The index of the removed reflection probe
  62709. */
  62710. removeReflectionProbe(toRemove: ReflectionProbe): number;
  62711. /**
  62712. * Adds the given reflection probe to this scene.
  62713. * @param newReflectionProbe The reflection probe to add
  62714. */
  62715. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  62716. }
  62717. /**
  62718. * Class used to generate realtime reflection / refraction cube textures
  62719. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62720. */
  62721. export class ReflectionProbe {
  62722. /** defines the name of the probe */
  62723. name: string;
  62724. private _scene;
  62725. private _renderTargetTexture;
  62726. private _projectionMatrix;
  62727. private _viewMatrix;
  62728. private _target;
  62729. private _add;
  62730. private _attachedMesh;
  62731. private _invertYAxis;
  62732. /** Gets or sets probe position (center of the cube map) */
  62733. position: Vector3;
  62734. /**
  62735. * Creates a new reflection probe
  62736. * @param name defines the name of the probe
  62737. * @param size defines the texture resolution (for each face)
  62738. * @param scene defines the hosting scene
  62739. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  62740. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  62741. */
  62742. constructor(
  62743. /** defines the name of the probe */
  62744. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  62745. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  62746. get samples(): number;
  62747. set samples(value: number);
  62748. /** Gets or sets the refresh rate to use (on every frame by default) */
  62749. get refreshRate(): number;
  62750. set refreshRate(value: number);
  62751. /**
  62752. * Gets the hosting scene
  62753. * @returns a Scene
  62754. */
  62755. getScene(): Scene;
  62756. /** Gets the internal CubeTexture used to render to */
  62757. get cubeTexture(): RenderTargetTexture;
  62758. /** Gets the list of meshes to render */
  62759. get renderList(): Nullable<AbstractMesh[]>;
  62760. /**
  62761. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  62762. * @param mesh defines the mesh to attach to
  62763. */
  62764. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  62765. /**
  62766. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  62767. * @param renderingGroupId The rendering group id corresponding to its index
  62768. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  62769. */
  62770. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  62771. /**
  62772. * Clean all associated resources
  62773. */
  62774. dispose(): void;
  62775. /**
  62776. * Converts the reflection probe information to a readable string for debug purpose.
  62777. * @param fullDetails Supports for multiple levels of logging within scene loading
  62778. * @returns the human readable reflection probe info
  62779. */
  62780. toString(fullDetails?: boolean): string;
  62781. /**
  62782. * Get the class name of the relfection probe.
  62783. * @returns "ReflectionProbe"
  62784. */
  62785. getClassName(): string;
  62786. /**
  62787. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  62788. * @returns The JSON representation of the texture
  62789. */
  62790. serialize(): any;
  62791. /**
  62792. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  62793. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  62794. * @param scene Define the scene the parsed reflection probe should be instantiated in
  62795. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  62796. * @returns The parsed reflection probe if successful
  62797. */
  62798. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  62799. }
  62800. }
  62801. declare module BABYLON {
  62802. /** @hidden */
  62803. export var _BabylonLoaderRegistered: boolean;
  62804. /**
  62805. * Helps setting up some configuration for the babylon file loader.
  62806. */
  62807. export class BabylonFileLoaderConfiguration {
  62808. /**
  62809. * The loader does not allow injecting custom physix engine into the plugins.
  62810. * Unfortunately in ES6, we need to manually inject them into the plugin.
  62811. * So you could set this variable to your engine import to make it work.
  62812. */
  62813. static LoaderInjectedPhysicsEngine: any;
  62814. }
  62815. }
  62816. declare module BABYLON {
  62817. /**
  62818. * The Physically based simple base material of BJS.
  62819. *
  62820. * This enables better naming and convention enforcements on top of the pbrMaterial.
  62821. * It is used as the base class for both the specGloss and metalRough conventions.
  62822. */
  62823. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  62824. /**
  62825. * Number of Simultaneous lights allowed on the material.
  62826. */
  62827. maxSimultaneousLights: number;
  62828. /**
  62829. * If sets to true, disables all the lights affecting the material.
  62830. */
  62831. disableLighting: boolean;
  62832. /**
  62833. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  62834. */
  62835. environmentTexture: BaseTexture;
  62836. /**
  62837. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  62838. */
  62839. invertNormalMapX: boolean;
  62840. /**
  62841. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  62842. */
  62843. invertNormalMapY: boolean;
  62844. /**
  62845. * Normal map used in the model.
  62846. */
  62847. normalTexture: BaseTexture;
  62848. /**
  62849. * Emissivie color used to self-illuminate the model.
  62850. */
  62851. emissiveColor: Color3;
  62852. /**
  62853. * Emissivie texture used to self-illuminate the model.
  62854. */
  62855. emissiveTexture: BaseTexture;
  62856. /**
  62857. * Occlusion Channel Strenght.
  62858. */
  62859. occlusionStrength: number;
  62860. /**
  62861. * Occlusion Texture of the material (adding extra occlusion effects).
  62862. */
  62863. occlusionTexture: BaseTexture;
  62864. /**
  62865. * Defines the alpha limits in alpha test mode.
  62866. */
  62867. alphaCutOff: number;
  62868. /**
  62869. * Gets the current double sided mode.
  62870. */
  62871. get doubleSided(): boolean;
  62872. /**
  62873. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  62874. */
  62875. set doubleSided(value: boolean);
  62876. /**
  62877. * Stores the pre-calculated light information of a mesh in a texture.
  62878. */
  62879. lightmapTexture: BaseTexture;
  62880. /**
  62881. * If true, the light map contains occlusion information instead of lighting info.
  62882. */
  62883. useLightmapAsShadowmap: boolean;
  62884. /**
  62885. * Instantiates a new PBRMaterial instance.
  62886. *
  62887. * @param name The material name
  62888. * @param scene The scene the material will be use in.
  62889. */
  62890. constructor(name: string, scene: Scene);
  62891. getClassName(): string;
  62892. }
  62893. }
  62894. declare module BABYLON {
  62895. /**
  62896. * The PBR material of BJS following the metal roughness convention.
  62897. *
  62898. * This fits to the PBR convention in the GLTF definition:
  62899. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  62900. */
  62901. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  62902. /**
  62903. * The base color has two different interpretations depending on the value of metalness.
  62904. * When the material is a metal, the base color is the specific measured reflectance value
  62905. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  62906. * of the material.
  62907. */
  62908. baseColor: Color3;
  62909. /**
  62910. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  62911. * well as opacity information in the alpha channel.
  62912. */
  62913. baseTexture: BaseTexture;
  62914. /**
  62915. * Specifies the metallic scalar value of the material.
  62916. * Can also be used to scale the metalness values of the metallic texture.
  62917. */
  62918. metallic: number;
  62919. /**
  62920. * Specifies the roughness scalar value of the material.
  62921. * Can also be used to scale the roughness values of the metallic texture.
  62922. */
  62923. roughness: number;
  62924. /**
  62925. * Texture containing both the metallic value in the B channel and the
  62926. * roughness value in the G channel to keep better precision.
  62927. */
  62928. metallicRoughnessTexture: BaseTexture;
  62929. /**
  62930. * Instantiates a new PBRMetalRoughnessMaterial instance.
  62931. *
  62932. * @param name The material name
  62933. * @param scene The scene the material will be use in.
  62934. */
  62935. constructor(name: string, scene: Scene);
  62936. /**
  62937. * Return the currrent class name of the material.
  62938. */
  62939. getClassName(): string;
  62940. /**
  62941. * Makes a duplicate of the current material.
  62942. * @param name - name to use for the new material.
  62943. */
  62944. clone(name: string): PBRMetallicRoughnessMaterial;
  62945. /**
  62946. * Serialize the material to a parsable JSON object.
  62947. */
  62948. serialize(): any;
  62949. /**
  62950. * Parses a JSON object correponding to the serialize function.
  62951. */
  62952. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  62953. }
  62954. }
  62955. declare module BABYLON {
  62956. /**
  62957. * The PBR material of BJS following the specular glossiness convention.
  62958. *
  62959. * This fits to the PBR convention in the GLTF definition:
  62960. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  62961. */
  62962. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  62963. /**
  62964. * Specifies the diffuse color of the material.
  62965. */
  62966. diffuseColor: Color3;
  62967. /**
  62968. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  62969. * channel.
  62970. */
  62971. diffuseTexture: BaseTexture;
  62972. /**
  62973. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  62974. */
  62975. specularColor: Color3;
  62976. /**
  62977. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  62978. */
  62979. glossiness: number;
  62980. /**
  62981. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  62982. */
  62983. specularGlossinessTexture: BaseTexture;
  62984. /**
  62985. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  62986. *
  62987. * @param name The material name
  62988. * @param scene The scene the material will be use in.
  62989. */
  62990. constructor(name: string, scene: Scene);
  62991. /**
  62992. * Return the currrent class name of the material.
  62993. */
  62994. getClassName(): string;
  62995. /**
  62996. * Makes a duplicate of the current material.
  62997. * @param name - name to use for the new material.
  62998. */
  62999. clone(name: string): PBRSpecularGlossinessMaterial;
  63000. /**
  63001. * Serialize the material to a parsable JSON object.
  63002. */
  63003. serialize(): any;
  63004. /**
  63005. * Parses a JSON object correponding to the serialize function.
  63006. */
  63007. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  63008. }
  63009. }
  63010. declare module BABYLON {
  63011. /**
  63012. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  63013. * It can help converting any input color in a desired output one. This can then be used to create effects
  63014. * from sepia, black and white to sixties or futuristic rendering...
  63015. *
  63016. * The only supported format is currently 3dl.
  63017. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  63018. */
  63019. export class ColorGradingTexture extends BaseTexture {
  63020. /**
  63021. * The texture URL.
  63022. */
  63023. url: string;
  63024. /**
  63025. * Empty line regex stored for GC.
  63026. */
  63027. private static _noneEmptyLineRegex;
  63028. private _textureMatrix;
  63029. private _onLoad;
  63030. /**
  63031. * Instantiates a ColorGradingTexture from the following parameters.
  63032. *
  63033. * @param url The location of the color gradind data (currently only supporting 3dl)
  63034. * @param sceneOrEngine The scene or engine the texture will be used in
  63035. * @param onLoad defines a callback triggered when the texture has been loaded
  63036. */
  63037. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  63038. /**
  63039. * Fires the onload event from the constructor if requested.
  63040. */
  63041. private _triggerOnLoad;
  63042. /**
  63043. * Returns the texture matrix used in most of the material.
  63044. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  63045. */
  63046. getTextureMatrix(): Matrix;
  63047. /**
  63048. * Occurs when the file being loaded is a .3dl LUT file.
  63049. */
  63050. private load3dlTexture;
  63051. /**
  63052. * Starts the loading process of the texture.
  63053. */
  63054. private loadTexture;
  63055. /**
  63056. * Clones the color gradind texture.
  63057. */
  63058. clone(): ColorGradingTexture;
  63059. /**
  63060. * Called during delayed load for textures.
  63061. */
  63062. delayLoad(): void;
  63063. /**
  63064. * Parses a color grading texture serialized by Babylon.
  63065. * @param parsedTexture The texture information being parsedTexture
  63066. * @param scene The scene to load the texture in
  63067. * @param rootUrl The root url of the data assets to load
  63068. * @return A color gradind texture
  63069. */
  63070. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  63071. /**
  63072. * Serializes the LUT texture to json format.
  63073. */
  63074. serialize(): any;
  63075. }
  63076. }
  63077. declare module BABYLON {
  63078. /**
  63079. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  63080. */
  63081. export class EquiRectangularCubeTexture extends BaseTexture {
  63082. /** The six faces of the cube. */
  63083. private static _FacesMapping;
  63084. private _noMipmap;
  63085. private _onLoad;
  63086. private _onError;
  63087. /** The size of the cubemap. */
  63088. private _size;
  63089. /** The buffer of the image. */
  63090. private _buffer;
  63091. /** The width of the input image. */
  63092. private _width;
  63093. /** The height of the input image. */
  63094. private _height;
  63095. /** The URL to the image. */
  63096. url: string;
  63097. /**
  63098. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  63099. * @param url The location of the image
  63100. * @param scene The scene the texture will be used in
  63101. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63102. * @param noMipmap Forces to not generate the mipmap if true
  63103. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  63104. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  63105. * @param onLoad — defines a callback called when texture is loaded
  63106. * @param onError — defines a callback called if there is an error
  63107. */
  63108. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  63109. /**
  63110. * Load the image data, by putting the image on a canvas and extracting its buffer.
  63111. */
  63112. private loadImage;
  63113. /**
  63114. * Convert the image buffer into a cubemap and create a CubeTexture.
  63115. */
  63116. private loadTexture;
  63117. /**
  63118. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  63119. * @param buffer The ArrayBuffer that should be converted.
  63120. * @returns The buffer as Float32Array.
  63121. */
  63122. private getFloat32ArrayFromArrayBuffer;
  63123. /**
  63124. * Get the current class name of the texture useful for serialization or dynamic coding.
  63125. * @returns "EquiRectangularCubeTexture"
  63126. */
  63127. getClassName(): string;
  63128. /**
  63129. * Create a clone of the current EquiRectangularCubeTexture and return it.
  63130. * @returns A clone of the current EquiRectangularCubeTexture.
  63131. */
  63132. clone(): EquiRectangularCubeTexture;
  63133. }
  63134. }
  63135. declare module BABYLON {
  63136. /**
  63137. * Defines the options related to the creation of an HtmlElementTexture
  63138. */
  63139. export interface IHtmlElementTextureOptions {
  63140. /**
  63141. * Defines wether mip maps should be created or not.
  63142. */
  63143. generateMipMaps?: boolean;
  63144. /**
  63145. * Defines the sampling mode of the texture.
  63146. */
  63147. samplingMode?: number;
  63148. /**
  63149. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  63150. */
  63151. engine: Nullable<ThinEngine>;
  63152. /**
  63153. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  63154. */
  63155. scene: Nullable<Scene>;
  63156. }
  63157. /**
  63158. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  63159. * To be as efficient as possible depending on your constraints nothing aside the first upload
  63160. * is automatically managed.
  63161. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  63162. * in your application.
  63163. *
  63164. * As the update is not automatic, you need to call them manually.
  63165. */
  63166. export class HtmlElementTexture extends BaseTexture {
  63167. /**
  63168. * The texture URL.
  63169. */
  63170. element: HTMLVideoElement | HTMLCanvasElement;
  63171. private static readonly DefaultOptions;
  63172. private _textureMatrix;
  63173. private _isVideo;
  63174. private _generateMipMaps;
  63175. private _samplingMode;
  63176. /**
  63177. * Instantiates a HtmlElementTexture from the following parameters.
  63178. *
  63179. * @param name Defines the name of the texture
  63180. * @param element Defines the video or canvas the texture is filled with
  63181. * @param options Defines the other none mandatory texture creation options
  63182. */
  63183. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  63184. private _createInternalTexture;
  63185. /**
  63186. * Returns the texture matrix used in most of the material.
  63187. */
  63188. getTextureMatrix(): Matrix;
  63189. /**
  63190. * Updates the content of the texture.
  63191. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  63192. */
  63193. update(invertY?: Nullable<boolean>): void;
  63194. }
  63195. }
  63196. declare module BABYLON {
  63197. /**
  63198. * Based on jsTGALoader - Javascript loader for TGA file
  63199. * By Vincent Thibault
  63200. * @see http://blog.robrowser.com/javascript-tga-loader.html
  63201. */
  63202. export class TGATools {
  63203. private static _TYPE_INDEXED;
  63204. private static _TYPE_RGB;
  63205. private static _TYPE_GREY;
  63206. private static _TYPE_RLE_INDEXED;
  63207. private static _TYPE_RLE_RGB;
  63208. private static _TYPE_RLE_GREY;
  63209. private static _ORIGIN_MASK;
  63210. private static _ORIGIN_SHIFT;
  63211. private static _ORIGIN_BL;
  63212. private static _ORIGIN_BR;
  63213. private static _ORIGIN_UL;
  63214. private static _ORIGIN_UR;
  63215. /**
  63216. * Gets the header of a TGA file
  63217. * @param data defines the TGA data
  63218. * @returns the header
  63219. */
  63220. static GetTGAHeader(data: Uint8Array): any;
  63221. /**
  63222. * Uploads TGA content to a Babylon Texture
  63223. * @hidden
  63224. */
  63225. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  63226. /** @hidden */
  63227. 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;
  63228. /** @hidden */
  63229. 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;
  63230. /** @hidden */
  63231. 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;
  63232. /** @hidden */
  63233. 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;
  63234. /** @hidden */
  63235. 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;
  63236. /** @hidden */
  63237. 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;
  63238. }
  63239. }
  63240. declare module BABYLON {
  63241. /**
  63242. * Implementation of the TGA Texture Loader.
  63243. * @hidden
  63244. */
  63245. export class _TGATextureLoader implements IInternalTextureLoader {
  63246. /**
  63247. * Defines wether the loader supports cascade loading the different faces.
  63248. */
  63249. readonly supportCascades: boolean;
  63250. /**
  63251. * This returns if the loader support the current file information.
  63252. * @param extension defines the file extension of the file being loaded
  63253. * @returns true if the loader can load the specified file
  63254. */
  63255. canLoad(extension: string): boolean;
  63256. /**
  63257. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63258. * @param data contains the texture data
  63259. * @param texture defines the BabylonJS internal texture
  63260. * @param createPolynomials will be true if polynomials have been requested
  63261. * @param onLoad defines the callback to trigger once the texture is ready
  63262. * @param onError defines the callback to trigger in case of error
  63263. */
  63264. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63265. /**
  63266. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63267. * @param data contains the texture data
  63268. * @param texture defines the BabylonJS internal texture
  63269. * @param callback defines the method to call once ready to upload
  63270. */
  63271. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63272. }
  63273. }
  63274. declare module BABYLON {
  63275. /**
  63276. * Info about the .basis files
  63277. */
  63278. class BasisFileInfo {
  63279. /**
  63280. * If the file has alpha
  63281. */
  63282. hasAlpha: boolean;
  63283. /**
  63284. * Info about each image of the basis file
  63285. */
  63286. images: Array<{
  63287. levels: Array<{
  63288. width: number;
  63289. height: number;
  63290. transcodedPixels: ArrayBufferView;
  63291. }>;
  63292. }>;
  63293. }
  63294. /**
  63295. * Result of transcoding a basis file
  63296. */
  63297. class TranscodeResult {
  63298. /**
  63299. * Info about the .basis file
  63300. */
  63301. fileInfo: BasisFileInfo;
  63302. /**
  63303. * Format to use when loading the file
  63304. */
  63305. format: number;
  63306. }
  63307. /**
  63308. * Configuration options for the Basis transcoder
  63309. */
  63310. export class BasisTranscodeConfiguration {
  63311. /**
  63312. * Supported compression formats used to determine the supported output format of the transcoder
  63313. */
  63314. supportedCompressionFormats?: {
  63315. /**
  63316. * etc1 compression format
  63317. */
  63318. etc1?: boolean;
  63319. /**
  63320. * s3tc compression format
  63321. */
  63322. s3tc?: boolean;
  63323. /**
  63324. * pvrtc compression format
  63325. */
  63326. pvrtc?: boolean;
  63327. /**
  63328. * etc2 compression format
  63329. */
  63330. etc2?: boolean;
  63331. };
  63332. /**
  63333. * If mipmap levels should be loaded for transcoded images (Default: true)
  63334. */
  63335. loadMipmapLevels?: boolean;
  63336. /**
  63337. * Index of a single image to load (Default: all images)
  63338. */
  63339. loadSingleImage?: number;
  63340. }
  63341. /**
  63342. * Used to load .Basis files
  63343. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  63344. */
  63345. export class BasisTools {
  63346. private static _IgnoreSupportedFormats;
  63347. /**
  63348. * URL to use when loading the basis transcoder
  63349. */
  63350. static JSModuleURL: string;
  63351. /**
  63352. * URL to use when loading the wasm module for the transcoder
  63353. */
  63354. static WasmModuleURL: string;
  63355. /**
  63356. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  63357. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  63358. * @returns internal format corresponding to the Basis format
  63359. */
  63360. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  63361. private static _WorkerPromise;
  63362. private static _Worker;
  63363. private static _actionId;
  63364. private static _CreateWorkerAsync;
  63365. /**
  63366. * Transcodes a loaded image file to compressed pixel data
  63367. * @param data image data to transcode
  63368. * @param config configuration options for the transcoding
  63369. * @returns a promise resulting in the transcoded image
  63370. */
  63371. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  63372. /**
  63373. * Loads a texture from the transcode result
  63374. * @param texture texture load to
  63375. * @param transcodeResult the result of transcoding the basis file to load from
  63376. */
  63377. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  63378. }
  63379. }
  63380. declare module BABYLON {
  63381. /**
  63382. * Loader for .basis file format
  63383. */
  63384. export class _BasisTextureLoader implements IInternalTextureLoader {
  63385. /**
  63386. * Defines whether the loader supports cascade loading the different faces.
  63387. */
  63388. readonly supportCascades: boolean;
  63389. /**
  63390. * This returns if the loader support the current file information.
  63391. * @param extension defines the file extension of the file being loaded
  63392. * @returns true if the loader can load the specified file
  63393. */
  63394. canLoad(extension: string): boolean;
  63395. /**
  63396. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63397. * @param data contains the texture data
  63398. * @param texture defines the BabylonJS internal texture
  63399. * @param createPolynomials will be true if polynomials have been requested
  63400. * @param onLoad defines the callback to trigger once the texture is ready
  63401. * @param onError defines the callback to trigger in case of error
  63402. */
  63403. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63404. /**
  63405. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63406. * @param data contains the texture data
  63407. * @param texture defines the BabylonJS internal texture
  63408. * @param callback defines the method to call once ready to upload
  63409. */
  63410. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63411. }
  63412. }
  63413. declare module BABYLON {
  63414. /**
  63415. * Defines the basic options interface of a TexturePacker Frame
  63416. */
  63417. export interface ITexturePackerFrame {
  63418. /**
  63419. * The frame ID
  63420. */
  63421. id: number;
  63422. /**
  63423. * The frames Scale
  63424. */
  63425. scale: Vector2;
  63426. /**
  63427. * The Frames offset
  63428. */
  63429. offset: Vector2;
  63430. }
  63431. /**
  63432. * This is a support class for frame Data on texture packer sets.
  63433. */
  63434. export class TexturePackerFrame implements ITexturePackerFrame {
  63435. /**
  63436. * The frame ID
  63437. */
  63438. id: number;
  63439. /**
  63440. * The frames Scale
  63441. */
  63442. scale: Vector2;
  63443. /**
  63444. * The Frames offset
  63445. */
  63446. offset: Vector2;
  63447. /**
  63448. * Initializes a texture package frame.
  63449. * @param id The numerical frame identifier
  63450. * @param scale Scalar Vector2 for UV frame
  63451. * @param offset Vector2 for the frame position in UV units.
  63452. * @returns TexturePackerFrame
  63453. */
  63454. constructor(id: number, scale: Vector2, offset: Vector2);
  63455. }
  63456. }
  63457. declare module BABYLON {
  63458. /**
  63459. * Defines the basic options interface of a TexturePacker
  63460. */
  63461. export interface ITexturePackerOptions {
  63462. /**
  63463. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  63464. */
  63465. map?: string[];
  63466. /**
  63467. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63468. */
  63469. uvsIn?: string;
  63470. /**
  63471. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63472. */
  63473. uvsOut?: string;
  63474. /**
  63475. * number representing the layout style. Defaults to LAYOUT_STRIP
  63476. */
  63477. layout?: number;
  63478. /**
  63479. * number of columns if using custom column count layout(2). This defaults to 4.
  63480. */
  63481. colnum?: number;
  63482. /**
  63483. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  63484. */
  63485. updateInputMeshes?: boolean;
  63486. /**
  63487. * boolean flag to dispose all the source textures. Defaults to true.
  63488. */
  63489. disposeSources?: boolean;
  63490. /**
  63491. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  63492. */
  63493. fillBlanks?: boolean;
  63494. /**
  63495. * string value representing the context fill style color. Defaults to 'black'.
  63496. */
  63497. customFillColor?: string;
  63498. /**
  63499. * Width and Height Value of each Frame in the TexturePacker Sets
  63500. */
  63501. frameSize?: number;
  63502. /**
  63503. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  63504. */
  63505. paddingRatio?: number;
  63506. /**
  63507. * Number that declares the fill method for the padding gutter.
  63508. */
  63509. paddingMode?: number;
  63510. /**
  63511. * If in SUBUV_COLOR padding mode what color to use.
  63512. */
  63513. paddingColor?: Color3 | Color4;
  63514. }
  63515. /**
  63516. * Defines the basic interface of a TexturePacker JSON File
  63517. */
  63518. export interface ITexturePackerJSON {
  63519. /**
  63520. * The frame ID
  63521. */
  63522. name: string;
  63523. /**
  63524. * The base64 channel data
  63525. */
  63526. sets: any;
  63527. /**
  63528. * The options of the Packer
  63529. */
  63530. options: ITexturePackerOptions;
  63531. /**
  63532. * The frame data of the Packer
  63533. */
  63534. frames: Array<number>;
  63535. }
  63536. /**
  63537. * This is a support class that generates a series of packed texture sets.
  63538. * @see https://doc.babylonjs.com/babylon101/materials
  63539. */
  63540. export class TexturePacker {
  63541. /** Packer Layout Constant 0 */
  63542. static readonly LAYOUT_STRIP: number;
  63543. /** Packer Layout Constant 1 */
  63544. static readonly LAYOUT_POWER2: number;
  63545. /** Packer Layout Constant 2 */
  63546. static readonly LAYOUT_COLNUM: number;
  63547. /** Packer Layout Constant 0 */
  63548. static readonly SUBUV_WRAP: number;
  63549. /** Packer Layout Constant 1 */
  63550. static readonly SUBUV_EXTEND: number;
  63551. /** Packer Layout Constant 2 */
  63552. static readonly SUBUV_COLOR: number;
  63553. /** The Name of the Texture Package */
  63554. name: string;
  63555. /** The scene scope of the TexturePacker */
  63556. scene: Scene;
  63557. /** The Meshes to target */
  63558. meshes: AbstractMesh[];
  63559. /** Arguments passed with the Constructor */
  63560. options: ITexturePackerOptions;
  63561. /** The promise that is started upon initialization */
  63562. promise: Nullable<Promise<TexturePacker | string>>;
  63563. /** The Container object for the channel sets that are generated */
  63564. sets: object;
  63565. /** The Container array for the frames that are generated */
  63566. frames: TexturePackerFrame[];
  63567. /** The expected number of textures the system is parsing. */
  63568. private _expecting;
  63569. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  63570. private _paddingValue;
  63571. /**
  63572. * Initializes a texture package series from an array of meshes or a single mesh.
  63573. * @param name The name of the package
  63574. * @param meshes The target meshes to compose the package from
  63575. * @param options The arguments that texture packer should follow while building.
  63576. * @param scene The scene which the textures are scoped to.
  63577. * @returns TexturePacker
  63578. */
  63579. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  63580. /**
  63581. * Starts the package process
  63582. * @param resolve The promises resolution function
  63583. * @returns TexturePacker
  63584. */
  63585. private _createFrames;
  63586. /**
  63587. * Calculates the Size of the Channel Sets
  63588. * @returns Vector2
  63589. */
  63590. private _calculateSize;
  63591. /**
  63592. * Calculates the UV data for the frames.
  63593. * @param baseSize the base frameSize
  63594. * @param padding the base frame padding
  63595. * @param dtSize size of the Dynamic Texture for that channel
  63596. * @param dtUnits is 1/dtSize
  63597. * @param update flag to update the input meshes
  63598. */
  63599. private _calculateMeshUVFrames;
  63600. /**
  63601. * Calculates the frames Offset.
  63602. * @param index of the frame
  63603. * @returns Vector2
  63604. */
  63605. private _getFrameOffset;
  63606. /**
  63607. * Updates a Mesh to the frame data
  63608. * @param mesh that is the target
  63609. * @param frameID or the frame index
  63610. */
  63611. private _updateMeshUV;
  63612. /**
  63613. * Updates a Meshes materials to use the texture packer channels
  63614. * @param m is the mesh to target
  63615. * @param force all channels on the packer to be set.
  63616. */
  63617. private _updateTextureReferences;
  63618. /**
  63619. * Public method to set a Mesh to a frame
  63620. * @param m that is the target
  63621. * @param frameID or the frame index
  63622. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  63623. */
  63624. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  63625. /**
  63626. * Starts the async promise to compile the texture packer.
  63627. * @returns Promise<void>
  63628. */
  63629. processAsync(): Promise<void>;
  63630. /**
  63631. * Disposes all textures associated with this packer
  63632. */
  63633. dispose(): void;
  63634. /**
  63635. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  63636. * @param imageType is the image type to use.
  63637. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  63638. */
  63639. download(imageType?: string, quality?: number): void;
  63640. /**
  63641. * Public method to load a texturePacker JSON file.
  63642. * @param data of the JSON file in string format.
  63643. */
  63644. updateFromJSON(data: string): void;
  63645. }
  63646. }
  63647. declare module BABYLON {
  63648. /**
  63649. * 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.
  63650. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63651. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63652. */
  63653. export class CustomProceduralTexture extends ProceduralTexture {
  63654. private _animate;
  63655. private _time;
  63656. private _config;
  63657. private _texturePath;
  63658. /**
  63659. * Instantiates a new Custom Procedural Texture.
  63660. * 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.
  63661. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63662. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63663. * @param name Define the name of the texture
  63664. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  63665. * @param size Define the size of the texture to create
  63666. * @param scene Define the scene the texture belongs to
  63667. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  63668. * @param generateMipMaps Define if the texture should creates mip maps or not
  63669. */
  63670. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63671. private _loadJson;
  63672. /**
  63673. * Is the texture ready to be used ? (rendered at least once)
  63674. * @returns true if ready, otherwise, false.
  63675. */
  63676. isReady(): boolean;
  63677. /**
  63678. * Render the texture to its associated render target.
  63679. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  63680. */
  63681. render(useCameraPostProcess?: boolean): void;
  63682. /**
  63683. * Update the list of dependant textures samplers in the shader.
  63684. */
  63685. updateTextures(): void;
  63686. /**
  63687. * Update the uniform values of the procedural texture in the shader.
  63688. */
  63689. updateShaderUniforms(): void;
  63690. /**
  63691. * Define if the texture animates or not.
  63692. */
  63693. get animate(): boolean;
  63694. set animate(value: boolean);
  63695. }
  63696. }
  63697. declare module BABYLON {
  63698. /** @hidden */
  63699. export var noisePixelShader: {
  63700. name: string;
  63701. shader: string;
  63702. };
  63703. }
  63704. declare module BABYLON {
  63705. /**
  63706. * Class used to generate noise procedural textures
  63707. */
  63708. export class NoiseProceduralTexture extends ProceduralTexture {
  63709. /** Gets or sets the start time (default is 0) */
  63710. time: number;
  63711. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  63712. brightness: number;
  63713. /** Defines the number of octaves to process */
  63714. octaves: number;
  63715. /** Defines the level of persistence (0.8 by default) */
  63716. persistence: number;
  63717. /** Gets or sets animation speed factor (default is 1) */
  63718. animationSpeedFactor: number;
  63719. /**
  63720. * Creates a new NoiseProceduralTexture
  63721. * @param name defines the name fo the texture
  63722. * @param size defines the size of the texture (default is 256)
  63723. * @param scene defines the hosting scene
  63724. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  63725. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  63726. */
  63727. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63728. private _updateShaderUniforms;
  63729. protected _getDefines(): string;
  63730. /** Generate the current state of the procedural texture */
  63731. render(useCameraPostProcess?: boolean): void;
  63732. /**
  63733. * Serializes this noise procedural texture
  63734. * @returns a serialized noise procedural texture object
  63735. */
  63736. serialize(): any;
  63737. /**
  63738. * Clone the texture.
  63739. * @returns the cloned texture
  63740. */
  63741. clone(): NoiseProceduralTexture;
  63742. /**
  63743. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  63744. * @param parsedTexture defines parsed texture data
  63745. * @param scene defines the current scene
  63746. * @param rootUrl defines the root URL containing noise procedural texture information
  63747. * @returns a parsed NoiseProceduralTexture
  63748. */
  63749. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  63750. }
  63751. }
  63752. declare module BABYLON {
  63753. /**
  63754. * Raw cube texture where the raw buffers are passed in
  63755. */
  63756. export class RawCubeTexture extends CubeTexture {
  63757. /**
  63758. * Creates a cube texture where the raw buffers are passed in.
  63759. * @param scene defines the scene the texture is attached to
  63760. * @param data defines the array of data to use to create each face
  63761. * @param size defines the size of the textures
  63762. * @param format defines the format of the data
  63763. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  63764. * @param generateMipMaps defines if the engine should generate the mip levels
  63765. * @param invertY defines if data must be stored with Y axis inverted
  63766. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  63767. * @param compression defines the compression used (null by default)
  63768. */
  63769. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  63770. /**
  63771. * Updates the raw cube texture.
  63772. * @param data defines the data to store
  63773. * @param format defines the data format
  63774. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63775. * @param invertY defines if data must be stored with Y axis inverted
  63776. * @param compression defines the compression used (null by default)
  63777. * @param level defines which level of the texture to update
  63778. */
  63779. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  63780. /**
  63781. * Updates a raw cube texture with RGBD encoded data.
  63782. * @param data defines the array of data [mipmap][face] to use to create each face
  63783. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  63784. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  63785. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  63786. * @returns a promsie that resolves when the operation is complete
  63787. */
  63788. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  63789. /**
  63790. * Clones the raw cube texture.
  63791. * @return a new cube texture
  63792. */
  63793. clone(): CubeTexture;
  63794. /** @hidden */
  63795. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  63796. }
  63797. }
  63798. declare module BABYLON {
  63799. /**
  63800. * Class used to store 2D array textures containing user data
  63801. */
  63802. export class RawTexture2DArray extends Texture {
  63803. /** Gets or sets the texture format to use */
  63804. format: number;
  63805. /**
  63806. * Create a new RawTexture2DArray
  63807. * @param data defines the data of the texture
  63808. * @param width defines the width of the texture
  63809. * @param height defines the height of the texture
  63810. * @param depth defines the number of layers of the texture
  63811. * @param format defines the texture format to use
  63812. * @param scene defines the hosting scene
  63813. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63814. * @param invertY defines if texture must be stored with Y axis inverted
  63815. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63816. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63817. */
  63818. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63819. /** Gets or sets the texture format to use */
  63820. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63821. /**
  63822. * Update the texture with new data
  63823. * @param data defines the data to store in the texture
  63824. */
  63825. update(data: ArrayBufferView): void;
  63826. }
  63827. }
  63828. declare module BABYLON {
  63829. /**
  63830. * Class used to store 3D textures containing user data
  63831. */
  63832. export class RawTexture3D extends Texture {
  63833. /** Gets or sets the texture format to use */
  63834. format: number;
  63835. /**
  63836. * Create a new RawTexture3D
  63837. * @param data defines the data of the texture
  63838. * @param width defines the width of the texture
  63839. * @param height defines the height of the texture
  63840. * @param depth defines the depth of the texture
  63841. * @param format defines the texture format to use
  63842. * @param scene defines the hosting scene
  63843. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63844. * @param invertY defines if texture must be stored with Y axis inverted
  63845. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63846. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63847. */
  63848. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63849. /** Gets or sets the texture format to use */
  63850. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63851. /**
  63852. * Update the texture with new data
  63853. * @param data defines the data to store in the texture
  63854. */
  63855. update(data: ArrayBufferView): void;
  63856. }
  63857. }
  63858. declare module BABYLON {
  63859. /**
  63860. * Creates a refraction texture used by refraction channel of the standard material.
  63861. * It is like a mirror but to see through a material.
  63862. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63863. */
  63864. export class RefractionTexture extends RenderTargetTexture {
  63865. /**
  63866. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  63867. * 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.
  63868. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63869. */
  63870. refractionPlane: Plane;
  63871. /**
  63872. * Define how deep under the surface we should see.
  63873. */
  63874. depth: number;
  63875. /**
  63876. * Creates a refraction texture used by refraction channel of the standard material.
  63877. * It is like a mirror but to see through a material.
  63878. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63879. * @param name Define the texture name
  63880. * @param size Define the size of the underlying texture
  63881. * @param scene Define the scene the refraction belongs to
  63882. * @param generateMipMaps Define if we need to generate mips level for the refraction
  63883. */
  63884. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  63885. /**
  63886. * Clone the refraction texture.
  63887. * @returns the cloned texture
  63888. */
  63889. clone(): RefractionTexture;
  63890. /**
  63891. * Serialize the texture to a JSON representation you could use in Parse later on
  63892. * @returns the serialized JSON representation
  63893. */
  63894. serialize(): any;
  63895. }
  63896. }
  63897. declare module BABYLON {
  63898. /**
  63899. * Block used to add support for vertex skinning (bones)
  63900. */
  63901. export class BonesBlock extends NodeMaterialBlock {
  63902. /**
  63903. * Creates a new BonesBlock
  63904. * @param name defines the block name
  63905. */
  63906. constructor(name: string);
  63907. /**
  63908. * Initialize the block and prepare the context for build
  63909. * @param state defines the state that will be used for the build
  63910. */
  63911. initialize(state: NodeMaterialBuildState): void;
  63912. /**
  63913. * Gets the current class name
  63914. * @returns the class name
  63915. */
  63916. getClassName(): string;
  63917. /**
  63918. * Gets the matrix indices input component
  63919. */
  63920. get matricesIndices(): NodeMaterialConnectionPoint;
  63921. /**
  63922. * Gets the matrix weights input component
  63923. */
  63924. get matricesWeights(): NodeMaterialConnectionPoint;
  63925. /**
  63926. * Gets the extra matrix indices input component
  63927. */
  63928. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  63929. /**
  63930. * Gets the extra matrix weights input component
  63931. */
  63932. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  63933. /**
  63934. * Gets the world input component
  63935. */
  63936. get world(): NodeMaterialConnectionPoint;
  63937. /**
  63938. * Gets the output component
  63939. */
  63940. get output(): NodeMaterialConnectionPoint;
  63941. autoConfigure(material: NodeMaterial): void;
  63942. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  63943. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63944. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63945. protected _buildBlock(state: NodeMaterialBuildState): this;
  63946. }
  63947. }
  63948. declare module BABYLON {
  63949. /**
  63950. * Block used to add support for instances
  63951. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  63952. */
  63953. export class InstancesBlock extends NodeMaterialBlock {
  63954. /**
  63955. * Creates a new InstancesBlock
  63956. * @param name defines the block name
  63957. */
  63958. constructor(name: string);
  63959. /**
  63960. * Gets the current class name
  63961. * @returns the class name
  63962. */
  63963. getClassName(): string;
  63964. /**
  63965. * Gets the first world row input component
  63966. */
  63967. get world0(): NodeMaterialConnectionPoint;
  63968. /**
  63969. * Gets the second world row input component
  63970. */
  63971. get world1(): NodeMaterialConnectionPoint;
  63972. /**
  63973. * Gets the third world row input component
  63974. */
  63975. get world2(): NodeMaterialConnectionPoint;
  63976. /**
  63977. * Gets the forth world row input component
  63978. */
  63979. get world3(): NodeMaterialConnectionPoint;
  63980. /**
  63981. * Gets the world input component
  63982. */
  63983. get world(): NodeMaterialConnectionPoint;
  63984. /**
  63985. * Gets the output component
  63986. */
  63987. get output(): NodeMaterialConnectionPoint;
  63988. /**
  63989. * Gets the isntanceID component
  63990. */
  63991. get instanceID(): NodeMaterialConnectionPoint;
  63992. autoConfigure(material: NodeMaterial): void;
  63993. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  63994. protected _buildBlock(state: NodeMaterialBuildState): this;
  63995. }
  63996. }
  63997. declare module BABYLON {
  63998. /**
  63999. * Block used to add morph targets support to vertex shader
  64000. */
  64001. export class MorphTargetsBlock extends NodeMaterialBlock {
  64002. private _repeatableContentAnchor;
  64003. /**
  64004. * Create a new MorphTargetsBlock
  64005. * @param name defines the block name
  64006. */
  64007. constructor(name: string);
  64008. /**
  64009. * Gets the current class name
  64010. * @returns the class name
  64011. */
  64012. getClassName(): string;
  64013. /**
  64014. * Gets the position input component
  64015. */
  64016. get position(): NodeMaterialConnectionPoint;
  64017. /**
  64018. * Gets the normal input component
  64019. */
  64020. get normal(): NodeMaterialConnectionPoint;
  64021. /**
  64022. * Gets the tangent input component
  64023. */
  64024. get tangent(): NodeMaterialConnectionPoint;
  64025. /**
  64026. * Gets the tangent input component
  64027. */
  64028. get uv(): NodeMaterialConnectionPoint;
  64029. /**
  64030. * Gets the position output component
  64031. */
  64032. get positionOutput(): NodeMaterialConnectionPoint;
  64033. /**
  64034. * Gets the normal output component
  64035. */
  64036. get normalOutput(): NodeMaterialConnectionPoint;
  64037. /**
  64038. * Gets the tangent output component
  64039. */
  64040. get tangentOutput(): NodeMaterialConnectionPoint;
  64041. /**
  64042. * Gets the tangent output component
  64043. */
  64044. get uvOutput(): NodeMaterialConnectionPoint;
  64045. initialize(state: NodeMaterialBuildState): void;
  64046. autoConfigure(material: NodeMaterial): void;
  64047. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64048. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64049. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  64050. protected _buildBlock(state: NodeMaterialBuildState): this;
  64051. }
  64052. }
  64053. declare module BABYLON {
  64054. /**
  64055. * Block used to get data information from a light
  64056. */
  64057. export class LightInformationBlock extends NodeMaterialBlock {
  64058. private _lightDataUniformName;
  64059. private _lightColorUniformName;
  64060. private _lightTypeDefineName;
  64061. /**
  64062. * Gets or sets the light associated with this block
  64063. */
  64064. light: Nullable<Light>;
  64065. /**
  64066. * Creates a new LightInformationBlock
  64067. * @param name defines the block name
  64068. */
  64069. constructor(name: string);
  64070. /**
  64071. * Gets the current class name
  64072. * @returns the class name
  64073. */
  64074. getClassName(): string;
  64075. /**
  64076. * Gets the world position input component
  64077. */
  64078. get worldPosition(): NodeMaterialConnectionPoint;
  64079. /**
  64080. * Gets the direction output component
  64081. */
  64082. get direction(): NodeMaterialConnectionPoint;
  64083. /**
  64084. * Gets the direction output component
  64085. */
  64086. get color(): NodeMaterialConnectionPoint;
  64087. /**
  64088. * Gets the direction output component
  64089. */
  64090. get intensity(): NodeMaterialConnectionPoint;
  64091. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64092. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64093. protected _buildBlock(state: NodeMaterialBuildState): this;
  64094. serialize(): any;
  64095. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64096. }
  64097. }
  64098. declare module BABYLON {
  64099. /**
  64100. * Block used to add image processing support to fragment shader
  64101. */
  64102. export class ImageProcessingBlock extends NodeMaterialBlock {
  64103. /**
  64104. * Create a new ImageProcessingBlock
  64105. * @param name defines the block name
  64106. */
  64107. constructor(name: string);
  64108. /**
  64109. * Gets the current class name
  64110. * @returns the class name
  64111. */
  64112. getClassName(): string;
  64113. /**
  64114. * Gets the color input component
  64115. */
  64116. get color(): NodeMaterialConnectionPoint;
  64117. /**
  64118. * Gets the output component
  64119. */
  64120. get output(): NodeMaterialConnectionPoint;
  64121. /**
  64122. * Initialize the block and prepare the context for build
  64123. * @param state defines the state that will be used for the build
  64124. */
  64125. initialize(state: NodeMaterialBuildState): void;
  64126. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  64127. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64128. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64129. protected _buildBlock(state: NodeMaterialBuildState): this;
  64130. }
  64131. }
  64132. declare module BABYLON {
  64133. /**
  64134. * Block used to pertub normals based on a normal map
  64135. */
  64136. export class PerturbNormalBlock extends NodeMaterialBlock {
  64137. private _tangentSpaceParameterName;
  64138. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64139. invertX: boolean;
  64140. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  64141. invertY: boolean;
  64142. /**
  64143. * Create a new PerturbNormalBlock
  64144. * @param name defines the block name
  64145. */
  64146. constructor(name: string);
  64147. /**
  64148. * Gets the current class name
  64149. * @returns the class name
  64150. */
  64151. getClassName(): string;
  64152. /**
  64153. * Gets the world position input component
  64154. */
  64155. get worldPosition(): NodeMaterialConnectionPoint;
  64156. /**
  64157. * Gets the world normal input component
  64158. */
  64159. get worldNormal(): NodeMaterialConnectionPoint;
  64160. /**
  64161. * Gets the world tangent input component
  64162. */
  64163. get worldTangent(): NodeMaterialConnectionPoint;
  64164. /**
  64165. * Gets the uv input component
  64166. */
  64167. get uv(): NodeMaterialConnectionPoint;
  64168. /**
  64169. * Gets the normal map color input component
  64170. */
  64171. get normalMapColor(): NodeMaterialConnectionPoint;
  64172. /**
  64173. * Gets the strength input component
  64174. */
  64175. get strength(): NodeMaterialConnectionPoint;
  64176. /**
  64177. * Gets the output component
  64178. */
  64179. get output(): NodeMaterialConnectionPoint;
  64180. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64181. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64182. autoConfigure(material: NodeMaterial): void;
  64183. protected _buildBlock(state: NodeMaterialBuildState): this;
  64184. protected _dumpPropertiesCode(): string;
  64185. serialize(): any;
  64186. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64187. }
  64188. }
  64189. declare module BABYLON {
  64190. /**
  64191. * Block used to discard a pixel if a value is smaller than a cutoff
  64192. */
  64193. export class DiscardBlock extends NodeMaterialBlock {
  64194. /**
  64195. * Create a new DiscardBlock
  64196. * @param name defines the block name
  64197. */
  64198. constructor(name: string);
  64199. /**
  64200. * Gets the current class name
  64201. * @returns the class name
  64202. */
  64203. getClassName(): string;
  64204. /**
  64205. * Gets the color input component
  64206. */
  64207. get value(): NodeMaterialConnectionPoint;
  64208. /**
  64209. * Gets the cutoff input component
  64210. */
  64211. get cutoff(): NodeMaterialConnectionPoint;
  64212. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64213. }
  64214. }
  64215. declare module BABYLON {
  64216. /**
  64217. * Block used to test if the fragment shader is front facing
  64218. */
  64219. export class FrontFacingBlock extends NodeMaterialBlock {
  64220. /**
  64221. * Creates a new FrontFacingBlock
  64222. * @param name defines the block name
  64223. */
  64224. constructor(name: string);
  64225. /**
  64226. * Gets the current class name
  64227. * @returns the class name
  64228. */
  64229. getClassName(): string;
  64230. /**
  64231. * Gets the output component
  64232. */
  64233. get output(): NodeMaterialConnectionPoint;
  64234. protected _buildBlock(state: NodeMaterialBuildState): this;
  64235. }
  64236. }
  64237. declare module BABYLON {
  64238. /**
  64239. * Block used to get the derivative value on x and y of a given input
  64240. */
  64241. export class DerivativeBlock extends NodeMaterialBlock {
  64242. /**
  64243. * Create a new DerivativeBlock
  64244. * @param name defines the block name
  64245. */
  64246. constructor(name: string);
  64247. /**
  64248. * Gets the current class name
  64249. * @returns the class name
  64250. */
  64251. getClassName(): string;
  64252. /**
  64253. * Gets the input component
  64254. */
  64255. get input(): NodeMaterialConnectionPoint;
  64256. /**
  64257. * Gets the derivative output on x
  64258. */
  64259. get dx(): NodeMaterialConnectionPoint;
  64260. /**
  64261. * Gets the derivative output on y
  64262. */
  64263. get dy(): NodeMaterialConnectionPoint;
  64264. protected _buildBlock(state: NodeMaterialBuildState): this;
  64265. }
  64266. }
  64267. declare module BABYLON {
  64268. /**
  64269. * Block used to make gl_FragCoord available
  64270. */
  64271. export class FragCoordBlock extends NodeMaterialBlock {
  64272. /**
  64273. * Creates a new FragCoordBlock
  64274. * @param name defines the block name
  64275. */
  64276. constructor(name: string);
  64277. /**
  64278. * Gets the current class name
  64279. * @returns the class name
  64280. */
  64281. getClassName(): string;
  64282. /**
  64283. * Gets the xy component
  64284. */
  64285. get xy(): NodeMaterialConnectionPoint;
  64286. /**
  64287. * Gets the xyz component
  64288. */
  64289. get xyz(): NodeMaterialConnectionPoint;
  64290. /**
  64291. * Gets the xyzw component
  64292. */
  64293. get xyzw(): NodeMaterialConnectionPoint;
  64294. /**
  64295. * Gets the x component
  64296. */
  64297. get x(): NodeMaterialConnectionPoint;
  64298. /**
  64299. * Gets the y component
  64300. */
  64301. get y(): NodeMaterialConnectionPoint;
  64302. /**
  64303. * Gets the z component
  64304. */
  64305. get z(): NodeMaterialConnectionPoint;
  64306. /**
  64307. * Gets the w component
  64308. */
  64309. get output(): NodeMaterialConnectionPoint;
  64310. protected writeOutputs(state: NodeMaterialBuildState): string;
  64311. protected _buildBlock(state: NodeMaterialBuildState): this;
  64312. }
  64313. }
  64314. declare module BABYLON {
  64315. /**
  64316. * Block used to get the screen sizes
  64317. */
  64318. export class ScreenSizeBlock extends NodeMaterialBlock {
  64319. private _varName;
  64320. private _scene;
  64321. /**
  64322. * Creates a new ScreenSizeBlock
  64323. * @param name defines the block name
  64324. */
  64325. constructor(name: string);
  64326. /**
  64327. * Gets the current class name
  64328. * @returns the class name
  64329. */
  64330. getClassName(): string;
  64331. /**
  64332. * Gets the xy component
  64333. */
  64334. get xy(): NodeMaterialConnectionPoint;
  64335. /**
  64336. * Gets the x component
  64337. */
  64338. get x(): NodeMaterialConnectionPoint;
  64339. /**
  64340. * Gets the y component
  64341. */
  64342. get y(): NodeMaterialConnectionPoint;
  64343. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64344. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  64345. protected _buildBlock(state: NodeMaterialBuildState): this;
  64346. }
  64347. }
  64348. declare module BABYLON {
  64349. /**
  64350. * Block used to add support for scene fog
  64351. */
  64352. export class FogBlock extends NodeMaterialBlock {
  64353. private _fogDistanceName;
  64354. private _fogParameters;
  64355. /**
  64356. * Create a new FogBlock
  64357. * @param name defines the block name
  64358. */
  64359. constructor(name: string);
  64360. /**
  64361. * Gets the current class name
  64362. * @returns the class name
  64363. */
  64364. getClassName(): string;
  64365. /**
  64366. * Gets the world position input component
  64367. */
  64368. get worldPosition(): NodeMaterialConnectionPoint;
  64369. /**
  64370. * Gets the view input component
  64371. */
  64372. get view(): NodeMaterialConnectionPoint;
  64373. /**
  64374. * Gets the color input component
  64375. */
  64376. get input(): NodeMaterialConnectionPoint;
  64377. /**
  64378. * Gets the fog color input component
  64379. */
  64380. get fogColor(): NodeMaterialConnectionPoint;
  64381. /**
  64382. * Gets the output component
  64383. */
  64384. get output(): NodeMaterialConnectionPoint;
  64385. autoConfigure(material: NodeMaterial): void;
  64386. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64387. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64388. protected _buildBlock(state: NodeMaterialBuildState): this;
  64389. }
  64390. }
  64391. declare module BABYLON {
  64392. /**
  64393. * Block used to add light in the fragment shader
  64394. */
  64395. export class LightBlock extends NodeMaterialBlock {
  64396. private _lightId;
  64397. /**
  64398. * Gets or sets the light associated with this block
  64399. */
  64400. light: Nullable<Light>;
  64401. /**
  64402. * Create a new LightBlock
  64403. * @param name defines the block name
  64404. */
  64405. constructor(name: string);
  64406. /**
  64407. * Gets the current class name
  64408. * @returns the class name
  64409. */
  64410. getClassName(): string;
  64411. /**
  64412. * Gets the world position input component
  64413. */
  64414. get worldPosition(): NodeMaterialConnectionPoint;
  64415. /**
  64416. * Gets the world normal input component
  64417. */
  64418. get worldNormal(): NodeMaterialConnectionPoint;
  64419. /**
  64420. * Gets the camera (or eye) position component
  64421. */
  64422. get cameraPosition(): NodeMaterialConnectionPoint;
  64423. /**
  64424. * Gets the glossiness component
  64425. */
  64426. get glossiness(): NodeMaterialConnectionPoint;
  64427. /**
  64428. * Gets the glossinness power component
  64429. */
  64430. get glossPower(): NodeMaterialConnectionPoint;
  64431. /**
  64432. * Gets the diffuse color component
  64433. */
  64434. get diffuseColor(): NodeMaterialConnectionPoint;
  64435. /**
  64436. * Gets the specular color component
  64437. */
  64438. get specularColor(): NodeMaterialConnectionPoint;
  64439. /**
  64440. * Gets the view matrix component
  64441. */
  64442. get view(): NodeMaterialConnectionPoint;
  64443. /**
  64444. * Gets the diffuse output component
  64445. */
  64446. get diffuseOutput(): NodeMaterialConnectionPoint;
  64447. /**
  64448. * Gets the specular output component
  64449. */
  64450. get specularOutput(): NodeMaterialConnectionPoint;
  64451. /**
  64452. * Gets the shadow output component
  64453. */
  64454. get shadow(): NodeMaterialConnectionPoint;
  64455. autoConfigure(material: NodeMaterial): void;
  64456. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64457. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64458. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64459. private _injectVertexCode;
  64460. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64461. serialize(): any;
  64462. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64463. }
  64464. }
  64465. declare module BABYLON {
  64466. /**
  64467. * Block used to read a reflection texture from a sampler
  64468. */
  64469. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  64470. /**
  64471. * Create a new ReflectionTextureBlock
  64472. * @param name defines the block name
  64473. */
  64474. constructor(name: string);
  64475. /**
  64476. * Gets the current class name
  64477. * @returns the class name
  64478. */
  64479. getClassName(): string;
  64480. /**
  64481. * Gets the world position input component
  64482. */
  64483. get position(): NodeMaterialConnectionPoint;
  64484. /**
  64485. * Gets the world position input component
  64486. */
  64487. get worldPosition(): NodeMaterialConnectionPoint;
  64488. /**
  64489. * Gets the world normal input component
  64490. */
  64491. get worldNormal(): NodeMaterialConnectionPoint;
  64492. /**
  64493. * Gets the world input component
  64494. */
  64495. get world(): NodeMaterialConnectionPoint;
  64496. /**
  64497. * Gets the camera (or eye) position component
  64498. */
  64499. get cameraPosition(): NodeMaterialConnectionPoint;
  64500. /**
  64501. * Gets the view input component
  64502. */
  64503. get view(): NodeMaterialConnectionPoint;
  64504. /**
  64505. * Gets the rgb output component
  64506. */
  64507. get rgb(): NodeMaterialConnectionPoint;
  64508. /**
  64509. * Gets the rgba output component
  64510. */
  64511. get rgba(): NodeMaterialConnectionPoint;
  64512. /**
  64513. * Gets the r output component
  64514. */
  64515. get r(): NodeMaterialConnectionPoint;
  64516. /**
  64517. * Gets the g output component
  64518. */
  64519. get g(): NodeMaterialConnectionPoint;
  64520. /**
  64521. * Gets the b output component
  64522. */
  64523. get b(): NodeMaterialConnectionPoint;
  64524. /**
  64525. * Gets the a output component
  64526. */
  64527. get a(): NodeMaterialConnectionPoint;
  64528. autoConfigure(material: NodeMaterial): void;
  64529. protected _buildBlock(state: NodeMaterialBuildState): this;
  64530. }
  64531. }
  64532. declare module BABYLON {
  64533. /**
  64534. * Block used to add 2 vectors
  64535. */
  64536. export class AddBlock extends NodeMaterialBlock {
  64537. /**
  64538. * Creates a new AddBlock
  64539. * @param name defines the block name
  64540. */
  64541. constructor(name: string);
  64542. /**
  64543. * Gets the current class name
  64544. * @returns the class name
  64545. */
  64546. getClassName(): string;
  64547. /**
  64548. * Gets the left operand input component
  64549. */
  64550. get left(): NodeMaterialConnectionPoint;
  64551. /**
  64552. * Gets the right operand input component
  64553. */
  64554. get right(): NodeMaterialConnectionPoint;
  64555. /**
  64556. * Gets the output component
  64557. */
  64558. get output(): NodeMaterialConnectionPoint;
  64559. protected _buildBlock(state: NodeMaterialBuildState): this;
  64560. }
  64561. }
  64562. declare module BABYLON {
  64563. /**
  64564. * Block used to scale a vector by a float
  64565. */
  64566. export class ScaleBlock extends NodeMaterialBlock {
  64567. /**
  64568. * Creates a new ScaleBlock
  64569. * @param name defines the block name
  64570. */
  64571. constructor(name: string);
  64572. /**
  64573. * Gets the current class name
  64574. * @returns the class name
  64575. */
  64576. getClassName(): string;
  64577. /**
  64578. * Gets the input component
  64579. */
  64580. get input(): NodeMaterialConnectionPoint;
  64581. /**
  64582. * Gets the factor input component
  64583. */
  64584. get factor(): NodeMaterialConnectionPoint;
  64585. /**
  64586. * Gets the output component
  64587. */
  64588. get output(): NodeMaterialConnectionPoint;
  64589. protected _buildBlock(state: NodeMaterialBuildState): this;
  64590. }
  64591. }
  64592. declare module BABYLON {
  64593. /**
  64594. * Block used to clamp a float
  64595. */
  64596. export class ClampBlock extends NodeMaterialBlock {
  64597. /** Gets or sets the minimum range */
  64598. minimum: number;
  64599. /** Gets or sets the maximum range */
  64600. maximum: number;
  64601. /**
  64602. * Creates a new ClampBlock
  64603. * @param name defines the block name
  64604. */
  64605. constructor(name: string);
  64606. /**
  64607. * Gets the current class name
  64608. * @returns the class name
  64609. */
  64610. getClassName(): string;
  64611. /**
  64612. * Gets the value input component
  64613. */
  64614. get value(): NodeMaterialConnectionPoint;
  64615. /**
  64616. * Gets the output component
  64617. */
  64618. get output(): NodeMaterialConnectionPoint;
  64619. protected _buildBlock(state: NodeMaterialBuildState): this;
  64620. protected _dumpPropertiesCode(): string;
  64621. serialize(): any;
  64622. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64623. }
  64624. }
  64625. declare module BABYLON {
  64626. /**
  64627. * Block used to apply a cross product between 2 vectors
  64628. */
  64629. export class CrossBlock extends NodeMaterialBlock {
  64630. /**
  64631. * Creates a new CrossBlock
  64632. * @param name defines the block name
  64633. */
  64634. constructor(name: string);
  64635. /**
  64636. * Gets the current class name
  64637. * @returns the class name
  64638. */
  64639. getClassName(): string;
  64640. /**
  64641. * Gets the left operand input component
  64642. */
  64643. get left(): NodeMaterialConnectionPoint;
  64644. /**
  64645. * Gets the right operand input component
  64646. */
  64647. get right(): NodeMaterialConnectionPoint;
  64648. /**
  64649. * Gets the output component
  64650. */
  64651. get output(): NodeMaterialConnectionPoint;
  64652. protected _buildBlock(state: NodeMaterialBuildState): this;
  64653. }
  64654. }
  64655. declare module BABYLON {
  64656. /**
  64657. * Block used to apply a dot product between 2 vectors
  64658. */
  64659. export class DotBlock extends NodeMaterialBlock {
  64660. /**
  64661. * Creates a new DotBlock
  64662. * @param name defines the block name
  64663. */
  64664. constructor(name: string);
  64665. /**
  64666. * Gets the current class name
  64667. * @returns the class name
  64668. */
  64669. getClassName(): string;
  64670. /**
  64671. * Gets the left operand input component
  64672. */
  64673. get left(): NodeMaterialConnectionPoint;
  64674. /**
  64675. * Gets the right operand input component
  64676. */
  64677. get right(): NodeMaterialConnectionPoint;
  64678. /**
  64679. * Gets the output component
  64680. */
  64681. get output(): NodeMaterialConnectionPoint;
  64682. protected _buildBlock(state: NodeMaterialBuildState): this;
  64683. }
  64684. }
  64685. declare module BABYLON {
  64686. /**
  64687. * Block used to normalize a vector
  64688. */
  64689. export class NormalizeBlock extends NodeMaterialBlock {
  64690. /**
  64691. * Creates a new NormalizeBlock
  64692. * @param name defines the block name
  64693. */
  64694. constructor(name: string);
  64695. /**
  64696. * Gets the current class name
  64697. * @returns the class name
  64698. */
  64699. getClassName(): string;
  64700. /**
  64701. * Gets the input component
  64702. */
  64703. get input(): NodeMaterialConnectionPoint;
  64704. /**
  64705. * Gets the output component
  64706. */
  64707. get output(): NodeMaterialConnectionPoint;
  64708. protected _buildBlock(state: NodeMaterialBuildState): this;
  64709. }
  64710. }
  64711. declare module BABYLON {
  64712. /**
  64713. * Block used to create a Color3/4 out of individual inputs (one for each component)
  64714. */
  64715. export class ColorMergerBlock extends NodeMaterialBlock {
  64716. /**
  64717. * Create a new ColorMergerBlock
  64718. * @param name defines the block name
  64719. */
  64720. constructor(name: string);
  64721. /**
  64722. * Gets the current class name
  64723. * @returns the class name
  64724. */
  64725. getClassName(): string;
  64726. /**
  64727. * Gets the rgb component (input)
  64728. */
  64729. get rgbIn(): NodeMaterialConnectionPoint;
  64730. /**
  64731. * Gets the r component (input)
  64732. */
  64733. get r(): NodeMaterialConnectionPoint;
  64734. /**
  64735. * Gets the g component (input)
  64736. */
  64737. get g(): NodeMaterialConnectionPoint;
  64738. /**
  64739. * Gets the b component (input)
  64740. */
  64741. get b(): NodeMaterialConnectionPoint;
  64742. /**
  64743. * Gets the a component (input)
  64744. */
  64745. get a(): NodeMaterialConnectionPoint;
  64746. /**
  64747. * Gets the rgba component (output)
  64748. */
  64749. get rgba(): NodeMaterialConnectionPoint;
  64750. /**
  64751. * Gets the rgb component (output)
  64752. */
  64753. get rgbOut(): NodeMaterialConnectionPoint;
  64754. /**
  64755. * Gets the rgb component (output)
  64756. * @deprecated Please use rgbOut instead.
  64757. */
  64758. get rgb(): NodeMaterialConnectionPoint;
  64759. protected _buildBlock(state: NodeMaterialBuildState): this;
  64760. }
  64761. }
  64762. declare module BABYLON {
  64763. /**
  64764. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  64765. */
  64766. export class VectorSplitterBlock extends NodeMaterialBlock {
  64767. /**
  64768. * Create a new VectorSplitterBlock
  64769. * @param name defines the block name
  64770. */
  64771. constructor(name: string);
  64772. /**
  64773. * Gets the current class name
  64774. * @returns the class name
  64775. */
  64776. getClassName(): string;
  64777. /**
  64778. * Gets the xyzw component (input)
  64779. */
  64780. get xyzw(): NodeMaterialConnectionPoint;
  64781. /**
  64782. * Gets the xyz component (input)
  64783. */
  64784. get xyzIn(): NodeMaterialConnectionPoint;
  64785. /**
  64786. * Gets the xy component (input)
  64787. */
  64788. get xyIn(): NodeMaterialConnectionPoint;
  64789. /**
  64790. * Gets the xyz component (output)
  64791. */
  64792. get xyzOut(): NodeMaterialConnectionPoint;
  64793. /**
  64794. * Gets the xy component (output)
  64795. */
  64796. get xyOut(): NodeMaterialConnectionPoint;
  64797. /**
  64798. * Gets the x component (output)
  64799. */
  64800. get x(): NodeMaterialConnectionPoint;
  64801. /**
  64802. * Gets the y component (output)
  64803. */
  64804. get y(): NodeMaterialConnectionPoint;
  64805. /**
  64806. * Gets the z component (output)
  64807. */
  64808. get z(): NodeMaterialConnectionPoint;
  64809. /**
  64810. * Gets the w component (output)
  64811. */
  64812. get w(): NodeMaterialConnectionPoint;
  64813. protected _inputRename(name: string): string;
  64814. protected _outputRename(name: string): string;
  64815. protected _buildBlock(state: NodeMaterialBuildState): this;
  64816. }
  64817. }
  64818. declare module BABYLON {
  64819. /**
  64820. * Block used to lerp between 2 values
  64821. */
  64822. export class LerpBlock extends NodeMaterialBlock {
  64823. /**
  64824. * Creates a new LerpBlock
  64825. * @param name defines the block name
  64826. */
  64827. constructor(name: string);
  64828. /**
  64829. * Gets the current class name
  64830. * @returns the class name
  64831. */
  64832. getClassName(): string;
  64833. /**
  64834. * Gets the left operand input component
  64835. */
  64836. get left(): NodeMaterialConnectionPoint;
  64837. /**
  64838. * Gets the right operand input component
  64839. */
  64840. get right(): NodeMaterialConnectionPoint;
  64841. /**
  64842. * Gets the gradient operand input component
  64843. */
  64844. get gradient(): NodeMaterialConnectionPoint;
  64845. /**
  64846. * Gets the output component
  64847. */
  64848. get output(): NodeMaterialConnectionPoint;
  64849. protected _buildBlock(state: NodeMaterialBuildState): this;
  64850. }
  64851. }
  64852. declare module BABYLON {
  64853. /**
  64854. * Block used to divide 2 vectors
  64855. */
  64856. export class DivideBlock extends NodeMaterialBlock {
  64857. /**
  64858. * Creates a new DivideBlock
  64859. * @param name defines the block name
  64860. */
  64861. constructor(name: string);
  64862. /**
  64863. * Gets the current class name
  64864. * @returns the class name
  64865. */
  64866. getClassName(): string;
  64867. /**
  64868. * Gets the left operand input component
  64869. */
  64870. get left(): NodeMaterialConnectionPoint;
  64871. /**
  64872. * Gets the right operand input component
  64873. */
  64874. get right(): NodeMaterialConnectionPoint;
  64875. /**
  64876. * Gets the output component
  64877. */
  64878. get output(): NodeMaterialConnectionPoint;
  64879. protected _buildBlock(state: NodeMaterialBuildState): this;
  64880. }
  64881. }
  64882. declare module BABYLON {
  64883. /**
  64884. * Block used to subtract 2 vectors
  64885. */
  64886. export class SubtractBlock extends NodeMaterialBlock {
  64887. /**
  64888. * Creates a new SubtractBlock
  64889. * @param name defines the block name
  64890. */
  64891. constructor(name: string);
  64892. /**
  64893. * Gets the current class name
  64894. * @returns the class name
  64895. */
  64896. getClassName(): string;
  64897. /**
  64898. * Gets the left operand input component
  64899. */
  64900. get left(): NodeMaterialConnectionPoint;
  64901. /**
  64902. * Gets the right operand input component
  64903. */
  64904. get right(): NodeMaterialConnectionPoint;
  64905. /**
  64906. * Gets the output component
  64907. */
  64908. get output(): NodeMaterialConnectionPoint;
  64909. protected _buildBlock(state: NodeMaterialBuildState): this;
  64910. }
  64911. }
  64912. declare module BABYLON {
  64913. /**
  64914. * Block used to step a value
  64915. */
  64916. export class StepBlock extends NodeMaterialBlock {
  64917. /**
  64918. * Creates a new StepBlock
  64919. * @param name defines the block name
  64920. */
  64921. constructor(name: string);
  64922. /**
  64923. * Gets the current class name
  64924. * @returns the class name
  64925. */
  64926. getClassName(): string;
  64927. /**
  64928. * Gets the value operand input component
  64929. */
  64930. get value(): NodeMaterialConnectionPoint;
  64931. /**
  64932. * Gets the edge operand input component
  64933. */
  64934. get edge(): NodeMaterialConnectionPoint;
  64935. /**
  64936. * Gets the output component
  64937. */
  64938. get output(): NodeMaterialConnectionPoint;
  64939. protected _buildBlock(state: NodeMaterialBuildState): this;
  64940. }
  64941. }
  64942. declare module BABYLON {
  64943. /**
  64944. * Block used to get the opposite (1 - x) of a value
  64945. */
  64946. export class OneMinusBlock extends NodeMaterialBlock {
  64947. /**
  64948. * Creates a new OneMinusBlock
  64949. * @param name defines the block name
  64950. */
  64951. constructor(name: string);
  64952. /**
  64953. * Gets the current class name
  64954. * @returns the class name
  64955. */
  64956. getClassName(): string;
  64957. /**
  64958. * Gets the input component
  64959. */
  64960. get input(): NodeMaterialConnectionPoint;
  64961. /**
  64962. * Gets the output component
  64963. */
  64964. get output(): NodeMaterialConnectionPoint;
  64965. protected _buildBlock(state: NodeMaterialBuildState): this;
  64966. }
  64967. }
  64968. declare module BABYLON {
  64969. /**
  64970. * Block used to get the view direction
  64971. */
  64972. export class ViewDirectionBlock extends NodeMaterialBlock {
  64973. /**
  64974. * Creates a new ViewDirectionBlock
  64975. * @param name defines the block name
  64976. */
  64977. constructor(name: string);
  64978. /**
  64979. * Gets the current class name
  64980. * @returns the class name
  64981. */
  64982. getClassName(): string;
  64983. /**
  64984. * Gets the world position component
  64985. */
  64986. get worldPosition(): NodeMaterialConnectionPoint;
  64987. /**
  64988. * Gets the camera position component
  64989. */
  64990. get cameraPosition(): NodeMaterialConnectionPoint;
  64991. /**
  64992. * Gets the output component
  64993. */
  64994. get output(): NodeMaterialConnectionPoint;
  64995. autoConfigure(material: NodeMaterial): void;
  64996. protected _buildBlock(state: NodeMaterialBuildState): this;
  64997. }
  64998. }
  64999. declare module BABYLON {
  65000. /**
  65001. * Block used to compute fresnel value
  65002. */
  65003. export class FresnelBlock extends NodeMaterialBlock {
  65004. /**
  65005. * Create a new FresnelBlock
  65006. * @param name defines the block name
  65007. */
  65008. constructor(name: string);
  65009. /**
  65010. * Gets the current class name
  65011. * @returns the class name
  65012. */
  65013. getClassName(): string;
  65014. /**
  65015. * Gets the world normal input component
  65016. */
  65017. get worldNormal(): NodeMaterialConnectionPoint;
  65018. /**
  65019. * Gets the view direction input component
  65020. */
  65021. get viewDirection(): NodeMaterialConnectionPoint;
  65022. /**
  65023. * Gets the bias input component
  65024. */
  65025. get bias(): NodeMaterialConnectionPoint;
  65026. /**
  65027. * Gets the camera (or eye) position component
  65028. */
  65029. get power(): NodeMaterialConnectionPoint;
  65030. /**
  65031. * Gets the fresnel output component
  65032. */
  65033. get fresnel(): NodeMaterialConnectionPoint;
  65034. autoConfigure(material: NodeMaterial): void;
  65035. protected _buildBlock(state: NodeMaterialBuildState): this;
  65036. }
  65037. }
  65038. declare module BABYLON {
  65039. /**
  65040. * Block used to get the max of 2 values
  65041. */
  65042. export class MaxBlock extends NodeMaterialBlock {
  65043. /**
  65044. * Creates a new MaxBlock
  65045. * @param name defines the block name
  65046. */
  65047. constructor(name: string);
  65048. /**
  65049. * Gets the current class name
  65050. * @returns the class name
  65051. */
  65052. getClassName(): string;
  65053. /**
  65054. * Gets the left operand input component
  65055. */
  65056. get left(): NodeMaterialConnectionPoint;
  65057. /**
  65058. * Gets the right operand input component
  65059. */
  65060. get right(): NodeMaterialConnectionPoint;
  65061. /**
  65062. * Gets the output component
  65063. */
  65064. get output(): NodeMaterialConnectionPoint;
  65065. protected _buildBlock(state: NodeMaterialBuildState): this;
  65066. }
  65067. }
  65068. declare module BABYLON {
  65069. /**
  65070. * Block used to get the min of 2 values
  65071. */
  65072. export class MinBlock extends NodeMaterialBlock {
  65073. /**
  65074. * Creates a new MinBlock
  65075. * @param name defines the block name
  65076. */
  65077. constructor(name: string);
  65078. /**
  65079. * Gets the current class name
  65080. * @returns the class name
  65081. */
  65082. getClassName(): string;
  65083. /**
  65084. * Gets the left operand input component
  65085. */
  65086. get left(): NodeMaterialConnectionPoint;
  65087. /**
  65088. * Gets the right operand input component
  65089. */
  65090. get right(): NodeMaterialConnectionPoint;
  65091. /**
  65092. * Gets the output component
  65093. */
  65094. get output(): NodeMaterialConnectionPoint;
  65095. protected _buildBlock(state: NodeMaterialBuildState): this;
  65096. }
  65097. }
  65098. declare module BABYLON {
  65099. /**
  65100. * Block used to get the distance between 2 values
  65101. */
  65102. export class DistanceBlock extends NodeMaterialBlock {
  65103. /**
  65104. * Creates a new DistanceBlock
  65105. * @param name defines the block name
  65106. */
  65107. constructor(name: string);
  65108. /**
  65109. * Gets the current class name
  65110. * @returns the class name
  65111. */
  65112. getClassName(): string;
  65113. /**
  65114. * Gets the left operand input component
  65115. */
  65116. get left(): NodeMaterialConnectionPoint;
  65117. /**
  65118. * Gets the right operand input component
  65119. */
  65120. get right(): NodeMaterialConnectionPoint;
  65121. /**
  65122. * Gets the output component
  65123. */
  65124. get output(): NodeMaterialConnectionPoint;
  65125. protected _buildBlock(state: NodeMaterialBuildState): this;
  65126. }
  65127. }
  65128. declare module BABYLON {
  65129. /**
  65130. * Block used to get the length of a vector
  65131. */
  65132. export class LengthBlock extends NodeMaterialBlock {
  65133. /**
  65134. * Creates a new LengthBlock
  65135. * @param name defines the block name
  65136. */
  65137. constructor(name: string);
  65138. /**
  65139. * Gets the current class name
  65140. * @returns the class name
  65141. */
  65142. getClassName(): string;
  65143. /**
  65144. * Gets the value input component
  65145. */
  65146. get value(): NodeMaterialConnectionPoint;
  65147. /**
  65148. * Gets the output component
  65149. */
  65150. get output(): NodeMaterialConnectionPoint;
  65151. protected _buildBlock(state: NodeMaterialBuildState): this;
  65152. }
  65153. }
  65154. declare module BABYLON {
  65155. /**
  65156. * Block used to get negative version of a value (i.e. x * -1)
  65157. */
  65158. export class NegateBlock extends NodeMaterialBlock {
  65159. /**
  65160. * Creates a new NegateBlock
  65161. * @param name defines the block name
  65162. */
  65163. constructor(name: string);
  65164. /**
  65165. * Gets the current class name
  65166. * @returns the class name
  65167. */
  65168. getClassName(): string;
  65169. /**
  65170. * Gets the value input component
  65171. */
  65172. get value(): NodeMaterialConnectionPoint;
  65173. /**
  65174. * Gets the output component
  65175. */
  65176. get output(): NodeMaterialConnectionPoint;
  65177. protected _buildBlock(state: NodeMaterialBuildState): this;
  65178. }
  65179. }
  65180. declare module BABYLON {
  65181. /**
  65182. * Block used to get the value of the first parameter raised to the power of the second
  65183. */
  65184. export class PowBlock extends NodeMaterialBlock {
  65185. /**
  65186. * Creates a new PowBlock
  65187. * @param name defines the block name
  65188. */
  65189. constructor(name: string);
  65190. /**
  65191. * Gets the current class name
  65192. * @returns the class name
  65193. */
  65194. getClassName(): string;
  65195. /**
  65196. * Gets the value operand input component
  65197. */
  65198. get value(): NodeMaterialConnectionPoint;
  65199. /**
  65200. * Gets the power operand input component
  65201. */
  65202. get power(): NodeMaterialConnectionPoint;
  65203. /**
  65204. * Gets the output component
  65205. */
  65206. get output(): NodeMaterialConnectionPoint;
  65207. protected _buildBlock(state: NodeMaterialBuildState): this;
  65208. }
  65209. }
  65210. declare module BABYLON {
  65211. /**
  65212. * Block used to get a random number
  65213. */
  65214. export class RandomNumberBlock extends NodeMaterialBlock {
  65215. /**
  65216. * Creates a new RandomNumberBlock
  65217. * @param name defines the block name
  65218. */
  65219. constructor(name: string);
  65220. /**
  65221. * Gets the current class name
  65222. * @returns the class name
  65223. */
  65224. getClassName(): string;
  65225. /**
  65226. * Gets the seed input component
  65227. */
  65228. get seed(): NodeMaterialConnectionPoint;
  65229. /**
  65230. * Gets the output component
  65231. */
  65232. get output(): NodeMaterialConnectionPoint;
  65233. protected _buildBlock(state: NodeMaterialBuildState): this;
  65234. }
  65235. }
  65236. declare module BABYLON {
  65237. /**
  65238. * Block used to compute arc tangent of 2 values
  65239. */
  65240. export class ArcTan2Block extends NodeMaterialBlock {
  65241. /**
  65242. * Creates a new ArcTan2Block
  65243. * @param name defines the block name
  65244. */
  65245. constructor(name: string);
  65246. /**
  65247. * Gets the current class name
  65248. * @returns the class name
  65249. */
  65250. getClassName(): string;
  65251. /**
  65252. * Gets the x operand input component
  65253. */
  65254. get x(): NodeMaterialConnectionPoint;
  65255. /**
  65256. * Gets the y operand input component
  65257. */
  65258. get y(): NodeMaterialConnectionPoint;
  65259. /**
  65260. * Gets the output component
  65261. */
  65262. get output(): NodeMaterialConnectionPoint;
  65263. protected _buildBlock(state: NodeMaterialBuildState): this;
  65264. }
  65265. }
  65266. declare module BABYLON {
  65267. /**
  65268. * Block used to smooth step a value
  65269. */
  65270. export class SmoothStepBlock extends NodeMaterialBlock {
  65271. /**
  65272. * Creates a new SmoothStepBlock
  65273. * @param name defines the block name
  65274. */
  65275. constructor(name: string);
  65276. /**
  65277. * Gets the current class name
  65278. * @returns the class name
  65279. */
  65280. getClassName(): string;
  65281. /**
  65282. * Gets the value operand input component
  65283. */
  65284. get value(): NodeMaterialConnectionPoint;
  65285. /**
  65286. * Gets the first edge operand input component
  65287. */
  65288. get edge0(): NodeMaterialConnectionPoint;
  65289. /**
  65290. * Gets the second edge operand input component
  65291. */
  65292. get edge1(): NodeMaterialConnectionPoint;
  65293. /**
  65294. * Gets the output component
  65295. */
  65296. get output(): NodeMaterialConnectionPoint;
  65297. protected _buildBlock(state: NodeMaterialBuildState): this;
  65298. }
  65299. }
  65300. declare module BABYLON {
  65301. /**
  65302. * Block used to get the reciprocal (1 / x) of a value
  65303. */
  65304. export class ReciprocalBlock extends NodeMaterialBlock {
  65305. /**
  65306. * Creates a new ReciprocalBlock
  65307. * @param name defines the block name
  65308. */
  65309. constructor(name: string);
  65310. /**
  65311. * Gets the current class name
  65312. * @returns the class name
  65313. */
  65314. getClassName(): string;
  65315. /**
  65316. * Gets the input component
  65317. */
  65318. get input(): NodeMaterialConnectionPoint;
  65319. /**
  65320. * Gets the output component
  65321. */
  65322. get output(): NodeMaterialConnectionPoint;
  65323. protected _buildBlock(state: NodeMaterialBuildState): this;
  65324. }
  65325. }
  65326. declare module BABYLON {
  65327. /**
  65328. * Block used to replace a color by another one
  65329. */
  65330. export class ReplaceColorBlock extends NodeMaterialBlock {
  65331. /**
  65332. * Creates a new ReplaceColorBlock
  65333. * @param name defines the block name
  65334. */
  65335. constructor(name: string);
  65336. /**
  65337. * Gets the current class name
  65338. * @returns the class name
  65339. */
  65340. getClassName(): string;
  65341. /**
  65342. * Gets the value input component
  65343. */
  65344. get value(): NodeMaterialConnectionPoint;
  65345. /**
  65346. * Gets the reference input component
  65347. */
  65348. get reference(): NodeMaterialConnectionPoint;
  65349. /**
  65350. * Gets the distance input component
  65351. */
  65352. get distance(): NodeMaterialConnectionPoint;
  65353. /**
  65354. * Gets the replacement input component
  65355. */
  65356. get replacement(): NodeMaterialConnectionPoint;
  65357. /**
  65358. * Gets the output component
  65359. */
  65360. get output(): NodeMaterialConnectionPoint;
  65361. protected _buildBlock(state: NodeMaterialBuildState): this;
  65362. }
  65363. }
  65364. declare module BABYLON {
  65365. /**
  65366. * Block used to posterize a value
  65367. * @see https://en.wikipedia.org/wiki/Posterization
  65368. */
  65369. export class PosterizeBlock extends NodeMaterialBlock {
  65370. /**
  65371. * Creates a new PosterizeBlock
  65372. * @param name defines the block name
  65373. */
  65374. constructor(name: string);
  65375. /**
  65376. * Gets the current class name
  65377. * @returns the class name
  65378. */
  65379. getClassName(): string;
  65380. /**
  65381. * Gets the value input component
  65382. */
  65383. get value(): NodeMaterialConnectionPoint;
  65384. /**
  65385. * Gets the steps input component
  65386. */
  65387. get steps(): NodeMaterialConnectionPoint;
  65388. /**
  65389. * Gets the output component
  65390. */
  65391. get output(): NodeMaterialConnectionPoint;
  65392. protected _buildBlock(state: NodeMaterialBuildState): this;
  65393. }
  65394. }
  65395. declare module BABYLON {
  65396. /**
  65397. * Operations supported by the Wave block
  65398. */
  65399. export enum WaveBlockKind {
  65400. /** SawTooth */
  65401. SawTooth = 0,
  65402. /** Square */
  65403. Square = 1,
  65404. /** Triangle */
  65405. Triangle = 2
  65406. }
  65407. /**
  65408. * Block used to apply wave operation to floats
  65409. */
  65410. export class WaveBlock extends NodeMaterialBlock {
  65411. /**
  65412. * Gets or sets the kibnd of wave to be applied by the block
  65413. */
  65414. kind: WaveBlockKind;
  65415. /**
  65416. * Creates a new WaveBlock
  65417. * @param name defines the block name
  65418. */
  65419. constructor(name: string);
  65420. /**
  65421. * Gets the current class name
  65422. * @returns the class name
  65423. */
  65424. getClassName(): string;
  65425. /**
  65426. * Gets the input component
  65427. */
  65428. get input(): NodeMaterialConnectionPoint;
  65429. /**
  65430. * Gets the output component
  65431. */
  65432. get output(): NodeMaterialConnectionPoint;
  65433. protected _buildBlock(state: NodeMaterialBuildState): this;
  65434. serialize(): any;
  65435. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65436. }
  65437. }
  65438. declare module BABYLON {
  65439. /**
  65440. * Class used to store a color step for the GradientBlock
  65441. */
  65442. export class GradientBlockColorStep {
  65443. private _step;
  65444. /**
  65445. * Gets value indicating which step this color is associated with (between 0 and 1)
  65446. */
  65447. get step(): number;
  65448. /**
  65449. * Sets a value indicating which step this color is associated with (between 0 and 1)
  65450. */
  65451. set step(val: number);
  65452. private _color;
  65453. /**
  65454. * Gets the color associated with this step
  65455. */
  65456. get color(): Color3;
  65457. /**
  65458. * Sets the color associated with this step
  65459. */
  65460. set color(val: Color3);
  65461. /**
  65462. * Creates a new GradientBlockColorStep
  65463. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  65464. * @param color defines the color associated with this step
  65465. */
  65466. constructor(step: number, color: Color3);
  65467. }
  65468. /**
  65469. * Block used to return a color from a gradient based on an input value between 0 and 1
  65470. */
  65471. export class GradientBlock extends NodeMaterialBlock {
  65472. /**
  65473. * Gets or sets the list of color steps
  65474. */
  65475. colorSteps: GradientBlockColorStep[];
  65476. /** Gets an observable raised when the value is changed */
  65477. onValueChangedObservable: Observable<GradientBlock>;
  65478. /** calls observable when the value is changed*/
  65479. colorStepsUpdated(): void;
  65480. /**
  65481. * Creates a new GradientBlock
  65482. * @param name defines the block name
  65483. */
  65484. constructor(name: string);
  65485. /**
  65486. * Gets the current class name
  65487. * @returns the class name
  65488. */
  65489. getClassName(): string;
  65490. /**
  65491. * Gets the gradient input component
  65492. */
  65493. get gradient(): NodeMaterialConnectionPoint;
  65494. /**
  65495. * Gets the output component
  65496. */
  65497. get output(): NodeMaterialConnectionPoint;
  65498. private _writeColorConstant;
  65499. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65500. serialize(): any;
  65501. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65502. protected _dumpPropertiesCode(): string;
  65503. }
  65504. }
  65505. declare module BABYLON {
  65506. /**
  65507. * Block used to normalize lerp between 2 values
  65508. */
  65509. export class NLerpBlock extends NodeMaterialBlock {
  65510. /**
  65511. * Creates a new NLerpBlock
  65512. * @param name defines the block name
  65513. */
  65514. constructor(name: string);
  65515. /**
  65516. * Gets the current class name
  65517. * @returns the class name
  65518. */
  65519. getClassName(): string;
  65520. /**
  65521. * Gets the left operand input component
  65522. */
  65523. get left(): NodeMaterialConnectionPoint;
  65524. /**
  65525. * Gets the right operand input component
  65526. */
  65527. get right(): NodeMaterialConnectionPoint;
  65528. /**
  65529. * Gets the gradient operand input component
  65530. */
  65531. get gradient(): NodeMaterialConnectionPoint;
  65532. /**
  65533. * Gets the output component
  65534. */
  65535. get output(): NodeMaterialConnectionPoint;
  65536. protected _buildBlock(state: NodeMaterialBuildState): this;
  65537. }
  65538. }
  65539. declare module BABYLON {
  65540. /**
  65541. * block used to Generate a Worley Noise 3D Noise Pattern
  65542. */
  65543. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  65544. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65545. manhattanDistance: boolean;
  65546. /**
  65547. * Creates a new WorleyNoise3DBlock
  65548. * @param name defines the block name
  65549. */
  65550. constructor(name: string);
  65551. /**
  65552. * Gets the current class name
  65553. * @returns the class name
  65554. */
  65555. getClassName(): string;
  65556. /**
  65557. * Gets the seed input component
  65558. */
  65559. get seed(): NodeMaterialConnectionPoint;
  65560. /**
  65561. * Gets the jitter input component
  65562. */
  65563. get jitter(): NodeMaterialConnectionPoint;
  65564. /**
  65565. * Gets the output component
  65566. */
  65567. get output(): NodeMaterialConnectionPoint;
  65568. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65569. /**
  65570. * Exposes the properties to the UI?
  65571. */
  65572. protected _dumpPropertiesCode(): string;
  65573. /**
  65574. * Exposes the properties to the Seralize?
  65575. */
  65576. serialize(): any;
  65577. /**
  65578. * Exposes the properties to the deseralize?
  65579. */
  65580. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65581. }
  65582. }
  65583. declare module BABYLON {
  65584. /**
  65585. * block used to Generate a Simplex Perlin 3d Noise Pattern
  65586. */
  65587. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  65588. /**
  65589. * Creates a new SimplexPerlin3DBlock
  65590. * @param name defines the block name
  65591. */
  65592. constructor(name: string);
  65593. /**
  65594. * Gets the current class name
  65595. * @returns the class name
  65596. */
  65597. getClassName(): string;
  65598. /**
  65599. * Gets the seed operand input component
  65600. */
  65601. get seed(): NodeMaterialConnectionPoint;
  65602. /**
  65603. * Gets the output component
  65604. */
  65605. get output(): NodeMaterialConnectionPoint;
  65606. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65607. }
  65608. }
  65609. declare module BABYLON {
  65610. /**
  65611. * Block used to blend normals
  65612. */
  65613. export class NormalBlendBlock extends NodeMaterialBlock {
  65614. /**
  65615. * Creates a new NormalBlendBlock
  65616. * @param name defines the block name
  65617. */
  65618. constructor(name: string);
  65619. /**
  65620. * Gets the current class name
  65621. * @returns the class name
  65622. */
  65623. getClassName(): string;
  65624. /**
  65625. * Gets the first input component
  65626. */
  65627. get normalMap0(): NodeMaterialConnectionPoint;
  65628. /**
  65629. * Gets the second input component
  65630. */
  65631. get normalMap1(): NodeMaterialConnectionPoint;
  65632. /**
  65633. * Gets the output component
  65634. */
  65635. get output(): NodeMaterialConnectionPoint;
  65636. protected _buildBlock(state: NodeMaterialBuildState): this;
  65637. }
  65638. }
  65639. declare module BABYLON {
  65640. /**
  65641. * Block used to rotate a 2d vector by a given angle
  65642. */
  65643. export class Rotate2dBlock extends NodeMaterialBlock {
  65644. /**
  65645. * Creates a new Rotate2dBlock
  65646. * @param name defines the block name
  65647. */
  65648. constructor(name: string);
  65649. /**
  65650. * Gets the current class name
  65651. * @returns the class name
  65652. */
  65653. getClassName(): string;
  65654. /**
  65655. * Gets the input vector
  65656. */
  65657. get input(): NodeMaterialConnectionPoint;
  65658. /**
  65659. * Gets the input angle
  65660. */
  65661. get angle(): NodeMaterialConnectionPoint;
  65662. /**
  65663. * Gets the output component
  65664. */
  65665. get output(): NodeMaterialConnectionPoint;
  65666. autoConfigure(material: NodeMaterial): void;
  65667. protected _buildBlock(state: NodeMaterialBuildState): this;
  65668. }
  65669. }
  65670. declare module BABYLON {
  65671. /**
  65672. * Block used to get the reflected vector from a direction and a normal
  65673. */
  65674. export class ReflectBlock extends NodeMaterialBlock {
  65675. /**
  65676. * Creates a new ReflectBlock
  65677. * @param name defines the block name
  65678. */
  65679. constructor(name: string);
  65680. /**
  65681. * Gets the current class name
  65682. * @returns the class name
  65683. */
  65684. getClassName(): string;
  65685. /**
  65686. * Gets the incident component
  65687. */
  65688. get incident(): NodeMaterialConnectionPoint;
  65689. /**
  65690. * Gets the normal component
  65691. */
  65692. get normal(): NodeMaterialConnectionPoint;
  65693. /**
  65694. * Gets the output component
  65695. */
  65696. get output(): NodeMaterialConnectionPoint;
  65697. protected _buildBlock(state: NodeMaterialBuildState): this;
  65698. }
  65699. }
  65700. declare module BABYLON {
  65701. /**
  65702. * Block used to get the refracted vector from a direction and a normal
  65703. */
  65704. export class RefractBlock extends NodeMaterialBlock {
  65705. /**
  65706. * Creates a new RefractBlock
  65707. * @param name defines the block name
  65708. */
  65709. constructor(name: string);
  65710. /**
  65711. * Gets the current class name
  65712. * @returns the class name
  65713. */
  65714. getClassName(): string;
  65715. /**
  65716. * Gets the incident component
  65717. */
  65718. get incident(): NodeMaterialConnectionPoint;
  65719. /**
  65720. * Gets the normal component
  65721. */
  65722. get normal(): NodeMaterialConnectionPoint;
  65723. /**
  65724. * Gets the index of refraction component
  65725. */
  65726. get ior(): NodeMaterialConnectionPoint;
  65727. /**
  65728. * Gets the output component
  65729. */
  65730. get output(): NodeMaterialConnectionPoint;
  65731. protected _buildBlock(state: NodeMaterialBuildState): this;
  65732. }
  65733. }
  65734. declare module BABYLON {
  65735. /**
  65736. * Block used to desaturate a color
  65737. */
  65738. export class DesaturateBlock extends NodeMaterialBlock {
  65739. /**
  65740. * Creates a new DesaturateBlock
  65741. * @param name defines the block name
  65742. */
  65743. constructor(name: string);
  65744. /**
  65745. * Gets the current class name
  65746. * @returns the class name
  65747. */
  65748. getClassName(): string;
  65749. /**
  65750. * Gets the color operand input component
  65751. */
  65752. get color(): NodeMaterialConnectionPoint;
  65753. /**
  65754. * Gets the level operand input component
  65755. */
  65756. get level(): NodeMaterialConnectionPoint;
  65757. /**
  65758. * Gets the output component
  65759. */
  65760. get output(): NodeMaterialConnectionPoint;
  65761. protected _buildBlock(state: NodeMaterialBuildState): this;
  65762. }
  65763. }
  65764. declare module BABYLON {
  65765. /**
  65766. * Block used to implement the reflection module of the PBR material
  65767. */
  65768. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  65769. /** @hidden */
  65770. _defineLODReflectionAlpha: string;
  65771. /** @hidden */
  65772. _defineLinearSpecularReflection: string;
  65773. private _vEnvironmentIrradianceName;
  65774. /** @hidden */
  65775. _vReflectionMicrosurfaceInfosName: string;
  65776. /** @hidden */
  65777. _vReflectionInfosName: string;
  65778. /** @hidden */
  65779. _vReflectionFilteringInfoName: string;
  65780. private _scene;
  65781. /**
  65782. * The properties below are set by the main PBR block prior to calling methods of this class.
  65783. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65784. * It's less burden on the user side in the editor part.
  65785. */
  65786. /** @hidden */
  65787. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65788. /** @hidden */
  65789. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65790. /** @hidden */
  65791. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  65792. /** @hidden */
  65793. viewConnectionPoint: NodeMaterialConnectionPoint;
  65794. /**
  65795. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  65796. * diffuse part of the IBL.
  65797. */
  65798. useSphericalHarmonics: boolean;
  65799. /**
  65800. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  65801. */
  65802. forceIrradianceInFragment: boolean;
  65803. /**
  65804. * Create a new ReflectionBlock
  65805. * @param name defines the block name
  65806. */
  65807. constructor(name: string);
  65808. /**
  65809. * Gets the current class name
  65810. * @returns the class name
  65811. */
  65812. getClassName(): string;
  65813. /**
  65814. * Gets the position input component
  65815. */
  65816. get position(): NodeMaterialConnectionPoint;
  65817. /**
  65818. * Gets the world position input component
  65819. */
  65820. get worldPosition(): NodeMaterialConnectionPoint;
  65821. /**
  65822. * Gets the world normal input component
  65823. */
  65824. get worldNormal(): NodeMaterialConnectionPoint;
  65825. /**
  65826. * Gets the world input component
  65827. */
  65828. get world(): NodeMaterialConnectionPoint;
  65829. /**
  65830. * Gets the camera (or eye) position component
  65831. */
  65832. get cameraPosition(): NodeMaterialConnectionPoint;
  65833. /**
  65834. * Gets the view input component
  65835. */
  65836. get view(): NodeMaterialConnectionPoint;
  65837. /**
  65838. * Gets the color input component
  65839. */
  65840. get color(): NodeMaterialConnectionPoint;
  65841. /**
  65842. * Gets the reflection object output component
  65843. */
  65844. get reflection(): NodeMaterialConnectionPoint;
  65845. /**
  65846. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  65847. */
  65848. get hasTexture(): boolean;
  65849. /**
  65850. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  65851. */
  65852. get reflectionColor(): string;
  65853. protected _getTexture(): Nullable<BaseTexture>;
  65854. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65855. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65856. /**
  65857. * Gets the code to inject in the vertex shader
  65858. * @param state current state of the node material building
  65859. * @returns the shader code
  65860. */
  65861. handleVertexSide(state: NodeMaterialBuildState): string;
  65862. /**
  65863. * Gets the main code of the block (fragment side)
  65864. * @param state current state of the node material building
  65865. * @param normalVarName name of the existing variable corresponding to the normal
  65866. * @returns the shader code
  65867. */
  65868. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  65869. protected _buildBlock(state: NodeMaterialBuildState): this;
  65870. protected _dumpPropertiesCode(): string;
  65871. serialize(): any;
  65872. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65873. }
  65874. }
  65875. declare module BABYLON {
  65876. /**
  65877. * Block used to implement the sheen module of the PBR material
  65878. */
  65879. export class SheenBlock extends NodeMaterialBlock {
  65880. /**
  65881. * Create a new SheenBlock
  65882. * @param name defines the block name
  65883. */
  65884. constructor(name: string);
  65885. /**
  65886. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  65887. * It allows the strength of the sheen effect to not depend on the base color of the material,
  65888. * making it easier to setup and tweak the effect
  65889. */
  65890. albedoScaling: boolean;
  65891. /**
  65892. * Defines if the sheen is linked to the sheen color.
  65893. */
  65894. linkSheenWithAlbedo: boolean;
  65895. /**
  65896. * Initialize the block and prepare the context for build
  65897. * @param state defines the state that will be used for the build
  65898. */
  65899. initialize(state: NodeMaterialBuildState): void;
  65900. /**
  65901. * Gets the current class name
  65902. * @returns the class name
  65903. */
  65904. getClassName(): string;
  65905. /**
  65906. * Gets the intensity input component
  65907. */
  65908. get intensity(): NodeMaterialConnectionPoint;
  65909. /**
  65910. * Gets the color input component
  65911. */
  65912. get color(): NodeMaterialConnectionPoint;
  65913. /**
  65914. * Gets the roughness input component
  65915. */
  65916. get roughness(): NodeMaterialConnectionPoint;
  65917. /**
  65918. * Gets the sheen object output component
  65919. */
  65920. get sheen(): NodeMaterialConnectionPoint;
  65921. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65922. /**
  65923. * Gets the main code of the block (fragment side)
  65924. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65925. * @returns the shader code
  65926. */
  65927. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  65928. protected _buildBlock(state: NodeMaterialBuildState): this;
  65929. protected _dumpPropertiesCode(): string;
  65930. serialize(): any;
  65931. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65932. }
  65933. }
  65934. declare module BABYLON {
  65935. /**
  65936. * Block used to implement the anisotropy module of the PBR material
  65937. */
  65938. export class AnisotropyBlock extends NodeMaterialBlock {
  65939. /**
  65940. * The two properties below are set by the main PBR block prior to calling methods of this class.
  65941. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65942. * It's less burden on the user side in the editor part.
  65943. */
  65944. /** @hidden */
  65945. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65946. /** @hidden */
  65947. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65948. /**
  65949. * Create a new AnisotropyBlock
  65950. * @param name defines the block name
  65951. */
  65952. constructor(name: string);
  65953. /**
  65954. * Initialize the block and prepare the context for build
  65955. * @param state defines the state that will be used for the build
  65956. */
  65957. initialize(state: NodeMaterialBuildState): void;
  65958. /**
  65959. * Gets the current class name
  65960. * @returns the class name
  65961. */
  65962. getClassName(): string;
  65963. /**
  65964. * Gets the intensity input component
  65965. */
  65966. get intensity(): NodeMaterialConnectionPoint;
  65967. /**
  65968. * Gets the direction input component
  65969. */
  65970. get direction(): NodeMaterialConnectionPoint;
  65971. /**
  65972. * Gets the uv input component
  65973. */
  65974. get uv(): NodeMaterialConnectionPoint;
  65975. /**
  65976. * Gets the worldTangent input component
  65977. */
  65978. get worldTangent(): NodeMaterialConnectionPoint;
  65979. /**
  65980. * Gets the anisotropy object output component
  65981. */
  65982. get anisotropy(): NodeMaterialConnectionPoint;
  65983. private _generateTBNSpace;
  65984. /**
  65985. * Gets the main code of the block (fragment side)
  65986. * @param state current state of the node material building
  65987. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65988. * @returns the shader code
  65989. */
  65990. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  65991. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65992. protected _buildBlock(state: NodeMaterialBuildState): this;
  65993. }
  65994. }
  65995. declare module BABYLON {
  65996. /**
  65997. * Block used to implement the clear coat module of the PBR material
  65998. */
  65999. export class ClearCoatBlock extends NodeMaterialBlock {
  66000. private _scene;
  66001. /**
  66002. * Create a new ClearCoatBlock
  66003. * @param name defines the block name
  66004. */
  66005. constructor(name: string);
  66006. /**
  66007. * Defines if the F0 value should be remapped to account for the interface change in the material.
  66008. */
  66009. remapF0OnInterfaceChange: boolean;
  66010. /**
  66011. * Initialize the block and prepare the context for build
  66012. * @param state defines the state that will be used for the build
  66013. */
  66014. initialize(state: NodeMaterialBuildState): void;
  66015. /**
  66016. * Gets the current class name
  66017. * @returns the class name
  66018. */
  66019. getClassName(): string;
  66020. /**
  66021. * Gets the intensity input component
  66022. */
  66023. get intensity(): NodeMaterialConnectionPoint;
  66024. /**
  66025. * Gets the roughness input component
  66026. */
  66027. get roughness(): NodeMaterialConnectionPoint;
  66028. /**
  66029. * Gets the ior input component
  66030. */
  66031. get indexOfRefraction(): NodeMaterialConnectionPoint;
  66032. /**
  66033. * Gets the bump texture input component
  66034. */
  66035. get normalMapColor(): NodeMaterialConnectionPoint;
  66036. /**
  66037. * Gets the uv input component
  66038. */
  66039. get uv(): NodeMaterialConnectionPoint;
  66040. /**
  66041. * Gets the tint color input component
  66042. */
  66043. get tintColor(): NodeMaterialConnectionPoint;
  66044. /**
  66045. * Gets the tint "at distance" input component
  66046. */
  66047. get tintAtDistance(): NodeMaterialConnectionPoint;
  66048. /**
  66049. * Gets the tint thickness input component
  66050. */
  66051. get tintThickness(): NodeMaterialConnectionPoint;
  66052. /**
  66053. * Gets the world tangent input component
  66054. */
  66055. get worldTangent(): NodeMaterialConnectionPoint;
  66056. /**
  66057. * Gets the clear coat object output component
  66058. */
  66059. get clearcoat(): NodeMaterialConnectionPoint;
  66060. autoConfigure(material: NodeMaterial): void;
  66061. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66062. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66063. private _generateTBNSpace;
  66064. /**
  66065. * Gets the main code of the block (fragment side)
  66066. * @param state current state of the node material building
  66067. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  66068. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66069. * @param worldPosVarName name of the variable holding the world position
  66070. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  66071. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  66072. * @param worldNormalVarName name of the variable holding the world normal
  66073. * @returns the shader code
  66074. */
  66075. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  66076. protected _buildBlock(state: NodeMaterialBuildState): this;
  66077. protected _dumpPropertiesCode(): string;
  66078. serialize(): any;
  66079. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66080. }
  66081. }
  66082. declare module BABYLON {
  66083. /**
  66084. * Block used to implement the sub surface module of the PBR material
  66085. */
  66086. export class SubSurfaceBlock extends NodeMaterialBlock {
  66087. /**
  66088. * Create a new SubSurfaceBlock
  66089. * @param name defines the block name
  66090. */
  66091. constructor(name: string);
  66092. /**
  66093. * Initialize the block and prepare the context for build
  66094. * @param state defines the state that will be used for the build
  66095. */
  66096. initialize(state: NodeMaterialBuildState): void;
  66097. /**
  66098. * Gets the current class name
  66099. * @returns the class name
  66100. */
  66101. getClassName(): string;
  66102. /**
  66103. * Gets the thickness component
  66104. */
  66105. get thickness(): NodeMaterialConnectionPoint;
  66106. /**
  66107. * Gets the tint color input component
  66108. */
  66109. get tintColor(): NodeMaterialConnectionPoint;
  66110. /**
  66111. * Gets the translucency intensity input component
  66112. */
  66113. get translucencyIntensity(): NodeMaterialConnectionPoint;
  66114. /**
  66115. * Gets the translucency diffusion distance input component
  66116. */
  66117. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  66118. /**
  66119. * Gets the refraction object parameters
  66120. */
  66121. get refraction(): NodeMaterialConnectionPoint;
  66122. /**
  66123. * Gets the sub surface object output component
  66124. */
  66125. get subsurface(): NodeMaterialConnectionPoint;
  66126. autoConfigure(material: NodeMaterial): void;
  66127. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66128. /**
  66129. * Gets the main code of the block (fragment side)
  66130. * @param state current state of the node material building
  66131. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  66132. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66133. * @param worldPosVarName name of the variable holding the world position
  66134. * @returns the shader code
  66135. */
  66136. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  66137. protected _buildBlock(state: NodeMaterialBuildState): this;
  66138. }
  66139. }
  66140. declare module BABYLON {
  66141. /**
  66142. * Block used to implement the PBR metallic/roughness model
  66143. */
  66144. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  66145. /**
  66146. * Gets or sets the light associated with this block
  66147. */
  66148. light: Nullable<Light>;
  66149. private _lightId;
  66150. private _scene;
  66151. private _environmentBRDFTexture;
  66152. private _environmentBrdfSamplerName;
  66153. private _vNormalWName;
  66154. private _invertNormalName;
  66155. private _metallicReflectanceColor;
  66156. private _metallicF0Factor;
  66157. private _vMetallicReflectanceFactorsName;
  66158. /**
  66159. * Create a new ReflectionBlock
  66160. * @param name defines the block name
  66161. */
  66162. constructor(name: string);
  66163. /**
  66164. * Intensity of the direct lights e.g. the four lights available in your scene.
  66165. * This impacts both the direct diffuse and specular highlights.
  66166. */
  66167. directIntensity: number;
  66168. /**
  66169. * Intensity of the environment e.g. how much the environment will light the object
  66170. * either through harmonics for rough material or through the refelction for shiny ones.
  66171. */
  66172. environmentIntensity: number;
  66173. /**
  66174. * This is a special control allowing the reduction of the specular highlights coming from the
  66175. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  66176. */
  66177. specularIntensity: number;
  66178. /**
  66179. * Defines the falloff type used in this material.
  66180. * It by default is Physical.
  66181. */
  66182. lightFalloff: number;
  66183. /**
  66184. * Specifies that alpha test should be used
  66185. */
  66186. useAlphaTest: boolean;
  66187. /**
  66188. * Defines the alpha limits in alpha test mode.
  66189. */
  66190. alphaTestCutoff: number;
  66191. /**
  66192. * Specifies that alpha blending should be used
  66193. */
  66194. useAlphaBlending: boolean;
  66195. /**
  66196. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  66197. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  66198. */
  66199. useRadianceOverAlpha: boolean;
  66200. /**
  66201. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  66202. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  66203. */
  66204. useSpecularOverAlpha: boolean;
  66205. /**
  66206. * Enables specular anti aliasing in the PBR shader.
  66207. * It will both interacts on the Geometry for analytical and IBL lighting.
  66208. * It also prefilter the roughness map based on the bump values.
  66209. */
  66210. enableSpecularAntiAliasing: boolean;
  66211. /**
  66212. * Enables realtime filtering on the texture.
  66213. */
  66214. realTimeFiltering: boolean;
  66215. /**
  66216. * Quality switch for realtime filtering
  66217. */
  66218. realTimeFilteringQuality: number;
  66219. /**
  66220. * Defines if the material uses energy conservation.
  66221. */
  66222. useEnergyConservation: boolean;
  66223. /**
  66224. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  66225. * too much the area relying on ambient texture to define their ambient occlusion.
  66226. */
  66227. useRadianceOcclusion: boolean;
  66228. /**
  66229. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  66230. * makes the reflect vector face the model (under horizon).
  66231. */
  66232. useHorizonOcclusion: boolean;
  66233. /**
  66234. * If set to true, no lighting calculations will be applied.
  66235. */
  66236. unlit: boolean;
  66237. /**
  66238. * Force normal to face away from face.
  66239. */
  66240. forceNormalForward: boolean;
  66241. /**
  66242. * Defines the material debug mode.
  66243. * It helps seeing only some components of the material while troubleshooting.
  66244. */
  66245. debugMode: number;
  66246. /**
  66247. * Specify from where on screen the debug mode should start.
  66248. * The value goes from -1 (full screen) to 1 (not visible)
  66249. * It helps with side by side comparison against the final render
  66250. * This defaults to 0
  66251. */
  66252. debugLimit: number;
  66253. /**
  66254. * As the default viewing range might not be enough (if the ambient is really small for instance)
  66255. * You can use the factor to better multiply the final value.
  66256. */
  66257. debugFactor: number;
  66258. /**
  66259. * Initialize the block and prepare the context for build
  66260. * @param state defines the state that will be used for the build
  66261. */
  66262. initialize(state: NodeMaterialBuildState): void;
  66263. /**
  66264. * Gets the current class name
  66265. * @returns the class name
  66266. */
  66267. getClassName(): string;
  66268. /**
  66269. * Gets the world position input component
  66270. */
  66271. get worldPosition(): NodeMaterialConnectionPoint;
  66272. /**
  66273. * Gets the world normal input component
  66274. */
  66275. get worldNormal(): NodeMaterialConnectionPoint;
  66276. /**
  66277. * Gets the view matrix parameter
  66278. */
  66279. get view(): NodeMaterialConnectionPoint;
  66280. /**
  66281. * Gets the camera position input component
  66282. */
  66283. get cameraPosition(): NodeMaterialConnectionPoint;
  66284. /**
  66285. * Gets the perturbed normal input component
  66286. */
  66287. get perturbedNormal(): NodeMaterialConnectionPoint;
  66288. /**
  66289. * Gets the base color input component
  66290. */
  66291. get baseColor(): NodeMaterialConnectionPoint;
  66292. /**
  66293. * Gets the metallic input component
  66294. */
  66295. get metallic(): NodeMaterialConnectionPoint;
  66296. /**
  66297. * Gets the roughness input component
  66298. */
  66299. get roughness(): NodeMaterialConnectionPoint;
  66300. /**
  66301. * Gets the ambient occlusion input component
  66302. */
  66303. get ambientOcc(): NodeMaterialConnectionPoint;
  66304. /**
  66305. * Gets the opacity input component
  66306. */
  66307. get opacity(): NodeMaterialConnectionPoint;
  66308. /**
  66309. * Gets the index of refraction input component
  66310. */
  66311. get indexOfRefraction(): NodeMaterialConnectionPoint;
  66312. /**
  66313. * Gets the ambient color input component
  66314. */
  66315. get ambientColor(): NodeMaterialConnectionPoint;
  66316. /**
  66317. * Gets the reflection object parameters
  66318. */
  66319. get reflection(): NodeMaterialConnectionPoint;
  66320. /**
  66321. * Gets the clear coat object parameters
  66322. */
  66323. get clearcoat(): NodeMaterialConnectionPoint;
  66324. /**
  66325. * Gets the sheen object parameters
  66326. */
  66327. get sheen(): NodeMaterialConnectionPoint;
  66328. /**
  66329. * Gets the sub surface object parameters
  66330. */
  66331. get subsurface(): NodeMaterialConnectionPoint;
  66332. /**
  66333. * Gets the anisotropy object parameters
  66334. */
  66335. get anisotropy(): NodeMaterialConnectionPoint;
  66336. /**
  66337. * Gets the ambient output component
  66338. */
  66339. get ambientClr(): NodeMaterialConnectionPoint;
  66340. /**
  66341. * Gets the diffuse output component
  66342. */
  66343. get diffuseDir(): NodeMaterialConnectionPoint;
  66344. /**
  66345. * Gets the specular output component
  66346. */
  66347. get specularDir(): NodeMaterialConnectionPoint;
  66348. /**
  66349. * Gets the clear coat output component
  66350. */
  66351. get clearcoatDir(): NodeMaterialConnectionPoint;
  66352. /**
  66353. * Gets the sheen output component
  66354. */
  66355. get sheenDir(): NodeMaterialConnectionPoint;
  66356. /**
  66357. * Gets the indirect diffuse output component
  66358. */
  66359. get diffuseIndirect(): NodeMaterialConnectionPoint;
  66360. /**
  66361. * Gets the indirect specular output component
  66362. */
  66363. get specularIndirect(): NodeMaterialConnectionPoint;
  66364. /**
  66365. * Gets the indirect clear coat output component
  66366. */
  66367. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  66368. /**
  66369. * Gets the indirect sheen output component
  66370. */
  66371. get sheenIndirect(): NodeMaterialConnectionPoint;
  66372. /**
  66373. * Gets the refraction output component
  66374. */
  66375. get refraction(): NodeMaterialConnectionPoint;
  66376. /**
  66377. * Gets the global lighting output component
  66378. */
  66379. get lighting(): NodeMaterialConnectionPoint;
  66380. /**
  66381. * Gets the shadow output component
  66382. */
  66383. get shadow(): NodeMaterialConnectionPoint;
  66384. /**
  66385. * Gets the alpha output component
  66386. */
  66387. get alpha(): NodeMaterialConnectionPoint;
  66388. autoConfigure(material: NodeMaterial): void;
  66389. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66390. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66391. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66392. private _injectVertexCode;
  66393. private _getAlbedoOpacityCode;
  66394. private _getAmbientOcclusionCode;
  66395. private _getReflectivityCode;
  66396. protected _buildBlock(state: NodeMaterialBuildState): this;
  66397. protected _dumpPropertiesCode(): string;
  66398. serialize(): any;
  66399. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66400. }
  66401. }
  66402. declare module BABYLON {
  66403. /**
  66404. * Block used to compute value of one parameter modulo another
  66405. */
  66406. export class ModBlock extends NodeMaterialBlock {
  66407. /**
  66408. * Creates a new ModBlock
  66409. * @param name defines the block name
  66410. */
  66411. constructor(name: string);
  66412. /**
  66413. * Gets the current class name
  66414. * @returns the class name
  66415. */
  66416. getClassName(): string;
  66417. /**
  66418. * Gets the left operand input component
  66419. */
  66420. get left(): NodeMaterialConnectionPoint;
  66421. /**
  66422. * Gets the right operand input component
  66423. */
  66424. get right(): NodeMaterialConnectionPoint;
  66425. /**
  66426. * Gets the output component
  66427. */
  66428. get output(): NodeMaterialConnectionPoint;
  66429. protected _buildBlock(state: NodeMaterialBuildState): this;
  66430. }
  66431. }
  66432. declare module BABYLON {
  66433. /**
  66434. * Configuration for Draco compression
  66435. */
  66436. export interface IDracoCompressionConfiguration {
  66437. /**
  66438. * Configuration for the decoder.
  66439. */
  66440. decoder: {
  66441. /**
  66442. * The url to the WebAssembly module.
  66443. */
  66444. wasmUrl?: string;
  66445. /**
  66446. * The url to the WebAssembly binary.
  66447. */
  66448. wasmBinaryUrl?: string;
  66449. /**
  66450. * The url to the fallback JavaScript module.
  66451. */
  66452. fallbackUrl?: string;
  66453. };
  66454. }
  66455. /**
  66456. * Draco compression (https://google.github.io/draco/)
  66457. *
  66458. * This class wraps the Draco module.
  66459. *
  66460. * **Encoder**
  66461. *
  66462. * The encoder is not currently implemented.
  66463. *
  66464. * **Decoder**
  66465. *
  66466. * 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.
  66467. *
  66468. * To update the configuration, use the following code:
  66469. * ```javascript
  66470. * DracoCompression.Configuration = {
  66471. * decoder: {
  66472. * wasmUrl: "<url to the WebAssembly library>",
  66473. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  66474. * fallbackUrl: "<url to the fallback JavaScript library>",
  66475. * }
  66476. * };
  66477. * ```
  66478. *
  66479. * 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.
  66480. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  66481. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  66482. *
  66483. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  66484. * ```javascript
  66485. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  66486. * ```
  66487. *
  66488. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  66489. */
  66490. export class DracoCompression implements IDisposable {
  66491. private _workerPoolPromise?;
  66492. private _decoderModulePromise?;
  66493. /**
  66494. * The configuration. Defaults to the following urls:
  66495. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  66496. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  66497. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  66498. */
  66499. static Configuration: IDracoCompressionConfiguration;
  66500. /**
  66501. * Returns true if the decoder configuration is available.
  66502. */
  66503. static get DecoderAvailable(): boolean;
  66504. /**
  66505. * Default number of workers to create when creating the draco compression object.
  66506. */
  66507. static DefaultNumWorkers: number;
  66508. private static GetDefaultNumWorkers;
  66509. private static _Default;
  66510. /**
  66511. * Default instance for the draco compression object.
  66512. */
  66513. static get Default(): DracoCompression;
  66514. /**
  66515. * Constructor
  66516. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  66517. */
  66518. constructor(numWorkers?: number);
  66519. /**
  66520. * Stop all async operations and release resources.
  66521. */
  66522. dispose(): void;
  66523. /**
  66524. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  66525. * @returns a promise that resolves when ready
  66526. */
  66527. whenReadyAsync(): Promise<void>;
  66528. /**
  66529. * Decode Draco compressed mesh data to vertex data.
  66530. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  66531. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  66532. * @returns A promise that resolves with the decoded vertex data
  66533. */
  66534. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  66535. [kind: string]: number;
  66536. }): Promise<VertexData>;
  66537. }
  66538. }
  66539. declare module BABYLON {
  66540. /**
  66541. * Class for building Constructive Solid Geometry
  66542. */
  66543. export class CSG {
  66544. private polygons;
  66545. /**
  66546. * The world matrix
  66547. */
  66548. matrix: Matrix;
  66549. /**
  66550. * Stores the position
  66551. */
  66552. position: Vector3;
  66553. /**
  66554. * Stores the rotation
  66555. */
  66556. rotation: Vector3;
  66557. /**
  66558. * Stores the rotation quaternion
  66559. */
  66560. rotationQuaternion: Nullable<Quaternion>;
  66561. /**
  66562. * Stores the scaling vector
  66563. */
  66564. scaling: Vector3;
  66565. /**
  66566. * Convert the Mesh to CSG
  66567. * @param mesh The Mesh to convert to CSG
  66568. * @returns A new CSG from the Mesh
  66569. */
  66570. static FromMesh(mesh: Mesh): CSG;
  66571. /**
  66572. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  66573. * @param polygons Polygons used to construct a CSG solid
  66574. */
  66575. private static FromPolygons;
  66576. /**
  66577. * Clones, or makes a deep copy, of the CSG
  66578. * @returns A new CSG
  66579. */
  66580. clone(): CSG;
  66581. /**
  66582. * Unions this CSG with another CSG
  66583. * @param csg The CSG to union against this CSG
  66584. * @returns The unioned CSG
  66585. */
  66586. union(csg: CSG): CSG;
  66587. /**
  66588. * Unions this CSG with another CSG in place
  66589. * @param csg The CSG to union against this CSG
  66590. */
  66591. unionInPlace(csg: CSG): void;
  66592. /**
  66593. * Subtracts this CSG with another CSG
  66594. * @param csg The CSG to subtract against this CSG
  66595. * @returns A new CSG
  66596. */
  66597. subtract(csg: CSG): CSG;
  66598. /**
  66599. * Subtracts this CSG with another CSG in place
  66600. * @param csg The CSG to subtact against this CSG
  66601. */
  66602. subtractInPlace(csg: CSG): void;
  66603. /**
  66604. * Intersect this CSG with another CSG
  66605. * @param csg The CSG to intersect against this CSG
  66606. * @returns A new CSG
  66607. */
  66608. intersect(csg: CSG): CSG;
  66609. /**
  66610. * Intersects this CSG with another CSG in place
  66611. * @param csg The CSG to intersect against this CSG
  66612. */
  66613. intersectInPlace(csg: CSG): void;
  66614. /**
  66615. * Return a new CSG solid with solid and empty space switched. This solid is
  66616. * not modified.
  66617. * @returns A new CSG solid with solid and empty space switched
  66618. */
  66619. inverse(): CSG;
  66620. /**
  66621. * Inverses the CSG in place
  66622. */
  66623. inverseInPlace(): void;
  66624. /**
  66625. * This is used to keep meshes transformations so they can be restored
  66626. * when we build back a Babylon Mesh
  66627. * NB : All CSG operations are performed in world coordinates
  66628. * @param csg The CSG to copy the transform attributes from
  66629. * @returns This CSG
  66630. */
  66631. copyTransformAttributes(csg: CSG): CSG;
  66632. /**
  66633. * Build Raw mesh from CSG
  66634. * Coordinates here are in world space
  66635. * @param name The name of the mesh geometry
  66636. * @param scene The Scene
  66637. * @param keepSubMeshes Specifies if the submeshes should be kept
  66638. * @returns A new Mesh
  66639. */
  66640. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66641. /**
  66642. * Build Mesh from CSG taking material and transforms into account
  66643. * @param name The name of the Mesh
  66644. * @param material The material of the Mesh
  66645. * @param scene The Scene
  66646. * @param keepSubMeshes Specifies if submeshes should be kept
  66647. * @returns The new Mesh
  66648. */
  66649. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66650. }
  66651. }
  66652. declare module BABYLON {
  66653. /**
  66654. * Class used to create a trail following a mesh
  66655. */
  66656. export class TrailMesh extends Mesh {
  66657. private _generator;
  66658. private _autoStart;
  66659. private _running;
  66660. private _diameter;
  66661. private _length;
  66662. private _sectionPolygonPointsCount;
  66663. private _sectionVectors;
  66664. private _sectionNormalVectors;
  66665. private _beforeRenderObserver;
  66666. /**
  66667. * @constructor
  66668. * @param name The value used by scene.getMeshByName() to do a lookup.
  66669. * @param generator The mesh or transform node to generate a trail.
  66670. * @param scene The scene to add this mesh to.
  66671. * @param diameter Diameter of trailing mesh. Default is 1.
  66672. * @param length Length of trailing mesh. Default is 60.
  66673. * @param autoStart Automatically start trailing mesh. Default true.
  66674. */
  66675. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  66676. /**
  66677. * "TrailMesh"
  66678. * @returns "TrailMesh"
  66679. */
  66680. getClassName(): string;
  66681. private _createMesh;
  66682. /**
  66683. * Start trailing mesh.
  66684. */
  66685. start(): void;
  66686. /**
  66687. * Stop trailing mesh.
  66688. */
  66689. stop(): void;
  66690. /**
  66691. * Update trailing mesh geometry.
  66692. */
  66693. update(): void;
  66694. /**
  66695. * Returns a new TrailMesh object.
  66696. * @param name is a string, the name given to the new mesh
  66697. * @param newGenerator use new generator object for cloned trail mesh
  66698. * @returns a new mesh
  66699. */
  66700. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  66701. /**
  66702. * Serializes this trail mesh
  66703. * @param serializationObject object to write serialization to
  66704. */
  66705. serialize(serializationObject: any): void;
  66706. /**
  66707. * Parses a serialized trail mesh
  66708. * @param parsedMesh the serialized mesh
  66709. * @param scene the scene to create the trail mesh in
  66710. * @returns the created trail mesh
  66711. */
  66712. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  66713. }
  66714. }
  66715. declare module BABYLON {
  66716. /**
  66717. * Class containing static functions to help procedurally build meshes
  66718. */
  66719. export class TiledBoxBuilder {
  66720. /**
  66721. * Creates a box mesh
  66722. * 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)
  66723. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66724. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66725. * * 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
  66726. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66727. * @param name defines the name of the mesh
  66728. * @param options defines the options used to create the mesh
  66729. * @param scene defines the hosting scene
  66730. * @returns the box mesh
  66731. */
  66732. static CreateTiledBox(name: string, options: {
  66733. pattern?: number;
  66734. width?: number;
  66735. height?: number;
  66736. depth?: number;
  66737. tileSize?: number;
  66738. tileWidth?: number;
  66739. tileHeight?: number;
  66740. alignHorizontal?: number;
  66741. alignVertical?: number;
  66742. faceUV?: Vector4[];
  66743. faceColors?: Color4[];
  66744. sideOrientation?: number;
  66745. updatable?: boolean;
  66746. }, scene?: Nullable<Scene>): Mesh;
  66747. }
  66748. }
  66749. declare module BABYLON {
  66750. /**
  66751. * Class containing static functions to help procedurally build meshes
  66752. */
  66753. export class TorusKnotBuilder {
  66754. /**
  66755. * Creates a torus knot mesh
  66756. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66757. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66758. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66759. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66760. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66761. * * 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
  66762. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66763. * @param name defines the name of the mesh
  66764. * @param options defines the options used to create the mesh
  66765. * @param scene defines the hosting scene
  66766. * @returns the torus knot mesh
  66767. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66768. */
  66769. static CreateTorusKnot(name: string, options: {
  66770. radius?: number;
  66771. tube?: number;
  66772. radialSegments?: number;
  66773. tubularSegments?: number;
  66774. p?: number;
  66775. q?: number;
  66776. updatable?: boolean;
  66777. sideOrientation?: number;
  66778. frontUVs?: Vector4;
  66779. backUVs?: Vector4;
  66780. }, scene: any): Mesh;
  66781. }
  66782. }
  66783. declare module BABYLON {
  66784. /**
  66785. * Polygon
  66786. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  66787. */
  66788. export class Polygon {
  66789. /**
  66790. * Creates a rectangle
  66791. * @param xmin bottom X coord
  66792. * @param ymin bottom Y coord
  66793. * @param xmax top X coord
  66794. * @param ymax top Y coord
  66795. * @returns points that make the resulting rectation
  66796. */
  66797. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  66798. /**
  66799. * Creates a circle
  66800. * @param radius radius of circle
  66801. * @param cx scale in x
  66802. * @param cy scale in y
  66803. * @param numberOfSides number of sides that make up the circle
  66804. * @returns points that make the resulting circle
  66805. */
  66806. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  66807. /**
  66808. * Creates a polygon from input string
  66809. * @param input Input polygon data
  66810. * @returns the parsed points
  66811. */
  66812. static Parse(input: string): Vector2[];
  66813. /**
  66814. * Starts building a polygon from x and y coordinates
  66815. * @param x x coordinate
  66816. * @param y y coordinate
  66817. * @returns the started path2
  66818. */
  66819. static StartingAt(x: number, y: number): Path2;
  66820. }
  66821. /**
  66822. * Builds a polygon
  66823. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  66824. */
  66825. export class PolygonMeshBuilder {
  66826. private _points;
  66827. private _outlinepoints;
  66828. private _holes;
  66829. private _name;
  66830. private _scene;
  66831. private _epoints;
  66832. private _eholes;
  66833. private _addToepoint;
  66834. /**
  66835. * Babylon reference to the earcut plugin.
  66836. */
  66837. bjsEarcut: any;
  66838. /**
  66839. * Creates a PolygonMeshBuilder
  66840. * @param name name of the builder
  66841. * @param contours Path of the polygon
  66842. * @param scene scene to add to when creating the mesh
  66843. * @param earcutInjection can be used to inject your own earcut reference
  66844. */
  66845. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  66846. /**
  66847. * Adds a whole within the polygon
  66848. * @param hole Array of points defining the hole
  66849. * @returns this
  66850. */
  66851. addHole(hole: Vector2[]): PolygonMeshBuilder;
  66852. /**
  66853. * Creates the polygon
  66854. * @param updatable If the mesh should be updatable
  66855. * @param depth The depth of the mesh created
  66856. * @returns the created mesh
  66857. */
  66858. build(updatable?: boolean, depth?: number): Mesh;
  66859. /**
  66860. * Creates the polygon
  66861. * @param depth The depth of the mesh created
  66862. * @returns the created VertexData
  66863. */
  66864. buildVertexData(depth?: number): VertexData;
  66865. /**
  66866. * Adds a side to the polygon
  66867. * @param positions points that make the polygon
  66868. * @param normals normals of the polygon
  66869. * @param uvs uvs of the polygon
  66870. * @param indices indices of the polygon
  66871. * @param bounds bounds of the polygon
  66872. * @param points points of the polygon
  66873. * @param depth depth of the polygon
  66874. * @param flip flip of the polygon
  66875. */
  66876. private addSide;
  66877. }
  66878. }
  66879. declare module BABYLON {
  66880. /**
  66881. * Class containing static functions to help procedurally build meshes
  66882. */
  66883. export class PolygonBuilder {
  66884. /**
  66885. * Creates a polygon mesh
  66886. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66887. * * 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
  66888. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66889. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66890. * * 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)
  66891. * * Remember you can only change the shape positions, not their number when updating a polygon
  66892. * @param name defines the name of the mesh
  66893. * @param options defines the options used to create the mesh
  66894. * @param scene defines the hosting scene
  66895. * @param earcutInjection can be used to inject your own earcut reference
  66896. * @returns the polygon mesh
  66897. */
  66898. static CreatePolygon(name: string, options: {
  66899. shape: Vector3[];
  66900. holes?: Vector3[][];
  66901. depth?: number;
  66902. faceUV?: Vector4[];
  66903. faceColors?: Color4[];
  66904. updatable?: boolean;
  66905. sideOrientation?: number;
  66906. frontUVs?: Vector4;
  66907. backUVs?: Vector4;
  66908. wrap?: boolean;
  66909. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66910. /**
  66911. * Creates an extruded polygon mesh, with depth in the Y direction.
  66912. * * 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)
  66913. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66914. * @param name defines the name of the mesh
  66915. * @param options defines the options used to create the mesh
  66916. * @param scene defines the hosting scene
  66917. * @param earcutInjection can be used to inject your own earcut reference
  66918. * @returns the polygon mesh
  66919. */
  66920. static ExtrudePolygon(name: string, options: {
  66921. shape: Vector3[];
  66922. holes?: Vector3[][];
  66923. depth?: number;
  66924. faceUV?: Vector4[];
  66925. faceColors?: Color4[];
  66926. updatable?: boolean;
  66927. sideOrientation?: number;
  66928. frontUVs?: Vector4;
  66929. backUVs?: Vector4;
  66930. wrap?: boolean;
  66931. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66932. }
  66933. }
  66934. declare module BABYLON {
  66935. /**
  66936. * Class containing static functions to help procedurally build meshes
  66937. */
  66938. export class LatheBuilder {
  66939. /**
  66940. * Creates lathe mesh.
  66941. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66942. * * 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
  66943. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66944. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66945. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66946. * * 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
  66947. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66948. * * 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
  66949. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66950. * * 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
  66951. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66952. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66953. * @param name defines the name of the mesh
  66954. * @param options defines the options used to create the mesh
  66955. * @param scene defines the hosting scene
  66956. * @returns the lathe mesh
  66957. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66958. */
  66959. static CreateLathe(name: string, options: {
  66960. shape: Vector3[];
  66961. radius?: number;
  66962. tessellation?: number;
  66963. clip?: number;
  66964. arc?: number;
  66965. closed?: boolean;
  66966. updatable?: boolean;
  66967. sideOrientation?: number;
  66968. frontUVs?: Vector4;
  66969. backUVs?: Vector4;
  66970. cap?: number;
  66971. invertUV?: boolean;
  66972. }, scene?: Nullable<Scene>): Mesh;
  66973. }
  66974. }
  66975. declare module BABYLON {
  66976. /**
  66977. * Class containing static functions to help procedurally build meshes
  66978. */
  66979. export class TiledPlaneBuilder {
  66980. /**
  66981. * Creates a tiled plane mesh
  66982. * * The parameter `pattern` will, depending on value, do nothing or
  66983. * * * flip (reflect about central vertical) alternate tiles across and up
  66984. * * * flip every tile on alternate rows
  66985. * * * rotate (180 degs) alternate tiles across and up
  66986. * * * rotate every tile on alternate rows
  66987. * * * flip and rotate alternate tiles across and up
  66988. * * * flip and rotate every tile on alternate rows
  66989. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  66990. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  66991. * * 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
  66992. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66993. * * 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)
  66994. * * 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)
  66995. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66996. * @param name defines the name of the mesh
  66997. * @param options defines the options used to create the mesh
  66998. * @param scene defines the hosting scene
  66999. * @returns the box mesh
  67000. */
  67001. static CreateTiledPlane(name: string, options: {
  67002. pattern?: number;
  67003. tileSize?: number;
  67004. tileWidth?: number;
  67005. tileHeight?: number;
  67006. size?: number;
  67007. width?: number;
  67008. height?: number;
  67009. alignHorizontal?: number;
  67010. alignVertical?: number;
  67011. sideOrientation?: number;
  67012. frontUVs?: Vector4;
  67013. backUVs?: Vector4;
  67014. updatable?: boolean;
  67015. }, scene?: Nullable<Scene>): Mesh;
  67016. }
  67017. }
  67018. declare module BABYLON {
  67019. /**
  67020. * Class containing static functions to help procedurally build meshes
  67021. */
  67022. export class TubeBuilder {
  67023. /**
  67024. * Creates a tube mesh.
  67025. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67026. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67027. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67028. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67029. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67030. * * 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)
  67031. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67032. * * 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
  67033. * * 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
  67034. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67035. * * 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
  67036. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67037. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67038. * @param name defines the name of the mesh
  67039. * @param options defines the options used to create the mesh
  67040. * @param scene defines the hosting scene
  67041. * @returns the tube mesh
  67042. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67043. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67044. */
  67045. static CreateTube(name: string, options: {
  67046. path: Vector3[];
  67047. radius?: number;
  67048. tessellation?: number;
  67049. radiusFunction?: {
  67050. (i: number, distance: number): number;
  67051. };
  67052. cap?: number;
  67053. arc?: number;
  67054. updatable?: boolean;
  67055. sideOrientation?: number;
  67056. frontUVs?: Vector4;
  67057. backUVs?: Vector4;
  67058. instance?: Mesh;
  67059. invertUV?: boolean;
  67060. }, scene?: Nullable<Scene>): Mesh;
  67061. }
  67062. }
  67063. declare module BABYLON {
  67064. /**
  67065. * Class containing static functions to help procedurally build meshes
  67066. */
  67067. export class IcoSphereBuilder {
  67068. /**
  67069. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  67070. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  67071. * * 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`)
  67072. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  67073. * * 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
  67074. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67075. * * 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
  67076. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67077. * @param name defines the name of the mesh
  67078. * @param options defines the options used to create the mesh
  67079. * @param scene defines the hosting scene
  67080. * @returns the icosahedron mesh
  67081. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  67082. */
  67083. static CreateIcoSphere(name: string, options: {
  67084. radius?: number;
  67085. radiusX?: number;
  67086. radiusY?: number;
  67087. radiusZ?: number;
  67088. flat?: boolean;
  67089. subdivisions?: number;
  67090. sideOrientation?: number;
  67091. frontUVs?: Vector4;
  67092. backUVs?: Vector4;
  67093. updatable?: boolean;
  67094. }, scene?: Nullable<Scene>): Mesh;
  67095. }
  67096. }
  67097. declare module BABYLON {
  67098. /**
  67099. * Class containing static functions to help procedurally build meshes
  67100. */
  67101. export class DecalBuilder {
  67102. /**
  67103. * Creates a decal mesh.
  67104. * 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
  67105. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67106. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67107. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67108. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67109. * @param name defines the name of the mesh
  67110. * @param sourceMesh defines the mesh where the decal must be applied
  67111. * @param options defines the options used to create the mesh
  67112. * @param scene defines the hosting scene
  67113. * @returns the decal mesh
  67114. * @see https://doc.babylonjs.com/how_to/decals
  67115. */
  67116. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67117. position?: Vector3;
  67118. normal?: Vector3;
  67119. size?: Vector3;
  67120. angle?: number;
  67121. }): Mesh;
  67122. }
  67123. }
  67124. declare module BABYLON {
  67125. /**
  67126. * Class containing static functions to help procedurally build meshes
  67127. */
  67128. export class MeshBuilder {
  67129. /**
  67130. * Creates a box mesh
  67131. * * The parameter `size` sets the size (float) of each box side (default 1)
  67132. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  67133. * * 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)
  67134. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67135. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67136. * * 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
  67137. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67138. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  67139. * @param name defines the name of the mesh
  67140. * @param options defines the options used to create the mesh
  67141. * @param scene defines the hosting scene
  67142. * @returns the box mesh
  67143. */
  67144. static CreateBox(name: string, options: {
  67145. size?: number;
  67146. width?: number;
  67147. height?: number;
  67148. depth?: number;
  67149. faceUV?: Vector4[];
  67150. faceColors?: Color4[];
  67151. sideOrientation?: number;
  67152. frontUVs?: Vector4;
  67153. backUVs?: Vector4;
  67154. wrap?: boolean;
  67155. topBaseAt?: number;
  67156. bottomBaseAt?: number;
  67157. updatable?: boolean;
  67158. }, scene?: Nullable<Scene>): Mesh;
  67159. /**
  67160. * Creates a tiled box mesh
  67161. * * faceTiles sets the pattern, tile size and number of tiles for a face
  67162. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67163. * @param name defines the name of the mesh
  67164. * @param options defines the options used to create the mesh
  67165. * @param scene defines the hosting scene
  67166. * @returns the tiled box mesh
  67167. */
  67168. static CreateTiledBox(name: string, options: {
  67169. pattern?: number;
  67170. size?: number;
  67171. width?: number;
  67172. height?: number;
  67173. depth: number;
  67174. tileSize?: number;
  67175. tileWidth?: number;
  67176. tileHeight?: number;
  67177. faceUV?: Vector4[];
  67178. faceColors?: Color4[];
  67179. alignHorizontal?: number;
  67180. alignVertical?: number;
  67181. sideOrientation?: number;
  67182. updatable?: boolean;
  67183. }, scene?: Nullable<Scene>): Mesh;
  67184. /**
  67185. * Creates a sphere mesh
  67186. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  67187. * * 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`)
  67188. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  67189. * * 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
  67190. * * 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)
  67191. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67192. * * 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
  67193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67194. * @param name defines the name of the mesh
  67195. * @param options defines the options used to create the mesh
  67196. * @param scene defines the hosting scene
  67197. * @returns the sphere mesh
  67198. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  67199. */
  67200. static CreateSphere(name: string, options: {
  67201. segments?: number;
  67202. diameter?: number;
  67203. diameterX?: number;
  67204. diameterY?: number;
  67205. diameterZ?: number;
  67206. arc?: number;
  67207. slice?: number;
  67208. sideOrientation?: number;
  67209. frontUVs?: Vector4;
  67210. backUVs?: Vector4;
  67211. updatable?: boolean;
  67212. }, scene?: Nullable<Scene>): Mesh;
  67213. /**
  67214. * Creates a plane polygonal mesh. By default, this is a disc
  67215. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  67216. * * 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
  67217. * * 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
  67218. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67219. * * 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
  67220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67221. * @param name defines the name of the mesh
  67222. * @param options defines the options used to create the mesh
  67223. * @param scene defines the hosting scene
  67224. * @returns the plane polygonal mesh
  67225. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  67226. */
  67227. static CreateDisc(name: string, options: {
  67228. radius?: number;
  67229. tessellation?: number;
  67230. arc?: number;
  67231. updatable?: boolean;
  67232. sideOrientation?: number;
  67233. frontUVs?: Vector4;
  67234. backUVs?: Vector4;
  67235. }, scene?: Nullable<Scene>): Mesh;
  67236. /**
  67237. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  67238. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  67239. * * 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`)
  67240. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  67241. * * 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
  67242. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67243. * * 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
  67244. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67245. * @param name defines the name of the mesh
  67246. * @param options defines the options used to create the mesh
  67247. * @param scene defines the hosting scene
  67248. * @returns the icosahedron mesh
  67249. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  67250. */
  67251. static CreateIcoSphere(name: string, options: {
  67252. radius?: number;
  67253. radiusX?: number;
  67254. radiusY?: number;
  67255. radiusZ?: number;
  67256. flat?: boolean;
  67257. subdivisions?: number;
  67258. sideOrientation?: number;
  67259. frontUVs?: Vector4;
  67260. backUVs?: Vector4;
  67261. updatable?: boolean;
  67262. }, scene?: Nullable<Scene>): Mesh;
  67263. /**
  67264. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67265. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  67266. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  67267. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  67268. * * 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
  67269. * * 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
  67270. * * 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
  67271. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67272. * * 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
  67273. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67274. * * 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
  67275. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  67276. * * 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
  67277. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  67278. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67279. * @param name defines the name of the mesh
  67280. * @param options defines the options used to create the mesh
  67281. * @param scene defines the hosting scene
  67282. * @returns the ribbon mesh
  67283. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  67284. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67285. */
  67286. static CreateRibbon(name: string, options: {
  67287. pathArray: Vector3[][];
  67288. closeArray?: boolean;
  67289. closePath?: boolean;
  67290. offset?: number;
  67291. updatable?: boolean;
  67292. sideOrientation?: number;
  67293. frontUVs?: Vector4;
  67294. backUVs?: Vector4;
  67295. instance?: Mesh;
  67296. invertUV?: boolean;
  67297. uvs?: Vector2[];
  67298. colors?: Color4[];
  67299. }, scene?: Nullable<Scene>): Mesh;
  67300. /**
  67301. * Creates a cylinder or a cone mesh
  67302. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  67303. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  67304. * * 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.
  67305. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  67306. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  67307. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  67308. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  67309. * * 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).
  67310. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  67311. * * 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).
  67312. * * 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
  67313. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  67314. * * 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
  67315. * * 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.
  67316. * * If `enclose` is false, a ring surface is one element.
  67317. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  67318. * * 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
  67319. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67320. * * 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
  67321. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67322. * @param name defines the name of the mesh
  67323. * @param options defines the options used to create the mesh
  67324. * @param scene defines the hosting scene
  67325. * @returns the cylinder mesh
  67326. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  67327. */
  67328. static CreateCylinder(name: string, options: {
  67329. height?: number;
  67330. diameterTop?: number;
  67331. diameterBottom?: number;
  67332. diameter?: number;
  67333. tessellation?: number;
  67334. subdivisions?: number;
  67335. arc?: number;
  67336. faceColors?: Color4[];
  67337. faceUV?: Vector4[];
  67338. updatable?: boolean;
  67339. hasRings?: boolean;
  67340. enclose?: boolean;
  67341. cap?: number;
  67342. sideOrientation?: number;
  67343. frontUVs?: Vector4;
  67344. backUVs?: Vector4;
  67345. }, scene?: Nullable<Scene>): Mesh;
  67346. /**
  67347. * Creates a torus mesh
  67348. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  67349. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  67350. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  67351. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67352. * * 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
  67353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67354. * @param name defines the name of the mesh
  67355. * @param options defines the options used to create the mesh
  67356. * @param scene defines the hosting scene
  67357. * @returns the torus mesh
  67358. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  67359. */
  67360. static CreateTorus(name: string, options: {
  67361. diameter?: number;
  67362. thickness?: number;
  67363. tessellation?: number;
  67364. updatable?: boolean;
  67365. sideOrientation?: number;
  67366. frontUVs?: Vector4;
  67367. backUVs?: Vector4;
  67368. }, scene?: Nullable<Scene>): Mesh;
  67369. /**
  67370. * Creates a torus knot mesh
  67371. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  67372. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  67373. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  67374. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  67375. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67376. * * 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
  67377. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67378. * @param name defines the name of the mesh
  67379. * @param options defines the options used to create the mesh
  67380. * @param scene defines the hosting scene
  67381. * @returns the torus knot mesh
  67382. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  67383. */
  67384. static CreateTorusKnot(name: string, options: {
  67385. radius?: number;
  67386. tube?: number;
  67387. radialSegments?: number;
  67388. tubularSegments?: number;
  67389. p?: number;
  67390. q?: number;
  67391. updatable?: boolean;
  67392. sideOrientation?: number;
  67393. frontUVs?: Vector4;
  67394. backUVs?: Vector4;
  67395. }, scene?: Nullable<Scene>): Mesh;
  67396. /**
  67397. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  67398. * * 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
  67399. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  67400. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  67401. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  67402. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  67403. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  67404. * * 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
  67405. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  67406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67407. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  67408. * @param name defines the name of the new line system
  67409. * @param options defines the options used to create the line system
  67410. * @param scene defines the hosting scene
  67411. * @returns a new line system mesh
  67412. */
  67413. static CreateLineSystem(name: string, options: {
  67414. lines: Vector3[][];
  67415. updatable?: boolean;
  67416. instance?: Nullable<LinesMesh>;
  67417. colors?: Nullable<Color4[][]>;
  67418. useVertexAlpha?: boolean;
  67419. }, scene: Nullable<Scene>): LinesMesh;
  67420. /**
  67421. * Creates a line mesh
  67422. * 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
  67423. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67424. * * The parameter `points` is an array successive Vector3
  67425. * * 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
  67426. * * The optional parameter `colors` is an array of successive Color4, one per line point
  67427. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  67428. * * When updating an instance, remember that only point positions can change, not the number of points
  67429. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67430. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  67431. * @param name defines the name of the new line system
  67432. * @param options defines the options used to create the line system
  67433. * @param scene defines the hosting scene
  67434. * @returns a new line mesh
  67435. */
  67436. static CreateLines(name: string, options: {
  67437. points: Vector3[];
  67438. updatable?: boolean;
  67439. instance?: Nullable<LinesMesh>;
  67440. colors?: Color4[];
  67441. useVertexAlpha?: boolean;
  67442. }, scene?: Nullable<Scene>): LinesMesh;
  67443. /**
  67444. * Creates a dashed line mesh
  67445. * * 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
  67446. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67447. * * The parameter `points` is an array successive Vector3
  67448. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  67449. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  67450. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  67451. * * 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
  67452. * * When updating an instance, remember that only point positions can change, not the number of points
  67453. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67454. * @param name defines the name of the mesh
  67455. * @param options defines the options used to create the mesh
  67456. * @param scene defines the hosting scene
  67457. * @returns the dashed line mesh
  67458. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  67459. */
  67460. static CreateDashedLines(name: string, options: {
  67461. points: Vector3[];
  67462. dashSize?: number;
  67463. gapSize?: number;
  67464. dashNb?: number;
  67465. updatable?: boolean;
  67466. instance?: LinesMesh;
  67467. }, scene?: Nullable<Scene>): LinesMesh;
  67468. /**
  67469. * 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.
  67470. * * 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.
  67471. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67472. * * 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.
  67473. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  67474. * * 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
  67475. * * 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
  67476. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  67477. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67478. * * 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
  67479. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  67480. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67481. * @param name defines the name of the mesh
  67482. * @param options defines the options used to create the mesh
  67483. * @param scene defines the hosting scene
  67484. * @returns the extruded shape mesh
  67485. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67486. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67487. */
  67488. static ExtrudeShape(name: string, options: {
  67489. shape: Vector3[];
  67490. path: Vector3[];
  67491. scale?: number;
  67492. rotation?: number;
  67493. cap?: number;
  67494. updatable?: boolean;
  67495. sideOrientation?: number;
  67496. frontUVs?: Vector4;
  67497. backUVs?: Vector4;
  67498. instance?: Mesh;
  67499. invertUV?: boolean;
  67500. }, scene?: Nullable<Scene>): Mesh;
  67501. /**
  67502. * Creates an custom extruded shape mesh.
  67503. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  67504. * * 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.
  67505. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67506. * * 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
  67507. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  67508. * * 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
  67509. * * It must returns a float value that will be the scale value applied to the shape on each path point
  67510. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  67511. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  67512. * * 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
  67513. * * 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
  67514. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  67515. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67516. * * 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
  67517. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67518. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67519. * @param name defines the name of the mesh
  67520. * @param options defines the options used to create the mesh
  67521. * @param scene defines the hosting scene
  67522. * @returns the custom extruded shape mesh
  67523. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  67524. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67525. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67526. */
  67527. static ExtrudeShapeCustom(name: string, options: {
  67528. shape: Vector3[];
  67529. path: Vector3[];
  67530. scaleFunction?: any;
  67531. rotationFunction?: any;
  67532. ribbonCloseArray?: boolean;
  67533. ribbonClosePath?: boolean;
  67534. cap?: number;
  67535. updatable?: boolean;
  67536. sideOrientation?: number;
  67537. frontUVs?: Vector4;
  67538. backUVs?: Vector4;
  67539. instance?: Mesh;
  67540. invertUV?: boolean;
  67541. }, scene?: Nullable<Scene>): Mesh;
  67542. /**
  67543. * Creates lathe mesh.
  67544. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  67545. * * 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
  67546. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  67547. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  67548. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  67549. * * 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
  67550. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  67551. * * 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
  67552. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67553. * * 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
  67554. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67556. * @param name defines the name of the mesh
  67557. * @param options defines the options used to create the mesh
  67558. * @param scene defines the hosting scene
  67559. * @returns the lathe mesh
  67560. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  67561. */
  67562. static CreateLathe(name: string, options: {
  67563. shape: Vector3[];
  67564. radius?: number;
  67565. tessellation?: number;
  67566. clip?: number;
  67567. arc?: number;
  67568. closed?: boolean;
  67569. updatable?: boolean;
  67570. sideOrientation?: number;
  67571. frontUVs?: Vector4;
  67572. backUVs?: Vector4;
  67573. cap?: number;
  67574. invertUV?: boolean;
  67575. }, scene?: Nullable<Scene>): Mesh;
  67576. /**
  67577. * Creates a tiled plane mesh
  67578. * * You can set a limited pattern arrangement with the tiles
  67579. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67580. * * 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
  67581. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67582. * @param name defines the name of the mesh
  67583. * @param options defines the options used to create the mesh
  67584. * @param scene defines the hosting scene
  67585. * @returns the plane mesh
  67586. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67587. */
  67588. static CreateTiledPlane(name: string, options: {
  67589. pattern?: number;
  67590. tileSize?: number;
  67591. tileWidth?: number;
  67592. tileHeight?: number;
  67593. size?: number;
  67594. width?: number;
  67595. height?: number;
  67596. alignHorizontal?: number;
  67597. alignVertical?: number;
  67598. sideOrientation?: number;
  67599. frontUVs?: Vector4;
  67600. backUVs?: Vector4;
  67601. updatable?: boolean;
  67602. }, scene?: Nullable<Scene>): Mesh;
  67603. /**
  67604. * Creates a plane mesh
  67605. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  67606. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  67607. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  67608. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67609. * * 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
  67610. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67611. * @param name defines the name of the mesh
  67612. * @param options defines the options used to create the mesh
  67613. * @param scene defines the hosting scene
  67614. * @returns the plane mesh
  67615. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67616. */
  67617. static CreatePlane(name: string, options: {
  67618. size?: number;
  67619. width?: number;
  67620. height?: number;
  67621. sideOrientation?: number;
  67622. frontUVs?: Vector4;
  67623. backUVs?: Vector4;
  67624. updatable?: boolean;
  67625. sourcePlane?: Plane;
  67626. }, scene?: Nullable<Scene>): Mesh;
  67627. /**
  67628. * Creates a ground mesh
  67629. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  67630. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  67631. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67632. * @param name defines the name of the mesh
  67633. * @param options defines the options used to create the mesh
  67634. * @param scene defines the hosting scene
  67635. * @returns the ground mesh
  67636. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  67637. */
  67638. static CreateGround(name: string, options: {
  67639. width?: number;
  67640. height?: number;
  67641. subdivisions?: number;
  67642. subdivisionsX?: number;
  67643. subdivisionsY?: number;
  67644. updatable?: boolean;
  67645. }, scene?: Nullable<Scene>): Mesh;
  67646. /**
  67647. * Creates a tiled ground mesh
  67648. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  67649. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  67650. * * 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
  67651. * * 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
  67652. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67653. * @param name defines the name of the mesh
  67654. * @param options defines the options used to create the mesh
  67655. * @param scene defines the hosting scene
  67656. * @returns the tiled ground mesh
  67657. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  67658. */
  67659. static CreateTiledGround(name: string, options: {
  67660. xmin: number;
  67661. zmin: number;
  67662. xmax: number;
  67663. zmax: number;
  67664. subdivisions?: {
  67665. w: number;
  67666. h: number;
  67667. };
  67668. precision?: {
  67669. w: number;
  67670. h: number;
  67671. };
  67672. updatable?: boolean;
  67673. }, scene?: Nullable<Scene>): Mesh;
  67674. /**
  67675. * Creates a ground mesh from a height map
  67676. * * The parameter `url` sets the URL of the height map image resource.
  67677. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  67678. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  67679. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  67680. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  67681. * * 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.
  67682. * * 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).
  67683. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  67684. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67685. * @param name defines the name of the mesh
  67686. * @param url defines the url to the height map
  67687. * @param options defines the options used to create the mesh
  67688. * @param scene defines the hosting scene
  67689. * @returns the ground mesh
  67690. * @see https://doc.babylonjs.com/babylon101/height_map
  67691. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  67692. */
  67693. static CreateGroundFromHeightMap(name: string, url: string, options: {
  67694. width?: number;
  67695. height?: number;
  67696. subdivisions?: number;
  67697. minHeight?: number;
  67698. maxHeight?: number;
  67699. colorFilter?: Color3;
  67700. alphaFilter?: number;
  67701. updatable?: boolean;
  67702. onReady?: (mesh: GroundMesh) => void;
  67703. }, scene?: Nullable<Scene>): GroundMesh;
  67704. /**
  67705. * Creates a polygon mesh
  67706. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  67707. * * 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
  67708. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67710. * * 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)
  67711. * * Remember you can only change the shape positions, not their number when updating a polygon
  67712. * @param name defines the name of the mesh
  67713. * @param options defines the options used to create the mesh
  67714. * @param scene defines the hosting scene
  67715. * @param earcutInjection can be used to inject your own earcut reference
  67716. * @returns the polygon mesh
  67717. */
  67718. static CreatePolygon(name: string, options: {
  67719. shape: Vector3[];
  67720. holes?: Vector3[][];
  67721. depth?: number;
  67722. faceUV?: Vector4[];
  67723. faceColors?: Color4[];
  67724. updatable?: boolean;
  67725. sideOrientation?: number;
  67726. frontUVs?: Vector4;
  67727. backUVs?: Vector4;
  67728. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67729. /**
  67730. * Creates an extruded polygon mesh, with depth in the Y direction.
  67731. * * 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)
  67732. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67733. * @param name defines the name of the mesh
  67734. * @param options defines the options used to create the mesh
  67735. * @param scene defines the hosting scene
  67736. * @param earcutInjection can be used to inject your own earcut reference
  67737. * @returns the polygon mesh
  67738. */
  67739. static ExtrudePolygon(name: string, options: {
  67740. shape: Vector3[];
  67741. holes?: Vector3[][];
  67742. depth?: number;
  67743. faceUV?: Vector4[];
  67744. faceColors?: Color4[];
  67745. updatable?: boolean;
  67746. sideOrientation?: number;
  67747. frontUVs?: Vector4;
  67748. backUVs?: Vector4;
  67749. wrap?: boolean;
  67750. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67751. /**
  67752. * Creates a tube mesh.
  67753. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67754. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67755. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67756. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67757. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67758. * * 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)
  67759. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67760. * * 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
  67761. * * 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
  67762. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67763. * * 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
  67764. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67765. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67766. * @param name defines the name of the mesh
  67767. * @param options defines the options used to create the mesh
  67768. * @param scene defines the hosting scene
  67769. * @returns the tube mesh
  67770. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67771. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67772. */
  67773. static CreateTube(name: string, options: {
  67774. path: Vector3[];
  67775. radius?: number;
  67776. tessellation?: number;
  67777. radiusFunction?: {
  67778. (i: number, distance: number): number;
  67779. };
  67780. cap?: number;
  67781. arc?: number;
  67782. updatable?: boolean;
  67783. sideOrientation?: number;
  67784. frontUVs?: Vector4;
  67785. backUVs?: Vector4;
  67786. instance?: Mesh;
  67787. invertUV?: boolean;
  67788. }, scene?: Nullable<Scene>): Mesh;
  67789. /**
  67790. * Creates a polyhedron mesh
  67791. * * 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
  67792. * * The parameter `size` (positive float, default 1) sets the polygon size
  67793. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  67794. * * 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`
  67795. * * 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
  67796. * * 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)`)
  67797. * * 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
  67798. * * 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
  67799. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67800. * * 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
  67801. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67802. * @param name defines the name of the mesh
  67803. * @param options defines the options used to create the mesh
  67804. * @param scene defines the hosting scene
  67805. * @returns the polyhedron mesh
  67806. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  67807. */
  67808. static CreatePolyhedron(name: string, options: {
  67809. type?: number;
  67810. size?: number;
  67811. sizeX?: number;
  67812. sizeY?: number;
  67813. sizeZ?: number;
  67814. custom?: any;
  67815. faceUV?: Vector4[];
  67816. faceColors?: Color4[];
  67817. flat?: boolean;
  67818. updatable?: boolean;
  67819. sideOrientation?: number;
  67820. frontUVs?: Vector4;
  67821. backUVs?: Vector4;
  67822. }, scene?: Nullable<Scene>): Mesh;
  67823. /**
  67824. * Creates a decal mesh.
  67825. * 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
  67826. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67827. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67828. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67829. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67830. * @param name defines the name of the mesh
  67831. * @param sourceMesh defines the mesh where the decal must be applied
  67832. * @param options defines the options used to create the mesh
  67833. * @param scene defines the hosting scene
  67834. * @returns the decal mesh
  67835. * @see https://doc.babylonjs.com/how_to/decals
  67836. */
  67837. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67838. position?: Vector3;
  67839. normal?: Vector3;
  67840. size?: Vector3;
  67841. angle?: number;
  67842. }): Mesh;
  67843. /**
  67844. * Creates a Capsule Mesh
  67845. * @param name defines the name of the mesh.
  67846. * @param options the constructors options used to shape the mesh.
  67847. * @param scene defines the scene the mesh is scoped to.
  67848. * @returns the capsule mesh
  67849. * @see https://doc.babylonjs.com/how_to/capsule_shape
  67850. */
  67851. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  67852. }
  67853. }
  67854. declare module BABYLON {
  67855. /**
  67856. * A simplifier interface for future simplification implementations
  67857. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67858. */
  67859. export interface ISimplifier {
  67860. /**
  67861. * Simplification of a given mesh according to the given settings.
  67862. * Since this requires computation, it is assumed that the function runs async.
  67863. * @param settings The settings of the simplification, including quality and distance
  67864. * @param successCallback A callback that will be called after the mesh was simplified.
  67865. * @param errorCallback in case of an error, this callback will be called. optional.
  67866. */
  67867. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  67868. }
  67869. /**
  67870. * Expected simplification settings.
  67871. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  67872. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67873. */
  67874. export interface ISimplificationSettings {
  67875. /**
  67876. * Gets or sets the expected quality
  67877. */
  67878. quality: number;
  67879. /**
  67880. * Gets or sets the distance when this optimized version should be used
  67881. */
  67882. distance: number;
  67883. /**
  67884. * Gets an already optimized mesh
  67885. */
  67886. optimizeMesh?: boolean;
  67887. }
  67888. /**
  67889. * Class used to specify simplification options
  67890. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67891. */
  67892. export class SimplificationSettings implements ISimplificationSettings {
  67893. /** expected quality */
  67894. quality: number;
  67895. /** distance when this optimized version should be used */
  67896. distance: number;
  67897. /** already optimized mesh */
  67898. optimizeMesh?: boolean | undefined;
  67899. /**
  67900. * Creates a SimplificationSettings
  67901. * @param quality expected quality
  67902. * @param distance distance when this optimized version should be used
  67903. * @param optimizeMesh already optimized mesh
  67904. */
  67905. constructor(
  67906. /** expected quality */
  67907. quality: number,
  67908. /** distance when this optimized version should be used */
  67909. distance: number,
  67910. /** already optimized mesh */
  67911. optimizeMesh?: boolean | undefined);
  67912. }
  67913. /**
  67914. * Interface used to define a simplification task
  67915. */
  67916. export interface ISimplificationTask {
  67917. /**
  67918. * Array of settings
  67919. */
  67920. settings: Array<ISimplificationSettings>;
  67921. /**
  67922. * Simplification type
  67923. */
  67924. simplificationType: SimplificationType;
  67925. /**
  67926. * Mesh to simplify
  67927. */
  67928. mesh: Mesh;
  67929. /**
  67930. * Callback called on success
  67931. */
  67932. successCallback?: () => void;
  67933. /**
  67934. * Defines if parallel processing can be used
  67935. */
  67936. parallelProcessing: boolean;
  67937. }
  67938. /**
  67939. * Queue used to order the simplification tasks
  67940. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67941. */
  67942. export class SimplificationQueue {
  67943. private _simplificationArray;
  67944. /**
  67945. * Gets a boolean indicating that the process is still running
  67946. */
  67947. running: boolean;
  67948. /**
  67949. * Creates a new queue
  67950. */
  67951. constructor();
  67952. /**
  67953. * Adds a new simplification task
  67954. * @param task defines a task to add
  67955. */
  67956. addTask(task: ISimplificationTask): void;
  67957. /**
  67958. * Execute next task
  67959. */
  67960. executeNext(): void;
  67961. /**
  67962. * Execute a simplification task
  67963. * @param task defines the task to run
  67964. */
  67965. runSimplification(task: ISimplificationTask): void;
  67966. private getSimplifier;
  67967. }
  67968. /**
  67969. * The implemented types of simplification
  67970. * At the moment only Quadratic Error Decimation is implemented
  67971. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67972. */
  67973. export enum SimplificationType {
  67974. /** Quadratic error decimation */
  67975. QUADRATIC = 0
  67976. }
  67977. /**
  67978. * An implementation of the Quadratic Error simplification algorithm.
  67979. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  67980. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  67981. * @author RaananW
  67982. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67983. */
  67984. export class QuadraticErrorSimplification implements ISimplifier {
  67985. private _mesh;
  67986. private triangles;
  67987. private vertices;
  67988. private references;
  67989. private _reconstructedMesh;
  67990. /** Gets or sets the number pf sync interations */
  67991. syncIterations: number;
  67992. /** Gets or sets the aggressiveness of the simplifier */
  67993. aggressiveness: number;
  67994. /** Gets or sets the number of allowed iterations for decimation */
  67995. decimationIterations: number;
  67996. /** Gets or sets the espilon to use for bounding box computation */
  67997. boundingBoxEpsilon: number;
  67998. /**
  67999. * Creates a new QuadraticErrorSimplification
  68000. * @param _mesh defines the target mesh
  68001. */
  68002. constructor(_mesh: Mesh);
  68003. /**
  68004. * Simplification of a given mesh according to the given settings.
  68005. * Since this requires computation, it is assumed that the function runs async.
  68006. * @param settings The settings of the simplification, including quality and distance
  68007. * @param successCallback A callback that will be called after the mesh was simplified.
  68008. */
  68009. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  68010. private runDecimation;
  68011. private initWithMesh;
  68012. private init;
  68013. private reconstructMesh;
  68014. private initDecimatedMesh;
  68015. private isFlipped;
  68016. private updateTriangles;
  68017. private identifyBorder;
  68018. private updateMesh;
  68019. private vertexError;
  68020. private calculateError;
  68021. }
  68022. }
  68023. declare module BABYLON {
  68024. interface Scene {
  68025. /** @hidden (Backing field) */
  68026. _simplificationQueue: SimplificationQueue;
  68027. /**
  68028. * Gets or sets the simplification queue attached to the scene
  68029. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68030. */
  68031. simplificationQueue: SimplificationQueue;
  68032. }
  68033. interface Mesh {
  68034. /**
  68035. * Simplify the mesh according to the given array of settings.
  68036. * Function will return immediately and will simplify async
  68037. * @param settings a collection of simplification settings
  68038. * @param parallelProcessing should all levels calculate parallel or one after the other
  68039. * @param simplificationType the type of simplification to run
  68040. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  68041. * @returns the current mesh
  68042. */
  68043. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  68044. }
  68045. /**
  68046. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  68047. * created in a scene
  68048. */
  68049. export class SimplicationQueueSceneComponent implements ISceneComponent {
  68050. /**
  68051. * The component name helpfull to identify the component in the list of scene components.
  68052. */
  68053. readonly name: string;
  68054. /**
  68055. * The scene the component belongs to.
  68056. */
  68057. scene: Scene;
  68058. /**
  68059. * Creates a new instance of the component for the given scene
  68060. * @param scene Defines the scene to register the component in
  68061. */
  68062. constructor(scene: Scene);
  68063. /**
  68064. * Registers the component in a given scene
  68065. */
  68066. register(): void;
  68067. /**
  68068. * Rebuilds the elements related to this component in case of
  68069. * context lost for instance.
  68070. */
  68071. rebuild(): void;
  68072. /**
  68073. * Disposes the component and the associated ressources
  68074. */
  68075. dispose(): void;
  68076. private _beforeCameraUpdate;
  68077. }
  68078. }
  68079. declare module BABYLON {
  68080. interface Mesh {
  68081. /**
  68082. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  68083. */
  68084. thinInstanceEnablePicking: boolean;
  68085. /**
  68086. * Creates a new thin instance
  68087. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  68088. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  68089. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  68090. */
  68091. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  68092. /**
  68093. * Adds the transformation (matrix) of the current mesh as a thin instance
  68094. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  68095. * @returns the thin instance index number
  68096. */
  68097. thinInstanceAddSelf(refresh: boolean): number;
  68098. /**
  68099. * Registers a custom attribute to be used with thin instances
  68100. * @param kind name of the attribute
  68101. * @param stride size in floats of the attribute
  68102. */
  68103. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  68104. /**
  68105. * Sets the matrix of a thin instance
  68106. * @param index index of the thin instance
  68107. * @param matrix matrix to set
  68108. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  68109. */
  68110. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  68111. /**
  68112. * Sets the value of a custom attribute for a thin instance
  68113. * @param kind name of the attribute
  68114. * @param index index of the thin instance
  68115. * @param value value to set
  68116. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  68117. */
  68118. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  68119. /**
  68120. * Gets / sets the number of thin instances to display. Note that you can't set a number higher than what the underlying buffer can handle.
  68121. */
  68122. thinInstanceCount: number;
  68123. /**
  68124. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  68125. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  68126. * @param buffer buffer to set
  68127. * @param stride size in floats of each value of the buffer
  68128. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  68129. */
  68130. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  68131. /**
  68132. * Gets the list of world matrices
  68133. * @return an array containing all the world matrices from the thin instances
  68134. */
  68135. thinInstanceGetWorldMatrices(): Matrix[];
  68136. /**
  68137. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  68138. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  68139. */
  68140. thinInstanceBufferUpdated(kind: string): void;
  68141. /**
  68142. * Applies a partial update to a buffer directly on the GPU
  68143. * Note that the buffer located on the CPU is NOT updated! It's up to you to update it (or not) with the same data you pass to this method
  68144. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  68145. * @param data the data to set in the GPU buffer
  68146. * @param offset the offset in the GPU buffer where to update the data
  68147. */
  68148. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  68149. /**
  68150. * Refreshes the bounding info, taking into account all the thin instances defined
  68151. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  68152. */
  68153. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  68154. /** @hidden */
  68155. _thinInstanceInitializeUserStorage(): void;
  68156. /** @hidden */
  68157. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  68158. /** @hidden */
  68159. _userThinInstanceBuffersStorage: {
  68160. data: {
  68161. [key: string]: Float32Array;
  68162. };
  68163. sizes: {
  68164. [key: string]: number;
  68165. };
  68166. vertexBuffers: {
  68167. [key: string]: Nullable<VertexBuffer>;
  68168. };
  68169. strides: {
  68170. [key: string]: number;
  68171. };
  68172. };
  68173. }
  68174. }
  68175. declare module BABYLON {
  68176. /**
  68177. * Navigation plugin interface to add navigation constrained by a navigation mesh
  68178. */
  68179. export interface INavigationEnginePlugin {
  68180. /**
  68181. * plugin name
  68182. */
  68183. name: string;
  68184. /**
  68185. * Creates a navigation mesh
  68186. * @param meshes array of all the geometry used to compute the navigatio mesh
  68187. * @param parameters bunch of parameters used to filter geometry
  68188. */
  68189. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  68190. /**
  68191. * Create a navigation mesh debug mesh
  68192. * @param scene is where the mesh will be added
  68193. * @returns debug display mesh
  68194. */
  68195. createDebugNavMesh(scene: Scene): Mesh;
  68196. /**
  68197. * Get a navigation mesh constrained position, closest to the parameter position
  68198. * @param position world position
  68199. * @returns the closest point to position constrained by the navigation mesh
  68200. */
  68201. getClosestPoint(position: Vector3): Vector3;
  68202. /**
  68203. * Get a navigation mesh constrained position, closest to the parameter position
  68204. * @param position world position
  68205. * @param result output the closest point to position constrained by the navigation mesh
  68206. */
  68207. getClosestPointToRef(position: Vector3, result: Vector3): void;
  68208. /**
  68209. * Get a navigation mesh constrained position, within a particular radius
  68210. * @param position world position
  68211. * @param maxRadius the maximum distance to the constrained world position
  68212. * @returns the closest point to position constrained by the navigation mesh
  68213. */
  68214. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  68215. /**
  68216. * Get a navigation mesh constrained position, within a particular radius
  68217. * @param position world position
  68218. * @param maxRadius the maximum distance to the constrained world position
  68219. * @param result output the closest point to position constrained by the navigation mesh
  68220. */
  68221. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  68222. /**
  68223. * Compute the final position from a segment made of destination-position
  68224. * @param position world position
  68225. * @param destination world position
  68226. * @returns the resulting point along the navmesh
  68227. */
  68228. moveAlong(position: Vector3, destination: Vector3): Vector3;
  68229. /**
  68230. * Compute the final position from a segment made of destination-position
  68231. * @param position world position
  68232. * @param destination world position
  68233. * @param result output the resulting point along the navmesh
  68234. */
  68235. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  68236. /**
  68237. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  68238. * @param start world position
  68239. * @param end world position
  68240. * @returns array containing world position composing the path
  68241. */
  68242. computePath(start: Vector3, end: Vector3): Vector3[];
  68243. /**
  68244. * If this plugin is supported
  68245. * @returns true if plugin is supported
  68246. */
  68247. isSupported(): boolean;
  68248. /**
  68249. * Create a new Crowd so you can add agents
  68250. * @param maxAgents the maximum agent count in the crowd
  68251. * @param maxAgentRadius the maximum radius an agent can have
  68252. * @param scene to attach the crowd to
  68253. * @returns the crowd you can add agents to
  68254. */
  68255. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  68256. /**
  68257. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68258. * The queries will try to find a solution within those bounds
  68259. * default is (1,1,1)
  68260. * @param extent x,y,z value that define the extent around the queries point of reference
  68261. */
  68262. setDefaultQueryExtent(extent: Vector3): void;
  68263. /**
  68264. * Get the Bounding box extent specified by setDefaultQueryExtent
  68265. * @returns the box extent values
  68266. */
  68267. getDefaultQueryExtent(): Vector3;
  68268. /**
  68269. * build the navmesh from a previously saved state using getNavmeshData
  68270. * @param data the Uint8Array returned by getNavmeshData
  68271. */
  68272. buildFromNavmeshData(data: Uint8Array): void;
  68273. /**
  68274. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  68275. * @returns data the Uint8Array that can be saved and reused
  68276. */
  68277. getNavmeshData(): Uint8Array;
  68278. /**
  68279. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68280. * @param result output the box extent values
  68281. */
  68282. getDefaultQueryExtentToRef(result: Vector3): void;
  68283. /**
  68284. * Release all resources
  68285. */
  68286. dispose(): void;
  68287. }
  68288. /**
  68289. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  68290. */
  68291. export interface ICrowd {
  68292. /**
  68293. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  68294. * You can attach anything to that node. The node position is updated in the scene update tick.
  68295. * @param pos world position that will be constrained by the navigation mesh
  68296. * @param parameters agent parameters
  68297. * @param transform hooked to the agent that will be update by the scene
  68298. * @returns agent index
  68299. */
  68300. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68301. /**
  68302. * Returns the agent position in world space
  68303. * @param index agent index returned by addAgent
  68304. * @returns world space position
  68305. */
  68306. getAgentPosition(index: number): Vector3;
  68307. /**
  68308. * Gets the agent position result in world space
  68309. * @param index agent index returned by addAgent
  68310. * @param result output world space position
  68311. */
  68312. getAgentPositionToRef(index: number, result: Vector3): void;
  68313. /**
  68314. * Gets the agent velocity in world space
  68315. * @param index agent index returned by addAgent
  68316. * @returns world space velocity
  68317. */
  68318. getAgentVelocity(index: number): Vector3;
  68319. /**
  68320. * Gets the agent velocity result in world space
  68321. * @param index agent index returned by addAgent
  68322. * @param result output world space velocity
  68323. */
  68324. getAgentVelocityToRef(index: number, result: Vector3): void;
  68325. /**
  68326. * Gets the agent next target point on the path
  68327. * @param index agent index returned by addAgent
  68328. * @returns world space position
  68329. */
  68330. getAgentNextTargetPath(index: number): Vector3;
  68331. /**
  68332. * Gets the agent state
  68333. * @param index agent index returned by addAgent
  68334. * @returns agent state
  68335. */
  68336. getAgentState(index: number): number;
  68337. /**
  68338. * returns true if the agent in over an off mesh link connection
  68339. * @param index agent index returned by addAgent
  68340. * @returns true if over an off mesh link connection
  68341. */
  68342. overOffmeshConnection(index: number): boolean;
  68343. /**
  68344. * Gets the agent next target point on the path
  68345. * @param index agent index returned by addAgent
  68346. * @param result output world space position
  68347. */
  68348. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  68349. /**
  68350. * remove a particular agent previously created
  68351. * @param index agent index returned by addAgent
  68352. */
  68353. removeAgent(index: number): void;
  68354. /**
  68355. * get the list of all agents attached to this crowd
  68356. * @returns list of agent indices
  68357. */
  68358. getAgents(): number[];
  68359. /**
  68360. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68361. * @param deltaTime in seconds
  68362. */
  68363. update(deltaTime: number): void;
  68364. /**
  68365. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68366. * @param index agent index returned by addAgent
  68367. * @param destination targeted world position
  68368. */
  68369. agentGoto(index: number, destination: Vector3): void;
  68370. /**
  68371. * Teleport the agent to a new position
  68372. * @param index agent index returned by addAgent
  68373. * @param destination targeted world position
  68374. */
  68375. agentTeleport(index: number, destination: Vector3): void;
  68376. /**
  68377. * Update agent parameters
  68378. * @param index agent index returned by addAgent
  68379. * @param parameters agent parameters
  68380. */
  68381. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68382. /**
  68383. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68384. * The queries will try to find a solution within those bounds
  68385. * default is (1,1,1)
  68386. * @param extent x,y,z value that define the extent around the queries point of reference
  68387. */
  68388. setDefaultQueryExtent(extent: Vector3): void;
  68389. /**
  68390. * Get the Bounding box extent specified by setDefaultQueryExtent
  68391. * @returns the box extent values
  68392. */
  68393. getDefaultQueryExtent(): Vector3;
  68394. /**
  68395. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68396. * @param result output the box extent values
  68397. */
  68398. getDefaultQueryExtentToRef(result: Vector3): void;
  68399. /**
  68400. * Release all resources
  68401. */
  68402. dispose(): void;
  68403. }
  68404. /**
  68405. * Configures an agent
  68406. */
  68407. export interface IAgentParameters {
  68408. /**
  68409. * Agent radius. [Limit: >= 0]
  68410. */
  68411. radius: number;
  68412. /**
  68413. * Agent height. [Limit: > 0]
  68414. */
  68415. height: number;
  68416. /**
  68417. * Maximum allowed acceleration. [Limit: >= 0]
  68418. */
  68419. maxAcceleration: number;
  68420. /**
  68421. * Maximum allowed speed. [Limit: >= 0]
  68422. */
  68423. maxSpeed: number;
  68424. /**
  68425. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  68426. */
  68427. collisionQueryRange: number;
  68428. /**
  68429. * The path visibility optimization range. [Limit: > 0]
  68430. */
  68431. pathOptimizationRange: number;
  68432. /**
  68433. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  68434. */
  68435. separationWeight: number;
  68436. }
  68437. /**
  68438. * Configures the navigation mesh creation
  68439. */
  68440. export interface INavMeshParameters {
  68441. /**
  68442. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  68443. */
  68444. cs: number;
  68445. /**
  68446. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  68447. */
  68448. ch: number;
  68449. /**
  68450. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  68451. */
  68452. walkableSlopeAngle: number;
  68453. /**
  68454. * Minimum floor to 'ceiling' height that will still allow the floor area to
  68455. * be considered walkable. [Limit: >= 3] [Units: vx]
  68456. */
  68457. walkableHeight: number;
  68458. /**
  68459. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  68460. */
  68461. walkableClimb: number;
  68462. /**
  68463. * The distance to erode/shrink the walkable area of the heightfield away from
  68464. * obstructions. [Limit: >=0] [Units: vx]
  68465. */
  68466. walkableRadius: number;
  68467. /**
  68468. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  68469. */
  68470. maxEdgeLen: number;
  68471. /**
  68472. * The maximum distance a simplfied contour's border edges should deviate
  68473. * the original raw contour. [Limit: >=0] [Units: vx]
  68474. */
  68475. maxSimplificationError: number;
  68476. /**
  68477. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  68478. */
  68479. minRegionArea: number;
  68480. /**
  68481. * Any regions with a span count smaller than this value will, if possible,
  68482. * be merged with larger regions. [Limit: >=0] [Units: vx]
  68483. */
  68484. mergeRegionArea: number;
  68485. /**
  68486. * The maximum number of vertices allowed for polygons generated during the
  68487. * contour to polygon conversion process. [Limit: >= 3]
  68488. */
  68489. maxVertsPerPoly: number;
  68490. /**
  68491. * Sets the sampling distance to use when generating the detail mesh.
  68492. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  68493. */
  68494. detailSampleDist: number;
  68495. /**
  68496. * The maximum distance the detail mesh surface should deviate from heightfield
  68497. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  68498. */
  68499. detailSampleMaxError: number;
  68500. }
  68501. }
  68502. declare module BABYLON {
  68503. /**
  68504. * RecastJS navigation plugin
  68505. */
  68506. export class RecastJSPlugin implements INavigationEnginePlugin {
  68507. /**
  68508. * Reference to the Recast library
  68509. */
  68510. bjsRECAST: any;
  68511. /**
  68512. * plugin name
  68513. */
  68514. name: string;
  68515. /**
  68516. * the first navmesh created. We might extend this to support multiple navmeshes
  68517. */
  68518. navMesh: any;
  68519. /**
  68520. * Initializes the recastJS plugin
  68521. * @param recastInjection can be used to inject your own recast reference
  68522. */
  68523. constructor(recastInjection?: any);
  68524. /**
  68525. * Creates a navigation mesh
  68526. * @param meshes array of all the geometry used to compute the navigatio mesh
  68527. * @param parameters bunch of parameters used to filter geometry
  68528. */
  68529. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  68530. /**
  68531. * Create a navigation mesh debug mesh
  68532. * @param scene is where the mesh will be added
  68533. * @returns debug display mesh
  68534. */
  68535. createDebugNavMesh(scene: Scene): Mesh;
  68536. /**
  68537. * Get a navigation mesh constrained position, closest to the parameter position
  68538. * @param position world position
  68539. * @returns the closest point to position constrained by the navigation mesh
  68540. */
  68541. getClosestPoint(position: Vector3): Vector3;
  68542. /**
  68543. * Get a navigation mesh constrained position, closest to the parameter position
  68544. * @param position world position
  68545. * @param result output the closest point to position constrained by the navigation mesh
  68546. */
  68547. getClosestPointToRef(position: Vector3, result: Vector3): void;
  68548. /**
  68549. * Get a navigation mesh constrained position, within a particular radius
  68550. * @param position world position
  68551. * @param maxRadius the maximum distance to the constrained world position
  68552. * @returns the closest point to position constrained by the navigation mesh
  68553. */
  68554. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  68555. /**
  68556. * Get a navigation mesh constrained position, within a particular radius
  68557. * @param position world position
  68558. * @param maxRadius the maximum distance to the constrained world position
  68559. * @param result output the closest point to position constrained by the navigation mesh
  68560. */
  68561. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  68562. /**
  68563. * Compute the final position from a segment made of destination-position
  68564. * @param position world position
  68565. * @param destination world position
  68566. * @returns the resulting point along the navmesh
  68567. */
  68568. moveAlong(position: Vector3, destination: Vector3): Vector3;
  68569. /**
  68570. * Compute the final position from a segment made of destination-position
  68571. * @param position world position
  68572. * @param destination world position
  68573. * @param result output the resulting point along the navmesh
  68574. */
  68575. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  68576. /**
  68577. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  68578. * @param start world position
  68579. * @param end world position
  68580. * @returns array containing world position composing the path
  68581. */
  68582. computePath(start: Vector3, end: Vector3): Vector3[];
  68583. /**
  68584. * Create a new Crowd so you can add agents
  68585. * @param maxAgents the maximum agent count in the crowd
  68586. * @param maxAgentRadius the maximum radius an agent can have
  68587. * @param scene to attach the crowd to
  68588. * @returns the crowd you can add agents to
  68589. */
  68590. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  68591. /**
  68592. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68593. * The queries will try to find a solution within those bounds
  68594. * default is (1,1,1)
  68595. * @param extent x,y,z value that define the extent around the queries point of reference
  68596. */
  68597. setDefaultQueryExtent(extent: Vector3): void;
  68598. /**
  68599. * Get the Bounding box extent specified by setDefaultQueryExtent
  68600. * @returns the box extent values
  68601. */
  68602. getDefaultQueryExtent(): Vector3;
  68603. /**
  68604. * build the navmesh from a previously saved state using getNavmeshData
  68605. * @param data the Uint8Array returned by getNavmeshData
  68606. */
  68607. buildFromNavmeshData(data: Uint8Array): void;
  68608. /**
  68609. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  68610. * @returns data the Uint8Array that can be saved and reused
  68611. */
  68612. getNavmeshData(): Uint8Array;
  68613. /**
  68614. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68615. * @param result output the box extent values
  68616. */
  68617. getDefaultQueryExtentToRef(result: Vector3): void;
  68618. /**
  68619. * Disposes
  68620. */
  68621. dispose(): void;
  68622. /**
  68623. * If this plugin is supported
  68624. * @returns true if plugin is supported
  68625. */
  68626. isSupported(): boolean;
  68627. }
  68628. /**
  68629. * Recast detour crowd implementation
  68630. */
  68631. export class RecastJSCrowd implements ICrowd {
  68632. /**
  68633. * Recast/detour plugin
  68634. */
  68635. bjsRECASTPlugin: RecastJSPlugin;
  68636. /**
  68637. * Link to the detour crowd
  68638. */
  68639. recastCrowd: any;
  68640. /**
  68641. * One transform per agent
  68642. */
  68643. transforms: TransformNode[];
  68644. /**
  68645. * All agents created
  68646. */
  68647. agents: number[];
  68648. /**
  68649. * Link to the scene is kept to unregister the crowd from the scene
  68650. */
  68651. private _scene;
  68652. /**
  68653. * Observer for crowd updates
  68654. */
  68655. private _onBeforeAnimationsObserver;
  68656. /**
  68657. * Constructor
  68658. * @param plugin recastJS plugin
  68659. * @param maxAgents the maximum agent count in the crowd
  68660. * @param maxAgentRadius the maximum radius an agent can have
  68661. * @param scene to attach the crowd to
  68662. * @returns the crowd you can add agents to
  68663. */
  68664. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  68665. /**
  68666. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  68667. * You can attach anything to that node. The node position is updated in the scene update tick.
  68668. * @param pos world position that will be constrained by the navigation mesh
  68669. * @param parameters agent parameters
  68670. * @param transform hooked to the agent that will be update by the scene
  68671. * @returns agent index
  68672. */
  68673. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68674. /**
  68675. * Returns the agent position in world space
  68676. * @param index agent index returned by addAgent
  68677. * @returns world space position
  68678. */
  68679. getAgentPosition(index: number): Vector3;
  68680. /**
  68681. * Returns the agent position result in world space
  68682. * @param index agent index returned by addAgent
  68683. * @param result output world space position
  68684. */
  68685. getAgentPositionToRef(index: number, result: Vector3): void;
  68686. /**
  68687. * Returns the agent velocity in world space
  68688. * @param index agent index returned by addAgent
  68689. * @returns world space velocity
  68690. */
  68691. getAgentVelocity(index: number): Vector3;
  68692. /**
  68693. * Returns the agent velocity result in world space
  68694. * @param index agent index returned by addAgent
  68695. * @param result output world space velocity
  68696. */
  68697. getAgentVelocityToRef(index: number, result: Vector3): void;
  68698. /**
  68699. * Returns the agent next target point on the path
  68700. * @param index agent index returned by addAgent
  68701. * @returns world space position
  68702. */
  68703. getAgentNextTargetPath(index: number): Vector3;
  68704. /**
  68705. * Returns the agent next target point on the path
  68706. * @param index agent index returned by addAgent
  68707. * @param result output world space position
  68708. */
  68709. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  68710. /**
  68711. * Gets the agent state
  68712. * @param index agent index returned by addAgent
  68713. * @returns agent state
  68714. */
  68715. getAgentState(index: number): number;
  68716. /**
  68717. * returns true if the agent in over an off mesh link connection
  68718. * @param index agent index returned by addAgent
  68719. * @returns true if over an off mesh link connection
  68720. */
  68721. overOffmeshConnection(index: number): boolean;
  68722. /**
  68723. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68724. * @param index agent index returned by addAgent
  68725. * @param destination targeted world position
  68726. */
  68727. agentGoto(index: number, destination: Vector3): void;
  68728. /**
  68729. * Teleport the agent to a new position
  68730. * @param index agent index returned by addAgent
  68731. * @param destination targeted world position
  68732. */
  68733. agentTeleport(index: number, destination: Vector3): void;
  68734. /**
  68735. * Update agent parameters
  68736. * @param index agent index returned by addAgent
  68737. * @param parameters agent parameters
  68738. */
  68739. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68740. /**
  68741. * remove a particular agent previously created
  68742. * @param index agent index returned by addAgent
  68743. */
  68744. removeAgent(index: number): void;
  68745. /**
  68746. * get the list of all agents attached to this crowd
  68747. * @returns list of agent indices
  68748. */
  68749. getAgents(): number[];
  68750. /**
  68751. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68752. * @param deltaTime in seconds
  68753. */
  68754. update(deltaTime: number): void;
  68755. /**
  68756. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68757. * The queries will try to find a solution within those bounds
  68758. * default is (1,1,1)
  68759. * @param extent x,y,z value that define the extent around the queries point of reference
  68760. */
  68761. setDefaultQueryExtent(extent: Vector3): void;
  68762. /**
  68763. * Get the Bounding box extent specified by setDefaultQueryExtent
  68764. * @returns the box extent values
  68765. */
  68766. getDefaultQueryExtent(): Vector3;
  68767. /**
  68768. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68769. * @param result output the box extent values
  68770. */
  68771. getDefaultQueryExtentToRef(result: Vector3): void;
  68772. /**
  68773. * Release all resources
  68774. */
  68775. dispose(): void;
  68776. }
  68777. }
  68778. declare module BABYLON {
  68779. /**
  68780. * Class used to enable access to IndexedDB
  68781. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68782. */
  68783. export class Database implements IOfflineProvider {
  68784. private _callbackManifestChecked;
  68785. private _currentSceneUrl;
  68786. private _db;
  68787. private _enableSceneOffline;
  68788. private _enableTexturesOffline;
  68789. private _manifestVersionFound;
  68790. private _mustUpdateRessources;
  68791. private _hasReachedQuota;
  68792. private _isSupported;
  68793. private _idbFactory;
  68794. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  68795. private static IsUASupportingBlobStorage;
  68796. /**
  68797. * Gets a boolean indicating if Database storate is enabled (off by default)
  68798. */
  68799. static IDBStorageEnabled: boolean;
  68800. /**
  68801. * Gets a boolean indicating if scene must be saved in the database
  68802. */
  68803. get enableSceneOffline(): boolean;
  68804. /**
  68805. * Gets a boolean indicating if textures must be saved in the database
  68806. */
  68807. get enableTexturesOffline(): boolean;
  68808. /**
  68809. * Creates a new Database
  68810. * @param urlToScene defines the url to load the scene
  68811. * @param callbackManifestChecked defines the callback to use when manifest is checked
  68812. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  68813. */
  68814. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  68815. private static _ParseURL;
  68816. private static _ReturnFullUrlLocation;
  68817. private _checkManifestFile;
  68818. /**
  68819. * Open the database and make it available
  68820. * @param successCallback defines the callback to call on success
  68821. * @param errorCallback defines the callback to call on error
  68822. */
  68823. open(successCallback: () => void, errorCallback: () => void): void;
  68824. /**
  68825. * Loads an image from the database
  68826. * @param url defines the url to load from
  68827. * @param image defines the target DOM image
  68828. */
  68829. loadImage(url: string, image: HTMLImageElement): void;
  68830. private _loadImageFromDBAsync;
  68831. private _saveImageIntoDBAsync;
  68832. private _checkVersionFromDB;
  68833. private _loadVersionFromDBAsync;
  68834. private _saveVersionIntoDBAsync;
  68835. /**
  68836. * Loads a file from database
  68837. * @param url defines the URL to load from
  68838. * @param sceneLoaded defines a callback to call on success
  68839. * @param progressCallBack defines a callback to call when progress changed
  68840. * @param errorCallback defines a callback to call on error
  68841. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68842. */
  68843. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68844. private _loadFileAsync;
  68845. private _saveFileAsync;
  68846. /**
  68847. * Validates if xhr data is correct
  68848. * @param xhr defines the request to validate
  68849. * @param dataType defines the expected data type
  68850. * @returns true if data is correct
  68851. */
  68852. private static _ValidateXHRData;
  68853. }
  68854. }
  68855. declare module BABYLON {
  68856. /** @hidden */
  68857. export var gpuUpdateParticlesPixelShader: {
  68858. name: string;
  68859. shader: string;
  68860. };
  68861. }
  68862. declare module BABYLON {
  68863. /** @hidden */
  68864. export var gpuUpdateParticlesVertexShader: {
  68865. name: string;
  68866. shader: string;
  68867. };
  68868. }
  68869. declare module BABYLON {
  68870. /** @hidden */
  68871. export var clipPlaneFragmentDeclaration2: {
  68872. name: string;
  68873. shader: string;
  68874. };
  68875. }
  68876. declare module BABYLON {
  68877. /** @hidden */
  68878. export var gpuRenderParticlesPixelShader: {
  68879. name: string;
  68880. shader: string;
  68881. };
  68882. }
  68883. declare module BABYLON {
  68884. /** @hidden */
  68885. export var clipPlaneVertexDeclaration2: {
  68886. name: string;
  68887. shader: string;
  68888. };
  68889. }
  68890. declare module BABYLON {
  68891. /** @hidden */
  68892. export var gpuRenderParticlesVertexShader: {
  68893. name: string;
  68894. shader: string;
  68895. };
  68896. }
  68897. declare module BABYLON {
  68898. /**
  68899. * This represents a GPU particle system in Babylon
  68900. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  68901. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  68902. */
  68903. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  68904. /**
  68905. * The layer mask we are rendering the particles through.
  68906. */
  68907. layerMask: number;
  68908. private _capacity;
  68909. private _activeCount;
  68910. private _currentActiveCount;
  68911. private _accumulatedCount;
  68912. private _renderEffect;
  68913. private _updateEffect;
  68914. private _buffer0;
  68915. private _buffer1;
  68916. private _spriteBuffer;
  68917. private _updateVAO;
  68918. private _renderVAO;
  68919. private _targetIndex;
  68920. private _sourceBuffer;
  68921. private _targetBuffer;
  68922. private _currentRenderId;
  68923. private _started;
  68924. private _stopped;
  68925. private _timeDelta;
  68926. private _randomTexture;
  68927. private _randomTexture2;
  68928. private _attributesStrideSize;
  68929. private _updateEffectOptions;
  68930. private _randomTextureSize;
  68931. private _actualFrame;
  68932. private _customEffect;
  68933. private readonly _rawTextureWidth;
  68934. /**
  68935. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  68936. */
  68937. static get IsSupported(): boolean;
  68938. /**
  68939. * An event triggered when the system is disposed.
  68940. */
  68941. onDisposeObservable: Observable<IParticleSystem>;
  68942. /**
  68943. * An event triggered when the system is stopped
  68944. */
  68945. onStoppedObservable: Observable<IParticleSystem>;
  68946. /**
  68947. * Gets the maximum number of particles active at the same time.
  68948. * @returns The max number of active particles.
  68949. */
  68950. getCapacity(): number;
  68951. /**
  68952. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  68953. * to override the particles.
  68954. */
  68955. forceDepthWrite: boolean;
  68956. /**
  68957. * Gets or set the number of active particles
  68958. */
  68959. get activeParticleCount(): number;
  68960. set activeParticleCount(value: number);
  68961. private _preWarmDone;
  68962. /**
  68963. * Specifies if the particles are updated in emitter local space or world space.
  68964. */
  68965. isLocal: boolean;
  68966. /** Gets or sets a matrix to use to compute projection */
  68967. defaultProjectionMatrix: Matrix;
  68968. /**
  68969. * Is this system ready to be used/rendered
  68970. * @return true if the system is ready
  68971. */
  68972. isReady(): boolean;
  68973. /**
  68974. * Gets if the system has been started. (Note: this will still be true after stop is called)
  68975. * @returns True if it has been started, otherwise false.
  68976. */
  68977. isStarted(): boolean;
  68978. /**
  68979. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  68980. * @returns True if it has been stopped, otherwise false.
  68981. */
  68982. isStopped(): boolean;
  68983. /**
  68984. * Gets a boolean indicating that the system is stopping
  68985. * @returns true if the system is currently stopping
  68986. */
  68987. isStopping(): boolean;
  68988. /**
  68989. * Gets the number of particles active at the same time.
  68990. * @returns The number of active particles.
  68991. */
  68992. getActiveCount(): number;
  68993. /**
  68994. * Starts the particle system and begins to emit
  68995. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  68996. */
  68997. start(delay?: number): void;
  68998. /**
  68999. * Stops the particle system.
  69000. */
  69001. stop(): void;
  69002. /**
  69003. * Remove all active particles
  69004. */
  69005. reset(): void;
  69006. /**
  69007. * Returns the string "GPUParticleSystem"
  69008. * @returns a string containing the class name
  69009. */
  69010. getClassName(): string;
  69011. /**
  69012. * Gets the custom effect used to render the particles
  69013. * @param blendMode Blend mode for which the effect should be retrieved
  69014. * @returns The effect
  69015. */
  69016. getCustomEffect(blendMode?: number): Nullable<Effect>;
  69017. /**
  69018. * Sets the custom effect used to render the particles
  69019. * @param effect The effect to set
  69020. * @param blendMode Blend mode for which the effect should be set
  69021. */
  69022. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  69023. /** @hidden */
  69024. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  69025. /**
  69026. * Observable that will be called just before the particles are drawn
  69027. */
  69028. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  69029. /**
  69030. * Gets the name of the particle vertex shader
  69031. */
  69032. get vertexShaderName(): string;
  69033. private _colorGradientsTexture;
  69034. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  69035. /**
  69036. * Adds a new color gradient
  69037. * @param gradient defines the gradient to use (between 0 and 1)
  69038. * @param color1 defines the color to affect to the specified gradient
  69039. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  69040. * @returns the current particle system
  69041. */
  69042. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  69043. private _refreshColorGradient;
  69044. /** Force the system to rebuild all gradients that need to be resync */
  69045. forceRefreshGradients(): void;
  69046. /**
  69047. * Remove a specific color gradient
  69048. * @param gradient defines the gradient to remove
  69049. * @returns the current particle system
  69050. */
  69051. removeColorGradient(gradient: number): GPUParticleSystem;
  69052. private _angularSpeedGradientsTexture;
  69053. private _sizeGradientsTexture;
  69054. private _velocityGradientsTexture;
  69055. private _limitVelocityGradientsTexture;
  69056. private _dragGradientsTexture;
  69057. private _addFactorGradient;
  69058. /**
  69059. * Adds a new size gradient
  69060. * @param gradient defines the gradient to use (between 0 and 1)
  69061. * @param factor defines the size factor to affect to the specified gradient
  69062. * @returns the current particle system
  69063. */
  69064. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  69065. /**
  69066. * Remove a specific size gradient
  69067. * @param gradient defines the gradient to remove
  69068. * @returns the current particle system
  69069. */
  69070. removeSizeGradient(gradient: number): GPUParticleSystem;
  69071. private _refreshFactorGradient;
  69072. /**
  69073. * Adds a new angular speed gradient
  69074. * @param gradient defines the gradient to use (between 0 and 1)
  69075. * @param factor defines the angular speed to affect to the specified gradient
  69076. * @returns the current particle system
  69077. */
  69078. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  69079. /**
  69080. * Remove a specific angular speed gradient
  69081. * @param gradient defines the gradient to remove
  69082. * @returns the current particle system
  69083. */
  69084. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  69085. /**
  69086. * Adds a new velocity gradient
  69087. * @param gradient defines the gradient to use (between 0 and 1)
  69088. * @param factor defines the velocity to affect to the specified gradient
  69089. * @returns the current particle system
  69090. */
  69091. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  69092. /**
  69093. * Remove a specific velocity gradient
  69094. * @param gradient defines the gradient to remove
  69095. * @returns the current particle system
  69096. */
  69097. removeVelocityGradient(gradient: number): GPUParticleSystem;
  69098. /**
  69099. * Adds a new limit velocity gradient
  69100. * @param gradient defines the gradient to use (between 0 and 1)
  69101. * @param factor defines the limit velocity value to affect to the specified gradient
  69102. * @returns the current particle system
  69103. */
  69104. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  69105. /**
  69106. * Remove a specific limit velocity gradient
  69107. * @param gradient defines the gradient to remove
  69108. * @returns the current particle system
  69109. */
  69110. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  69111. /**
  69112. * Adds a new drag gradient
  69113. * @param gradient defines the gradient to use (between 0 and 1)
  69114. * @param factor defines the drag value to affect to the specified gradient
  69115. * @returns the current particle system
  69116. */
  69117. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  69118. /**
  69119. * Remove a specific drag gradient
  69120. * @param gradient defines the gradient to remove
  69121. * @returns the current particle system
  69122. */
  69123. removeDragGradient(gradient: number): GPUParticleSystem;
  69124. /**
  69125. * Not supported by GPUParticleSystem
  69126. * @param gradient defines the gradient to use (between 0 and 1)
  69127. * @param factor defines the emit rate value to affect to the specified gradient
  69128. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69129. * @returns the current particle system
  69130. */
  69131. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69132. /**
  69133. * Not supported by GPUParticleSystem
  69134. * @param gradient defines the gradient to remove
  69135. * @returns the current particle system
  69136. */
  69137. removeEmitRateGradient(gradient: number): IParticleSystem;
  69138. /**
  69139. * Not supported by GPUParticleSystem
  69140. * @param gradient defines the gradient to use (between 0 and 1)
  69141. * @param factor defines the start size value to affect to the specified gradient
  69142. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69143. * @returns the current particle system
  69144. */
  69145. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69146. /**
  69147. * Not supported by GPUParticleSystem
  69148. * @param gradient defines the gradient to remove
  69149. * @returns the current particle system
  69150. */
  69151. removeStartSizeGradient(gradient: number): IParticleSystem;
  69152. /**
  69153. * Not supported by GPUParticleSystem
  69154. * @param gradient defines the gradient to use (between 0 and 1)
  69155. * @param min defines the color remap minimal range
  69156. * @param max defines the color remap maximal range
  69157. * @returns the current particle system
  69158. */
  69159. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  69160. /**
  69161. * Not supported by GPUParticleSystem
  69162. * @param gradient defines the gradient to remove
  69163. * @returns the current particle system
  69164. */
  69165. removeColorRemapGradient(): IParticleSystem;
  69166. /**
  69167. * Not supported by GPUParticleSystem
  69168. * @param gradient defines the gradient to use (between 0 and 1)
  69169. * @param min defines the alpha remap minimal range
  69170. * @param max defines the alpha remap maximal range
  69171. * @returns the current particle system
  69172. */
  69173. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  69174. /**
  69175. * Not supported by GPUParticleSystem
  69176. * @param gradient defines the gradient to remove
  69177. * @returns the current particle system
  69178. */
  69179. removeAlphaRemapGradient(): IParticleSystem;
  69180. /**
  69181. * Not supported by GPUParticleSystem
  69182. * @param gradient defines the gradient to use (between 0 and 1)
  69183. * @param color defines the color to affect to the specified gradient
  69184. * @returns the current particle system
  69185. */
  69186. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  69187. /**
  69188. * Not supported by GPUParticleSystem
  69189. * @param gradient defines the gradient to remove
  69190. * @returns the current particle system
  69191. */
  69192. removeRampGradient(): IParticleSystem;
  69193. /**
  69194. * Not supported by GPUParticleSystem
  69195. * @returns the list of ramp gradients
  69196. */
  69197. getRampGradients(): Nullable<Array<Color3Gradient>>;
  69198. /**
  69199. * Not supported by GPUParticleSystem
  69200. * Gets or sets a boolean indicating that ramp gradients must be used
  69201. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  69202. */
  69203. get useRampGradients(): boolean;
  69204. set useRampGradients(value: boolean);
  69205. /**
  69206. * Not supported by GPUParticleSystem
  69207. * @param gradient defines the gradient to use (between 0 and 1)
  69208. * @param factor defines the life time factor to affect to the specified gradient
  69209. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69210. * @returns the current particle system
  69211. */
  69212. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69213. /**
  69214. * Not supported by GPUParticleSystem
  69215. * @param gradient defines the gradient to remove
  69216. * @returns the current particle system
  69217. */
  69218. removeLifeTimeGradient(gradient: number): IParticleSystem;
  69219. /**
  69220. * Instantiates a GPU particle system.
  69221. * 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.
  69222. * @param name The name of the particle system
  69223. * @param options The options used to create the system
  69224. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  69225. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  69226. * @param customEffect a custom effect used to change the way particles are rendered by default
  69227. */
  69228. constructor(name: string, options: Partial<{
  69229. capacity: number;
  69230. randomTextureSize: number;
  69231. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  69232. protected _reset(): void;
  69233. private _createUpdateVAO;
  69234. private _createRenderVAO;
  69235. private _initialize;
  69236. /** @hidden */
  69237. _recreateUpdateEffect(): void;
  69238. private _getEffect;
  69239. /**
  69240. * Fill the defines array according to the current settings of the particle system
  69241. * @param defines Array to be updated
  69242. * @param blendMode blend mode to take into account when updating the array
  69243. */
  69244. fillDefines(defines: Array<string>, blendMode?: number): void;
  69245. /**
  69246. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  69247. * @param uniforms Uniforms array to fill
  69248. * @param attributes Attributes array to fill
  69249. * @param samplers Samplers array to fill
  69250. */
  69251. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  69252. /** @hidden */
  69253. _recreateRenderEffect(): Effect;
  69254. /**
  69255. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  69256. * @param preWarm defines if we are in the pre-warmimg phase
  69257. */
  69258. animate(preWarm?: boolean): void;
  69259. private _createFactorGradientTexture;
  69260. private _createSizeGradientTexture;
  69261. private _createAngularSpeedGradientTexture;
  69262. private _createVelocityGradientTexture;
  69263. private _createLimitVelocityGradientTexture;
  69264. private _createDragGradientTexture;
  69265. private _createColorGradientTexture;
  69266. /**
  69267. * Renders the particle system in its current state
  69268. * @param preWarm defines if the system should only update the particles but not render them
  69269. * @returns the current number of particles
  69270. */
  69271. render(preWarm?: boolean): number;
  69272. /**
  69273. * Rebuilds the particle system
  69274. */
  69275. rebuild(): void;
  69276. private _releaseBuffers;
  69277. private _releaseVAOs;
  69278. /**
  69279. * Disposes the particle system and free the associated resources
  69280. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  69281. */
  69282. dispose(disposeTexture?: boolean): void;
  69283. /**
  69284. * Clones the particle system.
  69285. * @param name The name of the cloned object
  69286. * @param newEmitter The new emitter to use
  69287. * @returns the cloned particle system
  69288. */
  69289. clone(name: string, newEmitter: any): GPUParticleSystem;
  69290. /**
  69291. * Serializes the particle system to a JSON object
  69292. * @param serializeTexture defines if the texture must be serialized as well
  69293. * @returns the JSON object
  69294. */
  69295. serialize(serializeTexture?: boolean): any;
  69296. /**
  69297. * Parses a JSON object to create a GPU particle system.
  69298. * @param parsedParticleSystem The JSON object to parse
  69299. * @param sceneOrEngine The scene or the engine to create the particle system in
  69300. * @param rootUrl The root url to use to load external dependencies like texture
  69301. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  69302. * @returns the parsed GPU particle system
  69303. */
  69304. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  69305. }
  69306. }
  69307. declare module BABYLON {
  69308. /**
  69309. * Represents a set of particle systems working together to create a specific effect
  69310. */
  69311. export class ParticleSystemSet implements IDisposable {
  69312. /**
  69313. * Gets or sets base Assets URL
  69314. */
  69315. static BaseAssetsUrl: string;
  69316. private _emitterCreationOptions;
  69317. private _emitterNode;
  69318. /**
  69319. * Gets the particle system list
  69320. */
  69321. systems: IParticleSystem[];
  69322. /**
  69323. * Gets the emitter node used with this set
  69324. */
  69325. get emitterNode(): Nullable<TransformNode>;
  69326. /**
  69327. * Creates a new emitter mesh as a sphere
  69328. * @param options defines the options used to create the sphere
  69329. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  69330. * @param scene defines the hosting scene
  69331. */
  69332. setEmitterAsSphere(options: {
  69333. diameter: number;
  69334. segments: number;
  69335. color: Color3;
  69336. }, renderingGroupId: number, scene: Scene): void;
  69337. /**
  69338. * Starts all particle systems of the set
  69339. * @param emitter defines an optional mesh to use as emitter for the particle systems
  69340. */
  69341. start(emitter?: AbstractMesh): void;
  69342. /**
  69343. * Release all associated resources
  69344. */
  69345. dispose(): void;
  69346. /**
  69347. * Serialize the set into a JSON compatible object
  69348. * @param serializeTexture defines if the texture must be serialized as well
  69349. * @returns a JSON compatible representation of the set
  69350. */
  69351. serialize(serializeTexture?: boolean): any;
  69352. /**
  69353. * Parse a new ParticleSystemSet from a serialized source
  69354. * @param data defines a JSON compatible representation of the set
  69355. * @param scene defines the hosting scene
  69356. * @param gpu defines if we want GPU particles or CPU particles
  69357. * @returns a new ParticleSystemSet
  69358. */
  69359. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  69360. }
  69361. }
  69362. declare module BABYLON {
  69363. /**
  69364. * This class is made for on one-liner static method to help creating particle system set.
  69365. */
  69366. export class ParticleHelper {
  69367. /**
  69368. * Gets or sets base Assets URL
  69369. */
  69370. static BaseAssetsUrl: string;
  69371. /** Define the Url to load snippets */
  69372. static SnippetUrl: string;
  69373. /**
  69374. * Create a default particle system that you can tweak
  69375. * @param emitter defines the emitter to use
  69376. * @param capacity defines the system capacity (default is 500 particles)
  69377. * @param scene defines the hosting scene
  69378. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  69379. * @returns the new Particle system
  69380. */
  69381. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  69382. /**
  69383. * This is the main static method (one-liner) of this helper to create different particle systems
  69384. * @param type This string represents the type to the particle system to create
  69385. * @param scene The scene where the particle system should live
  69386. * @param gpu If the system will use gpu
  69387. * @returns the ParticleSystemSet created
  69388. */
  69389. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  69390. /**
  69391. * Static function used to export a particle system to a ParticleSystemSet variable.
  69392. * Please note that the emitter shape is not exported
  69393. * @param systems defines the particle systems to export
  69394. * @returns the created particle system set
  69395. */
  69396. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  69397. /**
  69398. * Creates a particle system from a snippet saved in a remote file
  69399. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  69400. * @param url defines the url to load from
  69401. * @param scene defines the hosting scene
  69402. * @param gpu If the system will use gpu
  69403. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69404. * @returns a promise that will resolve to the new particle system
  69405. */
  69406. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69407. /**
  69408. * Creates a particle system from a snippet saved by the particle system editor
  69409. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  69410. * @param scene defines the hosting scene
  69411. * @param gpu If the system will use gpu
  69412. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69413. * @returns a promise that will resolve to the new particle system
  69414. */
  69415. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69416. }
  69417. }
  69418. declare module BABYLON {
  69419. interface Engine {
  69420. /**
  69421. * Create an effect to use with particle systems.
  69422. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  69423. * the particle system for which you want to create a custom effect in the last parameter
  69424. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  69425. * @param uniformsNames defines a list of attribute names
  69426. * @param samplers defines an array of string used to represent textures
  69427. * @param defines defines the string containing the defines to use to compile the shaders
  69428. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  69429. * @param onCompiled defines a function to call when the effect creation is successful
  69430. * @param onError defines a function to call when the effect creation has failed
  69431. * @param particleSystem the particle system you want to create the effect for
  69432. * @returns the new Effect
  69433. */
  69434. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  69435. }
  69436. interface Mesh {
  69437. /**
  69438. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  69439. * @returns an array of IParticleSystem
  69440. */
  69441. getEmittedParticleSystems(): IParticleSystem[];
  69442. /**
  69443. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  69444. * @returns an array of IParticleSystem
  69445. */
  69446. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  69447. }
  69448. }
  69449. declare module BABYLON {
  69450. /** Defines the 4 color options */
  69451. export enum PointColor {
  69452. /** color value */
  69453. Color = 2,
  69454. /** uv value */
  69455. UV = 1,
  69456. /** random value */
  69457. Random = 0,
  69458. /** stated value */
  69459. Stated = 3
  69460. }
  69461. /**
  69462. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  69463. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  69464. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  69465. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  69466. *
  69467. * Full documentation here : TO BE ENTERED
  69468. */
  69469. export class PointsCloudSystem implements IDisposable {
  69470. /**
  69471. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  69472. * Example : var p = SPS.particles[i];
  69473. */
  69474. particles: CloudPoint[];
  69475. /**
  69476. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  69477. */
  69478. nbParticles: number;
  69479. /**
  69480. * This a counter for your own usage. It's not set by any SPS functions.
  69481. */
  69482. counter: number;
  69483. /**
  69484. * The PCS name. This name is also given to the underlying mesh.
  69485. */
  69486. name: string;
  69487. /**
  69488. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  69489. */
  69490. mesh: Mesh;
  69491. /**
  69492. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  69493. * Please read :
  69494. */
  69495. vars: any;
  69496. /**
  69497. * @hidden
  69498. */
  69499. _size: number;
  69500. private _scene;
  69501. private _promises;
  69502. private _positions;
  69503. private _indices;
  69504. private _normals;
  69505. private _colors;
  69506. private _uvs;
  69507. private _indices32;
  69508. private _positions32;
  69509. private _colors32;
  69510. private _uvs32;
  69511. private _updatable;
  69512. private _isVisibilityBoxLocked;
  69513. private _alwaysVisible;
  69514. private _groups;
  69515. private _groupCounter;
  69516. private _computeParticleColor;
  69517. private _computeParticleTexture;
  69518. private _computeParticleRotation;
  69519. private _computeBoundingBox;
  69520. private _isReady;
  69521. /**
  69522. * Creates a PCS (Points Cloud System) object
  69523. * @param name (String) is the PCS name, this will be the underlying mesh name
  69524. * @param pointSize (number) is the size for each point
  69525. * @param scene (Scene) is the scene in which the PCS is added
  69526. * @param options defines the options of the PCS e.g.
  69527. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  69528. */
  69529. constructor(name: string, pointSize: number, scene: Scene, options?: {
  69530. updatable?: boolean;
  69531. });
  69532. /**
  69533. * Builds the PCS underlying mesh. Returns a standard Mesh.
  69534. * If no points were added to the PCS, the returned mesh is just a single point.
  69535. * @returns a promise for the created mesh
  69536. */
  69537. buildMeshAsync(): Promise<Mesh>;
  69538. /**
  69539. * @hidden
  69540. */
  69541. private _buildMesh;
  69542. private _addParticle;
  69543. private _randomUnitVector;
  69544. private _getColorIndicesForCoord;
  69545. private _setPointsColorOrUV;
  69546. private _colorFromTexture;
  69547. private _calculateDensity;
  69548. /**
  69549. * Adds points to the PCS in random positions within a unit sphere
  69550. * @param nb (positive integer) the number of particles to be created from this model
  69551. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  69552. * @returns the number of groups in the system
  69553. */
  69554. addPoints(nb: number, pointFunction?: any): number;
  69555. /**
  69556. * Adds points to the PCS from the surface of the model shape
  69557. * @param mesh is any Mesh object that will be used as a surface model for the points
  69558. * @param nb (positive integer) the number of particles to be created from this model
  69559. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69560. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69561. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69562. * @returns the number of groups in the system
  69563. */
  69564. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69565. /**
  69566. * Adds points to the PCS inside the model shape
  69567. * @param mesh is any Mesh object that will be used as a surface model for the points
  69568. * @param nb (positive integer) the number of particles to be created from this model
  69569. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69570. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69571. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69572. * @returns the number of groups in the system
  69573. */
  69574. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69575. /**
  69576. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  69577. * This method calls `updateParticle()` for each particle of the SPS.
  69578. * For an animated SPS, it is usually called within the render loop.
  69579. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  69580. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  69581. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  69582. * @returns the PCS.
  69583. */
  69584. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  69585. /**
  69586. * Disposes the PCS.
  69587. */
  69588. dispose(): void;
  69589. /**
  69590. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  69591. * doc :
  69592. * @returns the PCS.
  69593. */
  69594. refreshVisibleSize(): PointsCloudSystem;
  69595. /**
  69596. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  69597. * @param size the size (float) of the visibility box
  69598. * note : this doesn't lock the PCS mesh bounding box.
  69599. * doc :
  69600. */
  69601. setVisibilityBox(size: number): void;
  69602. /**
  69603. * Gets whether the PCS is always visible or not
  69604. * doc :
  69605. */
  69606. get isAlwaysVisible(): boolean;
  69607. /**
  69608. * Sets the PCS as always visible or not
  69609. * doc :
  69610. */
  69611. set isAlwaysVisible(val: boolean);
  69612. /**
  69613. * Tells to `setParticles()` to compute the particle rotations or not
  69614. * Default value : false. The PCS is faster when it's set to false
  69615. * Note : particle rotations are only applied to parent particles
  69616. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  69617. */
  69618. set computeParticleRotation(val: boolean);
  69619. /**
  69620. * Tells to `setParticles()` to compute the particle colors or not.
  69621. * Default value : true. The PCS is faster when it's set to false.
  69622. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69623. */
  69624. set computeParticleColor(val: boolean);
  69625. set computeParticleTexture(val: boolean);
  69626. /**
  69627. * Gets if `setParticles()` computes the particle colors or not.
  69628. * Default value : false. The PCS is faster when it's set to false.
  69629. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69630. */
  69631. get computeParticleColor(): boolean;
  69632. /**
  69633. * Gets if `setParticles()` computes the particle textures or not.
  69634. * Default value : false. The PCS is faster when it's set to false.
  69635. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  69636. */
  69637. get computeParticleTexture(): boolean;
  69638. /**
  69639. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  69640. */
  69641. set computeBoundingBox(val: boolean);
  69642. /**
  69643. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  69644. */
  69645. get computeBoundingBox(): boolean;
  69646. /**
  69647. * This function does nothing. It may be overwritten to set all the particle first values.
  69648. * The PCS doesn't call this function, you may have to call it by your own.
  69649. * doc :
  69650. */
  69651. initParticles(): void;
  69652. /**
  69653. * This function does nothing. It may be overwritten to recycle a particle
  69654. * The PCS doesn't call this function, you can to call it
  69655. * doc :
  69656. * @param particle The particle to recycle
  69657. * @returns the recycled particle
  69658. */
  69659. recycleParticle(particle: CloudPoint): CloudPoint;
  69660. /**
  69661. * Updates a particle : this function should be overwritten by the user.
  69662. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  69663. * doc :
  69664. * @example : just set a particle position or velocity and recycle conditions
  69665. * @param particle The particle to update
  69666. * @returns the updated particle
  69667. */
  69668. updateParticle(particle: CloudPoint): CloudPoint;
  69669. /**
  69670. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  69671. * This does nothing and may be overwritten by the user.
  69672. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69673. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69674. * @param update the boolean update value actually passed to setParticles()
  69675. */
  69676. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69677. /**
  69678. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  69679. * This will be passed three parameters.
  69680. * This does nothing and may be overwritten by the user.
  69681. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69682. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69683. * @param update the boolean update value actually passed to setParticles()
  69684. */
  69685. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69686. }
  69687. }
  69688. declare module BABYLON {
  69689. /**
  69690. * Represents one particle of a points cloud system.
  69691. */
  69692. export class CloudPoint {
  69693. /**
  69694. * particle global index
  69695. */
  69696. idx: number;
  69697. /**
  69698. * The color of the particle
  69699. */
  69700. color: Nullable<Color4>;
  69701. /**
  69702. * The world space position of the particle.
  69703. */
  69704. position: Vector3;
  69705. /**
  69706. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  69707. */
  69708. rotation: Vector3;
  69709. /**
  69710. * The world space rotation quaternion of the particle.
  69711. */
  69712. rotationQuaternion: Nullable<Quaternion>;
  69713. /**
  69714. * The uv of the particle.
  69715. */
  69716. uv: Nullable<Vector2>;
  69717. /**
  69718. * The current speed of the particle.
  69719. */
  69720. velocity: Vector3;
  69721. /**
  69722. * The pivot point in the particle local space.
  69723. */
  69724. pivot: Vector3;
  69725. /**
  69726. * Must the particle be translated from its pivot point in its local space ?
  69727. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  69728. * Default : false
  69729. */
  69730. translateFromPivot: boolean;
  69731. /**
  69732. * Index of this particle in the global "positions" array (Internal use)
  69733. * @hidden
  69734. */
  69735. _pos: number;
  69736. /**
  69737. * @hidden Index of this particle in the global "indices" array (Internal use)
  69738. */
  69739. _ind: number;
  69740. /**
  69741. * Group this particle belongs to
  69742. */
  69743. _group: PointsGroup;
  69744. /**
  69745. * Group id of this particle
  69746. */
  69747. groupId: number;
  69748. /**
  69749. * Index of the particle in its group id (Internal use)
  69750. */
  69751. idxInGroup: number;
  69752. /**
  69753. * @hidden Particle BoundingInfo object (Internal use)
  69754. */
  69755. _boundingInfo: BoundingInfo;
  69756. /**
  69757. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  69758. */
  69759. _pcs: PointsCloudSystem;
  69760. /**
  69761. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  69762. */
  69763. _stillInvisible: boolean;
  69764. /**
  69765. * @hidden Last computed particle rotation matrix
  69766. */
  69767. _rotationMatrix: number[];
  69768. /**
  69769. * Parent particle Id, if any.
  69770. * Default null.
  69771. */
  69772. parentId: Nullable<number>;
  69773. /**
  69774. * @hidden Internal global position in the PCS.
  69775. */
  69776. _globalPosition: Vector3;
  69777. /**
  69778. * Creates a Point Cloud object.
  69779. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  69780. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  69781. * @param group (PointsGroup) is the group the particle belongs to
  69782. * @param groupId (integer) is the group identifier in the PCS.
  69783. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  69784. * @param pcs defines the PCS it is associated to
  69785. */
  69786. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  69787. /**
  69788. * get point size
  69789. */
  69790. get size(): Vector3;
  69791. /**
  69792. * Set point size
  69793. */
  69794. set size(scale: Vector3);
  69795. /**
  69796. * Legacy support, changed quaternion to rotationQuaternion
  69797. */
  69798. get quaternion(): Nullable<Quaternion>;
  69799. /**
  69800. * Legacy support, changed quaternion to rotationQuaternion
  69801. */
  69802. set quaternion(q: Nullable<Quaternion>);
  69803. /**
  69804. * Returns a boolean. True if the particle intersects a mesh, else false
  69805. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  69806. * @param target is the object (point or mesh) what the intersection is computed against
  69807. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  69808. * @returns true if it intersects
  69809. */
  69810. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  69811. /**
  69812. * get the rotation matrix of the particle
  69813. * @hidden
  69814. */
  69815. getRotationMatrix(m: Matrix): void;
  69816. }
  69817. /**
  69818. * Represents a group of points in a points cloud system
  69819. * * PCS internal tool, don't use it manually.
  69820. */
  69821. export class PointsGroup {
  69822. /**
  69823. * The group id
  69824. * @hidden
  69825. */
  69826. groupID: number;
  69827. /**
  69828. * image data for group (internal use)
  69829. * @hidden
  69830. */
  69831. _groupImageData: Nullable<ArrayBufferView>;
  69832. /**
  69833. * Image Width (internal use)
  69834. * @hidden
  69835. */
  69836. _groupImgWidth: number;
  69837. /**
  69838. * Image Height (internal use)
  69839. * @hidden
  69840. */
  69841. _groupImgHeight: number;
  69842. /**
  69843. * Custom position function (internal use)
  69844. * @hidden
  69845. */
  69846. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  69847. /**
  69848. * density per facet for surface points
  69849. * @hidden
  69850. */
  69851. _groupDensity: number[];
  69852. /**
  69853. * Only when points are colored by texture carries pointer to texture list array
  69854. * @hidden
  69855. */
  69856. _textureNb: number;
  69857. /**
  69858. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  69859. * PCS internal tool, don't use it manually.
  69860. * @hidden
  69861. */
  69862. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  69863. }
  69864. }
  69865. declare module BABYLON {
  69866. interface Scene {
  69867. /** @hidden (Backing field) */
  69868. _physicsEngine: Nullable<IPhysicsEngine>;
  69869. /** @hidden */
  69870. _physicsTimeAccumulator: number;
  69871. /**
  69872. * Gets the current physics engine
  69873. * @returns a IPhysicsEngine or null if none attached
  69874. */
  69875. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  69876. /**
  69877. * Enables physics to the current scene
  69878. * @param gravity defines the scene's gravity for the physics engine
  69879. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  69880. * @return a boolean indicating if the physics engine was initialized
  69881. */
  69882. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  69883. /**
  69884. * Disables and disposes the physics engine associated with the scene
  69885. */
  69886. disablePhysicsEngine(): void;
  69887. /**
  69888. * Gets a boolean indicating if there is an active physics engine
  69889. * @returns a boolean indicating if there is an active physics engine
  69890. */
  69891. isPhysicsEnabled(): boolean;
  69892. /**
  69893. * Deletes a physics compound impostor
  69894. * @param compound defines the compound to delete
  69895. */
  69896. deleteCompoundImpostor(compound: any): void;
  69897. /**
  69898. * An event triggered when physic simulation is about to be run
  69899. */
  69900. onBeforePhysicsObservable: Observable<Scene>;
  69901. /**
  69902. * An event triggered when physic simulation has been done
  69903. */
  69904. onAfterPhysicsObservable: Observable<Scene>;
  69905. }
  69906. interface AbstractMesh {
  69907. /** @hidden */
  69908. _physicsImpostor: Nullable<PhysicsImpostor>;
  69909. /**
  69910. * Gets or sets impostor used for physic simulation
  69911. * @see https://doc.babylonjs.com/features/physics_engine
  69912. */
  69913. physicsImpostor: Nullable<PhysicsImpostor>;
  69914. /**
  69915. * Gets the current physics impostor
  69916. * @see https://doc.babylonjs.com/features/physics_engine
  69917. * @returns a physics impostor or null
  69918. */
  69919. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  69920. /** Apply a physic impulse to the mesh
  69921. * @param force defines the force to apply
  69922. * @param contactPoint defines where to apply the force
  69923. * @returns the current mesh
  69924. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  69925. */
  69926. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  69927. /**
  69928. * Creates a physic joint between two meshes
  69929. * @param otherMesh defines the other mesh to use
  69930. * @param pivot1 defines the pivot to use on this mesh
  69931. * @param pivot2 defines the pivot to use on the other mesh
  69932. * @param options defines additional options (can be plugin dependent)
  69933. * @returns the current mesh
  69934. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  69935. */
  69936. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  69937. /** @hidden */
  69938. _disposePhysicsObserver: Nullable<Observer<Node>>;
  69939. }
  69940. /**
  69941. * Defines the physics engine scene component responsible to manage a physics engine
  69942. */
  69943. export class PhysicsEngineSceneComponent implements ISceneComponent {
  69944. /**
  69945. * The component name helpful to identify the component in the list of scene components.
  69946. */
  69947. readonly name: string;
  69948. /**
  69949. * The scene the component belongs to.
  69950. */
  69951. scene: Scene;
  69952. /**
  69953. * Creates a new instance of the component for the given scene
  69954. * @param scene Defines the scene to register the component in
  69955. */
  69956. constructor(scene: Scene);
  69957. /**
  69958. * Registers the component in a given scene
  69959. */
  69960. register(): void;
  69961. /**
  69962. * Rebuilds the elements related to this component in case of
  69963. * context lost for instance.
  69964. */
  69965. rebuild(): void;
  69966. /**
  69967. * Disposes the component and the associated ressources
  69968. */
  69969. dispose(): void;
  69970. }
  69971. }
  69972. declare module BABYLON {
  69973. /**
  69974. * A helper for physics simulations
  69975. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69976. */
  69977. export class PhysicsHelper {
  69978. private _scene;
  69979. private _physicsEngine;
  69980. /**
  69981. * Initializes the Physics helper
  69982. * @param scene Babylon.js scene
  69983. */
  69984. constructor(scene: Scene);
  69985. /**
  69986. * Applies a radial explosion impulse
  69987. * @param origin the origin of the explosion
  69988. * @param radiusOrEventOptions the radius or the options of radial explosion
  69989. * @param strength the explosion strength
  69990. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69991. * @returns A physics radial explosion event, or null
  69992. */
  69993. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69994. /**
  69995. * Applies a radial explosion force
  69996. * @param origin the origin of the explosion
  69997. * @param radiusOrEventOptions the radius or the options of radial explosion
  69998. * @param strength the explosion strength
  69999. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70000. * @returns A physics radial explosion event, or null
  70001. */
  70002. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  70003. /**
  70004. * Creates a gravitational field
  70005. * @param origin the origin of the explosion
  70006. * @param radiusOrEventOptions the radius or the options of radial explosion
  70007. * @param strength the explosion strength
  70008. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70009. * @returns A physics gravitational field event, or null
  70010. */
  70011. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  70012. /**
  70013. * Creates a physics updraft event
  70014. * @param origin the origin of the updraft
  70015. * @param radiusOrEventOptions the radius or the options of the updraft
  70016. * @param strength the strength of the updraft
  70017. * @param height the height of the updraft
  70018. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  70019. * @returns A physics updraft event, or null
  70020. */
  70021. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  70022. /**
  70023. * Creates a physics vortex event
  70024. * @param origin the of the vortex
  70025. * @param radiusOrEventOptions the radius or the options of the vortex
  70026. * @param strength the strength of the vortex
  70027. * @param height the height of the vortex
  70028. * @returns a Physics vortex event, or null
  70029. * A physics vortex event or null
  70030. */
  70031. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  70032. }
  70033. /**
  70034. * Represents a physics radial explosion event
  70035. */
  70036. class PhysicsRadialExplosionEvent {
  70037. private _scene;
  70038. private _options;
  70039. private _sphere;
  70040. private _dataFetched;
  70041. /**
  70042. * Initializes a radial explosioin event
  70043. * @param _scene BabylonJS scene
  70044. * @param _options The options for the vortex event
  70045. */
  70046. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  70047. /**
  70048. * Returns the data related to the radial explosion event (sphere).
  70049. * @returns The radial explosion event data
  70050. */
  70051. getData(): PhysicsRadialExplosionEventData;
  70052. /**
  70053. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  70054. * @param impostor A physics imposter
  70055. * @param origin the origin of the explosion
  70056. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  70057. */
  70058. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  70059. /**
  70060. * Triggers affecterd impostors callbacks
  70061. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  70062. */
  70063. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  70064. /**
  70065. * Disposes the sphere.
  70066. * @param force Specifies if the sphere should be disposed by force
  70067. */
  70068. dispose(force?: boolean): void;
  70069. /*** Helpers ***/
  70070. private _prepareSphere;
  70071. private _intersectsWithSphere;
  70072. }
  70073. /**
  70074. * Represents a gravitational field event
  70075. */
  70076. class PhysicsGravitationalFieldEvent {
  70077. private _physicsHelper;
  70078. private _scene;
  70079. private _origin;
  70080. private _options;
  70081. private _tickCallback;
  70082. private _sphere;
  70083. private _dataFetched;
  70084. /**
  70085. * Initializes the physics gravitational field event
  70086. * @param _physicsHelper A physics helper
  70087. * @param _scene BabylonJS scene
  70088. * @param _origin The origin position of the gravitational field event
  70089. * @param _options The options for the vortex event
  70090. */
  70091. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  70092. /**
  70093. * Returns the data related to the gravitational field event (sphere).
  70094. * @returns A gravitational field event
  70095. */
  70096. getData(): PhysicsGravitationalFieldEventData;
  70097. /**
  70098. * Enables the gravitational field.
  70099. */
  70100. enable(): void;
  70101. /**
  70102. * Disables the gravitational field.
  70103. */
  70104. disable(): void;
  70105. /**
  70106. * Disposes the sphere.
  70107. * @param force The force to dispose from the gravitational field event
  70108. */
  70109. dispose(force?: boolean): void;
  70110. private _tick;
  70111. }
  70112. /**
  70113. * Represents a physics updraft event
  70114. */
  70115. class PhysicsUpdraftEvent {
  70116. private _scene;
  70117. private _origin;
  70118. private _options;
  70119. private _physicsEngine;
  70120. private _originTop;
  70121. private _originDirection;
  70122. private _tickCallback;
  70123. private _cylinder;
  70124. private _cylinderPosition;
  70125. private _dataFetched;
  70126. /**
  70127. * Initializes the physics updraft event
  70128. * @param _scene BabylonJS scene
  70129. * @param _origin The origin position of the updraft
  70130. * @param _options The options for the updraft event
  70131. */
  70132. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  70133. /**
  70134. * Returns the data related to the updraft event (cylinder).
  70135. * @returns A physics updraft event
  70136. */
  70137. getData(): PhysicsUpdraftEventData;
  70138. /**
  70139. * Enables the updraft.
  70140. */
  70141. enable(): void;
  70142. /**
  70143. * Disables the updraft.
  70144. */
  70145. disable(): void;
  70146. /**
  70147. * Disposes the cylinder.
  70148. * @param force Specifies if the updraft should be disposed by force
  70149. */
  70150. dispose(force?: boolean): void;
  70151. private getImpostorHitData;
  70152. private _tick;
  70153. /*** Helpers ***/
  70154. private _prepareCylinder;
  70155. private _intersectsWithCylinder;
  70156. }
  70157. /**
  70158. * Represents a physics vortex event
  70159. */
  70160. class PhysicsVortexEvent {
  70161. private _scene;
  70162. private _origin;
  70163. private _options;
  70164. private _physicsEngine;
  70165. private _originTop;
  70166. private _tickCallback;
  70167. private _cylinder;
  70168. private _cylinderPosition;
  70169. private _dataFetched;
  70170. /**
  70171. * Initializes the physics vortex event
  70172. * @param _scene The BabylonJS scene
  70173. * @param _origin The origin position of the vortex
  70174. * @param _options The options for the vortex event
  70175. */
  70176. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  70177. /**
  70178. * Returns the data related to the vortex event (cylinder).
  70179. * @returns The physics vortex event data
  70180. */
  70181. getData(): PhysicsVortexEventData;
  70182. /**
  70183. * Enables the vortex.
  70184. */
  70185. enable(): void;
  70186. /**
  70187. * Disables the cortex.
  70188. */
  70189. disable(): void;
  70190. /**
  70191. * Disposes the sphere.
  70192. * @param force
  70193. */
  70194. dispose(force?: boolean): void;
  70195. private getImpostorHitData;
  70196. private _tick;
  70197. /*** Helpers ***/
  70198. private _prepareCylinder;
  70199. private _intersectsWithCylinder;
  70200. }
  70201. /**
  70202. * Options fot the radial explosion event
  70203. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70204. */
  70205. export class PhysicsRadialExplosionEventOptions {
  70206. /**
  70207. * The radius of the sphere for the radial explosion.
  70208. */
  70209. radius: number;
  70210. /**
  70211. * The strenth of the explosion.
  70212. */
  70213. strength: number;
  70214. /**
  70215. * The strenght of the force in correspondence to the distance of the affected object
  70216. */
  70217. falloff: PhysicsRadialImpulseFalloff;
  70218. /**
  70219. * Sphere options for the radial explosion.
  70220. */
  70221. sphere: {
  70222. segments: number;
  70223. diameter: number;
  70224. };
  70225. /**
  70226. * Sphere options for the radial explosion.
  70227. */
  70228. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  70229. }
  70230. /**
  70231. * Options fot the updraft event
  70232. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70233. */
  70234. export class PhysicsUpdraftEventOptions {
  70235. /**
  70236. * The radius of the cylinder for the vortex
  70237. */
  70238. radius: number;
  70239. /**
  70240. * The strenth of the updraft.
  70241. */
  70242. strength: number;
  70243. /**
  70244. * The height of the cylinder for the updraft.
  70245. */
  70246. height: number;
  70247. /**
  70248. * The mode for the the updraft.
  70249. */
  70250. updraftMode: PhysicsUpdraftMode;
  70251. }
  70252. /**
  70253. * Options fot the vortex event
  70254. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70255. */
  70256. export class PhysicsVortexEventOptions {
  70257. /**
  70258. * The radius of the cylinder for the vortex
  70259. */
  70260. radius: number;
  70261. /**
  70262. * The strenth of the vortex.
  70263. */
  70264. strength: number;
  70265. /**
  70266. * The height of the cylinder for the vortex.
  70267. */
  70268. height: number;
  70269. /**
  70270. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  70271. */
  70272. centripetalForceThreshold: number;
  70273. /**
  70274. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  70275. */
  70276. centripetalForceMultiplier: number;
  70277. /**
  70278. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  70279. */
  70280. centrifugalForceMultiplier: number;
  70281. /**
  70282. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  70283. */
  70284. updraftForceMultiplier: number;
  70285. }
  70286. /**
  70287. * The strenght of the force in correspondence to the distance of the affected object
  70288. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70289. */
  70290. export enum PhysicsRadialImpulseFalloff {
  70291. /** Defines that impulse is constant in strength across it's whole radius */
  70292. Constant = 0,
  70293. /** Defines that impulse gets weaker if it's further from the origin */
  70294. Linear = 1
  70295. }
  70296. /**
  70297. * The strength of the force in correspondence to the distance of the affected object
  70298. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70299. */
  70300. export enum PhysicsUpdraftMode {
  70301. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  70302. Center = 0,
  70303. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  70304. Perpendicular = 1
  70305. }
  70306. /**
  70307. * Interface for a physics hit data
  70308. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70309. */
  70310. export interface PhysicsHitData {
  70311. /**
  70312. * The force applied at the contact point
  70313. */
  70314. force: Vector3;
  70315. /**
  70316. * The contact point
  70317. */
  70318. contactPoint: Vector3;
  70319. /**
  70320. * The distance from the origin to the contact point
  70321. */
  70322. distanceFromOrigin: number;
  70323. }
  70324. /**
  70325. * Interface for radial explosion event data
  70326. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70327. */
  70328. export interface PhysicsRadialExplosionEventData {
  70329. /**
  70330. * A sphere used for the radial explosion event
  70331. */
  70332. sphere: Mesh;
  70333. }
  70334. /**
  70335. * Interface for gravitational field event data
  70336. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70337. */
  70338. export interface PhysicsGravitationalFieldEventData {
  70339. /**
  70340. * A sphere mesh used for the gravitational field event
  70341. */
  70342. sphere: Mesh;
  70343. }
  70344. /**
  70345. * Interface for updraft event data
  70346. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70347. */
  70348. export interface PhysicsUpdraftEventData {
  70349. /**
  70350. * A cylinder used for the updraft event
  70351. */
  70352. cylinder: Mesh;
  70353. }
  70354. /**
  70355. * Interface for vortex event data
  70356. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70357. */
  70358. export interface PhysicsVortexEventData {
  70359. /**
  70360. * A cylinder used for the vortex event
  70361. */
  70362. cylinder: Mesh;
  70363. }
  70364. /**
  70365. * Interface for an affected physics impostor
  70366. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70367. */
  70368. export interface PhysicsAffectedImpostorWithData {
  70369. /**
  70370. * The impostor affected by the effect
  70371. */
  70372. impostor: PhysicsImpostor;
  70373. /**
  70374. * The data about the hit/horce from the explosion
  70375. */
  70376. hitData: PhysicsHitData;
  70377. }
  70378. }
  70379. declare module BABYLON {
  70380. /** @hidden */
  70381. export var blackAndWhitePixelShader: {
  70382. name: string;
  70383. shader: string;
  70384. };
  70385. }
  70386. declare module BABYLON {
  70387. /**
  70388. * Post process used to render in black and white
  70389. */
  70390. export class BlackAndWhitePostProcess extends PostProcess {
  70391. /**
  70392. * Linear about to convert he result to black and white (default: 1)
  70393. */
  70394. degree: number;
  70395. /**
  70396. * Gets a string identifying the name of the class
  70397. * @returns "BlackAndWhitePostProcess" string
  70398. */
  70399. getClassName(): string;
  70400. /**
  70401. * Creates a black and white post process
  70402. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  70403. * @param name The name of the effect.
  70404. * @param options The required width/height ratio to downsize to before computing the render pass.
  70405. * @param camera The camera to apply the render pass to.
  70406. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70407. * @param engine The engine which the post process will be applied. (default: current engine)
  70408. * @param reusable If the post process can be reused on the same frame. (default: false)
  70409. */
  70410. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70411. /** @hidden */
  70412. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  70413. }
  70414. }
  70415. declare module BABYLON {
  70416. /**
  70417. * This represents a set of one or more post processes in Babylon.
  70418. * A post process can be used to apply a shader to a texture after it is rendered.
  70419. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70420. */
  70421. export class PostProcessRenderEffect {
  70422. private _postProcesses;
  70423. private _getPostProcesses;
  70424. private _singleInstance;
  70425. private _cameras;
  70426. private _indicesForCamera;
  70427. /**
  70428. * Name of the effect
  70429. * @hidden
  70430. */
  70431. _name: string;
  70432. /**
  70433. * Instantiates a post process render effect.
  70434. * A post process can be used to apply a shader to a texture after it is rendered.
  70435. * @param engine The engine the effect is tied to
  70436. * @param name The name of the effect
  70437. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  70438. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  70439. */
  70440. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  70441. /**
  70442. * Checks if all the post processes in the effect are supported.
  70443. */
  70444. get isSupported(): boolean;
  70445. /**
  70446. * Updates the current state of the effect
  70447. * @hidden
  70448. */
  70449. _update(): void;
  70450. /**
  70451. * Attaches the effect on cameras
  70452. * @param cameras The camera to attach to.
  70453. * @hidden
  70454. */
  70455. _attachCameras(cameras: Camera): void;
  70456. /**
  70457. * Attaches the effect on cameras
  70458. * @param cameras The camera to attach to.
  70459. * @hidden
  70460. */
  70461. _attachCameras(cameras: Camera[]): void;
  70462. /**
  70463. * Detaches the effect on cameras
  70464. * @param cameras The camera to detatch from.
  70465. * @hidden
  70466. */
  70467. _detachCameras(cameras: Camera): void;
  70468. /**
  70469. * Detatches the effect on cameras
  70470. * @param cameras The camera to detatch from.
  70471. * @hidden
  70472. */
  70473. _detachCameras(cameras: Camera[]): void;
  70474. /**
  70475. * Enables the effect on given cameras
  70476. * @param cameras The camera to enable.
  70477. * @hidden
  70478. */
  70479. _enable(cameras: Camera): void;
  70480. /**
  70481. * Enables the effect on given cameras
  70482. * @param cameras The camera to enable.
  70483. * @hidden
  70484. */
  70485. _enable(cameras: Nullable<Camera[]>): void;
  70486. /**
  70487. * Disables the effect on the given cameras
  70488. * @param cameras The camera to disable.
  70489. * @hidden
  70490. */
  70491. _disable(cameras: Camera): void;
  70492. /**
  70493. * Disables the effect on the given cameras
  70494. * @param cameras The camera to disable.
  70495. * @hidden
  70496. */
  70497. _disable(cameras: Nullable<Camera[]>): void;
  70498. /**
  70499. * Gets a list of the post processes contained in the effect.
  70500. * @param camera The camera to get the post processes on.
  70501. * @returns The list of the post processes in the effect.
  70502. */
  70503. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  70504. }
  70505. }
  70506. declare module BABYLON {
  70507. /** @hidden */
  70508. export var extractHighlightsPixelShader: {
  70509. name: string;
  70510. shader: string;
  70511. };
  70512. }
  70513. declare module BABYLON {
  70514. /**
  70515. * 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.
  70516. */
  70517. export class ExtractHighlightsPostProcess extends PostProcess {
  70518. /**
  70519. * The luminance threshold, pixels below this value will be set to black.
  70520. */
  70521. threshold: number;
  70522. /** @hidden */
  70523. _exposure: number;
  70524. /**
  70525. * Post process which has the input texture to be used when performing highlight extraction
  70526. * @hidden
  70527. */
  70528. _inputPostProcess: Nullable<PostProcess>;
  70529. /**
  70530. * Gets a string identifying the name of the class
  70531. * @returns "ExtractHighlightsPostProcess" string
  70532. */
  70533. getClassName(): string;
  70534. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70535. }
  70536. }
  70537. declare module BABYLON {
  70538. /** @hidden */
  70539. export var bloomMergePixelShader: {
  70540. name: string;
  70541. shader: string;
  70542. };
  70543. }
  70544. declare module BABYLON {
  70545. /**
  70546. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70547. */
  70548. export class BloomMergePostProcess extends PostProcess {
  70549. /** Weight of the bloom to be added to the original input. */
  70550. weight: number;
  70551. /**
  70552. * Gets a string identifying the name of the class
  70553. * @returns "BloomMergePostProcess" string
  70554. */
  70555. getClassName(): string;
  70556. /**
  70557. * Creates a new instance of @see BloomMergePostProcess
  70558. * @param name The name of the effect.
  70559. * @param originalFromInput Post process which's input will be used for the merge.
  70560. * @param blurred Blurred highlights post process which's output will be used.
  70561. * @param weight Weight of the bloom to be added to the original input.
  70562. * @param options The required width/height ratio to downsize to before computing the render pass.
  70563. * @param camera The camera to apply the render pass to.
  70564. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70565. * @param engine The engine which the post process will be applied. (default: current engine)
  70566. * @param reusable If the post process can be reused on the same frame. (default: false)
  70567. * @param textureType Type of textures used when performing the post process. (default: 0)
  70568. * @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)
  70569. */
  70570. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  70571. /** Weight of the bloom to be added to the original input. */
  70572. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70573. }
  70574. }
  70575. declare module BABYLON {
  70576. /**
  70577. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  70578. */
  70579. export class BloomEffect extends PostProcessRenderEffect {
  70580. private bloomScale;
  70581. /**
  70582. * @hidden Internal
  70583. */
  70584. _effects: Array<PostProcess>;
  70585. /**
  70586. * @hidden Internal
  70587. */
  70588. _downscale: ExtractHighlightsPostProcess;
  70589. private _blurX;
  70590. private _blurY;
  70591. private _merge;
  70592. /**
  70593. * The luminance threshold to find bright areas of the image to bloom.
  70594. */
  70595. get threshold(): number;
  70596. set threshold(value: number);
  70597. /**
  70598. * The strength of the bloom.
  70599. */
  70600. get weight(): number;
  70601. set weight(value: number);
  70602. /**
  70603. * Specifies the size of the bloom blur kernel, relative to the final output size
  70604. */
  70605. get kernel(): number;
  70606. set kernel(value: number);
  70607. /**
  70608. * Creates a new instance of @see BloomEffect
  70609. * @param scene The scene the effect belongs to.
  70610. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  70611. * @param bloomKernel The size of the kernel to be used when applying the blur.
  70612. * @param bloomWeight The the strength of bloom.
  70613. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70614. * @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)
  70615. */
  70616. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  70617. /**
  70618. * Disposes each of the internal effects for a given camera.
  70619. * @param camera The camera to dispose the effect on.
  70620. */
  70621. disposeEffects(camera: Camera): void;
  70622. /**
  70623. * @hidden Internal
  70624. */
  70625. _updateEffects(): void;
  70626. /**
  70627. * Internal
  70628. * @returns if all the contained post processes are ready.
  70629. * @hidden
  70630. */
  70631. _isReady(): boolean;
  70632. }
  70633. }
  70634. declare module BABYLON {
  70635. /** @hidden */
  70636. export var chromaticAberrationPixelShader: {
  70637. name: string;
  70638. shader: string;
  70639. };
  70640. }
  70641. declare module BABYLON {
  70642. /**
  70643. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  70644. */
  70645. export class ChromaticAberrationPostProcess extends PostProcess {
  70646. /**
  70647. * The amount of seperation of rgb channels (default: 30)
  70648. */
  70649. aberrationAmount: number;
  70650. /**
  70651. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  70652. */
  70653. radialIntensity: number;
  70654. /**
  70655. * 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))
  70656. */
  70657. direction: Vector2;
  70658. /**
  70659. * 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))
  70660. */
  70661. centerPosition: Vector2;
  70662. /** The width of the screen to apply the effect on */
  70663. screenWidth: number;
  70664. /** The height of the screen to apply the effect on */
  70665. screenHeight: number;
  70666. /**
  70667. * Gets a string identifying the name of the class
  70668. * @returns "ChromaticAberrationPostProcess" string
  70669. */
  70670. getClassName(): string;
  70671. /**
  70672. * Creates a new instance ChromaticAberrationPostProcess
  70673. * @param name The name of the effect.
  70674. * @param screenWidth The width of the screen to apply the effect on.
  70675. * @param screenHeight The height of the screen to apply the effect on.
  70676. * @param options The required width/height ratio to downsize to before computing the render pass.
  70677. * @param camera The camera to apply the render pass to.
  70678. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70679. * @param engine The engine which the post process will be applied. (default: current engine)
  70680. * @param reusable If the post process can be reused on the same frame. (default: false)
  70681. * @param textureType Type of textures used when performing the post process. (default: 0)
  70682. * @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)
  70683. */
  70684. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70685. /** @hidden */
  70686. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  70687. }
  70688. }
  70689. declare module BABYLON {
  70690. /** @hidden */
  70691. export var circleOfConfusionPixelShader: {
  70692. name: string;
  70693. shader: string;
  70694. };
  70695. }
  70696. declare module BABYLON {
  70697. /**
  70698. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  70699. */
  70700. export class CircleOfConfusionPostProcess extends PostProcess {
  70701. /**
  70702. * 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.
  70703. */
  70704. lensSize: number;
  70705. /**
  70706. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70707. */
  70708. fStop: number;
  70709. /**
  70710. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70711. */
  70712. focusDistance: number;
  70713. /**
  70714. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  70715. */
  70716. focalLength: number;
  70717. /**
  70718. * Gets a string identifying the name of the class
  70719. * @returns "CircleOfConfusionPostProcess" string
  70720. */
  70721. getClassName(): string;
  70722. private _depthTexture;
  70723. /**
  70724. * Creates a new instance CircleOfConfusionPostProcess
  70725. * @param name The name of the effect.
  70726. * @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.
  70727. * @param options The required width/height ratio to downsize to before computing the render pass.
  70728. * @param camera The camera to apply the render pass to.
  70729. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70730. * @param engine The engine which the post process will be applied. (default: current engine)
  70731. * @param reusable If the post process can be reused on the same frame. (default: false)
  70732. * @param textureType Type of textures used when performing the post process. (default: 0)
  70733. * @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)
  70734. */
  70735. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70736. /**
  70737. * 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.
  70738. */
  70739. set depthTexture(value: RenderTargetTexture);
  70740. }
  70741. }
  70742. declare module BABYLON {
  70743. /** @hidden */
  70744. export var colorCorrectionPixelShader: {
  70745. name: string;
  70746. shader: string;
  70747. };
  70748. }
  70749. declare module BABYLON {
  70750. /**
  70751. *
  70752. * This post-process allows the modification of rendered colors by using
  70753. * a 'look-up table' (LUT). This effect is also called Color Grading.
  70754. *
  70755. * The object needs to be provided an url to a texture containing the color
  70756. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  70757. * Use an image editing software to tweak the LUT to match your needs.
  70758. *
  70759. * For an example of a color LUT, see here:
  70760. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  70761. * For explanations on color grading, see here:
  70762. * @see http://udn.epicgames.com/Three/ColorGrading.html
  70763. *
  70764. */
  70765. export class ColorCorrectionPostProcess extends PostProcess {
  70766. private _colorTableTexture;
  70767. /**
  70768. * Gets the color table url used to create the LUT texture
  70769. */
  70770. colorTableUrl: string;
  70771. /**
  70772. * Gets a string identifying the name of the class
  70773. * @returns "ColorCorrectionPostProcess" string
  70774. */
  70775. getClassName(): string;
  70776. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70777. /** @hidden */
  70778. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  70779. }
  70780. }
  70781. declare module BABYLON {
  70782. /** @hidden */
  70783. export var convolutionPixelShader: {
  70784. name: string;
  70785. shader: string;
  70786. };
  70787. }
  70788. declare module BABYLON {
  70789. /**
  70790. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  70791. * input texture to perform effects such as edge detection or sharpening
  70792. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70793. */
  70794. export class ConvolutionPostProcess extends PostProcess {
  70795. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  70796. kernel: number[];
  70797. /**
  70798. * Gets a string identifying the name of the class
  70799. * @returns "ConvolutionPostProcess" string
  70800. */
  70801. getClassName(): string;
  70802. /**
  70803. * Creates a new instance ConvolutionPostProcess
  70804. * @param name The name of the effect.
  70805. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  70806. * @param options The required width/height ratio to downsize to before computing the render pass.
  70807. * @param camera The camera to apply the render pass to.
  70808. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70809. * @param engine The engine which the post process will be applied. (default: current engine)
  70810. * @param reusable If the post process can be reused on the same frame. (default: false)
  70811. * @param textureType Type of textures used when performing the post process. (default: 0)
  70812. */
  70813. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70814. /** @hidden */
  70815. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  70816. /**
  70817. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70818. */
  70819. static EdgeDetect0Kernel: number[];
  70820. /**
  70821. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70822. */
  70823. static EdgeDetect1Kernel: number[];
  70824. /**
  70825. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70826. */
  70827. static EdgeDetect2Kernel: number[];
  70828. /**
  70829. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70830. */
  70831. static SharpenKernel: number[];
  70832. /**
  70833. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70834. */
  70835. static EmbossKernel: number[];
  70836. /**
  70837. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70838. */
  70839. static GaussianKernel: number[];
  70840. }
  70841. }
  70842. declare module BABYLON {
  70843. /**
  70844. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  70845. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  70846. * based on samples that have a large difference in distance than the center pixel.
  70847. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  70848. */
  70849. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  70850. /**
  70851. * The direction the blur should be applied
  70852. */
  70853. direction: Vector2;
  70854. /**
  70855. * Gets a string identifying the name of the class
  70856. * @returns "DepthOfFieldBlurPostProcess" string
  70857. */
  70858. getClassName(): string;
  70859. /**
  70860. * Creates a new instance CircleOfConfusionPostProcess
  70861. * @param name The name of the effect.
  70862. * @param scene The scene the effect belongs to.
  70863. * @param direction The direction the blur should be applied.
  70864. * @param kernel The size of the kernel used to blur.
  70865. * @param options The required width/height ratio to downsize to before computing the render pass.
  70866. * @param camera The camera to apply the render pass to.
  70867. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  70868. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  70869. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70870. * @param engine The engine which the post process will be applied. (default: current engine)
  70871. * @param reusable If the post process can be reused on the same frame. (default: false)
  70872. * @param textureType Type of textures used when performing the post process. (default: 0)
  70873. * @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)
  70874. */
  70875. 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);
  70876. }
  70877. }
  70878. declare module BABYLON {
  70879. /** @hidden */
  70880. export var depthOfFieldMergePixelShader: {
  70881. name: string;
  70882. shader: string;
  70883. };
  70884. }
  70885. declare module BABYLON {
  70886. /**
  70887. * Options to be set when merging outputs from the default pipeline.
  70888. */
  70889. export class DepthOfFieldMergePostProcessOptions {
  70890. /**
  70891. * The original image to merge on top of
  70892. */
  70893. originalFromInput: PostProcess;
  70894. /**
  70895. * Parameters to perform the merge of the depth of field effect
  70896. */
  70897. depthOfField?: {
  70898. circleOfConfusion: PostProcess;
  70899. blurSteps: Array<PostProcess>;
  70900. };
  70901. /**
  70902. * Parameters to perform the merge of bloom effect
  70903. */
  70904. bloom?: {
  70905. blurred: PostProcess;
  70906. weight: number;
  70907. };
  70908. }
  70909. /**
  70910. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70911. */
  70912. export class DepthOfFieldMergePostProcess extends PostProcess {
  70913. private blurSteps;
  70914. /**
  70915. * Gets a string identifying the name of the class
  70916. * @returns "DepthOfFieldMergePostProcess" string
  70917. */
  70918. getClassName(): string;
  70919. /**
  70920. * Creates a new instance of DepthOfFieldMergePostProcess
  70921. * @param name The name of the effect.
  70922. * @param originalFromInput Post process which's input will be used for the merge.
  70923. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  70924. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  70925. * @param options The required width/height ratio to downsize to before computing the render pass.
  70926. * @param camera The camera to apply the render pass to.
  70927. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70928. * @param engine The engine which the post process will be applied. (default: current engine)
  70929. * @param reusable If the post process can be reused on the same frame. (default: false)
  70930. * @param textureType Type of textures used when performing the post process. (default: 0)
  70931. * @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)
  70932. */
  70933. 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);
  70934. /**
  70935. * Updates the effect with the current post process compile time values and recompiles the shader.
  70936. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  70937. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  70938. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  70939. * @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
  70940. * @param onCompiled Called when the shader has been compiled.
  70941. * @param onError Called if there is an error when compiling a shader.
  70942. */
  70943. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  70944. }
  70945. }
  70946. declare module BABYLON {
  70947. /**
  70948. * Specifies the level of max blur that should be applied when using the depth of field effect
  70949. */
  70950. export enum DepthOfFieldEffectBlurLevel {
  70951. /**
  70952. * Subtle blur
  70953. */
  70954. Low = 0,
  70955. /**
  70956. * Medium blur
  70957. */
  70958. Medium = 1,
  70959. /**
  70960. * Large blur
  70961. */
  70962. High = 2
  70963. }
  70964. /**
  70965. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  70966. */
  70967. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  70968. private _circleOfConfusion;
  70969. /**
  70970. * @hidden Internal, blurs from high to low
  70971. */
  70972. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  70973. private _depthOfFieldBlurY;
  70974. private _dofMerge;
  70975. /**
  70976. * @hidden Internal post processes in depth of field effect
  70977. */
  70978. _effects: Array<PostProcess>;
  70979. /**
  70980. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  70981. */
  70982. set focalLength(value: number);
  70983. get focalLength(): number;
  70984. /**
  70985. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70986. */
  70987. set fStop(value: number);
  70988. get fStop(): number;
  70989. /**
  70990. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70991. */
  70992. set focusDistance(value: number);
  70993. get focusDistance(): number;
  70994. /**
  70995. * 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.
  70996. */
  70997. set lensSize(value: number);
  70998. get lensSize(): number;
  70999. /**
  71000. * Creates a new instance DepthOfFieldEffect
  71001. * @param scene The scene the effect belongs to.
  71002. * @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.
  71003. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  71004. * @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)
  71005. */
  71006. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  71007. /**
  71008. * Get the current class name of the current effet
  71009. * @returns "DepthOfFieldEffect"
  71010. */
  71011. getClassName(): string;
  71012. /**
  71013. * 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.
  71014. */
  71015. set depthTexture(value: RenderTargetTexture);
  71016. /**
  71017. * Disposes each of the internal effects for a given camera.
  71018. * @param camera The camera to dispose the effect on.
  71019. */
  71020. disposeEffects(camera: Camera): void;
  71021. /**
  71022. * @hidden Internal
  71023. */
  71024. _updateEffects(): void;
  71025. /**
  71026. * Internal
  71027. * @returns if all the contained post processes are ready.
  71028. * @hidden
  71029. */
  71030. _isReady(): boolean;
  71031. }
  71032. }
  71033. declare module BABYLON {
  71034. /** @hidden */
  71035. export var displayPassPixelShader: {
  71036. name: string;
  71037. shader: string;
  71038. };
  71039. }
  71040. declare module BABYLON {
  71041. /**
  71042. * DisplayPassPostProcess which produces an output the same as it's input
  71043. */
  71044. export class DisplayPassPostProcess extends PostProcess {
  71045. /**
  71046. * Gets a string identifying the name of the class
  71047. * @returns "DisplayPassPostProcess" string
  71048. */
  71049. getClassName(): string;
  71050. /**
  71051. * Creates the DisplayPassPostProcess
  71052. * @param name The name of the effect.
  71053. * @param options The required width/height ratio to downsize to before computing the render pass.
  71054. * @param camera The camera to apply the render pass to.
  71055. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71056. * @param engine The engine which the post process will be applied. (default: current engine)
  71057. * @param reusable If the post process can be reused on the same frame. (default: false)
  71058. */
  71059. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71060. /** @hidden */
  71061. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  71062. }
  71063. }
  71064. declare module BABYLON {
  71065. /** @hidden */
  71066. export var filterPixelShader: {
  71067. name: string;
  71068. shader: string;
  71069. };
  71070. }
  71071. declare module BABYLON {
  71072. /**
  71073. * Applies a kernel filter to the image
  71074. */
  71075. export class FilterPostProcess extends PostProcess {
  71076. /** The matrix to be applied to the image */
  71077. kernelMatrix: Matrix;
  71078. /**
  71079. * Gets a string identifying the name of the class
  71080. * @returns "FilterPostProcess" string
  71081. */
  71082. getClassName(): string;
  71083. /**
  71084. *
  71085. * @param name The name of the effect.
  71086. * @param kernelMatrix The matrix to be applied to the image
  71087. * @param options The required width/height ratio to downsize to before computing the render pass.
  71088. * @param camera The camera to apply the render pass to.
  71089. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71090. * @param engine The engine which the post process will be applied. (default: current engine)
  71091. * @param reusable If the post process can be reused on the same frame. (default: false)
  71092. */
  71093. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71094. /** @hidden */
  71095. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  71096. }
  71097. }
  71098. declare module BABYLON {
  71099. /** @hidden */
  71100. export var fxaaPixelShader: {
  71101. name: string;
  71102. shader: string;
  71103. };
  71104. }
  71105. declare module BABYLON {
  71106. /** @hidden */
  71107. export var fxaaVertexShader: {
  71108. name: string;
  71109. shader: string;
  71110. };
  71111. }
  71112. declare module BABYLON {
  71113. /**
  71114. * Fxaa post process
  71115. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  71116. */
  71117. export class FxaaPostProcess extends PostProcess {
  71118. /**
  71119. * Gets a string identifying the name of the class
  71120. * @returns "FxaaPostProcess" string
  71121. */
  71122. getClassName(): string;
  71123. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71124. private _getDefines;
  71125. /** @hidden */
  71126. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  71127. }
  71128. }
  71129. declare module BABYLON {
  71130. /** @hidden */
  71131. export var grainPixelShader: {
  71132. name: string;
  71133. shader: string;
  71134. };
  71135. }
  71136. declare module BABYLON {
  71137. /**
  71138. * The GrainPostProcess adds noise to the image at mid luminance levels
  71139. */
  71140. export class GrainPostProcess extends PostProcess {
  71141. /**
  71142. * The intensity of the grain added (default: 30)
  71143. */
  71144. intensity: number;
  71145. /**
  71146. * If the grain should be randomized on every frame
  71147. */
  71148. animated: boolean;
  71149. /**
  71150. * Gets a string identifying the name of the class
  71151. * @returns "GrainPostProcess" string
  71152. */
  71153. getClassName(): string;
  71154. /**
  71155. * Creates a new instance of @see GrainPostProcess
  71156. * @param name The name of the effect.
  71157. * @param options The required width/height ratio to downsize to before computing the render pass.
  71158. * @param camera The camera to apply the render pass to.
  71159. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71160. * @param engine The engine which the post process will be applied. (default: current engine)
  71161. * @param reusable If the post process can be reused on the same frame. (default: false)
  71162. * @param textureType Type of textures used when performing the post process. (default: 0)
  71163. * @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)
  71164. */
  71165. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71166. /** @hidden */
  71167. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  71168. }
  71169. }
  71170. declare module BABYLON {
  71171. /** @hidden */
  71172. export var highlightsPixelShader: {
  71173. name: string;
  71174. shader: string;
  71175. };
  71176. }
  71177. declare module BABYLON {
  71178. /**
  71179. * Extracts highlights from the image
  71180. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71181. */
  71182. export class HighlightsPostProcess extends PostProcess {
  71183. /**
  71184. * Gets a string identifying the name of the class
  71185. * @returns "HighlightsPostProcess" string
  71186. */
  71187. getClassName(): string;
  71188. /**
  71189. * Extracts highlights from the image
  71190. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71191. * @param name The name of the effect.
  71192. * @param options The required width/height ratio to downsize to before computing the render pass.
  71193. * @param camera The camera to apply the render pass to.
  71194. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71195. * @param engine The engine which the post process will be applied. (default: current engine)
  71196. * @param reusable If the post process can be reused on the same frame. (default: false)
  71197. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  71198. */
  71199. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71200. }
  71201. }
  71202. declare module BABYLON {
  71203. /**
  71204. * Contains all parameters needed for the prepass to perform
  71205. * motion blur
  71206. */
  71207. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  71208. /**
  71209. * Is motion blur enabled
  71210. */
  71211. enabled: boolean;
  71212. /**
  71213. * Name of the configuration
  71214. */
  71215. name: string;
  71216. /**
  71217. * Textures that should be present in the MRT for this effect to work
  71218. */
  71219. readonly texturesRequired: number[];
  71220. }
  71221. }
  71222. declare module BABYLON {
  71223. interface Scene {
  71224. /** @hidden (Backing field) */
  71225. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  71226. /**
  71227. * Gets or Sets the current geometry buffer associated to the scene.
  71228. */
  71229. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  71230. /**
  71231. * Enables a GeometryBufferRender and associates it with the scene
  71232. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  71233. * @returns the GeometryBufferRenderer
  71234. */
  71235. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  71236. /**
  71237. * Disables the GeometryBufferRender associated with the scene
  71238. */
  71239. disableGeometryBufferRenderer(): void;
  71240. }
  71241. /**
  71242. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  71243. * in several rendering techniques.
  71244. */
  71245. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  71246. /**
  71247. * The component name helpful to identify the component in the list of scene components.
  71248. */
  71249. readonly name: string;
  71250. /**
  71251. * The scene the component belongs to.
  71252. */
  71253. scene: Scene;
  71254. /**
  71255. * Creates a new instance of the component for the given scene
  71256. * @param scene Defines the scene to register the component in
  71257. */
  71258. constructor(scene: Scene);
  71259. /**
  71260. * Registers the component in a given scene
  71261. */
  71262. register(): void;
  71263. /**
  71264. * Rebuilds the elements related to this component in case of
  71265. * context lost for instance.
  71266. */
  71267. rebuild(): void;
  71268. /**
  71269. * Disposes the component and the associated ressources
  71270. */
  71271. dispose(): void;
  71272. private _gatherRenderTargets;
  71273. }
  71274. }
  71275. declare module BABYLON {
  71276. /** @hidden */
  71277. export var motionBlurPixelShader: {
  71278. name: string;
  71279. shader: string;
  71280. };
  71281. }
  71282. declare module BABYLON {
  71283. /**
  71284. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  71285. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  71286. * As an example, all you have to do is to create the post-process:
  71287. * var mb = new BABYLON.MotionBlurPostProcess(
  71288. * 'mb', // The name of the effect.
  71289. * scene, // The scene containing the objects to blur according to their velocity.
  71290. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  71291. * camera // The camera to apply the render pass to.
  71292. * );
  71293. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  71294. */
  71295. export class MotionBlurPostProcess extends PostProcess {
  71296. /**
  71297. * Defines how much the image is blurred by the movement. Default value is equal to 1
  71298. */
  71299. motionStrength: number;
  71300. /**
  71301. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  71302. */
  71303. get motionBlurSamples(): number;
  71304. /**
  71305. * Sets the number of iterations to be used for motion blur quality
  71306. */
  71307. set motionBlurSamples(samples: number);
  71308. private _motionBlurSamples;
  71309. /**
  71310. * Gets wether or not the motion blur post-process is in object based mode.
  71311. */
  71312. get isObjectBased(): boolean;
  71313. /**
  71314. * Sets wether or not the motion blur post-process is in object based mode.
  71315. */
  71316. set isObjectBased(value: boolean);
  71317. private _isObjectBased;
  71318. private _forceGeometryBuffer;
  71319. private _geometryBufferRenderer;
  71320. private _prePassRenderer;
  71321. private _invViewProjection;
  71322. private _previousViewProjection;
  71323. /**
  71324. * Gets a string identifying the name of the class
  71325. * @returns "MotionBlurPostProcess" string
  71326. */
  71327. getClassName(): string;
  71328. /**
  71329. * Creates a new instance MotionBlurPostProcess
  71330. * @param name The name of the effect.
  71331. * @param scene The scene containing the objects to blur according to their velocity.
  71332. * @param options The required width/height ratio to downsize to before computing the render pass.
  71333. * @param camera The camera to apply the render pass to.
  71334. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71335. * @param engine The engine which the post process will be applied. (default: current engine)
  71336. * @param reusable If the post process can be reused on the same frame. (default: false)
  71337. * @param textureType Type of textures used when performing the post process. (default: 0)
  71338. * @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: true)
  71339. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  71340. */
  71341. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  71342. /**
  71343. * Excludes the given skinned mesh from computing bones velocities.
  71344. * 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.
  71345. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  71346. */
  71347. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  71348. /**
  71349. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  71350. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  71351. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  71352. */
  71353. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  71354. /**
  71355. * Disposes the post process.
  71356. * @param camera The camera to dispose the post process on.
  71357. */
  71358. dispose(camera?: Camera): void;
  71359. /**
  71360. * Called on the mode changed (object based or screen based).
  71361. */
  71362. private _applyMode;
  71363. /**
  71364. * Called on the effect is applied when the motion blur post-process is in object based mode.
  71365. */
  71366. private _onApplyObjectBased;
  71367. /**
  71368. * Called on the effect is applied when the motion blur post-process is in screen based mode.
  71369. */
  71370. private _onApplyScreenBased;
  71371. /**
  71372. * Called on the effect must be updated (changed mode, samples count, etc.).
  71373. */
  71374. private _updateEffect;
  71375. /** @hidden */
  71376. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  71377. }
  71378. }
  71379. declare module BABYLON {
  71380. /** @hidden */
  71381. export var refractionPixelShader: {
  71382. name: string;
  71383. shader: string;
  71384. };
  71385. }
  71386. declare module BABYLON {
  71387. /**
  71388. * Post process which applies a refractin texture
  71389. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71390. */
  71391. export class RefractionPostProcess extends PostProcess {
  71392. private _refTexture;
  71393. private _ownRefractionTexture;
  71394. /** the base color of the refraction (used to taint the rendering) */
  71395. color: Color3;
  71396. /** simulated refraction depth */
  71397. depth: number;
  71398. /** the coefficient of the base color (0 to remove base color tainting) */
  71399. colorLevel: number;
  71400. /** Gets the url used to load the refraction texture */
  71401. refractionTextureUrl: string;
  71402. /**
  71403. * Gets or sets the refraction texture
  71404. * Please note that you are responsible for disposing the texture if you set it manually
  71405. */
  71406. get refractionTexture(): Texture;
  71407. set refractionTexture(value: Texture);
  71408. /**
  71409. * Gets a string identifying the name of the class
  71410. * @returns "RefractionPostProcess" string
  71411. */
  71412. getClassName(): string;
  71413. /**
  71414. * Initializes the RefractionPostProcess
  71415. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71416. * @param name The name of the effect.
  71417. * @param refractionTextureUrl Url of the refraction texture to use
  71418. * @param color the base color of the refraction (used to taint the rendering)
  71419. * @param depth simulated refraction depth
  71420. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  71421. * @param camera The camera to apply the render pass to.
  71422. * @param options The required width/height ratio to downsize to before computing the render pass.
  71423. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71424. * @param engine The engine which the post process will be applied. (default: current engine)
  71425. * @param reusable If the post process can be reused on the same frame. (default: false)
  71426. */
  71427. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71428. /**
  71429. * Disposes of the post process
  71430. * @param camera Camera to dispose post process on
  71431. */
  71432. dispose(camera: Camera): void;
  71433. /** @hidden */
  71434. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  71435. }
  71436. }
  71437. declare module BABYLON {
  71438. /** @hidden */
  71439. export var sharpenPixelShader: {
  71440. name: string;
  71441. shader: string;
  71442. };
  71443. }
  71444. declare module BABYLON {
  71445. /**
  71446. * The SharpenPostProcess applies a sharpen kernel to every pixel
  71447. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  71448. */
  71449. export class SharpenPostProcess extends PostProcess {
  71450. /**
  71451. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  71452. */
  71453. colorAmount: number;
  71454. /**
  71455. * How much sharpness should be applied (default: 0.3)
  71456. */
  71457. edgeAmount: number;
  71458. /**
  71459. * Gets a string identifying the name of the class
  71460. * @returns "SharpenPostProcess" string
  71461. */
  71462. getClassName(): string;
  71463. /**
  71464. * Creates a new instance ConvolutionPostProcess
  71465. * @param name The name of the effect.
  71466. * @param options The required width/height ratio to downsize to before computing the render pass.
  71467. * @param camera The camera to apply the render pass to.
  71468. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71469. * @param engine The engine which the post process will be applied. (default: current engine)
  71470. * @param reusable If the post process can be reused on the same frame. (default: false)
  71471. * @param textureType Type of textures used when performing the post process. (default: 0)
  71472. * @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)
  71473. */
  71474. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71475. /** @hidden */
  71476. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  71477. }
  71478. }
  71479. declare module BABYLON {
  71480. /**
  71481. * PostProcessRenderPipeline
  71482. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71483. */
  71484. export class PostProcessRenderPipeline {
  71485. private engine;
  71486. private _renderEffects;
  71487. private _renderEffectsForIsolatedPass;
  71488. /**
  71489. * List of inspectable custom properties (used by the Inspector)
  71490. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  71491. */
  71492. inspectableCustomProperties: IInspectable[];
  71493. /**
  71494. * @hidden
  71495. */
  71496. protected _cameras: Camera[];
  71497. /** @hidden */
  71498. _name: string;
  71499. /**
  71500. * Gets pipeline name
  71501. */
  71502. get name(): string;
  71503. /** Gets the list of attached cameras */
  71504. get cameras(): Camera[];
  71505. /**
  71506. * Initializes a PostProcessRenderPipeline
  71507. * @param engine engine to add the pipeline to
  71508. * @param name name of the pipeline
  71509. */
  71510. constructor(engine: Engine, name: string);
  71511. /**
  71512. * Gets the class name
  71513. * @returns "PostProcessRenderPipeline"
  71514. */
  71515. getClassName(): string;
  71516. /**
  71517. * If all the render effects in the pipeline are supported
  71518. */
  71519. get isSupported(): boolean;
  71520. /**
  71521. * Adds an effect to the pipeline
  71522. * @param renderEffect the effect to add
  71523. */
  71524. addEffect(renderEffect: PostProcessRenderEffect): void;
  71525. /** @hidden */
  71526. _rebuild(): void;
  71527. /** @hidden */
  71528. _enableEffect(renderEffectName: string, cameras: Camera): void;
  71529. /** @hidden */
  71530. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  71531. /** @hidden */
  71532. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  71533. /** @hidden */
  71534. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  71535. /** @hidden */
  71536. _attachCameras(cameras: Camera, unique: boolean): void;
  71537. /** @hidden */
  71538. _attachCameras(cameras: Camera[], unique: boolean): void;
  71539. /** @hidden */
  71540. _detachCameras(cameras: Camera): void;
  71541. /** @hidden */
  71542. _detachCameras(cameras: Nullable<Camera[]>): void;
  71543. /** @hidden */
  71544. _update(): void;
  71545. /** @hidden */
  71546. _reset(): void;
  71547. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  71548. /**
  71549. * Sets the required values to the prepass renderer.
  71550. * @param prePassRenderer defines the prepass renderer to setup.
  71551. * @returns true if the pre pass is needed.
  71552. */
  71553. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  71554. /**
  71555. * Disposes of the pipeline
  71556. */
  71557. dispose(): void;
  71558. }
  71559. }
  71560. declare module BABYLON {
  71561. /**
  71562. * PostProcessRenderPipelineManager class
  71563. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71564. */
  71565. export class PostProcessRenderPipelineManager {
  71566. private _renderPipelines;
  71567. /**
  71568. * Initializes a PostProcessRenderPipelineManager
  71569. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71570. */
  71571. constructor();
  71572. /**
  71573. * Gets the list of supported render pipelines
  71574. */
  71575. get supportedPipelines(): PostProcessRenderPipeline[];
  71576. /**
  71577. * Adds a pipeline to the manager
  71578. * @param renderPipeline The pipeline to add
  71579. */
  71580. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  71581. /**
  71582. * Attaches a camera to the pipeline
  71583. * @param renderPipelineName The name of the pipeline to attach to
  71584. * @param cameras the camera to attach
  71585. * @param unique if the camera can be attached multiple times to the pipeline
  71586. */
  71587. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  71588. /**
  71589. * Detaches a camera from the pipeline
  71590. * @param renderPipelineName The name of the pipeline to detach from
  71591. * @param cameras the camera to detach
  71592. */
  71593. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  71594. /**
  71595. * Enables an effect by name on a pipeline
  71596. * @param renderPipelineName the name of the pipeline to enable the effect in
  71597. * @param renderEffectName the name of the effect to enable
  71598. * @param cameras the cameras that the effect should be enabled on
  71599. */
  71600. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  71601. /**
  71602. * Disables an effect by name on a pipeline
  71603. * @param renderPipelineName the name of the pipeline to disable the effect in
  71604. * @param renderEffectName the name of the effect to disable
  71605. * @param cameras the cameras that the effect should be disabled on
  71606. */
  71607. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  71608. /**
  71609. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  71610. */
  71611. update(): void;
  71612. /** @hidden */
  71613. _rebuild(): void;
  71614. /**
  71615. * Disposes of the manager and pipelines
  71616. */
  71617. dispose(): void;
  71618. }
  71619. }
  71620. declare module BABYLON {
  71621. interface Scene {
  71622. /** @hidden (Backing field) */
  71623. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  71624. /**
  71625. * Gets the postprocess render pipeline manager
  71626. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71627. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  71628. */
  71629. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  71630. }
  71631. /**
  71632. * Defines the Render Pipeline scene component responsible to rendering pipelines
  71633. */
  71634. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  71635. /**
  71636. * The component name helpfull to identify the component in the list of scene components.
  71637. */
  71638. readonly name: string;
  71639. /**
  71640. * The scene the component belongs to.
  71641. */
  71642. scene: Scene;
  71643. /**
  71644. * Creates a new instance of the component for the given scene
  71645. * @param scene Defines the scene to register the component in
  71646. */
  71647. constructor(scene: Scene);
  71648. /**
  71649. * Registers the component in a given scene
  71650. */
  71651. register(): void;
  71652. /**
  71653. * Rebuilds the elements related to this component in case of
  71654. * context lost for instance.
  71655. */
  71656. rebuild(): void;
  71657. /**
  71658. * Disposes the component and the associated ressources
  71659. */
  71660. dispose(): void;
  71661. private _gatherRenderTargets;
  71662. }
  71663. }
  71664. declare module BABYLON {
  71665. /**
  71666. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  71667. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  71668. */
  71669. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71670. private _scene;
  71671. private _camerasToBeAttached;
  71672. /**
  71673. * ID of the sharpen post process,
  71674. */
  71675. private readonly SharpenPostProcessId;
  71676. /**
  71677. * @ignore
  71678. * ID of the image processing post process;
  71679. */
  71680. readonly ImageProcessingPostProcessId: string;
  71681. /**
  71682. * @ignore
  71683. * ID of the Fast Approximate Anti-Aliasing post process;
  71684. */
  71685. readonly FxaaPostProcessId: string;
  71686. /**
  71687. * ID of the chromatic aberration post process,
  71688. */
  71689. private readonly ChromaticAberrationPostProcessId;
  71690. /**
  71691. * ID of the grain post process
  71692. */
  71693. private readonly GrainPostProcessId;
  71694. /**
  71695. * Sharpen post process which will apply a sharpen convolution to enhance edges
  71696. */
  71697. sharpen: SharpenPostProcess;
  71698. private _sharpenEffect;
  71699. private bloom;
  71700. /**
  71701. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  71702. */
  71703. depthOfField: DepthOfFieldEffect;
  71704. /**
  71705. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71706. */
  71707. fxaa: FxaaPostProcess;
  71708. /**
  71709. * Image post processing pass used to perform operations such as tone mapping or color grading.
  71710. */
  71711. imageProcessing: ImageProcessingPostProcess;
  71712. /**
  71713. * Chromatic aberration post process which will shift rgb colors in the image
  71714. */
  71715. chromaticAberration: ChromaticAberrationPostProcess;
  71716. private _chromaticAberrationEffect;
  71717. /**
  71718. * Grain post process which add noise to the image
  71719. */
  71720. grain: GrainPostProcess;
  71721. private _grainEffect;
  71722. /**
  71723. * Glow post process which adds a glow to emissive areas of the image
  71724. */
  71725. private _glowLayer;
  71726. /**
  71727. * Animations which can be used to tweak settings over a period of time
  71728. */
  71729. animations: Animation[];
  71730. private _imageProcessingConfigurationObserver;
  71731. private _sharpenEnabled;
  71732. private _bloomEnabled;
  71733. private _depthOfFieldEnabled;
  71734. private _depthOfFieldBlurLevel;
  71735. private _fxaaEnabled;
  71736. private _imageProcessingEnabled;
  71737. private _defaultPipelineTextureType;
  71738. private _bloomScale;
  71739. private _chromaticAberrationEnabled;
  71740. private _grainEnabled;
  71741. private _buildAllowed;
  71742. /**
  71743. * This is triggered each time the pipeline has been built.
  71744. */
  71745. onBuildObservable: Observable<DefaultRenderingPipeline>;
  71746. /**
  71747. * Gets active scene
  71748. */
  71749. get scene(): Scene;
  71750. /**
  71751. * Enable or disable the sharpen process from the pipeline
  71752. */
  71753. set sharpenEnabled(enabled: boolean);
  71754. get sharpenEnabled(): boolean;
  71755. private _resizeObserver;
  71756. private _hardwareScaleLevel;
  71757. private _bloomKernel;
  71758. /**
  71759. * Specifies the size of the bloom blur kernel, relative to the final output size
  71760. */
  71761. get bloomKernel(): number;
  71762. set bloomKernel(value: number);
  71763. /**
  71764. * Specifies the weight of the bloom in the final rendering
  71765. */
  71766. private _bloomWeight;
  71767. /**
  71768. * Specifies the luma threshold for the area that will be blurred by the bloom
  71769. */
  71770. private _bloomThreshold;
  71771. private _hdr;
  71772. /**
  71773. * The strength of the bloom.
  71774. */
  71775. set bloomWeight(value: number);
  71776. get bloomWeight(): number;
  71777. /**
  71778. * The strength of the bloom.
  71779. */
  71780. set bloomThreshold(value: number);
  71781. get bloomThreshold(): number;
  71782. /**
  71783. * The scale of the bloom, lower value will provide better performance.
  71784. */
  71785. set bloomScale(value: number);
  71786. get bloomScale(): number;
  71787. /**
  71788. * Enable or disable the bloom from the pipeline
  71789. */
  71790. set bloomEnabled(enabled: boolean);
  71791. get bloomEnabled(): boolean;
  71792. private _rebuildBloom;
  71793. /**
  71794. * If the depth of field is enabled.
  71795. */
  71796. get depthOfFieldEnabled(): boolean;
  71797. set depthOfFieldEnabled(enabled: boolean);
  71798. /**
  71799. * Blur level of the depth of field effect. (Higher blur will effect performance)
  71800. */
  71801. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  71802. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  71803. /**
  71804. * If the anti aliasing is enabled.
  71805. */
  71806. set fxaaEnabled(enabled: boolean);
  71807. get fxaaEnabled(): boolean;
  71808. private _samples;
  71809. /**
  71810. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71811. */
  71812. set samples(sampleCount: number);
  71813. get samples(): number;
  71814. /**
  71815. * If image processing is enabled.
  71816. */
  71817. set imageProcessingEnabled(enabled: boolean);
  71818. get imageProcessingEnabled(): boolean;
  71819. /**
  71820. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  71821. */
  71822. set glowLayerEnabled(enabled: boolean);
  71823. get glowLayerEnabled(): boolean;
  71824. /**
  71825. * Gets the glow layer (or null if not defined)
  71826. */
  71827. get glowLayer(): Nullable<GlowLayer>;
  71828. /**
  71829. * Enable or disable the chromaticAberration process from the pipeline
  71830. */
  71831. set chromaticAberrationEnabled(enabled: boolean);
  71832. get chromaticAberrationEnabled(): boolean;
  71833. /**
  71834. * Enable or disable the grain process from the pipeline
  71835. */
  71836. set grainEnabled(enabled: boolean);
  71837. get grainEnabled(): boolean;
  71838. /**
  71839. * @constructor
  71840. * @param name - The rendering pipeline name (default: "")
  71841. * @param hdr - If high dynamic range textures should be used (default: true)
  71842. * @param scene - The scene linked to this pipeline (default: the last created scene)
  71843. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  71844. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  71845. */
  71846. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  71847. /**
  71848. * Get the class name
  71849. * @returns "DefaultRenderingPipeline"
  71850. */
  71851. getClassName(): string;
  71852. /**
  71853. * Force the compilation of the entire pipeline.
  71854. */
  71855. prepare(): void;
  71856. private _hasCleared;
  71857. private _prevPostProcess;
  71858. private _prevPrevPostProcess;
  71859. private _setAutoClearAndTextureSharing;
  71860. private _depthOfFieldSceneObserver;
  71861. private _buildPipeline;
  71862. private _disposePostProcesses;
  71863. /**
  71864. * Adds a camera to the pipeline
  71865. * @param camera the camera to be added
  71866. */
  71867. addCamera(camera: Camera): void;
  71868. /**
  71869. * Removes a camera from the pipeline
  71870. * @param camera the camera to remove
  71871. */
  71872. removeCamera(camera: Camera): void;
  71873. /**
  71874. * Dispose of the pipeline and stop all post processes
  71875. */
  71876. dispose(): void;
  71877. /**
  71878. * Serialize the rendering pipeline (Used when exporting)
  71879. * @returns the serialized object
  71880. */
  71881. serialize(): any;
  71882. /**
  71883. * Parse the serialized pipeline
  71884. * @param source Source pipeline.
  71885. * @param scene The scene to load the pipeline to.
  71886. * @param rootUrl The URL of the serialized pipeline.
  71887. * @returns An instantiated pipeline from the serialized object.
  71888. */
  71889. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  71890. }
  71891. }
  71892. declare module BABYLON {
  71893. /** @hidden */
  71894. export var lensHighlightsPixelShader: {
  71895. name: string;
  71896. shader: string;
  71897. };
  71898. }
  71899. declare module BABYLON {
  71900. /** @hidden */
  71901. export var depthOfFieldPixelShader: {
  71902. name: string;
  71903. shader: string;
  71904. };
  71905. }
  71906. declare module BABYLON {
  71907. /**
  71908. * BABYLON.JS Chromatic Aberration GLSL Shader
  71909. * Author: Olivier Guyot
  71910. * Separates very slightly R, G and B colors on the edges of the screen
  71911. * Inspired by Francois Tarlier & Martins Upitis
  71912. */
  71913. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  71914. /**
  71915. * @ignore
  71916. * The chromatic aberration PostProcess id in the pipeline
  71917. */
  71918. LensChromaticAberrationEffect: string;
  71919. /**
  71920. * @ignore
  71921. * The highlights enhancing PostProcess id in the pipeline
  71922. */
  71923. HighlightsEnhancingEffect: string;
  71924. /**
  71925. * @ignore
  71926. * The depth-of-field PostProcess id in the pipeline
  71927. */
  71928. LensDepthOfFieldEffect: string;
  71929. private _scene;
  71930. private _depthTexture;
  71931. private _grainTexture;
  71932. private _chromaticAberrationPostProcess;
  71933. private _highlightsPostProcess;
  71934. private _depthOfFieldPostProcess;
  71935. private _edgeBlur;
  71936. private _grainAmount;
  71937. private _chromaticAberration;
  71938. private _distortion;
  71939. private _highlightsGain;
  71940. private _highlightsThreshold;
  71941. private _dofDistance;
  71942. private _dofAperture;
  71943. private _dofDarken;
  71944. private _dofPentagon;
  71945. private _blurNoise;
  71946. /**
  71947. * @constructor
  71948. *
  71949. * Effect parameters are as follow:
  71950. * {
  71951. * chromatic_aberration: number; // from 0 to x (1 for realism)
  71952. * edge_blur: number; // from 0 to x (1 for realism)
  71953. * distortion: number; // from 0 to x (1 for realism)
  71954. * grain_amount: number; // from 0 to 1
  71955. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  71956. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  71957. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  71958. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  71959. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  71960. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  71961. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  71962. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  71963. * }
  71964. * Note: if an effect parameter is unset, effect is disabled
  71965. *
  71966. * @param name The rendering pipeline name
  71967. * @param parameters - An object containing all parameters (see above)
  71968. * @param scene The scene linked to this pipeline
  71969. * @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)
  71970. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71971. */
  71972. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  71973. /**
  71974. * Get the class name
  71975. * @returns "LensRenderingPipeline"
  71976. */
  71977. getClassName(): string;
  71978. /**
  71979. * Gets associated scene
  71980. */
  71981. get scene(): Scene;
  71982. /**
  71983. * Gets or sets the edge blur
  71984. */
  71985. get edgeBlur(): number;
  71986. set edgeBlur(value: number);
  71987. /**
  71988. * Gets or sets the grain amount
  71989. */
  71990. get grainAmount(): number;
  71991. set grainAmount(value: number);
  71992. /**
  71993. * Gets or sets the chromatic aberration amount
  71994. */
  71995. get chromaticAberration(): number;
  71996. set chromaticAberration(value: number);
  71997. /**
  71998. * Gets or sets the depth of field aperture
  71999. */
  72000. get dofAperture(): number;
  72001. set dofAperture(value: number);
  72002. /**
  72003. * Gets or sets the edge distortion
  72004. */
  72005. get edgeDistortion(): number;
  72006. set edgeDistortion(value: number);
  72007. /**
  72008. * Gets or sets the depth of field distortion
  72009. */
  72010. get dofDistortion(): number;
  72011. set dofDistortion(value: number);
  72012. /**
  72013. * Gets or sets the darken out of focus amount
  72014. */
  72015. get darkenOutOfFocus(): number;
  72016. set darkenOutOfFocus(value: number);
  72017. /**
  72018. * Gets or sets a boolean indicating if blur noise is enabled
  72019. */
  72020. get blurNoise(): boolean;
  72021. set blurNoise(value: boolean);
  72022. /**
  72023. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  72024. */
  72025. get pentagonBokeh(): boolean;
  72026. set pentagonBokeh(value: boolean);
  72027. /**
  72028. * Gets or sets the highlight grain amount
  72029. */
  72030. get highlightsGain(): number;
  72031. set highlightsGain(value: number);
  72032. /**
  72033. * Gets or sets the highlight threshold
  72034. */
  72035. get highlightsThreshold(): number;
  72036. set highlightsThreshold(value: number);
  72037. /**
  72038. * Sets the amount of blur at the edges
  72039. * @param amount blur amount
  72040. */
  72041. setEdgeBlur(amount: number): void;
  72042. /**
  72043. * Sets edge blur to 0
  72044. */
  72045. disableEdgeBlur(): void;
  72046. /**
  72047. * Sets the amout of grain
  72048. * @param amount Amount of grain
  72049. */
  72050. setGrainAmount(amount: number): void;
  72051. /**
  72052. * Set grain amount to 0
  72053. */
  72054. disableGrain(): void;
  72055. /**
  72056. * Sets the chromatic aberration amount
  72057. * @param amount amount of chromatic aberration
  72058. */
  72059. setChromaticAberration(amount: number): void;
  72060. /**
  72061. * Sets chromatic aberration amount to 0
  72062. */
  72063. disableChromaticAberration(): void;
  72064. /**
  72065. * Sets the EdgeDistortion amount
  72066. * @param amount amount of EdgeDistortion
  72067. */
  72068. setEdgeDistortion(amount: number): void;
  72069. /**
  72070. * Sets edge distortion to 0
  72071. */
  72072. disableEdgeDistortion(): void;
  72073. /**
  72074. * Sets the FocusDistance amount
  72075. * @param amount amount of FocusDistance
  72076. */
  72077. setFocusDistance(amount: number): void;
  72078. /**
  72079. * Disables depth of field
  72080. */
  72081. disableDepthOfField(): void;
  72082. /**
  72083. * Sets the Aperture amount
  72084. * @param amount amount of Aperture
  72085. */
  72086. setAperture(amount: number): void;
  72087. /**
  72088. * Sets the DarkenOutOfFocus amount
  72089. * @param amount amount of DarkenOutOfFocus
  72090. */
  72091. setDarkenOutOfFocus(amount: number): void;
  72092. private _pentagonBokehIsEnabled;
  72093. /**
  72094. * Creates a pentagon bokeh effect
  72095. */
  72096. enablePentagonBokeh(): void;
  72097. /**
  72098. * Disables the pentagon bokeh effect
  72099. */
  72100. disablePentagonBokeh(): void;
  72101. /**
  72102. * Enables noise blur
  72103. */
  72104. enableNoiseBlur(): void;
  72105. /**
  72106. * Disables noise blur
  72107. */
  72108. disableNoiseBlur(): void;
  72109. /**
  72110. * Sets the HighlightsGain amount
  72111. * @param amount amount of HighlightsGain
  72112. */
  72113. setHighlightsGain(amount: number): void;
  72114. /**
  72115. * Sets the HighlightsThreshold amount
  72116. * @param amount amount of HighlightsThreshold
  72117. */
  72118. setHighlightsThreshold(amount: number): void;
  72119. /**
  72120. * Disables highlights
  72121. */
  72122. disableHighlights(): void;
  72123. /**
  72124. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  72125. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  72126. */
  72127. dispose(disableDepthRender?: boolean): void;
  72128. private _createChromaticAberrationPostProcess;
  72129. private _createHighlightsPostProcess;
  72130. private _createDepthOfFieldPostProcess;
  72131. private _createGrainTexture;
  72132. }
  72133. }
  72134. declare module BABYLON {
  72135. /**
  72136. * Contains all parameters needed for the prepass to perform
  72137. * screen space subsurface scattering
  72138. */
  72139. export class SSAO2Configuration implements PrePassEffectConfiguration {
  72140. /**
  72141. * Is subsurface enabled
  72142. */
  72143. enabled: boolean;
  72144. /**
  72145. * Name of the configuration
  72146. */
  72147. name: string;
  72148. /**
  72149. * Textures that should be present in the MRT for this effect to work
  72150. */
  72151. readonly texturesRequired: number[];
  72152. }
  72153. }
  72154. declare module BABYLON {
  72155. /** @hidden */
  72156. export var ssao2PixelShader: {
  72157. name: string;
  72158. shader: string;
  72159. };
  72160. }
  72161. declare module BABYLON {
  72162. /** @hidden */
  72163. export var ssaoCombinePixelShader: {
  72164. name: string;
  72165. shader: string;
  72166. };
  72167. }
  72168. declare module BABYLON {
  72169. /**
  72170. * Render pipeline to produce ssao effect
  72171. */
  72172. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  72173. /**
  72174. * @ignore
  72175. * The PassPostProcess id in the pipeline that contains the original scene color
  72176. */
  72177. SSAOOriginalSceneColorEffect: string;
  72178. /**
  72179. * @ignore
  72180. * The SSAO PostProcess id in the pipeline
  72181. */
  72182. SSAORenderEffect: string;
  72183. /**
  72184. * @ignore
  72185. * The horizontal blur PostProcess id in the pipeline
  72186. */
  72187. SSAOBlurHRenderEffect: string;
  72188. /**
  72189. * @ignore
  72190. * The vertical blur PostProcess id in the pipeline
  72191. */
  72192. SSAOBlurVRenderEffect: string;
  72193. /**
  72194. * @ignore
  72195. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  72196. */
  72197. SSAOCombineRenderEffect: string;
  72198. /**
  72199. * The output strength of the SSAO post-process. Default value is 1.0.
  72200. */
  72201. totalStrength: number;
  72202. /**
  72203. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  72204. */
  72205. maxZ: number;
  72206. /**
  72207. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  72208. */
  72209. minZAspect: number;
  72210. private _samples;
  72211. /**
  72212. * Number of samples used for the SSAO calculations. Default value is 8
  72213. */
  72214. set samples(n: number);
  72215. get samples(): number;
  72216. private _textureSamples;
  72217. /**
  72218. * Number of samples to use for antialiasing
  72219. */
  72220. set textureSamples(n: number);
  72221. get textureSamples(): number;
  72222. /**
  72223. * Force rendering the geometry through geometry buffer
  72224. */
  72225. private _forceGeometryBuffer;
  72226. /**
  72227. * Ratio object used for SSAO ratio and blur ratio
  72228. */
  72229. private _ratio;
  72230. /**
  72231. * Dynamically generated sphere sampler.
  72232. */
  72233. private _sampleSphere;
  72234. /**
  72235. * Blur filter offsets
  72236. */
  72237. private _samplerOffsets;
  72238. private _expensiveBlur;
  72239. /**
  72240. * If bilateral blur should be used
  72241. */
  72242. set expensiveBlur(b: boolean);
  72243. get expensiveBlur(): boolean;
  72244. /**
  72245. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  72246. */
  72247. radius: number;
  72248. /**
  72249. * The base color of the SSAO post-process
  72250. * The final result is "base + ssao" between [0, 1]
  72251. */
  72252. base: number;
  72253. /**
  72254. * Support test.
  72255. */
  72256. static get IsSupported(): boolean;
  72257. private _scene;
  72258. private _randomTexture;
  72259. private _originalColorPostProcess;
  72260. private _ssaoPostProcess;
  72261. private _blurHPostProcess;
  72262. private _blurVPostProcess;
  72263. private _ssaoCombinePostProcess;
  72264. private _prePassRenderer;
  72265. /**
  72266. * Gets active scene
  72267. */
  72268. get scene(): Scene;
  72269. /**
  72270. * @constructor
  72271. * @param name The rendering pipeline name
  72272. * @param scene The scene linked to this pipeline
  72273. * @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 }
  72274. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72275. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  72276. */
  72277. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  72278. /**
  72279. * Get the class name
  72280. * @returns "SSAO2RenderingPipeline"
  72281. */
  72282. getClassName(): string;
  72283. /**
  72284. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  72285. */
  72286. dispose(disableGeometryBufferRenderer?: boolean): void;
  72287. private _createBlurPostProcess;
  72288. /** @hidden */
  72289. _rebuild(): void;
  72290. private _bits;
  72291. private _radicalInverse_VdC;
  72292. private _hammersley;
  72293. private _hemisphereSample_uniform;
  72294. private _generateHemisphere;
  72295. private _getDefinesForSSAO;
  72296. private _createSSAOPostProcess;
  72297. private _createSSAOCombinePostProcess;
  72298. private _createRandomTexture;
  72299. /**
  72300. * Serialize the rendering pipeline (Used when exporting)
  72301. * @returns the serialized object
  72302. */
  72303. serialize(): any;
  72304. /**
  72305. * Parse the serialized pipeline
  72306. * @param source Source pipeline.
  72307. * @param scene The scene to load the pipeline to.
  72308. * @param rootUrl The URL of the serialized pipeline.
  72309. * @returns An instantiated pipeline from the serialized object.
  72310. */
  72311. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  72312. }
  72313. }
  72314. declare module BABYLON {
  72315. /** @hidden */
  72316. export var ssaoPixelShader: {
  72317. name: string;
  72318. shader: string;
  72319. };
  72320. }
  72321. declare module BABYLON {
  72322. /**
  72323. * Render pipeline to produce ssao effect
  72324. */
  72325. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  72326. /**
  72327. * @ignore
  72328. * The PassPostProcess id in the pipeline that contains the original scene color
  72329. */
  72330. SSAOOriginalSceneColorEffect: string;
  72331. /**
  72332. * @ignore
  72333. * The SSAO PostProcess id in the pipeline
  72334. */
  72335. SSAORenderEffect: string;
  72336. /**
  72337. * @ignore
  72338. * The horizontal blur PostProcess id in the pipeline
  72339. */
  72340. SSAOBlurHRenderEffect: string;
  72341. /**
  72342. * @ignore
  72343. * The vertical blur PostProcess id in the pipeline
  72344. */
  72345. SSAOBlurVRenderEffect: string;
  72346. /**
  72347. * @ignore
  72348. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  72349. */
  72350. SSAOCombineRenderEffect: string;
  72351. /**
  72352. * The output strength of the SSAO post-process. Default value is 1.0.
  72353. */
  72354. totalStrength: number;
  72355. /**
  72356. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  72357. */
  72358. radius: number;
  72359. /**
  72360. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  72361. * Must not be equal to fallOff and superior to fallOff.
  72362. * Default value is 0.0075
  72363. */
  72364. area: number;
  72365. /**
  72366. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  72367. * Must not be equal to area and inferior to area.
  72368. * Default value is 0.000001
  72369. */
  72370. fallOff: number;
  72371. /**
  72372. * The base color of the SSAO post-process
  72373. * The final result is "base + ssao" between [0, 1]
  72374. */
  72375. base: number;
  72376. private _scene;
  72377. private _depthTexture;
  72378. private _randomTexture;
  72379. private _originalColorPostProcess;
  72380. private _ssaoPostProcess;
  72381. private _blurHPostProcess;
  72382. private _blurVPostProcess;
  72383. private _ssaoCombinePostProcess;
  72384. private _firstUpdate;
  72385. /**
  72386. * Gets active scene
  72387. */
  72388. get scene(): Scene;
  72389. /**
  72390. * @constructor
  72391. * @param name - The rendering pipeline name
  72392. * @param scene - The scene linked to this pipeline
  72393. * @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 }
  72394. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  72395. */
  72396. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  72397. /**
  72398. * Get the class name
  72399. * @returns "SSAORenderingPipeline"
  72400. */
  72401. getClassName(): string;
  72402. /**
  72403. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  72404. */
  72405. dispose(disableDepthRender?: boolean): void;
  72406. private _createBlurPostProcess;
  72407. /** @hidden */
  72408. _rebuild(): void;
  72409. private _createSSAOPostProcess;
  72410. private _createSSAOCombinePostProcess;
  72411. private _createRandomTexture;
  72412. }
  72413. }
  72414. declare module BABYLON {
  72415. /**
  72416. * Contains all parameters needed for the prepass to perform
  72417. * screen space reflections
  72418. */
  72419. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  72420. /**
  72421. * Is ssr enabled
  72422. */
  72423. enabled: boolean;
  72424. /**
  72425. * Name of the configuration
  72426. */
  72427. name: string;
  72428. /**
  72429. * Textures that should be present in the MRT for this effect to work
  72430. */
  72431. readonly texturesRequired: number[];
  72432. }
  72433. }
  72434. declare module BABYLON {
  72435. /** @hidden */
  72436. export var screenSpaceReflectionPixelShader: {
  72437. name: string;
  72438. shader: string;
  72439. };
  72440. }
  72441. declare module BABYLON {
  72442. /**
  72443. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  72444. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  72445. */
  72446. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  72447. /**
  72448. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  72449. */
  72450. threshold: number;
  72451. /**
  72452. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  72453. */
  72454. strength: number;
  72455. /**
  72456. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  72457. */
  72458. reflectionSpecularFalloffExponent: number;
  72459. /**
  72460. * Gets or sets the step size used to iterate until the effect finds the color of the reflection's pixel. Typically in interval [0.1, 1.0]
  72461. */
  72462. step: number;
  72463. /**
  72464. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  72465. */
  72466. roughnessFactor: number;
  72467. private _forceGeometryBuffer;
  72468. private _geometryBufferRenderer;
  72469. private _prePassRenderer;
  72470. private _enableSmoothReflections;
  72471. private _reflectionSamples;
  72472. private _smoothSteps;
  72473. /**
  72474. * Gets a string identifying the name of the class
  72475. * @returns "ScreenSpaceReflectionPostProcess" string
  72476. */
  72477. getClassName(): string;
  72478. /**
  72479. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  72480. * @param name The name of the effect.
  72481. * @param scene The scene containing the objects to calculate reflections.
  72482. * @param options The required width/height ratio to downsize to before computing the render pass.
  72483. * @param camera The camera to apply the render pass to.
  72484. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72485. * @param engine The engine which the post process will be applied. (default: current engine)
  72486. * @param reusable If the post process can be reused on the same frame. (default: false)
  72487. * @param textureType Type of textures used when performing the post process. (default: 0)
  72488. * @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: true)
  72489. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  72490. */
  72491. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  72492. /**
  72493. * Gets wether or not smoothing reflections is enabled.
  72494. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72495. */
  72496. get enableSmoothReflections(): boolean;
  72497. /**
  72498. * Sets wether or not smoothing reflections is enabled.
  72499. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72500. */
  72501. set enableSmoothReflections(enabled: boolean);
  72502. /**
  72503. * Gets the number of samples taken while computing reflections. More samples count is high,
  72504. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72505. */
  72506. get reflectionSamples(): number;
  72507. /**
  72508. * Sets the number of samples taken while computing reflections. More samples count is high,
  72509. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72510. */
  72511. set reflectionSamples(samples: number);
  72512. /**
  72513. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  72514. * more the post-process will require GPU power and can generate a drop in FPS.
  72515. * Default value (5.0) work pretty well in all cases but can be adjusted.
  72516. */
  72517. get smoothSteps(): number;
  72518. set smoothSteps(steps: number);
  72519. private _updateEffectDefines;
  72520. /** @hidden */
  72521. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  72522. }
  72523. }
  72524. declare module BABYLON {
  72525. /** @hidden */
  72526. export var standardPixelShader: {
  72527. name: string;
  72528. shader: string;
  72529. };
  72530. }
  72531. declare module BABYLON {
  72532. /**
  72533. * Standard rendering pipeline
  72534. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72535. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  72536. */
  72537. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  72538. /**
  72539. * Public members
  72540. */
  72541. /**
  72542. * Post-process which contains the original scene color before the pipeline applies all the effects
  72543. */
  72544. originalPostProcess: Nullable<PostProcess>;
  72545. /**
  72546. * Post-process used to down scale an image x4
  72547. */
  72548. downSampleX4PostProcess: Nullable<PostProcess>;
  72549. /**
  72550. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  72551. */
  72552. brightPassPostProcess: Nullable<PostProcess>;
  72553. /**
  72554. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  72555. */
  72556. blurHPostProcesses: PostProcess[];
  72557. /**
  72558. * Post-process array storing all the vertical blur post-processes used by the pipeline
  72559. */
  72560. blurVPostProcesses: PostProcess[];
  72561. /**
  72562. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  72563. */
  72564. textureAdderPostProcess: Nullable<PostProcess>;
  72565. /**
  72566. * Post-process used to create volumetric lighting effect
  72567. */
  72568. volumetricLightPostProcess: Nullable<PostProcess>;
  72569. /**
  72570. * Post-process used to smooth the previous volumetric light post-process on the X axis
  72571. */
  72572. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  72573. /**
  72574. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  72575. */
  72576. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  72577. /**
  72578. * Post-process used to merge the volumetric light effect and the real scene color
  72579. */
  72580. volumetricLightMergePostProces: Nullable<PostProcess>;
  72581. /**
  72582. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  72583. */
  72584. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  72585. /**
  72586. * Base post-process used to calculate the average luminance of the final image for HDR
  72587. */
  72588. luminancePostProcess: Nullable<PostProcess>;
  72589. /**
  72590. * Post-processes used to create down sample post-processes in order to get
  72591. * the average luminance of the final image for HDR
  72592. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  72593. */
  72594. luminanceDownSamplePostProcesses: PostProcess[];
  72595. /**
  72596. * Post-process used to create a HDR effect (light adaptation)
  72597. */
  72598. hdrPostProcess: Nullable<PostProcess>;
  72599. /**
  72600. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  72601. */
  72602. textureAdderFinalPostProcess: Nullable<PostProcess>;
  72603. /**
  72604. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  72605. */
  72606. lensFlareFinalPostProcess: Nullable<PostProcess>;
  72607. /**
  72608. * Post-process used to merge the final HDR post-process and the real scene color
  72609. */
  72610. hdrFinalPostProcess: Nullable<PostProcess>;
  72611. /**
  72612. * Post-process used to create a lens flare effect
  72613. */
  72614. lensFlarePostProcess: Nullable<PostProcess>;
  72615. /**
  72616. * Post-process that merges the result of the lens flare post-process and the real scene color
  72617. */
  72618. lensFlareComposePostProcess: Nullable<PostProcess>;
  72619. /**
  72620. * Post-process used to create a motion blur effect
  72621. */
  72622. motionBlurPostProcess: Nullable<PostProcess>;
  72623. /**
  72624. * Post-process used to create a depth of field effect
  72625. */
  72626. depthOfFieldPostProcess: Nullable<PostProcess>;
  72627. /**
  72628. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  72629. */
  72630. fxaaPostProcess: Nullable<FxaaPostProcess>;
  72631. /**
  72632. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  72633. */
  72634. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  72635. /**
  72636. * Represents the brightness threshold in order to configure the illuminated surfaces
  72637. */
  72638. brightThreshold: number;
  72639. /**
  72640. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  72641. */
  72642. blurWidth: number;
  72643. /**
  72644. * Sets if the blur for highlighted surfaces must be only horizontal
  72645. */
  72646. horizontalBlur: boolean;
  72647. /**
  72648. * Gets the overall exposure used by the pipeline
  72649. */
  72650. get exposure(): number;
  72651. /**
  72652. * Sets the overall exposure used by the pipeline
  72653. */
  72654. set exposure(value: number);
  72655. /**
  72656. * Texture used typically to simulate "dirty" on camera lens
  72657. */
  72658. lensTexture: Nullable<Texture>;
  72659. /**
  72660. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  72661. */
  72662. volumetricLightCoefficient: number;
  72663. /**
  72664. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  72665. */
  72666. volumetricLightPower: number;
  72667. /**
  72668. * Used the set the blur intensity to smooth the volumetric lights
  72669. */
  72670. volumetricLightBlurScale: number;
  72671. /**
  72672. * Light (spot or directional) used to generate the volumetric lights rays
  72673. * The source light must have a shadow generate so the pipeline can get its
  72674. * depth map
  72675. */
  72676. sourceLight: Nullable<SpotLight | DirectionalLight>;
  72677. /**
  72678. * For eye adaptation, represents the minimum luminance the eye can see
  72679. */
  72680. hdrMinimumLuminance: number;
  72681. /**
  72682. * For eye adaptation, represents the decrease luminance speed
  72683. */
  72684. hdrDecreaseRate: number;
  72685. /**
  72686. * For eye adaptation, represents the increase luminance speed
  72687. */
  72688. hdrIncreaseRate: number;
  72689. /**
  72690. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72691. */
  72692. get hdrAutoExposure(): boolean;
  72693. /**
  72694. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72695. */
  72696. set hdrAutoExposure(value: boolean);
  72697. /**
  72698. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  72699. */
  72700. lensColorTexture: Nullable<Texture>;
  72701. /**
  72702. * The overall strengh for the lens flare effect
  72703. */
  72704. lensFlareStrength: number;
  72705. /**
  72706. * Dispersion coefficient for lens flare ghosts
  72707. */
  72708. lensFlareGhostDispersal: number;
  72709. /**
  72710. * Main lens flare halo width
  72711. */
  72712. lensFlareHaloWidth: number;
  72713. /**
  72714. * Based on the lens distortion effect, defines how much the lens flare result
  72715. * is distorted
  72716. */
  72717. lensFlareDistortionStrength: number;
  72718. /**
  72719. * Configures the blur intensity used for for lens flare (halo)
  72720. */
  72721. lensFlareBlurWidth: number;
  72722. /**
  72723. * Lens star texture must be used to simulate rays on the flares and is available
  72724. * in the documentation
  72725. */
  72726. lensStarTexture: Nullable<Texture>;
  72727. /**
  72728. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  72729. * flare effect by taking account of the dirt texture
  72730. */
  72731. lensFlareDirtTexture: Nullable<Texture>;
  72732. /**
  72733. * Represents the focal length for the depth of field effect
  72734. */
  72735. depthOfFieldDistance: number;
  72736. /**
  72737. * Represents the blur intensity for the blurred part of the depth of field effect
  72738. */
  72739. depthOfFieldBlurWidth: number;
  72740. /**
  72741. * Gets how much the image is blurred by the movement while using the motion blur post-process
  72742. */
  72743. get motionStrength(): number;
  72744. /**
  72745. * Sets how much the image is blurred by the movement while using the motion blur post-process
  72746. */
  72747. set motionStrength(strength: number);
  72748. /**
  72749. * Gets wether or not the motion blur post-process is object based or screen based.
  72750. */
  72751. get objectBasedMotionBlur(): boolean;
  72752. /**
  72753. * Sets wether or not the motion blur post-process should be object based or screen based
  72754. */
  72755. set objectBasedMotionBlur(value: boolean);
  72756. /**
  72757. * List of animations for the pipeline (IAnimatable implementation)
  72758. */
  72759. animations: Animation[];
  72760. /**
  72761. * Private members
  72762. */
  72763. private _scene;
  72764. private _currentDepthOfFieldSource;
  72765. private _basePostProcess;
  72766. private _fixedExposure;
  72767. private _currentExposure;
  72768. private _hdrAutoExposure;
  72769. private _hdrCurrentLuminance;
  72770. private _motionStrength;
  72771. private _isObjectBasedMotionBlur;
  72772. private _floatTextureType;
  72773. private _camerasToBeAttached;
  72774. private _ratio;
  72775. private _bloomEnabled;
  72776. private _depthOfFieldEnabled;
  72777. private _vlsEnabled;
  72778. private _lensFlareEnabled;
  72779. private _hdrEnabled;
  72780. private _motionBlurEnabled;
  72781. private _fxaaEnabled;
  72782. private _screenSpaceReflectionsEnabled;
  72783. private _motionBlurSamples;
  72784. private _volumetricLightStepsCount;
  72785. private _samples;
  72786. /**
  72787. * @ignore
  72788. * Specifies if the bloom pipeline is enabled
  72789. */
  72790. get BloomEnabled(): boolean;
  72791. set BloomEnabled(enabled: boolean);
  72792. /**
  72793. * @ignore
  72794. * Specifies if the depth of field pipeline is enabed
  72795. */
  72796. get DepthOfFieldEnabled(): boolean;
  72797. set DepthOfFieldEnabled(enabled: boolean);
  72798. /**
  72799. * @ignore
  72800. * Specifies if the lens flare pipeline is enabed
  72801. */
  72802. get LensFlareEnabled(): boolean;
  72803. set LensFlareEnabled(enabled: boolean);
  72804. /**
  72805. * @ignore
  72806. * Specifies if the HDR pipeline is enabled
  72807. */
  72808. get HDREnabled(): boolean;
  72809. set HDREnabled(enabled: boolean);
  72810. /**
  72811. * @ignore
  72812. * Specifies if the volumetric lights scattering effect is enabled
  72813. */
  72814. get VLSEnabled(): boolean;
  72815. set VLSEnabled(enabled: boolean);
  72816. /**
  72817. * @ignore
  72818. * Specifies if the motion blur effect is enabled
  72819. */
  72820. get MotionBlurEnabled(): boolean;
  72821. set MotionBlurEnabled(enabled: boolean);
  72822. /**
  72823. * Specifies if anti-aliasing is enabled
  72824. */
  72825. get fxaaEnabled(): boolean;
  72826. set fxaaEnabled(enabled: boolean);
  72827. /**
  72828. * Specifies if screen space reflections are enabled.
  72829. */
  72830. get screenSpaceReflectionsEnabled(): boolean;
  72831. set screenSpaceReflectionsEnabled(enabled: boolean);
  72832. /**
  72833. * Specifies the number of steps used to calculate the volumetric lights
  72834. * Typically in interval [50, 200]
  72835. */
  72836. get volumetricLightStepsCount(): number;
  72837. set volumetricLightStepsCount(count: number);
  72838. /**
  72839. * Specifies the number of samples used for the motion blur effect
  72840. * Typically in interval [16, 64]
  72841. */
  72842. get motionBlurSamples(): number;
  72843. set motionBlurSamples(samples: number);
  72844. /**
  72845. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  72846. */
  72847. get samples(): number;
  72848. set samples(sampleCount: number);
  72849. /**
  72850. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72851. * @constructor
  72852. * @param name The rendering pipeline name
  72853. * @param scene The scene linked to this pipeline
  72854. * @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)
  72855. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  72856. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72857. */
  72858. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  72859. private _buildPipeline;
  72860. private _createDownSampleX4PostProcess;
  72861. private _createBrightPassPostProcess;
  72862. private _createBlurPostProcesses;
  72863. private _createTextureAdderPostProcess;
  72864. private _createVolumetricLightPostProcess;
  72865. private _createLuminancePostProcesses;
  72866. private _createHdrPostProcess;
  72867. private _createLensFlarePostProcess;
  72868. private _createDepthOfFieldPostProcess;
  72869. private _createMotionBlurPostProcess;
  72870. private _getDepthTexture;
  72871. private _disposePostProcesses;
  72872. /**
  72873. * Dispose of the pipeline and stop all post processes
  72874. */
  72875. dispose(): void;
  72876. /**
  72877. * Serialize the rendering pipeline (Used when exporting)
  72878. * @returns the serialized object
  72879. */
  72880. serialize(): any;
  72881. /**
  72882. * Parse the serialized pipeline
  72883. * @param source Source pipeline.
  72884. * @param scene The scene to load the pipeline to.
  72885. * @param rootUrl The URL of the serialized pipeline.
  72886. * @returns An instantiated pipeline from the serialized object.
  72887. */
  72888. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  72889. /**
  72890. * Luminance steps
  72891. */
  72892. static LuminanceSteps: number;
  72893. }
  72894. }
  72895. declare module BABYLON {
  72896. /** @hidden */
  72897. export var stereoscopicInterlacePixelShader: {
  72898. name: string;
  72899. shader: string;
  72900. };
  72901. }
  72902. declare module BABYLON {
  72903. /**
  72904. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  72905. */
  72906. export class StereoscopicInterlacePostProcessI extends PostProcess {
  72907. private _stepSize;
  72908. private _passedProcess;
  72909. /**
  72910. * Gets a string identifying the name of the class
  72911. * @returns "StereoscopicInterlacePostProcessI" string
  72912. */
  72913. getClassName(): string;
  72914. /**
  72915. * Initializes a StereoscopicInterlacePostProcessI
  72916. * @param name The name of the effect.
  72917. * @param rigCameras The rig cameras to be appled to the post process
  72918. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  72919. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  72920. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72921. * @param engine The engine which the post process will be applied. (default: current engine)
  72922. * @param reusable If the post process can be reused on the same frame. (default: false)
  72923. */
  72924. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72925. }
  72926. /**
  72927. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  72928. */
  72929. export class StereoscopicInterlacePostProcess extends PostProcess {
  72930. private _stepSize;
  72931. private _passedProcess;
  72932. /**
  72933. * Gets a string identifying the name of the class
  72934. * @returns "StereoscopicInterlacePostProcess" string
  72935. */
  72936. getClassName(): string;
  72937. /**
  72938. * Initializes a StereoscopicInterlacePostProcess
  72939. * @param name The name of the effect.
  72940. * @param rigCameras The rig cameras to be appled to the post process
  72941. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  72942. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72943. * @param engine The engine which the post process will be applied. (default: current engine)
  72944. * @param reusable If the post process can be reused on the same frame. (default: false)
  72945. */
  72946. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72947. }
  72948. }
  72949. declare module BABYLON {
  72950. /** @hidden */
  72951. export var tonemapPixelShader: {
  72952. name: string;
  72953. shader: string;
  72954. };
  72955. }
  72956. declare module BABYLON {
  72957. /** Defines operator used for tonemapping */
  72958. export enum TonemappingOperator {
  72959. /** Hable */
  72960. Hable = 0,
  72961. /** Reinhard */
  72962. Reinhard = 1,
  72963. /** HejiDawson */
  72964. HejiDawson = 2,
  72965. /** Photographic */
  72966. Photographic = 3
  72967. }
  72968. /**
  72969. * Defines a post process to apply tone mapping
  72970. */
  72971. export class TonemapPostProcess extends PostProcess {
  72972. private _operator;
  72973. /** Defines the required exposure adjustement */
  72974. exposureAdjustment: number;
  72975. /**
  72976. * Gets a string identifying the name of the class
  72977. * @returns "TonemapPostProcess" string
  72978. */
  72979. getClassName(): string;
  72980. /**
  72981. * Creates a new TonemapPostProcess
  72982. * @param name defines the name of the postprocess
  72983. * @param _operator defines the operator to use
  72984. * @param exposureAdjustment defines the required exposure adjustement
  72985. * @param camera defines the camera to use (can be null)
  72986. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  72987. * @param engine defines the hosting engine (can be ignore if camera is set)
  72988. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72989. */
  72990. constructor(name: string, _operator: TonemappingOperator,
  72991. /** Defines the required exposure adjustement */
  72992. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  72993. }
  72994. }
  72995. declare module BABYLON {
  72996. /** @hidden */
  72997. export var volumetricLightScatteringPixelShader: {
  72998. name: string;
  72999. shader: string;
  73000. };
  73001. }
  73002. declare module BABYLON {
  73003. /** @hidden */
  73004. export var volumetricLightScatteringPassVertexShader: {
  73005. name: string;
  73006. shader: string;
  73007. };
  73008. }
  73009. declare module BABYLON {
  73010. /** @hidden */
  73011. export var volumetricLightScatteringPassPixelShader: {
  73012. name: string;
  73013. shader: string;
  73014. };
  73015. }
  73016. declare module BABYLON {
  73017. /**
  73018. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  73019. */
  73020. export class VolumetricLightScatteringPostProcess extends PostProcess {
  73021. private _volumetricLightScatteringPass;
  73022. private _volumetricLightScatteringRTT;
  73023. private _viewPort;
  73024. private _screenCoordinates;
  73025. private _cachedDefines;
  73026. /**
  73027. * If not undefined, the mesh position is computed from the attached node position
  73028. */
  73029. attachedNode: {
  73030. position: Vector3;
  73031. };
  73032. /**
  73033. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  73034. */
  73035. customMeshPosition: Vector3;
  73036. /**
  73037. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  73038. */
  73039. useCustomMeshPosition: boolean;
  73040. /**
  73041. * If the post-process should inverse the light scattering direction
  73042. */
  73043. invert: boolean;
  73044. /**
  73045. * The internal mesh used by the post-process
  73046. */
  73047. mesh: Mesh;
  73048. /**
  73049. * @hidden
  73050. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  73051. */
  73052. get useDiffuseColor(): boolean;
  73053. set useDiffuseColor(useDiffuseColor: boolean);
  73054. /**
  73055. * Array containing the excluded meshes not rendered in the internal pass
  73056. */
  73057. excludedMeshes: AbstractMesh[];
  73058. /**
  73059. * Controls the overall intensity of the post-process
  73060. */
  73061. exposure: number;
  73062. /**
  73063. * Dissipates each sample's contribution in range [0, 1]
  73064. */
  73065. decay: number;
  73066. /**
  73067. * Controls the overall intensity of each sample
  73068. */
  73069. weight: number;
  73070. /**
  73071. * Controls the density of each sample
  73072. */
  73073. density: number;
  73074. /**
  73075. * @constructor
  73076. * @param name The post-process name
  73077. * @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)
  73078. * @param camera The camera that the post-process will be attached to
  73079. * @param mesh The mesh used to create the light scattering
  73080. * @param samples The post-process quality, default 100
  73081. * @param samplingModeThe post-process filtering mode
  73082. * @param engine The babylon engine
  73083. * @param reusable If the post-process is reusable
  73084. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  73085. */
  73086. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  73087. /**
  73088. * Returns the string "VolumetricLightScatteringPostProcess"
  73089. * @returns "VolumetricLightScatteringPostProcess"
  73090. */
  73091. getClassName(): string;
  73092. private _isReady;
  73093. /**
  73094. * Sets the new light position for light scattering effect
  73095. * @param position The new custom light position
  73096. */
  73097. setCustomMeshPosition(position: Vector3): void;
  73098. /**
  73099. * Returns the light position for light scattering effect
  73100. * @return Vector3 The custom light position
  73101. */
  73102. getCustomMeshPosition(): Vector3;
  73103. /**
  73104. * Disposes the internal assets and detaches the post-process from the camera
  73105. */
  73106. dispose(camera: Camera): void;
  73107. /**
  73108. * Returns the render target texture used by the post-process
  73109. * @return the render target texture used by the post-process
  73110. */
  73111. getPass(): RenderTargetTexture;
  73112. private _meshExcluded;
  73113. private _createPass;
  73114. private _updateMeshScreenCoordinates;
  73115. /**
  73116. * Creates a default mesh for the Volumeric Light Scattering post-process
  73117. * @param name The mesh name
  73118. * @param scene The scene where to create the mesh
  73119. * @return the default mesh
  73120. */
  73121. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  73122. }
  73123. }
  73124. declare module BABYLON {
  73125. /** @hidden */
  73126. export var screenSpaceCurvaturePixelShader: {
  73127. name: string;
  73128. shader: string;
  73129. };
  73130. }
  73131. declare module BABYLON {
  73132. /**
  73133. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  73134. */
  73135. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  73136. /**
  73137. * Defines how much ridge the curvature effect displays.
  73138. */
  73139. ridge: number;
  73140. /**
  73141. * Defines how much valley the curvature effect displays.
  73142. */
  73143. valley: number;
  73144. private _geometryBufferRenderer;
  73145. /**
  73146. * Gets a string identifying the name of the class
  73147. * @returns "ScreenSpaceCurvaturePostProcess" string
  73148. */
  73149. getClassName(): string;
  73150. /**
  73151. * Creates a new instance ScreenSpaceCurvaturePostProcess
  73152. * @param name The name of the effect.
  73153. * @param scene The scene containing the objects to blur according to their velocity.
  73154. * @param options The required width/height ratio to downsize to before computing the render pass.
  73155. * @param camera The camera to apply the render pass to.
  73156. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73157. * @param engine The engine which the post process will be applied. (default: current engine)
  73158. * @param reusable If the post process can be reused on the same frame. (default: false)
  73159. * @param textureType Type of textures used when performing the post process. (default: 0)
  73160. * @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)
  73161. */
  73162. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73163. /**
  73164. * Support test.
  73165. */
  73166. static get IsSupported(): boolean;
  73167. /** @hidden */
  73168. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  73169. }
  73170. }
  73171. declare module BABYLON {
  73172. interface Scene {
  73173. /** @hidden (Backing field) */
  73174. _boundingBoxRenderer: BoundingBoxRenderer;
  73175. /** @hidden (Backing field) */
  73176. _forceShowBoundingBoxes: boolean;
  73177. /**
  73178. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  73179. */
  73180. forceShowBoundingBoxes: boolean;
  73181. /**
  73182. * Gets the bounding box renderer associated with the scene
  73183. * @returns a BoundingBoxRenderer
  73184. */
  73185. getBoundingBoxRenderer(): BoundingBoxRenderer;
  73186. }
  73187. interface AbstractMesh {
  73188. /** @hidden (Backing field) */
  73189. _showBoundingBox: boolean;
  73190. /**
  73191. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  73192. */
  73193. showBoundingBox: boolean;
  73194. }
  73195. /**
  73196. * Component responsible of rendering the bounding box of the meshes in a scene.
  73197. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  73198. */
  73199. export class BoundingBoxRenderer implements ISceneComponent {
  73200. /**
  73201. * The component name helpfull to identify the component in the list of scene components.
  73202. */
  73203. readonly name: string;
  73204. /**
  73205. * The scene the component belongs to.
  73206. */
  73207. scene: Scene;
  73208. /**
  73209. * Color of the bounding box lines placed in front of an object
  73210. */
  73211. frontColor: Color3;
  73212. /**
  73213. * Color of the bounding box lines placed behind an object
  73214. */
  73215. backColor: Color3;
  73216. /**
  73217. * Defines if the renderer should show the back lines or not
  73218. */
  73219. showBackLines: boolean;
  73220. /**
  73221. * Observable raised before rendering a bounding box
  73222. */
  73223. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  73224. /**
  73225. * Observable raised after rendering a bounding box
  73226. */
  73227. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  73228. /**
  73229. * Observable raised after resources are created
  73230. */
  73231. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  73232. /**
  73233. * When false, no bounding boxes will be rendered
  73234. */
  73235. enabled: boolean;
  73236. /**
  73237. * @hidden
  73238. */
  73239. renderList: SmartArray<BoundingBox>;
  73240. private _colorShader;
  73241. private _vertexBuffers;
  73242. private _indexBuffer;
  73243. private _fillIndexBuffer;
  73244. private _fillIndexData;
  73245. /**
  73246. * Instantiates a new bounding box renderer in a scene.
  73247. * @param scene the scene the renderer renders in
  73248. */
  73249. constructor(scene: Scene);
  73250. /**
  73251. * Registers the component in a given scene
  73252. */
  73253. register(): void;
  73254. private _evaluateSubMesh;
  73255. private _preActiveMesh;
  73256. private _prepareResources;
  73257. private _createIndexBuffer;
  73258. /**
  73259. * Rebuilds the elements related to this component in case of
  73260. * context lost for instance.
  73261. */
  73262. rebuild(): void;
  73263. /**
  73264. * @hidden
  73265. */
  73266. reset(): void;
  73267. /**
  73268. * Render the bounding boxes of a specific rendering group
  73269. * @param renderingGroupId defines the rendering group to render
  73270. */
  73271. render(renderingGroupId: number): void;
  73272. /**
  73273. * In case of occlusion queries, we can render the occlusion bounding box through this method
  73274. * @param mesh Define the mesh to render the occlusion bounding box for
  73275. */
  73276. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  73277. /**
  73278. * Dispose and release the resources attached to this renderer.
  73279. */
  73280. dispose(): void;
  73281. }
  73282. }
  73283. declare module BABYLON {
  73284. interface Scene {
  73285. /** @hidden (Backing field) */
  73286. _depthRenderer: {
  73287. [id: string]: DepthRenderer;
  73288. };
  73289. /**
  73290. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  73291. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  73292. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  73293. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  73294. * @returns the created depth renderer
  73295. */
  73296. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  73297. /**
  73298. * Disables a depth renderer for a given camera
  73299. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  73300. */
  73301. disableDepthRenderer(camera?: Nullable<Camera>): void;
  73302. }
  73303. /**
  73304. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  73305. * in several rendering techniques.
  73306. */
  73307. export class DepthRendererSceneComponent implements ISceneComponent {
  73308. /**
  73309. * The component name helpfull to identify the component in the list of scene components.
  73310. */
  73311. readonly name: string;
  73312. /**
  73313. * The scene the component belongs to.
  73314. */
  73315. scene: Scene;
  73316. /**
  73317. * Creates a new instance of the component for the given scene
  73318. * @param scene Defines the scene to register the component in
  73319. */
  73320. constructor(scene: Scene);
  73321. /**
  73322. * Registers the component in a given scene
  73323. */
  73324. register(): void;
  73325. /**
  73326. * Rebuilds the elements related to this component in case of
  73327. * context lost for instance.
  73328. */
  73329. rebuild(): void;
  73330. /**
  73331. * Disposes the component and the associated ressources
  73332. */
  73333. dispose(): void;
  73334. private _gatherRenderTargets;
  73335. private _gatherActiveCameraRenderTargets;
  73336. }
  73337. }
  73338. declare module BABYLON {
  73339. interface AbstractScene {
  73340. /** @hidden (Backing field) */
  73341. _prePassRenderer: Nullable<PrePassRenderer>;
  73342. /**
  73343. * Gets or Sets the current prepass renderer associated to the scene.
  73344. */
  73345. prePassRenderer: Nullable<PrePassRenderer>;
  73346. /**
  73347. * Enables the prepass and associates it with the scene
  73348. * @returns the PrePassRenderer
  73349. */
  73350. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  73351. /**
  73352. * Disables the prepass associated with the scene
  73353. */
  73354. disablePrePassRenderer(): void;
  73355. }
  73356. /**
  73357. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73358. * in several rendering techniques.
  73359. */
  73360. export class PrePassRendererSceneComponent implements ISceneComponent {
  73361. /**
  73362. * The component name helpful to identify the component in the list of scene components.
  73363. */
  73364. readonly name: string;
  73365. /**
  73366. * The scene the component belongs to.
  73367. */
  73368. scene: Scene;
  73369. /**
  73370. * Creates a new instance of the component for the given scene
  73371. * @param scene Defines the scene to register the component in
  73372. */
  73373. constructor(scene: Scene);
  73374. /**
  73375. * Registers the component in a given scene
  73376. */
  73377. register(): void;
  73378. private _beforeCameraDraw;
  73379. private _afterCameraDraw;
  73380. private _beforeClearStage;
  73381. private _beforeRenderingMeshStage;
  73382. private _afterRenderingMeshStage;
  73383. /**
  73384. * Rebuilds the elements related to this component in case of
  73385. * context lost for instance.
  73386. */
  73387. rebuild(): void;
  73388. /**
  73389. * Disposes the component and the associated ressources
  73390. */
  73391. dispose(): void;
  73392. }
  73393. }
  73394. declare module BABYLON {
  73395. /** @hidden */
  73396. export var fibonacci: {
  73397. name: string;
  73398. shader: string;
  73399. };
  73400. }
  73401. declare module BABYLON {
  73402. /** @hidden */
  73403. export var diffusionProfile: {
  73404. name: string;
  73405. shader: string;
  73406. };
  73407. }
  73408. declare module BABYLON {
  73409. /** @hidden */
  73410. export var subSurfaceScatteringPixelShader: {
  73411. name: string;
  73412. shader: string;
  73413. };
  73414. }
  73415. declare module BABYLON {
  73416. /**
  73417. * Sub surface scattering post process
  73418. */
  73419. export class SubSurfaceScatteringPostProcess extends PostProcess {
  73420. /**
  73421. * Gets a string identifying the name of the class
  73422. * @returns "SubSurfaceScatteringPostProcess" string
  73423. */
  73424. getClassName(): string;
  73425. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73426. }
  73427. }
  73428. declare module BABYLON {
  73429. /**
  73430. * Contains all parameters needed for the prepass to perform
  73431. * screen space subsurface scattering
  73432. */
  73433. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  73434. /** @hidden */
  73435. static _SceneComponentInitialization: (scene: Scene) => void;
  73436. private _ssDiffusionS;
  73437. private _ssFilterRadii;
  73438. private _ssDiffusionD;
  73439. /**
  73440. * Post process to attach for screen space subsurface scattering
  73441. */
  73442. postProcess: SubSurfaceScatteringPostProcess;
  73443. /**
  73444. * Diffusion profile color for subsurface scattering
  73445. */
  73446. get ssDiffusionS(): number[];
  73447. /**
  73448. * Diffusion profile max color channel value for subsurface scattering
  73449. */
  73450. get ssDiffusionD(): number[];
  73451. /**
  73452. * Diffusion profile filter radius for subsurface scattering
  73453. */
  73454. get ssFilterRadii(): number[];
  73455. /**
  73456. * Is subsurface enabled
  73457. */
  73458. enabled: boolean;
  73459. /**
  73460. * Name of the configuration
  73461. */
  73462. name: string;
  73463. /**
  73464. * Diffusion profile colors for subsurface scattering
  73465. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  73466. * See ...
  73467. * Note that you can only store up to 5 of them
  73468. */
  73469. ssDiffusionProfileColors: Color3[];
  73470. /**
  73471. * Defines the ratio real world => scene units.
  73472. * Used for subsurface scattering
  73473. */
  73474. metersPerUnit: number;
  73475. /**
  73476. * Textures that should be present in the MRT for this effect to work
  73477. */
  73478. readonly texturesRequired: number[];
  73479. private _scene;
  73480. /**
  73481. * Builds a subsurface configuration object
  73482. * @param scene The scene
  73483. */
  73484. constructor(scene: Scene);
  73485. /**
  73486. * Adds a new diffusion profile.
  73487. * Useful for more realistic subsurface scattering on diverse materials.
  73488. * @param color The color of the diffusion profile. Should be the average color of the material.
  73489. * @return The index of the diffusion profile for the material subsurface configuration
  73490. */
  73491. addDiffusionProfile(color: Color3): number;
  73492. /**
  73493. * Creates the sss post process
  73494. * @return The created post process
  73495. */
  73496. createPostProcess(): SubSurfaceScatteringPostProcess;
  73497. /**
  73498. * Deletes all diffusion profiles.
  73499. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  73500. */
  73501. clearAllDiffusionProfiles(): void;
  73502. /**
  73503. * Disposes this object
  73504. */
  73505. dispose(): void;
  73506. /**
  73507. * @hidden
  73508. * https://zero-radiance.github.io/post/sampling-diffusion/
  73509. *
  73510. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  73511. * ------------------------------------------------------------------------------------
  73512. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  73513. * PDF[r, phi, s] = r * R[r, phi, s]
  73514. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  73515. * ------------------------------------------------------------------------------------
  73516. * We importance sample the color channel with the widest scattering distance.
  73517. */
  73518. getDiffusionProfileParameters(color: Color3): number;
  73519. /**
  73520. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  73521. * 'u' is the random number (the value of the CDF): [0, 1).
  73522. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  73523. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  73524. */
  73525. private _sampleBurleyDiffusionProfile;
  73526. }
  73527. }
  73528. declare module BABYLON {
  73529. interface AbstractScene {
  73530. /** @hidden (Backing field) */
  73531. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  73532. /**
  73533. * Gets or Sets the current prepass renderer associated to the scene.
  73534. */
  73535. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  73536. /**
  73537. * Enables the subsurface effect for prepass
  73538. * @returns the SubSurfaceConfiguration
  73539. */
  73540. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  73541. /**
  73542. * Disables the subsurface effect for prepass
  73543. */
  73544. disableSubSurfaceForPrePass(): void;
  73545. }
  73546. /**
  73547. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73548. * in several rendering techniques.
  73549. */
  73550. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  73551. /**
  73552. * The component name helpful to identify the component in the list of scene components.
  73553. */
  73554. readonly name: string;
  73555. /**
  73556. * The scene the component belongs to.
  73557. */
  73558. scene: Scene;
  73559. /**
  73560. * Creates a new instance of the component for the given scene
  73561. * @param scene Defines the scene to register the component in
  73562. */
  73563. constructor(scene: Scene);
  73564. /**
  73565. * Registers the component in a given scene
  73566. */
  73567. register(): void;
  73568. /**
  73569. * Serializes the component data to the specified json object
  73570. * @param serializationObject The object to serialize to
  73571. */
  73572. serialize(serializationObject: any): void;
  73573. /**
  73574. * Adds all the elements from the container to the scene
  73575. * @param container the container holding the elements
  73576. */
  73577. addFromContainer(container: AbstractScene): void;
  73578. /**
  73579. * Removes all the elements in the container from the scene
  73580. * @param container contains the elements to remove
  73581. * @param dispose if the removed element should be disposed (default: false)
  73582. */
  73583. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  73584. /**
  73585. * Rebuilds the elements related to this component in case of
  73586. * context lost for instance.
  73587. */
  73588. rebuild(): void;
  73589. /**
  73590. * Disposes the component and the associated ressources
  73591. */
  73592. dispose(): void;
  73593. }
  73594. }
  73595. declare module BABYLON {
  73596. /** @hidden */
  73597. export var outlinePixelShader: {
  73598. name: string;
  73599. shader: string;
  73600. };
  73601. }
  73602. declare module BABYLON {
  73603. /** @hidden */
  73604. export var outlineVertexShader: {
  73605. name: string;
  73606. shader: string;
  73607. };
  73608. }
  73609. declare module BABYLON {
  73610. interface Scene {
  73611. /** @hidden */
  73612. _outlineRenderer: OutlineRenderer;
  73613. /**
  73614. * Gets the outline renderer associated with the scene
  73615. * @returns a OutlineRenderer
  73616. */
  73617. getOutlineRenderer(): OutlineRenderer;
  73618. }
  73619. interface AbstractMesh {
  73620. /** @hidden (Backing field) */
  73621. _renderOutline: boolean;
  73622. /**
  73623. * Gets or sets a boolean indicating if the outline must be rendered as well
  73624. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  73625. */
  73626. renderOutline: boolean;
  73627. /** @hidden (Backing field) */
  73628. _renderOverlay: boolean;
  73629. /**
  73630. * Gets or sets a boolean indicating if the overlay must be rendered as well
  73631. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  73632. */
  73633. renderOverlay: boolean;
  73634. }
  73635. /**
  73636. * This class is responsible to draw bothe outline/overlay of meshes.
  73637. * It should not be used directly but through the available method on mesh.
  73638. */
  73639. export class OutlineRenderer implements ISceneComponent {
  73640. /**
  73641. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  73642. */
  73643. private static _StencilReference;
  73644. /**
  73645. * The name of the component. Each component must have a unique name.
  73646. */
  73647. name: string;
  73648. /**
  73649. * The scene the component belongs to.
  73650. */
  73651. scene: Scene;
  73652. /**
  73653. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  73654. */
  73655. zOffset: number;
  73656. private _engine;
  73657. private _effect;
  73658. private _cachedDefines;
  73659. private _savedDepthWrite;
  73660. /**
  73661. * Instantiates a new outline renderer. (There could be only one per scene).
  73662. * @param scene Defines the scene it belongs to
  73663. */
  73664. constructor(scene: Scene);
  73665. /**
  73666. * Register the component to one instance of a scene.
  73667. */
  73668. register(): void;
  73669. /**
  73670. * Rebuilds the elements related to this component in case of
  73671. * context lost for instance.
  73672. */
  73673. rebuild(): void;
  73674. /**
  73675. * Disposes the component and the associated ressources.
  73676. */
  73677. dispose(): void;
  73678. /**
  73679. * Renders the outline in the canvas.
  73680. * @param subMesh Defines the sumesh to render
  73681. * @param batch Defines the batch of meshes in case of instances
  73682. * @param useOverlay Defines if the rendering is for the overlay or the outline
  73683. */
  73684. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  73685. /**
  73686. * Returns whether or not the outline renderer is ready for a given submesh.
  73687. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  73688. * @param subMesh Defines the submesh to check readyness for
  73689. * @param useInstances Defines wheter wee are trying to render instances or not
  73690. * @returns true if ready otherwise false
  73691. */
  73692. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73693. private _beforeRenderingMesh;
  73694. private _afterRenderingMesh;
  73695. }
  73696. }
  73697. declare module BABYLON {
  73698. /**
  73699. * Defines the basic options interface of a Sprite Frame Source Size.
  73700. */
  73701. export interface ISpriteJSONSpriteSourceSize {
  73702. /**
  73703. * number of the original width of the Frame
  73704. */
  73705. w: number;
  73706. /**
  73707. * number of the original height of the Frame
  73708. */
  73709. h: number;
  73710. }
  73711. /**
  73712. * Defines the basic options interface of a Sprite Frame Data.
  73713. */
  73714. export interface ISpriteJSONSpriteFrameData {
  73715. /**
  73716. * number of the x offset of the Frame
  73717. */
  73718. x: number;
  73719. /**
  73720. * number of the y offset of the Frame
  73721. */
  73722. y: number;
  73723. /**
  73724. * number of the width of the Frame
  73725. */
  73726. w: number;
  73727. /**
  73728. * number of the height of the Frame
  73729. */
  73730. h: number;
  73731. }
  73732. /**
  73733. * Defines the basic options interface of a JSON Sprite.
  73734. */
  73735. export interface ISpriteJSONSprite {
  73736. /**
  73737. * string name of the Frame
  73738. */
  73739. filename: string;
  73740. /**
  73741. * ISpriteJSONSpriteFrame basic object of the frame data
  73742. */
  73743. frame: ISpriteJSONSpriteFrameData;
  73744. /**
  73745. * boolean to flag is the frame was rotated.
  73746. */
  73747. rotated: boolean;
  73748. /**
  73749. * boolean to flag is the frame was trimmed.
  73750. */
  73751. trimmed: boolean;
  73752. /**
  73753. * ISpriteJSONSpriteFrame basic object of the source data
  73754. */
  73755. spriteSourceSize: ISpriteJSONSpriteFrameData;
  73756. /**
  73757. * ISpriteJSONSpriteFrame basic object of the source data
  73758. */
  73759. sourceSize: ISpriteJSONSpriteSourceSize;
  73760. }
  73761. /**
  73762. * Defines the basic options interface of a JSON atlas.
  73763. */
  73764. export interface ISpriteJSONAtlas {
  73765. /**
  73766. * Array of objects that contain the frame data.
  73767. */
  73768. frames: Array<ISpriteJSONSprite>;
  73769. /**
  73770. * object basic object containing the sprite meta data.
  73771. */
  73772. meta?: object;
  73773. }
  73774. }
  73775. declare module BABYLON {
  73776. /** @hidden */
  73777. export var spriteMapPixelShader: {
  73778. name: string;
  73779. shader: string;
  73780. };
  73781. }
  73782. declare module BABYLON {
  73783. /** @hidden */
  73784. export var spriteMapVertexShader: {
  73785. name: string;
  73786. shader: string;
  73787. };
  73788. }
  73789. declare module BABYLON {
  73790. /**
  73791. * Defines the basic options interface of a SpriteMap
  73792. */
  73793. export interface ISpriteMapOptions {
  73794. /**
  73795. * Vector2 of the number of cells in the grid.
  73796. */
  73797. stageSize?: Vector2;
  73798. /**
  73799. * Vector2 of the size of the output plane in World Units.
  73800. */
  73801. outputSize?: Vector2;
  73802. /**
  73803. * Vector3 of the position of the output plane in World Units.
  73804. */
  73805. outputPosition?: Vector3;
  73806. /**
  73807. * Vector3 of the rotation of the output plane.
  73808. */
  73809. outputRotation?: Vector3;
  73810. /**
  73811. * number of layers that the system will reserve in resources.
  73812. */
  73813. layerCount?: number;
  73814. /**
  73815. * number of max animation frames a single cell will reserve in resources.
  73816. */
  73817. maxAnimationFrames?: number;
  73818. /**
  73819. * number cell index of the base tile when the system compiles.
  73820. */
  73821. baseTile?: number;
  73822. /**
  73823. * boolean flip the sprite after its been repositioned by the framing data.
  73824. */
  73825. flipU?: boolean;
  73826. /**
  73827. * Vector3 scalar of the global RGB values of the SpriteMap.
  73828. */
  73829. colorMultiply?: Vector3;
  73830. }
  73831. /**
  73832. * Defines the IDisposable interface in order to be cleanable from resources.
  73833. */
  73834. export interface ISpriteMap extends IDisposable {
  73835. /**
  73836. * String name of the SpriteMap.
  73837. */
  73838. name: string;
  73839. /**
  73840. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  73841. */
  73842. atlasJSON: ISpriteJSONAtlas;
  73843. /**
  73844. * Texture of the SpriteMap.
  73845. */
  73846. spriteSheet: Texture;
  73847. /**
  73848. * The parameters to initialize the SpriteMap with.
  73849. */
  73850. options: ISpriteMapOptions;
  73851. }
  73852. /**
  73853. * Class used to manage a grid restricted sprite deployment on an Output plane.
  73854. */
  73855. export class SpriteMap implements ISpriteMap {
  73856. /** The Name of the spriteMap */
  73857. name: string;
  73858. /** The JSON file with the frame and meta data */
  73859. atlasJSON: ISpriteJSONAtlas;
  73860. /** The systems Sprite Sheet Texture */
  73861. spriteSheet: Texture;
  73862. /** Arguments passed with the Constructor */
  73863. options: ISpriteMapOptions;
  73864. /** Public Sprite Storage array, parsed from atlasJSON */
  73865. sprites: Array<ISpriteJSONSprite>;
  73866. /** Returns the Number of Sprites in the System */
  73867. get spriteCount(): number;
  73868. /** Returns the Position of Output Plane*/
  73869. get position(): Vector3;
  73870. /** Returns the Position of Output Plane*/
  73871. set position(v: Vector3);
  73872. /** Returns the Rotation of Output Plane*/
  73873. get rotation(): Vector3;
  73874. /** Returns the Rotation of Output Plane*/
  73875. set rotation(v: Vector3);
  73876. /** Sets the AnimationMap*/
  73877. get animationMap(): RawTexture;
  73878. /** Sets the AnimationMap*/
  73879. set animationMap(v: RawTexture);
  73880. /** Scene that the SpriteMap was created in */
  73881. private _scene;
  73882. /** Texture Buffer of Float32 that holds tile frame data*/
  73883. private _frameMap;
  73884. /** Texture Buffers of Float32 that holds tileMap data*/
  73885. private _tileMaps;
  73886. /** Texture Buffer of Float32 that holds Animation Data*/
  73887. private _animationMap;
  73888. /** Custom ShaderMaterial Central to the System*/
  73889. private _material;
  73890. /** Custom ShaderMaterial Central to the System*/
  73891. private _output;
  73892. /** Systems Time Ticker*/
  73893. private _time;
  73894. /**
  73895. * Creates a new SpriteMap
  73896. * @param name defines the SpriteMaps Name
  73897. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  73898. * @param spriteSheet is the Texture that the Sprites are on.
  73899. * @param options a basic deployment configuration
  73900. * @param scene The Scene that the map is deployed on
  73901. */
  73902. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  73903. /**
  73904. * Returns tileID location
  73905. * @returns Vector2 the cell position ID
  73906. */
  73907. getTileID(): Vector2;
  73908. /**
  73909. * Gets the UV location of the mouse over the SpriteMap.
  73910. * @returns Vector2 the UV position of the mouse interaction
  73911. */
  73912. getMousePosition(): Vector2;
  73913. /**
  73914. * Creates the "frame" texture Buffer
  73915. * -------------------------------------
  73916. * Structure of frames
  73917. * "filename": "Falling-Water-2.png",
  73918. * "frame": {"x":69,"y":103,"w":24,"h":32},
  73919. * "rotated": true,
  73920. * "trimmed": true,
  73921. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  73922. * "sourceSize": {"w":32,"h":32}
  73923. * @returns RawTexture of the frameMap
  73924. */
  73925. private _createFrameBuffer;
  73926. /**
  73927. * Creates the tileMap texture Buffer
  73928. * @param buffer normally and array of numbers, or a false to generate from scratch
  73929. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  73930. * @returns RawTexture of the tileMap
  73931. */
  73932. private _createTileBuffer;
  73933. /**
  73934. * Modifies the data of the tileMaps
  73935. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  73936. * @param pos is the iVector2 Coordinates of the Tile
  73937. * @param tile The SpriteIndex of the new Tile
  73938. */
  73939. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  73940. /**
  73941. * Creates the animationMap texture Buffer
  73942. * @param buffer normally and array of numbers, or a false to generate from scratch
  73943. * @returns RawTexture of the animationMap
  73944. */
  73945. private _createTileAnimationBuffer;
  73946. /**
  73947. * Modifies the data of the animationMap
  73948. * @param cellID is the Index of the Sprite
  73949. * @param _frame is the target Animation frame
  73950. * @param toCell is the Target Index of the next frame of the animation
  73951. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  73952. * @param speed is a global scalar of the time variable on the map.
  73953. */
  73954. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  73955. /**
  73956. * Exports the .tilemaps file
  73957. */
  73958. saveTileMaps(): void;
  73959. /**
  73960. * Imports the .tilemaps file
  73961. * @param url of the .tilemaps file
  73962. */
  73963. loadTileMaps(url: string): void;
  73964. /**
  73965. * Release associated resources
  73966. */
  73967. dispose(): void;
  73968. }
  73969. }
  73970. declare module BABYLON {
  73971. /**
  73972. * Class used to manage multiple sprites of different sizes on the same spritesheet
  73973. * @see https://doc.babylonjs.com/babylon101/sprites
  73974. */
  73975. export class SpritePackedManager extends SpriteManager {
  73976. /** defines the packed manager's name */
  73977. name: string;
  73978. /**
  73979. * Creates a new sprite manager from a packed sprite sheet
  73980. * @param name defines the manager's name
  73981. * @param imgUrl defines the sprite sheet url
  73982. * @param capacity defines the maximum allowed number of sprites
  73983. * @param scene defines the hosting scene
  73984. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  73985. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  73986. * @param samplingMode defines the smapling mode to use with spritesheet
  73987. * @param fromPacked set to true; do not alter
  73988. */
  73989. constructor(
  73990. /** defines the packed manager's name */
  73991. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  73992. }
  73993. }
  73994. declare module BABYLON {
  73995. /**
  73996. * Defines the list of states available for a task inside a AssetsManager
  73997. */
  73998. export enum AssetTaskState {
  73999. /**
  74000. * Initialization
  74001. */
  74002. INIT = 0,
  74003. /**
  74004. * Running
  74005. */
  74006. RUNNING = 1,
  74007. /**
  74008. * Done
  74009. */
  74010. DONE = 2,
  74011. /**
  74012. * Error
  74013. */
  74014. ERROR = 3
  74015. }
  74016. /**
  74017. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  74018. */
  74019. export abstract class AbstractAssetTask {
  74020. /**
  74021. * Task name
  74022. */ name: string;
  74023. /**
  74024. * Callback called when the task is successful
  74025. */
  74026. onSuccess: (task: any) => void;
  74027. /**
  74028. * Callback called when the task is not successful
  74029. */
  74030. onError: (task: any, message?: string, exception?: any) => void;
  74031. /**
  74032. * Creates a new AssetsManager
  74033. * @param name defines the name of the task
  74034. */
  74035. constructor(
  74036. /**
  74037. * Task name
  74038. */ name: string);
  74039. private _isCompleted;
  74040. private _taskState;
  74041. private _errorObject;
  74042. /**
  74043. * Get if the task is completed
  74044. */
  74045. get isCompleted(): boolean;
  74046. /**
  74047. * Gets the current state of the task
  74048. */
  74049. get taskState(): AssetTaskState;
  74050. /**
  74051. * Gets the current error object (if task is in error)
  74052. */
  74053. get errorObject(): {
  74054. message?: string;
  74055. exception?: any;
  74056. };
  74057. /**
  74058. * Internal only
  74059. * @hidden
  74060. */
  74061. _setErrorObject(message?: string, exception?: any): void;
  74062. /**
  74063. * Execute the current task
  74064. * @param scene defines the scene where you want your assets to be loaded
  74065. * @param onSuccess is a callback called when the task is successfully executed
  74066. * @param onError is a callback called if an error occurs
  74067. */
  74068. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74069. /**
  74070. * Execute the current task
  74071. * @param scene defines the scene where you want your assets to be loaded
  74072. * @param onSuccess is a callback called when the task is successfully executed
  74073. * @param onError is a callback called if an error occurs
  74074. */
  74075. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74076. /**
  74077. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  74078. * This can be used with failed tasks that have the reason for failure fixed.
  74079. */
  74080. reset(): void;
  74081. private onErrorCallback;
  74082. private onDoneCallback;
  74083. }
  74084. /**
  74085. * Define the interface used by progress events raised during assets loading
  74086. */
  74087. export interface IAssetsProgressEvent {
  74088. /**
  74089. * Defines the number of remaining tasks to process
  74090. */
  74091. remainingCount: number;
  74092. /**
  74093. * Defines the total number of tasks
  74094. */
  74095. totalCount: number;
  74096. /**
  74097. * Defines the task that was just processed
  74098. */
  74099. task: AbstractAssetTask;
  74100. }
  74101. /**
  74102. * Class used to share progress information about assets loading
  74103. */
  74104. export class AssetsProgressEvent implements IAssetsProgressEvent {
  74105. /**
  74106. * Defines the number of remaining tasks to process
  74107. */
  74108. remainingCount: number;
  74109. /**
  74110. * Defines the total number of tasks
  74111. */
  74112. totalCount: number;
  74113. /**
  74114. * Defines the task that was just processed
  74115. */
  74116. task: AbstractAssetTask;
  74117. /**
  74118. * Creates a AssetsProgressEvent
  74119. * @param remainingCount defines the number of remaining tasks to process
  74120. * @param totalCount defines the total number of tasks
  74121. * @param task defines the task that was just processed
  74122. */
  74123. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  74124. }
  74125. /**
  74126. * Define a task used by AssetsManager to load assets into a container
  74127. */
  74128. export class ContainerAssetTask extends AbstractAssetTask {
  74129. /**
  74130. * Defines the name of the task
  74131. */
  74132. name: string;
  74133. /**
  74134. * Defines the list of mesh's names you want to load
  74135. */
  74136. meshesNames: any;
  74137. /**
  74138. * Defines the root url to use as a base to load your meshes and associated resources
  74139. */
  74140. rootUrl: string;
  74141. /**
  74142. * Defines the filename or File of the scene to load from
  74143. */
  74144. sceneFilename: string | File;
  74145. /**
  74146. * Get the loaded asset container
  74147. */
  74148. loadedContainer: AssetContainer;
  74149. /**
  74150. * Gets the list of loaded meshes
  74151. */
  74152. loadedMeshes: Array<AbstractMesh>;
  74153. /**
  74154. * Gets the list of loaded particle systems
  74155. */
  74156. loadedParticleSystems: Array<IParticleSystem>;
  74157. /**
  74158. * Gets the list of loaded skeletons
  74159. */
  74160. loadedSkeletons: Array<Skeleton>;
  74161. /**
  74162. * Gets the list of loaded animation groups
  74163. */
  74164. loadedAnimationGroups: Array<AnimationGroup>;
  74165. /**
  74166. * Callback called when the task is successful
  74167. */
  74168. onSuccess: (task: ContainerAssetTask) => void;
  74169. /**
  74170. * Callback called when the task is successful
  74171. */
  74172. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  74173. /**
  74174. * Creates a new ContainerAssetTask
  74175. * @param name defines the name of the task
  74176. * @param meshesNames defines the list of mesh's names you want to load
  74177. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  74178. * @param sceneFilename defines the filename or File of the scene to load from
  74179. */
  74180. constructor(
  74181. /**
  74182. * Defines the name of the task
  74183. */
  74184. name: string,
  74185. /**
  74186. * Defines the list of mesh's names you want to load
  74187. */
  74188. meshesNames: any,
  74189. /**
  74190. * Defines the root url to use as a base to load your meshes and associated resources
  74191. */
  74192. rootUrl: string,
  74193. /**
  74194. * Defines the filename or File of the scene to load from
  74195. */
  74196. sceneFilename: string | File);
  74197. /**
  74198. * Execute the current task
  74199. * @param scene defines the scene where you want your assets to be loaded
  74200. * @param onSuccess is a callback called when the task is successfully executed
  74201. * @param onError is a callback called if an error occurs
  74202. */
  74203. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74204. }
  74205. /**
  74206. * Define a task used by AssetsManager to load meshes
  74207. */
  74208. export class MeshAssetTask extends AbstractAssetTask {
  74209. /**
  74210. * Defines the name of the task
  74211. */
  74212. name: string;
  74213. /**
  74214. * Defines the list of mesh's names you want to load
  74215. */
  74216. meshesNames: any;
  74217. /**
  74218. * Defines the root url to use as a base to load your meshes and associated resources
  74219. */
  74220. rootUrl: string;
  74221. /**
  74222. * Defines the filename or File of the scene to load from
  74223. */
  74224. sceneFilename: string | File;
  74225. /**
  74226. * Gets the list of loaded meshes
  74227. */
  74228. loadedMeshes: Array<AbstractMesh>;
  74229. /**
  74230. * Gets the list of loaded particle systems
  74231. */
  74232. loadedParticleSystems: Array<IParticleSystem>;
  74233. /**
  74234. * Gets the list of loaded skeletons
  74235. */
  74236. loadedSkeletons: Array<Skeleton>;
  74237. /**
  74238. * Gets the list of loaded animation groups
  74239. */
  74240. loadedAnimationGroups: Array<AnimationGroup>;
  74241. /**
  74242. * Callback called when the task is successful
  74243. */
  74244. onSuccess: (task: MeshAssetTask) => void;
  74245. /**
  74246. * Callback called when the task is successful
  74247. */
  74248. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  74249. /**
  74250. * Creates a new MeshAssetTask
  74251. * @param name defines the name of the task
  74252. * @param meshesNames defines the list of mesh's names you want to load
  74253. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  74254. * @param sceneFilename defines the filename or File of the scene to load from
  74255. */
  74256. constructor(
  74257. /**
  74258. * Defines the name of the task
  74259. */
  74260. name: string,
  74261. /**
  74262. * Defines the list of mesh's names you want to load
  74263. */
  74264. meshesNames: any,
  74265. /**
  74266. * Defines the root url to use as a base to load your meshes and associated resources
  74267. */
  74268. rootUrl: string,
  74269. /**
  74270. * Defines the filename or File of the scene to load from
  74271. */
  74272. sceneFilename: string | File);
  74273. /**
  74274. * Execute the current task
  74275. * @param scene defines the scene where you want your assets to be loaded
  74276. * @param onSuccess is a callback called when the task is successfully executed
  74277. * @param onError is a callback called if an error occurs
  74278. */
  74279. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74280. }
  74281. /**
  74282. * Define a task used by AssetsManager to load text content
  74283. */
  74284. export class TextFileAssetTask extends AbstractAssetTask {
  74285. /**
  74286. * Defines the name of the task
  74287. */
  74288. name: string;
  74289. /**
  74290. * Defines the location of the file to load
  74291. */
  74292. url: string;
  74293. /**
  74294. * Gets the loaded text string
  74295. */
  74296. text: string;
  74297. /**
  74298. * Callback called when the task is successful
  74299. */
  74300. onSuccess: (task: TextFileAssetTask) => void;
  74301. /**
  74302. * Callback called when the task is successful
  74303. */
  74304. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  74305. /**
  74306. * Creates a new TextFileAssetTask object
  74307. * @param name defines the name of the task
  74308. * @param url defines the location of the file to load
  74309. */
  74310. constructor(
  74311. /**
  74312. * Defines the name of the task
  74313. */
  74314. name: string,
  74315. /**
  74316. * Defines the location of the file to load
  74317. */
  74318. url: string);
  74319. /**
  74320. * Execute the current task
  74321. * @param scene defines the scene where you want your assets to be loaded
  74322. * @param onSuccess is a callback called when the task is successfully executed
  74323. * @param onError is a callback called if an error occurs
  74324. */
  74325. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74326. }
  74327. /**
  74328. * Define a task used by AssetsManager to load binary data
  74329. */
  74330. export class BinaryFileAssetTask extends AbstractAssetTask {
  74331. /**
  74332. * Defines the name of the task
  74333. */
  74334. name: string;
  74335. /**
  74336. * Defines the location of the file to load
  74337. */
  74338. url: string;
  74339. /**
  74340. * Gets the lodaded data (as an array buffer)
  74341. */
  74342. data: ArrayBuffer;
  74343. /**
  74344. * Callback called when the task is successful
  74345. */
  74346. onSuccess: (task: BinaryFileAssetTask) => void;
  74347. /**
  74348. * Callback called when the task is successful
  74349. */
  74350. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  74351. /**
  74352. * Creates a new BinaryFileAssetTask object
  74353. * @param name defines the name of the new task
  74354. * @param url defines the location of the file to load
  74355. */
  74356. constructor(
  74357. /**
  74358. * Defines the name of the task
  74359. */
  74360. name: string,
  74361. /**
  74362. * Defines the location of the file to load
  74363. */
  74364. url: string);
  74365. /**
  74366. * Execute the current task
  74367. * @param scene defines the scene where you want your assets to be loaded
  74368. * @param onSuccess is a callback called when the task is successfully executed
  74369. * @param onError is a callback called if an error occurs
  74370. */
  74371. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74372. }
  74373. /**
  74374. * Define a task used by AssetsManager to load images
  74375. */
  74376. export class ImageAssetTask extends AbstractAssetTask {
  74377. /**
  74378. * Defines the name of the task
  74379. */
  74380. name: string;
  74381. /**
  74382. * Defines the location of the image to load
  74383. */
  74384. url: string;
  74385. /**
  74386. * Gets the loaded images
  74387. */
  74388. image: HTMLImageElement;
  74389. /**
  74390. * Callback called when the task is successful
  74391. */
  74392. onSuccess: (task: ImageAssetTask) => void;
  74393. /**
  74394. * Callback called when the task is successful
  74395. */
  74396. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  74397. /**
  74398. * Creates a new ImageAssetTask
  74399. * @param name defines the name of the task
  74400. * @param url defines the location of the image to load
  74401. */
  74402. constructor(
  74403. /**
  74404. * Defines the name of the task
  74405. */
  74406. name: string,
  74407. /**
  74408. * Defines the location of the image to load
  74409. */
  74410. url: string);
  74411. /**
  74412. * Execute the current task
  74413. * @param scene defines the scene where you want your assets to be loaded
  74414. * @param onSuccess is a callback called when the task is successfully executed
  74415. * @param onError is a callback called if an error occurs
  74416. */
  74417. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74418. }
  74419. /**
  74420. * Defines the interface used by texture loading tasks
  74421. */
  74422. export interface ITextureAssetTask<TEX extends BaseTexture> {
  74423. /**
  74424. * Gets the loaded texture
  74425. */
  74426. texture: TEX;
  74427. }
  74428. /**
  74429. * Define a task used by AssetsManager to load 2D textures
  74430. */
  74431. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  74432. /**
  74433. * Defines the name of the task
  74434. */
  74435. name: string;
  74436. /**
  74437. * Defines the location of the file to load
  74438. */
  74439. url: string;
  74440. /**
  74441. * Defines if mipmap should not be generated (default is false)
  74442. */
  74443. noMipmap?: boolean | undefined;
  74444. /**
  74445. * Defines if texture must be inverted on Y axis (default is true)
  74446. */
  74447. invertY: boolean;
  74448. /**
  74449. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74450. */
  74451. samplingMode: number;
  74452. /**
  74453. * Gets the loaded texture
  74454. */
  74455. texture: Texture;
  74456. /**
  74457. * Callback called when the task is successful
  74458. */
  74459. onSuccess: (task: TextureAssetTask) => void;
  74460. /**
  74461. * Callback called when the task is successful
  74462. */
  74463. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  74464. /**
  74465. * Creates a new TextureAssetTask object
  74466. * @param name defines the name of the task
  74467. * @param url defines the location of the file to load
  74468. * @param noMipmap defines if mipmap should not be generated (default is false)
  74469. * @param invertY defines if texture must be inverted on Y axis (default is true)
  74470. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74471. */
  74472. constructor(
  74473. /**
  74474. * Defines the name of the task
  74475. */
  74476. name: string,
  74477. /**
  74478. * Defines the location of the file to load
  74479. */
  74480. url: string,
  74481. /**
  74482. * Defines if mipmap should not be generated (default is false)
  74483. */
  74484. noMipmap?: boolean | undefined,
  74485. /**
  74486. * Defines if texture must be inverted on Y axis (default is true)
  74487. */
  74488. invertY?: boolean,
  74489. /**
  74490. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74491. */
  74492. samplingMode?: number);
  74493. /**
  74494. * Execute the current task
  74495. * @param scene defines the scene where you want your assets to be loaded
  74496. * @param onSuccess is a callback called when the task is successfully executed
  74497. * @param onError is a callback called if an error occurs
  74498. */
  74499. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74500. }
  74501. /**
  74502. * Define a task used by AssetsManager to load cube textures
  74503. */
  74504. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  74505. /**
  74506. * Defines the name of the task
  74507. */
  74508. name: string;
  74509. /**
  74510. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74511. */
  74512. url: string;
  74513. /**
  74514. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74515. */
  74516. extensions?: string[] | undefined;
  74517. /**
  74518. * Defines if mipmaps should not be generated (default is false)
  74519. */
  74520. noMipmap?: boolean | undefined;
  74521. /**
  74522. * Defines the explicit list of files (undefined by default)
  74523. */
  74524. files?: string[] | undefined;
  74525. /**
  74526. * Gets the loaded texture
  74527. */
  74528. texture: CubeTexture;
  74529. /**
  74530. * Callback called when the task is successful
  74531. */
  74532. onSuccess: (task: CubeTextureAssetTask) => void;
  74533. /**
  74534. * Callback called when the task is successful
  74535. */
  74536. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  74537. /**
  74538. * Creates a new CubeTextureAssetTask
  74539. * @param name defines the name of the task
  74540. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74541. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74542. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74543. * @param files defines the explicit list of files (undefined by default)
  74544. */
  74545. constructor(
  74546. /**
  74547. * Defines the name of the task
  74548. */
  74549. name: string,
  74550. /**
  74551. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74552. */
  74553. url: string,
  74554. /**
  74555. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74556. */
  74557. extensions?: string[] | undefined,
  74558. /**
  74559. * Defines if mipmaps should not be generated (default is false)
  74560. */
  74561. noMipmap?: boolean | undefined,
  74562. /**
  74563. * Defines the explicit list of files (undefined by default)
  74564. */
  74565. files?: string[] | undefined);
  74566. /**
  74567. * Execute the current task
  74568. * @param scene defines the scene where you want your assets to be loaded
  74569. * @param onSuccess is a callback called when the task is successfully executed
  74570. * @param onError is a callback called if an error occurs
  74571. */
  74572. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74573. }
  74574. /**
  74575. * Define a task used by AssetsManager to load HDR cube textures
  74576. */
  74577. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  74578. /**
  74579. * Defines the name of the task
  74580. */
  74581. name: string;
  74582. /**
  74583. * Defines the location of the file to load
  74584. */
  74585. url: string;
  74586. /**
  74587. * Defines the desired size (the more it increases the longer the generation will be)
  74588. */
  74589. size: number;
  74590. /**
  74591. * Defines if mipmaps should not be generated (default is false)
  74592. */
  74593. noMipmap: boolean;
  74594. /**
  74595. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74596. */
  74597. generateHarmonics: boolean;
  74598. /**
  74599. * 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)
  74600. */
  74601. gammaSpace: boolean;
  74602. /**
  74603. * Internal Use Only
  74604. */
  74605. reserved: boolean;
  74606. /**
  74607. * Gets the loaded texture
  74608. */
  74609. texture: HDRCubeTexture;
  74610. /**
  74611. * Callback called when the task is successful
  74612. */
  74613. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  74614. /**
  74615. * Callback called when the task is successful
  74616. */
  74617. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  74618. /**
  74619. * Creates a new HDRCubeTextureAssetTask object
  74620. * @param name defines the name of the task
  74621. * @param url defines the location of the file to load
  74622. * @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.
  74623. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74624. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74625. * @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)
  74626. * @param reserved Internal use only
  74627. */
  74628. constructor(
  74629. /**
  74630. * Defines the name of the task
  74631. */
  74632. name: string,
  74633. /**
  74634. * Defines the location of the file to load
  74635. */
  74636. url: string,
  74637. /**
  74638. * Defines the desired size (the more it increases the longer the generation will be)
  74639. */
  74640. size: number,
  74641. /**
  74642. * Defines if mipmaps should not be generated (default is false)
  74643. */
  74644. noMipmap?: boolean,
  74645. /**
  74646. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74647. */
  74648. generateHarmonics?: boolean,
  74649. /**
  74650. * 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)
  74651. */
  74652. gammaSpace?: boolean,
  74653. /**
  74654. * Internal Use Only
  74655. */
  74656. reserved?: boolean);
  74657. /**
  74658. * Execute the current task
  74659. * @param scene defines the scene where you want your assets to be loaded
  74660. * @param onSuccess is a callback called when the task is successfully executed
  74661. * @param onError is a callback called if an error occurs
  74662. */
  74663. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74664. }
  74665. /**
  74666. * Define a task used by AssetsManager to load Equirectangular cube textures
  74667. */
  74668. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  74669. /**
  74670. * Defines the name of the task
  74671. */
  74672. name: string;
  74673. /**
  74674. * Defines the location of the file to load
  74675. */
  74676. url: string;
  74677. /**
  74678. * Defines the desired size (the more it increases the longer the generation will be)
  74679. */
  74680. size: number;
  74681. /**
  74682. * Defines if mipmaps should not be generated (default is false)
  74683. */
  74684. noMipmap: boolean;
  74685. /**
  74686. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74687. * but the standard material would require them in Gamma space) (default is true)
  74688. */
  74689. gammaSpace: boolean;
  74690. /**
  74691. * Gets the loaded texture
  74692. */
  74693. texture: EquiRectangularCubeTexture;
  74694. /**
  74695. * Callback called when the task is successful
  74696. */
  74697. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  74698. /**
  74699. * Callback called when the task is successful
  74700. */
  74701. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  74702. /**
  74703. * Creates a new EquiRectangularCubeTextureAssetTask object
  74704. * @param name defines the name of the task
  74705. * @param url defines the location of the file to load
  74706. * @param size defines the desired size (the more it increases the longer the generation will be)
  74707. * If the size is omitted this implies you are using a preprocessed cubemap.
  74708. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74709. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  74710. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  74711. * (default is true)
  74712. */
  74713. constructor(
  74714. /**
  74715. * Defines the name of the task
  74716. */
  74717. name: string,
  74718. /**
  74719. * Defines the location of the file to load
  74720. */
  74721. url: string,
  74722. /**
  74723. * Defines the desired size (the more it increases the longer the generation will be)
  74724. */
  74725. size: number,
  74726. /**
  74727. * Defines if mipmaps should not be generated (default is false)
  74728. */
  74729. noMipmap?: boolean,
  74730. /**
  74731. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74732. * but the standard material would require them in Gamma space) (default is true)
  74733. */
  74734. gammaSpace?: boolean);
  74735. /**
  74736. * Execute the current task
  74737. * @param scene defines the scene where you want your assets to be loaded
  74738. * @param onSuccess is a callback called when the task is successfully executed
  74739. * @param onError is a callback called if an error occurs
  74740. */
  74741. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74742. }
  74743. /**
  74744. * This class can be used to easily import assets into a scene
  74745. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  74746. */
  74747. export class AssetsManager {
  74748. private _scene;
  74749. private _isLoading;
  74750. protected _tasks: AbstractAssetTask[];
  74751. protected _waitingTasksCount: number;
  74752. protected _totalTasksCount: number;
  74753. /**
  74754. * Callback called when all tasks are processed
  74755. */
  74756. onFinish: (tasks: AbstractAssetTask[]) => void;
  74757. /**
  74758. * Callback called when a task is successful
  74759. */
  74760. onTaskSuccess: (task: AbstractAssetTask) => void;
  74761. /**
  74762. * Callback called when a task had an error
  74763. */
  74764. onTaskError: (task: AbstractAssetTask) => void;
  74765. /**
  74766. * Callback called when a task is done (whatever the result is)
  74767. */
  74768. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  74769. /**
  74770. * Observable called when all tasks are processed
  74771. */
  74772. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  74773. /**
  74774. * Observable called when a task had an error
  74775. */
  74776. onTaskErrorObservable: Observable<AbstractAssetTask>;
  74777. /**
  74778. * Observable called when all tasks were executed
  74779. */
  74780. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  74781. /**
  74782. * Observable called when a task is done (whatever the result is)
  74783. */
  74784. onProgressObservable: Observable<IAssetsProgressEvent>;
  74785. /**
  74786. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  74787. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  74788. */
  74789. useDefaultLoadingScreen: boolean;
  74790. /**
  74791. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  74792. * when all assets have been downloaded.
  74793. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  74794. */
  74795. autoHideLoadingUI: boolean;
  74796. /**
  74797. * Creates a new AssetsManager
  74798. * @param scene defines the scene to work on
  74799. */
  74800. constructor(scene: Scene);
  74801. /**
  74802. * Add a ContainerAssetTask to the list of active tasks
  74803. * @param taskName defines the name of the new task
  74804. * @param meshesNames defines the name of meshes to load
  74805. * @param rootUrl defines the root url to use to locate files
  74806. * @param sceneFilename defines the filename of the scene file
  74807. * @returns a new ContainerAssetTask object
  74808. */
  74809. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  74810. /**
  74811. * Add a MeshAssetTask to the list of active tasks
  74812. * @param taskName defines the name of the new task
  74813. * @param meshesNames defines the name of meshes to load
  74814. * @param rootUrl defines the root url to use to locate files
  74815. * @param sceneFilename defines the filename of the scene file
  74816. * @returns a new MeshAssetTask object
  74817. */
  74818. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  74819. /**
  74820. * Add a TextFileAssetTask to the list of active tasks
  74821. * @param taskName defines the name of the new task
  74822. * @param url defines the url of the file to load
  74823. * @returns a new TextFileAssetTask object
  74824. */
  74825. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  74826. /**
  74827. * Add a BinaryFileAssetTask to the list of active tasks
  74828. * @param taskName defines the name of the new task
  74829. * @param url defines the url of the file to load
  74830. * @returns a new BinaryFileAssetTask object
  74831. */
  74832. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  74833. /**
  74834. * Add a ImageAssetTask to the list of active tasks
  74835. * @param taskName defines the name of the new task
  74836. * @param url defines the url of the file to load
  74837. * @returns a new ImageAssetTask object
  74838. */
  74839. addImageTask(taskName: string, url: string): ImageAssetTask;
  74840. /**
  74841. * Add a TextureAssetTask to the list of active tasks
  74842. * @param taskName defines the name of the new task
  74843. * @param url defines the url of the file to load
  74844. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74845. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  74846. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  74847. * @returns a new TextureAssetTask object
  74848. */
  74849. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  74850. /**
  74851. * Add a CubeTextureAssetTask to the list of active tasks
  74852. * @param taskName defines the name of the new task
  74853. * @param url defines the url of the file to load
  74854. * @param extensions defines the extension to use to load the cube map (can be null)
  74855. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74856. * @param files defines the list of files to load (can be null)
  74857. * @returns a new CubeTextureAssetTask object
  74858. */
  74859. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  74860. /**
  74861. *
  74862. * Add a HDRCubeTextureAssetTask to the list of active tasks
  74863. * @param taskName defines the name of the new task
  74864. * @param url defines the url of the file to load
  74865. * @param size defines the size you want for the cubemap (can be null)
  74866. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74867. * @param generateHarmonics defines if you want to automatically generate (true by default)
  74868. * @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)
  74869. * @param reserved Internal use only
  74870. * @returns a new HDRCubeTextureAssetTask object
  74871. */
  74872. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  74873. /**
  74874. *
  74875. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  74876. * @param taskName defines the name of the new task
  74877. * @param url defines the url of the file to load
  74878. * @param size defines the size you want for the cubemap (can be null)
  74879. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74880. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  74881. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  74882. * @returns a new EquiRectangularCubeTextureAssetTask object
  74883. */
  74884. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  74885. /**
  74886. * Remove a task from the assets manager.
  74887. * @param task the task to remove
  74888. */
  74889. removeTask(task: AbstractAssetTask): void;
  74890. private _decreaseWaitingTasksCount;
  74891. private _runTask;
  74892. /**
  74893. * Reset the AssetsManager and remove all tasks
  74894. * @return the current instance of the AssetsManager
  74895. */
  74896. reset(): AssetsManager;
  74897. /**
  74898. * Start the loading process
  74899. * @return the current instance of the AssetsManager
  74900. */
  74901. load(): AssetsManager;
  74902. /**
  74903. * Start the loading process as an async operation
  74904. * @return a promise returning the list of failed tasks
  74905. */
  74906. loadAsync(): Promise<void>;
  74907. }
  74908. }
  74909. declare module BABYLON {
  74910. /**
  74911. * Wrapper class for promise with external resolve and reject.
  74912. */
  74913. export class Deferred<T> {
  74914. /**
  74915. * The promise associated with this deferred object.
  74916. */
  74917. readonly promise: Promise<T>;
  74918. private _resolve;
  74919. private _reject;
  74920. /**
  74921. * The resolve method of the promise associated with this deferred object.
  74922. */
  74923. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  74924. /**
  74925. * The reject method of the promise associated with this deferred object.
  74926. */
  74927. get reject(): (reason?: any) => void;
  74928. /**
  74929. * Constructor for this deferred object.
  74930. */
  74931. constructor();
  74932. }
  74933. }
  74934. declare module BABYLON {
  74935. /**
  74936. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  74937. */
  74938. export class MeshExploder {
  74939. private _centerMesh;
  74940. private _meshes;
  74941. private _meshesOrigins;
  74942. private _toCenterVectors;
  74943. private _scaledDirection;
  74944. private _newPosition;
  74945. private _centerPosition;
  74946. /**
  74947. * Explodes meshes from a center mesh.
  74948. * @param meshes The meshes to explode.
  74949. * @param centerMesh The mesh to be center of explosion.
  74950. */
  74951. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  74952. private _setCenterMesh;
  74953. /**
  74954. * Get class name
  74955. * @returns "MeshExploder"
  74956. */
  74957. getClassName(): string;
  74958. /**
  74959. * "Exploded meshes"
  74960. * @returns Array of meshes with the centerMesh at index 0.
  74961. */
  74962. getMeshes(): Array<Mesh>;
  74963. /**
  74964. * Explodes meshes giving a specific direction
  74965. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  74966. */
  74967. explode(direction?: number): void;
  74968. }
  74969. }
  74970. declare module BABYLON {
  74971. /**
  74972. * Class used to help managing file picking and drag'n'drop
  74973. */
  74974. export class FilesInput {
  74975. /**
  74976. * List of files ready to be loaded
  74977. */
  74978. static get FilesToLoad(): {
  74979. [key: string]: File;
  74980. };
  74981. /**
  74982. * Callback called when a file is processed
  74983. */
  74984. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  74985. private _engine;
  74986. private _currentScene;
  74987. private _sceneLoadedCallback;
  74988. private _progressCallback;
  74989. private _additionalRenderLoopLogicCallback;
  74990. private _textureLoadingCallback;
  74991. private _startingProcessingFilesCallback;
  74992. private _onReloadCallback;
  74993. private _errorCallback;
  74994. private _elementToMonitor;
  74995. private _sceneFileToLoad;
  74996. private _filesToLoad;
  74997. /**
  74998. * Creates a new FilesInput
  74999. * @param engine defines the rendering engine
  75000. * @param scene defines the hosting scene
  75001. * @param sceneLoadedCallback callback called when scene is loaded
  75002. * @param progressCallback callback called to track progress
  75003. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  75004. * @param textureLoadingCallback callback called when a texture is loading
  75005. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  75006. * @param onReloadCallback callback called when a reload is requested
  75007. * @param errorCallback callback call if an error occurs
  75008. */
  75009. constructor(engine: Engine, scene: Nullable<Scene>, sceneLoadedCallback: Nullable<(sceneFile: File, scene: Scene) => void>, progressCallback: Nullable<(progress: ISceneLoaderProgressEvent) => void>, additionalRenderLoopLogicCallback: Nullable<() => void>, textureLoadingCallback: Nullable<(remaining: number) => void>, startingProcessingFilesCallback: Nullable<(files?: File[]) => void>, onReloadCallback: Nullable<(sceneFile: File) => void>, errorCallback: Nullable<(sceneFile: File, scene: Nullable<Scene>, message: string) => void>);
  75010. private _dragEnterHandler;
  75011. private _dragOverHandler;
  75012. private _dropHandler;
  75013. /**
  75014. * Calls this function to listen to drag'n'drop events on a specific DOM element
  75015. * @param elementToMonitor defines the DOM element to track
  75016. */
  75017. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  75018. /** Gets the current list of files to load */
  75019. get filesToLoad(): File[];
  75020. /**
  75021. * Release all associated resources
  75022. */
  75023. dispose(): void;
  75024. private renderFunction;
  75025. private drag;
  75026. private drop;
  75027. private _traverseFolder;
  75028. private _processFiles;
  75029. /**
  75030. * Load files from a drop event
  75031. * @param event defines the drop event to use as source
  75032. */
  75033. loadFiles(event: any): void;
  75034. private _processReload;
  75035. /**
  75036. * Reload the current scene from the loaded files
  75037. */
  75038. reload(): void;
  75039. }
  75040. }
  75041. declare module BABYLON {
  75042. /**
  75043. * Defines the root class used to create scene optimization to use with SceneOptimizer
  75044. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75045. */
  75046. export class SceneOptimization {
  75047. /**
  75048. * Defines the priority of this optimization (0 by default which means first in the list)
  75049. */
  75050. priority: number;
  75051. /**
  75052. * Gets a string describing the action executed by the current optimization
  75053. * @returns description string
  75054. */
  75055. getDescription(): string;
  75056. /**
  75057. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75058. * @param scene defines the current scene where to apply this optimization
  75059. * @param optimizer defines the current optimizer
  75060. * @returns true if everything that can be done was applied
  75061. */
  75062. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75063. /**
  75064. * Creates the SceneOptimization object
  75065. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75066. * @param desc defines the description associated with the optimization
  75067. */
  75068. constructor(
  75069. /**
  75070. * Defines the priority of this optimization (0 by default which means first in the list)
  75071. */
  75072. priority?: number);
  75073. }
  75074. /**
  75075. * Defines an optimization used to reduce the size of render target textures
  75076. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75077. */
  75078. export class TextureOptimization extends SceneOptimization {
  75079. /**
  75080. * Defines the priority of this optimization (0 by default which means first in the list)
  75081. */
  75082. priority: number;
  75083. /**
  75084. * 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
  75085. */
  75086. maximumSize: number;
  75087. /**
  75088. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75089. */
  75090. step: number;
  75091. /**
  75092. * Gets a string describing the action executed by the current optimization
  75093. * @returns description string
  75094. */
  75095. getDescription(): string;
  75096. /**
  75097. * Creates the TextureOptimization object
  75098. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75099. * @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
  75100. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75101. */
  75102. constructor(
  75103. /**
  75104. * Defines the priority of this optimization (0 by default which means first in the list)
  75105. */
  75106. priority?: number,
  75107. /**
  75108. * 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
  75109. */
  75110. maximumSize?: number,
  75111. /**
  75112. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75113. */
  75114. step?: number);
  75115. /**
  75116. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75117. * @param scene defines the current scene where to apply this optimization
  75118. * @param optimizer defines the current optimizer
  75119. * @returns true if everything that can be done was applied
  75120. */
  75121. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75122. }
  75123. /**
  75124. * Defines an optimization used to increase or decrease the rendering resolution
  75125. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75126. */
  75127. export class HardwareScalingOptimization extends SceneOptimization {
  75128. /**
  75129. * Defines the priority of this optimization (0 by default which means first in the list)
  75130. */
  75131. priority: number;
  75132. /**
  75133. * Defines the maximum scale to use (2 by default)
  75134. */
  75135. maximumScale: number;
  75136. /**
  75137. * Defines the step to use between two passes (0.5 by default)
  75138. */
  75139. step: number;
  75140. private _currentScale;
  75141. private _directionOffset;
  75142. /**
  75143. * Gets a string describing the action executed by the current optimization
  75144. * @return description string
  75145. */
  75146. getDescription(): string;
  75147. /**
  75148. * Creates the HardwareScalingOptimization object
  75149. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75150. * @param maximumScale defines the maximum scale to use (2 by default)
  75151. * @param step defines the step to use between two passes (0.5 by default)
  75152. */
  75153. constructor(
  75154. /**
  75155. * Defines the priority of this optimization (0 by default which means first in the list)
  75156. */
  75157. priority?: number,
  75158. /**
  75159. * Defines the maximum scale to use (2 by default)
  75160. */
  75161. maximumScale?: number,
  75162. /**
  75163. * Defines the step to use between two passes (0.5 by default)
  75164. */
  75165. step?: number);
  75166. /**
  75167. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75168. * @param scene defines the current scene where to apply this optimization
  75169. * @param optimizer defines the current optimizer
  75170. * @returns true if everything that can be done was applied
  75171. */
  75172. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75173. }
  75174. /**
  75175. * Defines an optimization used to remove shadows
  75176. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75177. */
  75178. export class ShadowsOptimization extends SceneOptimization {
  75179. /**
  75180. * Gets a string describing the action executed by the current optimization
  75181. * @return description string
  75182. */
  75183. getDescription(): string;
  75184. /**
  75185. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75186. * @param scene defines the current scene where to apply this optimization
  75187. * @param optimizer defines the current optimizer
  75188. * @returns true if everything that can be done was applied
  75189. */
  75190. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75191. }
  75192. /**
  75193. * Defines an optimization used to turn post-processes off
  75194. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75195. */
  75196. export class PostProcessesOptimization extends SceneOptimization {
  75197. /**
  75198. * Gets a string describing the action executed by the current optimization
  75199. * @return description string
  75200. */
  75201. getDescription(): string;
  75202. /**
  75203. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75204. * @param scene defines the current scene where to apply this optimization
  75205. * @param optimizer defines the current optimizer
  75206. * @returns true if everything that can be done was applied
  75207. */
  75208. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75209. }
  75210. /**
  75211. * Defines an optimization used to turn lens flares off
  75212. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75213. */
  75214. export class LensFlaresOptimization extends SceneOptimization {
  75215. /**
  75216. * Gets a string describing the action executed by the current optimization
  75217. * @return description string
  75218. */
  75219. getDescription(): string;
  75220. /**
  75221. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75222. * @param scene defines the current scene where to apply this optimization
  75223. * @param optimizer defines the current optimizer
  75224. * @returns true if everything that can be done was applied
  75225. */
  75226. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75227. }
  75228. /**
  75229. * Defines an optimization based on user defined callback.
  75230. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75231. */
  75232. export class CustomOptimization extends SceneOptimization {
  75233. /**
  75234. * Callback called to apply the custom optimization.
  75235. */
  75236. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  75237. /**
  75238. * Callback called to get custom description
  75239. */
  75240. onGetDescription: () => string;
  75241. /**
  75242. * Gets a string describing the action executed by the current optimization
  75243. * @returns description string
  75244. */
  75245. getDescription(): string;
  75246. /**
  75247. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75248. * @param scene defines the current scene where to apply this optimization
  75249. * @param optimizer defines the current optimizer
  75250. * @returns true if everything that can be done was applied
  75251. */
  75252. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75253. }
  75254. /**
  75255. * Defines an optimization used to turn particles off
  75256. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75257. */
  75258. export class ParticlesOptimization extends SceneOptimization {
  75259. /**
  75260. * Gets a string describing the action executed by the current optimization
  75261. * @return description string
  75262. */
  75263. getDescription(): string;
  75264. /**
  75265. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75266. * @param scene defines the current scene where to apply this optimization
  75267. * @param optimizer defines the current optimizer
  75268. * @returns true if everything that can be done was applied
  75269. */
  75270. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75271. }
  75272. /**
  75273. * Defines an optimization used to turn render targets off
  75274. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75275. */
  75276. export class RenderTargetsOptimization extends SceneOptimization {
  75277. /**
  75278. * Gets a string describing the action executed by the current optimization
  75279. * @return description string
  75280. */
  75281. getDescription(): string;
  75282. /**
  75283. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75284. * @param scene defines the current scene where to apply this optimization
  75285. * @param optimizer defines the current optimizer
  75286. * @returns true if everything that can be done was applied
  75287. */
  75288. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75289. }
  75290. /**
  75291. * Defines an optimization used to merge meshes with compatible materials
  75292. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75293. */
  75294. export class MergeMeshesOptimization extends SceneOptimization {
  75295. private static _UpdateSelectionTree;
  75296. /**
  75297. * Gets or sets a boolean which defines if optimization octree has to be updated
  75298. */
  75299. static get UpdateSelectionTree(): boolean;
  75300. /**
  75301. * Gets or sets a boolean which defines if optimization octree has to be updated
  75302. */
  75303. static set UpdateSelectionTree(value: boolean);
  75304. /**
  75305. * Gets a string describing the action executed by the current optimization
  75306. * @return description string
  75307. */
  75308. getDescription(): string;
  75309. private _canBeMerged;
  75310. /**
  75311. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75312. * @param scene defines the current scene where to apply this optimization
  75313. * @param optimizer defines the current optimizer
  75314. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  75315. * @returns true if everything that can be done was applied
  75316. */
  75317. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  75318. }
  75319. /**
  75320. * Defines a list of options used by SceneOptimizer
  75321. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75322. */
  75323. export class SceneOptimizerOptions {
  75324. /**
  75325. * Defines the target frame rate to reach (60 by default)
  75326. */
  75327. targetFrameRate: number;
  75328. /**
  75329. * Defines the interval between two checkes (2000ms by default)
  75330. */
  75331. trackerDuration: number;
  75332. /**
  75333. * Gets the list of optimizations to apply
  75334. */
  75335. optimizations: SceneOptimization[];
  75336. /**
  75337. * Creates a new list of options used by SceneOptimizer
  75338. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  75339. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  75340. */
  75341. constructor(
  75342. /**
  75343. * Defines the target frame rate to reach (60 by default)
  75344. */
  75345. targetFrameRate?: number,
  75346. /**
  75347. * Defines the interval between two checkes (2000ms by default)
  75348. */
  75349. trackerDuration?: number);
  75350. /**
  75351. * Add a new optimization
  75352. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  75353. * @returns the current SceneOptimizerOptions
  75354. */
  75355. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  75356. /**
  75357. * Add a new custom optimization
  75358. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  75359. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  75360. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75361. * @returns the current SceneOptimizerOptions
  75362. */
  75363. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  75364. /**
  75365. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  75366. * @param targetFrameRate defines the target frame rate (60 by default)
  75367. * @returns a SceneOptimizerOptions object
  75368. */
  75369. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75370. /**
  75371. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  75372. * @param targetFrameRate defines the target frame rate (60 by default)
  75373. * @returns a SceneOptimizerOptions object
  75374. */
  75375. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75376. /**
  75377. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  75378. * @param targetFrameRate defines the target frame rate (60 by default)
  75379. * @returns a SceneOptimizerOptions object
  75380. */
  75381. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75382. }
  75383. /**
  75384. * Class used to run optimizations in order to reach a target frame rate
  75385. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75386. */
  75387. export class SceneOptimizer implements IDisposable {
  75388. private _isRunning;
  75389. private _options;
  75390. private _scene;
  75391. private _currentPriorityLevel;
  75392. private _targetFrameRate;
  75393. private _trackerDuration;
  75394. private _currentFrameRate;
  75395. private _sceneDisposeObserver;
  75396. private _improvementMode;
  75397. /**
  75398. * Defines an observable called when the optimizer reaches the target frame rate
  75399. */
  75400. onSuccessObservable: Observable<SceneOptimizer>;
  75401. /**
  75402. * Defines an observable called when the optimizer enables an optimization
  75403. */
  75404. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  75405. /**
  75406. * Defines an observable called when the optimizer is not able to reach the target frame rate
  75407. */
  75408. onFailureObservable: Observable<SceneOptimizer>;
  75409. /**
  75410. * Gets a boolean indicating if the optimizer is in improvement mode
  75411. */
  75412. get isInImprovementMode(): boolean;
  75413. /**
  75414. * Gets the current priority level (0 at start)
  75415. */
  75416. get currentPriorityLevel(): number;
  75417. /**
  75418. * Gets the current frame rate checked by the SceneOptimizer
  75419. */
  75420. get currentFrameRate(): number;
  75421. /**
  75422. * Gets or sets the current target frame rate (60 by default)
  75423. */
  75424. get targetFrameRate(): number;
  75425. /**
  75426. * Gets or sets the current target frame rate (60 by default)
  75427. */
  75428. set targetFrameRate(value: number);
  75429. /**
  75430. * Gets or sets the current interval between two checks (every 2000ms by default)
  75431. */
  75432. get trackerDuration(): number;
  75433. /**
  75434. * Gets or sets the current interval between two checks (every 2000ms by default)
  75435. */
  75436. set trackerDuration(value: number);
  75437. /**
  75438. * Gets the list of active optimizations
  75439. */
  75440. get optimizations(): SceneOptimization[];
  75441. /**
  75442. * Creates a new SceneOptimizer
  75443. * @param scene defines the scene to work on
  75444. * @param options defines the options to use with the SceneOptimizer
  75445. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  75446. * @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)
  75447. */
  75448. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  75449. /**
  75450. * Stops the current optimizer
  75451. */
  75452. stop(): void;
  75453. /**
  75454. * Reset the optimizer to initial step (current priority level = 0)
  75455. */
  75456. reset(): void;
  75457. /**
  75458. * Start the optimizer. By default it will try to reach a specific framerate
  75459. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  75460. */
  75461. start(): void;
  75462. private _checkCurrentState;
  75463. /**
  75464. * Release all resources
  75465. */
  75466. dispose(): void;
  75467. /**
  75468. * Helper function to create a SceneOptimizer with one single line of code
  75469. * @param scene defines the scene to work on
  75470. * @param options defines the options to use with the SceneOptimizer
  75471. * @param onSuccess defines a callback to call on success
  75472. * @param onFailure defines a callback to call on failure
  75473. * @returns the new SceneOptimizer object
  75474. */
  75475. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  75476. }
  75477. }
  75478. declare module BABYLON {
  75479. /**
  75480. * Class used to serialize a scene into a string
  75481. */
  75482. export class SceneSerializer {
  75483. /**
  75484. * Clear cache used by a previous serialization
  75485. */
  75486. static ClearCache(): void;
  75487. /**
  75488. * Serialize a scene into a JSON compatible object
  75489. * @param scene defines the scene to serialize
  75490. * @returns a JSON compatible object
  75491. */
  75492. static Serialize(scene: Scene): any;
  75493. /**
  75494. * Serialize a mesh into a JSON compatible object
  75495. * @param toSerialize defines the mesh to serialize
  75496. * @param withParents defines if parents must be serialized as well
  75497. * @param withChildren defines if children must be serialized as well
  75498. * @returns a JSON compatible object
  75499. */
  75500. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  75501. }
  75502. }
  75503. declare module BABYLON {
  75504. /**
  75505. * Class used to host texture specific utilities
  75506. */
  75507. export class TextureTools {
  75508. /**
  75509. * Uses the GPU to create a copy texture rescaled at a given size
  75510. * @param texture Texture to copy from
  75511. * @param width defines the desired width
  75512. * @param height defines the desired height
  75513. * @param useBilinearMode defines if bilinear mode has to be used
  75514. * @return the generated texture
  75515. */
  75516. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  75517. }
  75518. }
  75519. declare module BABYLON {
  75520. /**
  75521. * This represents the different options available for the video capture.
  75522. */
  75523. export interface VideoRecorderOptions {
  75524. /** Defines the mime type of the video. */
  75525. mimeType: string;
  75526. /** Defines the FPS the video should be recorded at. */
  75527. fps: number;
  75528. /** Defines the chunk size for the recording data. */
  75529. recordChunckSize: number;
  75530. /** The audio tracks to attach to the recording. */
  75531. audioTracks?: MediaStreamTrack[];
  75532. }
  75533. /**
  75534. * This can help with recording videos from BabylonJS.
  75535. * This is based on the available WebRTC functionalities of the browser.
  75536. *
  75537. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  75538. */
  75539. export class VideoRecorder {
  75540. private static readonly _defaultOptions;
  75541. /**
  75542. * Returns whether or not the VideoRecorder is available in your browser.
  75543. * @param engine Defines the Babylon Engine.
  75544. * @returns true if supported otherwise false.
  75545. */
  75546. static IsSupported(engine: Engine): boolean;
  75547. private readonly _options;
  75548. private _canvas;
  75549. private _mediaRecorder;
  75550. private _recordedChunks;
  75551. private _fileName;
  75552. private _resolve;
  75553. private _reject;
  75554. /**
  75555. * True when a recording is already in progress.
  75556. */
  75557. get isRecording(): boolean;
  75558. /**
  75559. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  75560. * @param engine Defines the BabylonJS Engine you wish to record.
  75561. * @param options Defines options that can be used to customize the capture.
  75562. */
  75563. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  75564. /**
  75565. * Stops the current recording before the default capture timeout passed in the startRecording function.
  75566. */
  75567. stopRecording(): void;
  75568. /**
  75569. * Starts recording the canvas for a max duration specified in parameters.
  75570. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  75571. * If null no automatic download will start and you can rely on the promise to get the data back.
  75572. * @param maxDuration Defines the maximum recording time in seconds.
  75573. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  75574. * @return A promise callback at the end of the recording with the video data in Blob.
  75575. */
  75576. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  75577. /**
  75578. * Releases internal resources used during the recording.
  75579. */
  75580. dispose(): void;
  75581. private _handleDataAvailable;
  75582. private _handleError;
  75583. private _handleStop;
  75584. }
  75585. }
  75586. declare module BABYLON {
  75587. /**
  75588. * Class containing a set of static utilities functions for screenshots
  75589. */
  75590. export class ScreenshotTools {
  75591. /**
  75592. * Captures a screenshot of the current rendering
  75593. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75594. * @param engine defines the rendering engine
  75595. * @param camera defines the source camera
  75596. * @param size This parameter can be set to a single number or to an object with the
  75597. * following (optional) properties: precision, width, height. If a single number is passed,
  75598. * it will be used for both width and height. If an object is passed, the screenshot size
  75599. * will be derived from the parameters. The precision property is a multiplier allowing
  75600. * rendering at a higher or lower resolution
  75601. * @param successCallback defines the callback receives a single parameter which contains the
  75602. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75603. * src parameter of an <img> to display it
  75604. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75605. * Check your browser for supported MIME types
  75606. */
  75607. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  75608. /**
  75609. * Captures a screenshot of the current rendering
  75610. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75611. * @param engine defines the rendering engine
  75612. * @param camera defines the source camera
  75613. * @param size This parameter can be set to a single number or to an object with the
  75614. * following (optional) properties: precision, width, height. If a single number is passed,
  75615. * it will be used for both width and height. If an object is passed, the screenshot size
  75616. * will be derived from the parameters. The precision property is a multiplier allowing
  75617. * rendering at a higher or lower resolution
  75618. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75619. * Check your browser for supported MIME types
  75620. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75621. * to the src parameter of an <img> to display it
  75622. */
  75623. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  75624. /**
  75625. * Generates an image screenshot from the specified camera.
  75626. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75627. * @param engine The engine to use for rendering
  75628. * @param camera The camera to use for rendering
  75629. * @param size This parameter can be set to a single number or to an object with the
  75630. * following (optional) properties: precision, width, height. If a single number is passed,
  75631. * it will be used for both width and height. If an object is passed, the screenshot size
  75632. * will be derived from the parameters. The precision property is a multiplier allowing
  75633. * rendering at a higher or lower resolution
  75634. * @param successCallback The callback receives a single parameter which contains the
  75635. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75636. * src parameter of an <img> to display it
  75637. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75638. * Check your browser for supported MIME types
  75639. * @param samples Texture samples (default: 1)
  75640. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75641. * @param fileName A name for for the downloaded file.
  75642. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75643. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  75644. */
  75645. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean, enableStencilBuffer?: boolean): void;
  75646. /**
  75647. * Generates an image screenshot from the specified camera.
  75648. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75649. * @param engine The engine to use for rendering
  75650. * @param camera The camera to use for rendering
  75651. * @param size This parameter can be set to a single number or to an object with the
  75652. * following (optional) properties: precision, width, height. If a single number is passed,
  75653. * it will be used for both width and height. If an object is passed, the screenshot size
  75654. * will be derived from the parameters. The precision property is a multiplier allowing
  75655. * rendering at a higher or lower resolution
  75656. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75657. * Check your browser for supported MIME types
  75658. * @param samples Texture samples (default: 1)
  75659. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75660. * @param fileName A name for for the downloaded file.
  75661. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75662. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75663. * to the src parameter of an <img> to display it
  75664. */
  75665. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  75666. /**
  75667. * Gets height and width for screenshot size
  75668. * @private
  75669. */
  75670. private static _getScreenshotSize;
  75671. }
  75672. }
  75673. declare module BABYLON {
  75674. /**
  75675. * Interface for a data buffer
  75676. */
  75677. export interface IDataBuffer {
  75678. /**
  75679. * Reads bytes from the data buffer.
  75680. * @param byteOffset The byte offset to read
  75681. * @param byteLength The byte length to read
  75682. * @returns A promise that resolves when the bytes are read
  75683. */
  75684. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  75685. /**
  75686. * The byte length of the buffer.
  75687. */
  75688. readonly byteLength: number;
  75689. }
  75690. /**
  75691. * Utility class for reading from a data buffer
  75692. */
  75693. export class DataReader {
  75694. /**
  75695. * The data buffer associated with this data reader.
  75696. */
  75697. readonly buffer: IDataBuffer;
  75698. /**
  75699. * The current byte offset from the beginning of the data buffer.
  75700. */
  75701. byteOffset: number;
  75702. private _dataView;
  75703. private _dataByteOffset;
  75704. /**
  75705. * Constructor
  75706. * @param buffer The buffer to read
  75707. */
  75708. constructor(buffer: IDataBuffer);
  75709. /**
  75710. * Loads the given byte length.
  75711. * @param byteLength The byte length to load
  75712. * @returns A promise that resolves when the load is complete
  75713. */
  75714. loadAsync(byteLength: number): Promise<void>;
  75715. /**
  75716. * Read a unsigned 32-bit integer from the currently loaded data range.
  75717. * @returns The 32-bit integer read
  75718. */
  75719. readUint32(): number;
  75720. /**
  75721. * Read a byte array from the currently loaded data range.
  75722. * @param byteLength The byte length to read
  75723. * @returns The byte array read
  75724. */
  75725. readUint8Array(byteLength: number): Uint8Array;
  75726. /**
  75727. * Read a string from the currently loaded data range.
  75728. * @param byteLength The byte length to read
  75729. * @returns The string read
  75730. */
  75731. readString(byteLength: number): string;
  75732. /**
  75733. * Skips the given byte length the currently loaded data range.
  75734. * @param byteLength The byte length to skip
  75735. */
  75736. skipBytes(byteLength: number): void;
  75737. }
  75738. }
  75739. declare module BABYLON {
  75740. /**
  75741. * Class for storing data to local storage if available or in-memory storage otherwise
  75742. */
  75743. export class DataStorage {
  75744. private static _Storage;
  75745. private static _GetStorage;
  75746. /**
  75747. * Reads a string from the data storage
  75748. * @param key The key to read
  75749. * @param defaultValue The value if the key doesn't exist
  75750. * @returns The string value
  75751. */
  75752. static ReadString(key: string, defaultValue: string): string;
  75753. /**
  75754. * Writes a string to the data storage
  75755. * @param key The key to write
  75756. * @param value The value to write
  75757. */
  75758. static WriteString(key: string, value: string): void;
  75759. /**
  75760. * Reads a boolean from the data storage
  75761. * @param key The key to read
  75762. * @param defaultValue The value if the key doesn't exist
  75763. * @returns The boolean value
  75764. */
  75765. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  75766. /**
  75767. * Writes a boolean to the data storage
  75768. * @param key The key to write
  75769. * @param value The value to write
  75770. */
  75771. static WriteBoolean(key: string, value: boolean): void;
  75772. /**
  75773. * Reads a number from the data storage
  75774. * @param key The key to read
  75775. * @param defaultValue The value if the key doesn't exist
  75776. * @returns The number value
  75777. */
  75778. static ReadNumber(key: string, defaultValue: number): number;
  75779. /**
  75780. * Writes a number to the data storage
  75781. * @param key The key to write
  75782. * @param value The value to write
  75783. */
  75784. static WriteNumber(key: string, value: number): void;
  75785. }
  75786. }
  75787. declare module BABYLON {
  75788. /**
  75789. * Class used to record delta files between 2 scene states
  75790. */
  75791. export class SceneRecorder {
  75792. private _trackedScene;
  75793. private _savedJSON;
  75794. /**
  75795. * Track a given scene. This means the current scene state will be considered the original state
  75796. * @param scene defines the scene to track
  75797. */
  75798. track(scene: Scene): void;
  75799. /**
  75800. * Get the delta between current state and original state
  75801. * @returns a string containing the delta
  75802. */
  75803. getDelta(): any;
  75804. private _compareArray;
  75805. private _compareObjects;
  75806. private _compareCollections;
  75807. private static GetShadowGeneratorById;
  75808. /**
  75809. * Apply a given delta to a given scene
  75810. * @param deltaJSON defines the JSON containing the delta
  75811. * @param scene defines the scene to apply the delta to
  75812. */
  75813. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  75814. private static _ApplyPropertiesToEntity;
  75815. private static _ApplyDeltaForEntity;
  75816. }
  75817. }
  75818. declare module BABYLON {
  75819. /**
  75820. * A 3D trajectory consisting of an order list of vectors describing a
  75821. * path of motion through 3D space.
  75822. */
  75823. export class Trajectory {
  75824. private _points;
  75825. private readonly _segmentLength;
  75826. /**
  75827. * Serialize to JSON.
  75828. * @returns serialized JSON string
  75829. */
  75830. serialize(): string;
  75831. /**
  75832. * Deserialize from JSON.
  75833. * @param json serialized JSON string
  75834. * @returns deserialized Trajectory
  75835. */
  75836. static Deserialize(json: string): Trajectory;
  75837. /**
  75838. * Create a new empty Trajectory.
  75839. * @param segmentLength radius of discretization for Trajectory points
  75840. */
  75841. constructor(segmentLength?: number);
  75842. /**
  75843. * Get the length of the Trajectory.
  75844. * @returns length of the Trajectory
  75845. */
  75846. getLength(): number;
  75847. /**
  75848. * Append a new point to the Trajectory.
  75849. * NOTE: This implementation has many allocations.
  75850. * @param point point to append to the Trajectory
  75851. */
  75852. add(point: DeepImmutable<Vector3>): void;
  75853. /**
  75854. * Create a new Trajectory with a segment length chosen to make it
  75855. * probable that the new Trajectory will have a specified number of
  75856. * segments. This operation is imprecise.
  75857. * @param targetResolution number of segments desired
  75858. * @returns new Trajectory with approximately the requested number of segments
  75859. */
  75860. resampleAtTargetResolution(targetResolution: number): Trajectory;
  75861. /**
  75862. * Convert Trajectory segments into tokenized representation. This
  75863. * representation is an array of numbers where each nth number is the
  75864. * index of the token which is most similar to the nth segment of the
  75865. * Trajectory.
  75866. * @param tokens list of vectors which serve as discrete tokens
  75867. * @returns list of indices of most similar token per segment
  75868. */
  75869. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  75870. private static _forwardDir;
  75871. private static _inverseFromVec;
  75872. private static _upDir;
  75873. private static _fromToVec;
  75874. private static _lookMatrix;
  75875. /**
  75876. * Transform the rotation (i.e., direction) of a segment to isolate
  75877. * the relative transformation represented by the segment. This operation
  75878. * may or may not succeed due to singularities in the equations that define
  75879. * motion relativity in this context.
  75880. * @param priorVec the origin of the prior segment
  75881. * @param fromVec the origin of the current segment
  75882. * @param toVec the destination of the current segment
  75883. * @param result reference to output variable
  75884. * @returns whether or not transformation was successful
  75885. */
  75886. private static _transformSegmentDirToRef;
  75887. private static _bestMatch;
  75888. private static _score;
  75889. private static _bestScore;
  75890. /**
  75891. * Determine which token vector is most similar to the
  75892. * segment vector.
  75893. * @param segment segment vector
  75894. * @param tokens token vector list
  75895. * @returns index of the most similar token to the segment
  75896. */
  75897. private static _tokenizeSegment;
  75898. }
  75899. /**
  75900. * Class representing a set of known, named trajectories to which Trajectories can be
  75901. * added and using which Trajectories can be recognized.
  75902. */
  75903. export class TrajectoryClassifier {
  75904. private _maximumAllowableMatchCost;
  75905. private _vector3Alphabet;
  75906. private _levenshteinAlphabet;
  75907. private _nameToDescribedTrajectory;
  75908. /**
  75909. * Serialize to JSON.
  75910. * @returns JSON serialization
  75911. */
  75912. serialize(): string;
  75913. /**
  75914. * Deserialize from JSON.
  75915. * @param json JSON serialization
  75916. * @returns deserialized TrajectorySet
  75917. */
  75918. static Deserialize(json: string): TrajectoryClassifier;
  75919. /**
  75920. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  75921. * VERY naive, need to be generating these things from known
  75922. * sets. Better version later, probably eliminating this one.
  75923. * @returns auto-generated TrajectorySet
  75924. */
  75925. static Generate(): TrajectoryClassifier;
  75926. private constructor();
  75927. /**
  75928. * Add a new Trajectory to the set with a given name.
  75929. * @param trajectory new Trajectory to be added
  75930. * @param classification name to which to add the Trajectory
  75931. */
  75932. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  75933. /**
  75934. * Remove a known named trajectory and all Trajectories associated with it.
  75935. * @param classification name to remove
  75936. * @returns whether anything was removed
  75937. */
  75938. deleteClassification(classification: string): boolean;
  75939. /**
  75940. * Attempt to recognize a Trajectory from among all the classifications
  75941. * already known to the classifier.
  75942. * @param trajectory Trajectory to be recognized
  75943. * @returns classification of Trajectory if recognized, null otherwise
  75944. */
  75945. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  75946. }
  75947. }
  75948. declare module BABYLON {
  75949. /**
  75950. * An interface for all Hit test features
  75951. */
  75952. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  75953. /**
  75954. * Triggered when new babylon (transformed) hit test results are available
  75955. */
  75956. onHitTestResultObservable: Observable<T[]>;
  75957. }
  75958. /**
  75959. * Options used for hit testing
  75960. */
  75961. export interface IWebXRLegacyHitTestOptions {
  75962. /**
  75963. * Only test when user interacted with the scene. Default - hit test every frame
  75964. */
  75965. testOnPointerDownOnly?: boolean;
  75966. /**
  75967. * The node to use to transform the local results to world coordinates
  75968. */
  75969. worldParentNode?: TransformNode;
  75970. }
  75971. /**
  75972. * Interface defining the babylon result of raycasting/hit-test
  75973. */
  75974. export interface IWebXRLegacyHitResult {
  75975. /**
  75976. * Transformation matrix that can be applied to a node that will put it in the hit point location
  75977. */
  75978. transformationMatrix: Matrix;
  75979. /**
  75980. * The native hit test result
  75981. */
  75982. xrHitResult: XRHitResult | XRHitTestResult;
  75983. }
  75984. /**
  75985. * The currently-working hit-test module.
  75986. * Hit test (or Ray-casting) is used to interact with the real world.
  75987. * For further information read here - https://github.com/immersive-web/hit-test
  75988. */
  75989. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  75990. /**
  75991. * options to use when constructing this feature
  75992. */
  75993. readonly options: IWebXRLegacyHitTestOptions;
  75994. private _direction;
  75995. private _mat;
  75996. private _onSelectEnabled;
  75997. private _origin;
  75998. /**
  75999. * The module's name
  76000. */
  76001. static readonly Name: string;
  76002. /**
  76003. * The (Babylon) version of this module.
  76004. * This is an integer representing the implementation version.
  76005. * This number does not correspond to the WebXR specs version
  76006. */
  76007. static readonly Version: number;
  76008. /**
  76009. * Populated with the last native XR Hit Results
  76010. */
  76011. lastNativeXRHitResults: XRHitResult[];
  76012. /**
  76013. * Triggered when new babylon (transformed) hit test results are available
  76014. */
  76015. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  76016. /**
  76017. * Creates a new instance of the (legacy version) hit test feature
  76018. * @param _xrSessionManager an instance of WebXRSessionManager
  76019. * @param options options to use when constructing this feature
  76020. */
  76021. constructor(_xrSessionManager: WebXRSessionManager,
  76022. /**
  76023. * options to use when constructing this feature
  76024. */
  76025. options?: IWebXRLegacyHitTestOptions);
  76026. /**
  76027. * execute a hit test with an XR Ray
  76028. *
  76029. * @param xrSession a native xrSession that will execute this hit test
  76030. * @param xrRay the ray (position and direction) to use for ray-casting
  76031. * @param referenceSpace native XR reference space to use for the hit-test
  76032. * @param filter filter function that will filter the results
  76033. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  76034. */
  76035. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  76036. /**
  76037. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  76038. * @param event the (select) event to use to select with
  76039. * @param referenceSpace the reference space to use for this hit test
  76040. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  76041. */
  76042. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  76043. /**
  76044. * attach this feature
  76045. * Will usually be called by the features manager
  76046. *
  76047. * @returns true if successful.
  76048. */
  76049. attach(): boolean;
  76050. /**
  76051. * detach this feature.
  76052. * Will usually be called by the features manager
  76053. *
  76054. * @returns true if successful.
  76055. */
  76056. detach(): boolean;
  76057. /**
  76058. * Dispose this feature and all of the resources attached
  76059. */
  76060. dispose(): void;
  76061. protected _onXRFrame(frame: XRFrame): void;
  76062. private _onHitTestResults;
  76063. private _onSelect;
  76064. }
  76065. }
  76066. declare module BABYLON {
  76067. /**
  76068. * Options used for hit testing (version 2)
  76069. */
  76070. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  76071. /**
  76072. * Do not create a permanent hit test. Will usually be used when only
  76073. * transient inputs are needed.
  76074. */
  76075. disablePermanentHitTest?: boolean;
  76076. /**
  76077. * Enable transient (for example touch-based) hit test inspections
  76078. */
  76079. enableTransientHitTest?: boolean;
  76080. /**
  76081. * Offset ray for the permanent hit test
  76082. */
  76083. offsetRay?: Vector3;
  76084. /**
  76085. * Offset ray for the transient hit test
  76086. */
  76087. transientOffsetRay?: Vector3;
  76088. /**
  76089. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  76090. */
  76091. useReferenceSpace?: boolean;
  76092. /**
  76093. * Override the default entity type(s) of the hit-test result
  76094. */
  76095. entityTypes?: XRHitTestTrackableType[];
  76096. }
  76097. /**
  76098. * Interface defining the babylon result of hit-test
  76099. */
  76100. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  76101. /**
  76102. * The input source that generated this hit test (if transient)
  76103. */
  76104. inputSource?: XRInputSource;
  76105. /**
  76106. * Is this a transient hit test
  76107. */
  76108. isTransient?: boolean;
  76109. /**
  76110. * Position of the hit test result
  76111. */
  76112. position: Vector3;
  76113. /**
  76114. * Rotation of the hit test result
  76115. */
  76116. rotationQuaternion: Quaternion;
  76117. /**
  76118. * The native hit test result
  76119. */
  76120. xrHitResult: XRHitTestResult;
  76121. }
  76122. /**
  76123. * The currently-working hit-test module.
  76124. * Hit test (or Ray-casting) is used to interact with the real world.
  76125. * For further information read here - https://github.com/immersive-web/hit-test
  76126. *
  76127. * Tested on chrome (mobile) 80.
  76128. */
  76129. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  76130. /**
  76131. * options to use when constructing this feature
  76132. */
  76133. readonly options: IWebXRHitTestOptions;
  76134. private _tmpMat;
  76135. private _tmpPos;
  76136. private _tmpQuat;
  76137. private _transientXrHitTestSource;
  76138. private _xrHitTestSource;
  76139. private initHitTestSource;
  76140. /**
  76141. * The module's name
  76142. */
  76143. static readonly Name: string;
  76144. /**
  76145. * The (Babylon) version of this module.
  76146. * This is an integer representing the implementation version.
  76147. * This number does not correspond to the WebXR specs version
  76148. */
  76149. static readonly Version: number;
  76150. /**
  76151. * When set to true, each hit test will have its own position/rotation objects
  76152. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  76153. * the developers will clone them or copy them as they see fit.
  76154. */
  76155. autoCloneTransformation: boolean;
  76156. /**
  76157. * Triggered when new babylon (transformed) hit test results are available
  76158. * Note - this will be called when results come back from the device. It can be an empty array!!
  76159. */
  76160. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  76161. /**
  76162. * Use this to temporarily pause hit test checks.
  76163. */
  76164. paused: boolean;
  76165. /**
  76166. * Creates a new instance of the hit test feature
  76167. * @param _xrSessionManager an instance of WebXRSessionManager
  76168. * @param options options to use when constructing this feature
  76169. */
  76170. constructor(_xrSessionManager: WebXRSessionManager,
  76171. /**
  76172. * options to use when constructing this feature
  76173. */
  76174. options?: IWebXRHitTestOptions);
  76175. /**
  76176. * attach this feature
  76177. * Will usually be called by the features manager
  76178. *
  76179. * @returns true if successful.
  76180. */
  76181. attach(): boolean;
  76182. /**
  76183. * detach this feature.
  76184. * Will usually be called by the features manager
  76185. *
  76186. * @returns true if successful.
  76187. */
  76188. detach(): boolean;
  76189. /**
  76190. * Dispose this feature and all of the resources attached
  76191. */
  76192. dispose(): void;
  76193. protected _onXRFrame(frame: XRFrame): void;
  76194. private _processWebXRHitTestResult;
  76195. }
  76196. }
  76197. declare module BABYLON {
  76198. /**
  76199. * Configuration options of the anchor system
  76200. */
  76201. export interface IWebXRAnchorSystemOptions {
  76202. /**
  76203. * a node that will be used to convert local to world coordinates
  76204. */
  76205. worldParentNode?: TransformNode;
  76206. /**
  76207. * If set to true a reference of the created anchors will be kept until the next session starts
  76208. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  76209. */
  76210. doNotRemoveAnchorsOnSessionEnded?: boolean;
  76211. }
  76212. /**
  76213. * A babylon container for an XR Anchor
  76214. */
  76215. export interface IWebXRAnchor {
  76216. /**
  76217. * A babylon-assigned ID for this anchor
  76218. */
  76219. id: number;
  76220. /**
  76221. * Transformation matrix to apply to an object attached to this anchor
  76222. */
  76223. transformationMatrix: Matrix;
  76224. /**
  76225. * The native anchor object
  76226. */
  76227. xrAnchor: XRAnchor;
  76228. /**
  76229. * if defined, this object will be constantly updated by the anchor's position and rotation
  76230. */
  76231. attachedNode?: TransformNode;
  76232. /**
  76233. * Remove this anchor from the scene
  76234. */
  76235. remove(): void;
  76236. }
  76237. /**
  76238. * An implementation of the anchor system for WebXR.
  76239. * For further information see https://github.com/immersive-web/anchors/
  76240. */
  76241. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  76242. private _options;
  76243. private _lastFrameDetected;
  76244. private _trackedAnchors;
  76245. private _referenceSpaceForFrameAnchors;
  76246. private _futureAnchors;
  76247. /**
  76248. * The module's name
  76249. */
  76250. static readonly Name: string;
  76251. /**
  76252. * The (Babylon) version of this module.
  76253. * This is an integer representing the implementation version.
  76254. * This number does not correspond to the WebXR specs version
  76255. */
  76256. static readonly Version: number;
  76257. /**
  76258. * Observers registered here will be executed when a new anchor was added to the session
  76259. */
  76260. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  76261. /**
  76262. * Observers registered here will be executed when an anchor was removed from the session
  76263. */
  76264. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  76265. /**
  76266. * Observers registered here will be executed when an existing anchor updates
  76267. * This can execute N times every frame
  76268. */
  76269. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  76270. /**
  76271. * Set the reference space to use for anchor creation, when not using a hit test.
  76272. * Will default to the session's reference space if not defined
  76273. */
  76274. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  76275. /**
  76276. * constructs a new anchor system
  76277. * @param _xrSessionManager an instance of WebXRSessionManager
  76278. * @param _options configuration object for this feature
  76279. */
  76280. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  76281. private _tmpVector;
  76282. private _tmpQuaternion;
  76283. private _populateTmpTransformation;
  76284. /**
  76285. * Create a new anchor point using a hit test result at a specific point in the scene
  76286. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  76287. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  76288. *
  76289. * @param hitTestResult The hit test result to use for this anchor creation
  76290. * @param position an optional position offset for this anchor
  76291. * @param rotationQuaternion an optional rotation offset for this anchor
  76292. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  76293. */
  76294. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  76295. /**
  76296. * Add a new anchor at a specific position and rotation
  76297. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  76298. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  76299. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  76300. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  76301. *
  76302. * @param position the position in which to add an anchor
  76303. * @param rotationQuaternion an optional rotation for the anchor transformation
  76304. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  76305. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  76306. */
  76307. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  76308. /**
  76309. * Get the list of anchors currently being tracked by the system
  76310. */
  76311. get anchors(): IWebXRAnchor[];
  76312. /**
  76313. * detach this feature.
  76314. * Will usually be called by the features manager
  76315. *
  76316. * @returns true if successful.
  76317. */
  76318. detach(): boolean;
  76319. /**
  76320. * Dispose this feature and all of the resources attached
  76321. */
  76322. dispose(): void;
  76323. protected _onXRFrame(frame: XRFrame): void;
  76324. /**
  76325. * avoiding using Array.find for global support.
  76326. * @param xrAnchor the plane to find in the array
  76327. */
  76328. private _findIndexInAnchorArray;
  76329. private _updateAnchorWithXRFrame;
  76330. private _createAnchorAtTransformation;
  76331. }
  76332. }
  76333. declare module BABYLON {
  76334. /**
  76335. * Options used in the plane detector module
  76336. */
  76337. export interface IWebXRPlaneDetectorOptions {
  76338. /**
  76339. * The node to use to transform the local results to world coordinates
  76340. */
  76341. worldParentNode?: TransformNode;
  76342. /**
  76343. * If set to true a reference of the created planes will be kept until the next session starts
  76344. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  76345. */
  76346. doNotRemovePlanesOnSessionEnded?: boolean;
  76347. }
  76348. /**
  76349. * A babylon interface for a WebXR plane.
  76350. * A Plane is actually a polygon, built from N points in space
  76351. *
  76352. * Supported in chrome 79, not supported in canary 81 ATM
  76353. */
  76354. export interface IWebXRPlane {
  76355. /**
  76356. * a babylon-assigned ID for this polygon
  76357. */
  76358. id: number;
  76359. /**
  76360. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  76361. */
  76362. polygonDefinition: Array<Vector3>;
  76363. /**
  76364. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  76365. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  76366. */
  76367. transformationMatrix: Matrix;
  76368. /**
  76369. * the native xr-plane object
  76370. */
  76371. xrPlane: XRPlane;
  76372. }
  76373. /**
  76374. * The plane detector is used to detect planes in the real world when in AR
  76375. * For more information see https://github.com/immersive-web/real-world-geometry/
  76376. */
  76377. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  76378. private _options;
  76379. private _detectedPlanes;
  76380. private _enabled;
  76381. private _lastFrameDetected;
  76382. /**
  76383. * The module's name
  76384. */
  76385. static readonly Name: string;
  76386. /**
  76387. * The (Babylon) version of this module.
  76388. * This is an integer representing the implementation version.
  76389. * This number does not correspond to the WebXR specs version
  76390. */
  76391. static readonly Version: number;
  76392. /**
  76393. * Observers registered here will be executed when a new plane was added to the session
  76394. */
  76395. onPlaneAddedObservable: Observable<IWebXRPlane>;
  76396. /**
  76397. * Observers registered here will be executed when a plane is no longer detected in the session
  76398. */
  76399. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  76400. /**
  76401. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  76402. * This can execute N times every frame
  76403. */
  76404. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  76405. /**
  76406. * construct a new Plane Detector
  76407. * @param _xrSessionManager an instance of xr Session manager
  76408. * @param _options configuration to use when constructing this feature
  76409. */
  76410. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  76411. /**
  76412. * detach this feature.
  76413. * Will usually be called by the features manager
  76414. *
  76415. * @returns true if successful.
  76416. */
  76417. detach(): boolean;
  76418. /**
  76419. * Dispose this feature and all of the resources attached
  76420. */
  76421. dispose(): void;
  76422. /**
  76423. * Check if the needed objects are defined.
  76424. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  76425. */
  76426. isCompatible(): boolean;
  76427. protected _onXRFrame(frame: XRFrame): void;
  76428. private _init;
  76429. private _updatePlaneWithXRPlane;
  76430. /**
  76431. * avoiding using Array.find for global support.
  76432. * @param xrPlane the plane to find in the array
  76433. */
  76434. private findIndexInPlaneArray;
  76435. }
  76436. }
  76437. declare module BABYLON {
  76438. /**
  76439. * Options interface for the background remover plugin
  76440. */
  76441. export interface IWebXRBackgroundRemoverOptions {
  76442. /**
  76443. * Further background meshes to disable when entering AR
  76444. */
  76445. backgroundMeshes?: AbstractMesh[];
  76446. /**
  76447. * flags to configure the removal of the environment helper.
  76448. * If not set, the entire background will be removed. If set, flags should be set as well.
  76449. */
  76450. environmentHelperRemovalFlags?: {
  76451. /**
  76452. * Should the skybox be removed (default false)
  76453. */
  76454. skyBox?: boolean;
  76455. /**
  76456. * Should the ground be removed (default false)
  76457. */
  76458. ground?: boolean;
  76459. };
  76460. /**
  76461. * don't disable the environment helper
  76462. */
  76463. ignoreEnvironmentHelper?: boolean;
  76464. }
  76465. /**
  76466. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  76467. */
  76468. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  76469. /**
  76470. * read-only options to be used in this module
  76471. */
  76472. readonly options: IWebXRBackgroundRemoverOptions;
  76473. /**
  76474. * The module's name
  76475. */
  76476. static readonly Name: string;
  76477. /**
  76478. * The (Babylon) version of this module.
  76479. * This is an integer representing the implementation version.
  76480. * This number does not correspond to the WebXR specs version
  76481. */
  76482. static readonly Version: number;
  76483. /**
  76484. * registered observers will be triggered when the background state changes
  76485. */
  76486. onBackgroundStateChangedObservable: Observable<boolean>;
  76487. /**
  76488. * constructs a new background remover module
  76489. * @param _xrSessionManager the session manager for this module
  76490. * @param options read-only options to be used in this module
  76491. */
  76492. constructor(_xrSessionManager: WebXRSessionManager,
  76493. /**
  76494. * read-only options to be used in this module
  76495. */
  76496. options?: IWebXRBackgroundRemoverOptions);
  76497. /**
  76498. * attach this feature
  76499. * Will usually be called by the features manager
  76500. *
  76501. * @returns true if successful.
  76502. */
  76503. attach(): boolean;
  76504. /**
  76505. * detach this feature.
  76506. * Will usually be called by the features manager
  76507. *
  76508. * @returns true if successful.
  76509. */
  76510. detach(): boolean;
  76511. /**
  76512. * Dispose this feature and all of the resources attached
  76513. */
  76514. dispose(): void;
  76515. protected _onXRFrame(_xrFrame: XRFrame): void;
  76516. private _setBackgroundState;
  76517. }
  76518. }
  76519. declare module BABYLON {
  76520. /**
  76521. * Options for the controller physics feature
  76522. */
  76523. export class IWebXRControllerPhysicsOptions {
  76524. /**
  76525. * Should the headset get its own impostor
  76526. */
  76527. enableHeadsetImpostor?: boolean;
  76528. /**
  76529. * Optional parameters for the headset impostor
  76530. */
  76531. headsetImpostorParams?: {
  76532. /**
  76533. * The type of impostor to create. Default is sphere
  76534. */
  76535. impostorType: number;
  76536. /**
  76537. * the size of the impostor. Defaults to 10cm
  76538. */
  76539. impostorSize?: number | {
  76540. width: number;
  76541. height: number;
  76542. depth: number;
  76543. };
  76544. /**
  76545. * Friction definitions
  76546. */
  76547. friction?: number;
  76548. /**
  76549. * Restitution
  76550. */
  76551. restitution?: number;
  76552. };
  76553. /**
  76554. * The physics properties of the future impostors
  76555. */
  76556. physicsProperties?: {
  76557. /**
  76558. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  76559. * Note that this requires a physics engine that supports mesh impostors!
  76560. */
  76561. useControllerMesh?: boolean;
  76562. /**
  76563. * The type of impostor to create. Default is sphere
  76564. */
  76565. impostorType?: number;
  76566. /**
  76567. * the size of the impostor. Defaults to 10cm
  76568. */
  76569. impostorSize?: number | {
  76570. width: number;
  76571. height: number;
  76572. depth: number;
  76573. };
  76574. /**
  76575. * Friction definitions
  76576. */
  76577. friction?: number;
  76578. /**
  76579. * Restitution
  76580. */
  76581. restitution?: number;
  76582. };
  76583. /**
  76584. * the xr input to use with this pointer selection
  76585. */
  76586. xrInput: WebXRInput;
  76587. }
  76588. /**
  76589. * Add physics impostor to your webxr controllers,
  76590. * including naive calculation of their linear and angular velocity
  76591. */
  76592. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  76593. private readonly _options;
  76594. private _attachController;
  76595. private _controllers;
  76596. private _debugMode;
  76597. private _delta;
  76598. private _headsetImpostor?;
  76599. private _headsetMesh?;
  76600. private _lastTimestamp;
  76601. private _tmpQuaternion;
  76602. private _tmpVector;
  76603. /**
  76604. * The module's name
  76605. */
  76606. static readonly Name: string;
  76607. /**
  76608. * The (Babylon) version of this module.
  76609. * This is an integer representing the implementation version.
  76610. * This number does not correspond to the webxr specs version
  76611. */
  76612. static readonly Version: number;
  76613. /**
  76614. * Construct a new Controller Physics Feature
  76615. * @param _xrSessionManager the corresponding xr session manager
  76616. * @param _options options to create this feature with
  76617. */
  76618. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  76619. /**
  76620. * @hidden
  76621. * enable debugging - will show console outputs and the impostor mesh
  76622. */
  76623. _enablePhysicsDebug(): void;
  76624. /**
  76625. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  76626. * @param xrController the controller to add
  76627. */
  76628. addController(xrController: WebXRInputSource): void;
  76629. /**
  76630. * attach this feature
  76631. * Will usually be called by the features manager
  76632. *
  76633. * @returns true if successful.
  76634. */
  76635. attach(): boolean;
  76636. /**
  76637. * detach this feature.
  76638. * Will usually be called by the features manager
  76639. *
  76640. * @returns true if successful.
  76641. */
  76642. detach(): boolean;
  76643. /**
  76644. * Get the headset impostor, if enabled
  76645. * @returns the impostor
  76646. */
  76647. getHeadsetImpostor(): PhysicsImpostor | undefined;
  76648. /**
  76649. * Get the physics impostor of a specific controller.
  76650. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  76651. * @param controller the controller or the controller id of which to get the impostor
  76652. * @returns the impostor or null
  76653. */
  76654. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  76655. /**
  76656. * Update the physics properties provided in the constructor
  76657. * @param newProperties the new properties object
  76658. */
  76659. setPhysicsProperties(newProperties: {
  76660. impostorType?: number;
  76661. impostorSize?: number | {
  76662. width: number;
  76663. height: number;
  76664. depth: number;
  76665. };
  76666. friction?: number;
  76667. restitution?: number;
  76668. }): void;
  76669. protected _onXRFrame(_xrFrame: any): void;
  76670. private _detachController;
  76671. }
  76672. }
  76673. declare module BABYLON {
  76674. /**
  76675. * A babylon interface for a "WebXR" feature point.
  76676. * Represents the position and confidence value of a given feature point.
  76677. */
  76678. export interface IWebXRFeaturePoint {
  76679. /**
  76680. * Represents the position of the feature point in world space.
  76681. */
  76682. position: Vector3;
  76683. /**
  76684. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  76685. */
  76686. confidenceValue: number;
  76687. }
  76688. /**
  76689. * The feature point system is used to detect feature points from real world geometry.
  76690. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  76691. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  76692. */
  76693. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  76694. private _enabled;
  76695. private _featurePointCloud;
  76696. /**
  76697. * The module's name
  76698. */
  76699. static readonly Name: string;
  76700. /**
  76701. * The (Babylon) version of this module.
  76702. * This is an integer representing the implementation version.
  76703. * This number does not correspond to the WebXR specs version
  76704. */
  76705. static readonly Version: number;
  76706. /**
  76707. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  76708. * Will notify the observers about which feature points have been added.
  76709. */
  76710. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  76711. /**
  76712. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  76713. * Will notify the observers about which feature points have been updated.
  76714. */
  76715. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  76716. /**
  76717. * The current feature point cloud maintained across frames.
  76718. */
  76719. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  76720. /**
  76721. * construct the feature point system
  76722. * @param _xrSessionManager an instance of xr Session manager
  76723. */
  76724. constructor(_xrSessionManager: WebXRSessionManager);
  76725. /**
  76726. * Detach this feature.
  76727. * Will usually be called by the features manager
  76728. *
  76729. * @returns true if successful.
  76730. */
  76731. detach(): boolean;
  76732. /**
  76733. * Dispose this feature and all of the resources attached
  76734. */
  76735. dispose(): void;
  76736. /**
  76737. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  76738. */
  76739. protected _onXRFrame(frame: XRFrame): void;
  76740. /**
  76741. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  76742. */
  76743. private _init;
  76744. }
  76745. }
  76746. declare module BABYLON {
  76747. /**
  76748. * Configuration interface for the hand tracking feature
  76749. */
  76750. export interface IWebXRHandTrackingOptions {
  76751. /**
  76752. * The xrInput that will be used as source for new hands
  76753. */
  76754. xrInput: WebXRInput;
  76755. /**
  76756. * Configuration object for the joint meshes
  76757. */
  76758. jointMeshes?: {
  76759. /**
  76760. * Should the meshes created be invisible (defaults to false)
  76761. */
  76762. invisible?: boolean;
  76763. /**
  76764. * A source mesh to be used to create instances. Defaults to a sphere.
  76765. * This mesh will be the source for all other (25) meshes.
  76766. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  76767. */
  76768. sourceMesh?: Mesh;
  76769. /**
  76770. * This function will be called after a mesh was created for a specific joint.
  76771. * Using this function you can either manipulate the instance or return a new mesh.
  76772. * When returning a new mesh the instance created before will be disposed
  76773. */
  76774. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  76775. /**
  76776. * Should the source mesh stay visible. Defaults to false
  76777. */
  76778. keepOriginalVisible?: boolean;
  76779. /**
  76780. * Scale factor for all instances (defaults to 2)
  76781. */
  76782. scaleFactor?: number;
  76783. /**
  76784. * Should each instance have its own physics impostor
  76785. */
  76786. enablePhysics?: boolean;
  76787. /**
  76788. * If enabled, override default physics properties
  76789. */
  76790. physicsProps?: {
  76791. friction?: number;
  76792. restitution?: number;
  76793. impostorType?: number;
  76794. };
  76795. /**
  76796. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  76797. */
  76798. handMesh?: AbstractMesh;
  76799. };
  76800. }
  76801. /**
  76802. * Parts of the hands divided to writs and finger names
  76803. */
  76804. export const enum HandPart {
  76805. /**
  76806. * HandPart - Wrist
  76807. */
  76808. WRIST = "wrist",
  76809. /**
  76810. * HandPart - The THumb
  76811. */
  76812. THUMB = "thumb",
  76813. /**
  76814. * HandPart - Index finger
  76815. */
  76816. INDEX = "index",
  76817. /**
  76818. * HandPart - Middle finger
  76819. */
  76820. MIDDLE = "middle",
  76821. /**
  76822. * HandPart - Ring finger
  76823. */
  76824. RING = "ring",
  76825. /**
  76826. * HandPart - Little finger
  76827. */
  76828. LITTLE = "little"
  76829. }
  76830. /**
  76831. * Representing a single hand (with its corresponding native XRHand object)
  76832. */
  76833. export class WebXRHand implements IDisposable {
  76834. /** the controller to which the hand correlates */
  76835. readonly xrController: WebXRInputSource;
  76836. /** the meshes to be used to track the hand joints */
  76837. readonly trackedMeshes: AbstractMesh[];
  76838. /**
  76839. * Hand-parts definition (key is HandPart)
  76840. */
  76841. handPartsDefinition: {
  76842. [key: string]: number[];
  76843. };
  76844. /**
  76845. * Populate the HandPartsDefinition object.
  76846. * This is called as a side effect since certain browsers don't have XRHand defined.
  76847. */
  76848. private generateHandPartsDefinition;
  76849. /**
  76850. * Construct a new hand object
  76851. * @param xrController the controller to which the hand correlates
  76852. * @param trackedMeshes the meshes to be used to track the hand joints
  76853. */
  76854. constructor(
  76855. /** the controller to which the hand correlates */
  76856. xrController: WebXRInputSource,
  76857. /** the meshes to be used to track the hand joints */
  76858. trackedMeshes: AbstractMesh[]);
  76859. /**
  76860. * Update this hand from the latest xr frame
  76861. * @param xrFrame xrFrame to update from
  76862. * @param referenceSpace The current viewer reference space
  76863. * @param scaleFactor optional scale factor for the meshes
  76864. */
  76865. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  76866. /**
  76867. * Get meshes of part of the hand
  76868. * @param part the part of hand to get
  76869. * @returns An array of meshes that correlate to the hand part requested
  76870. */
  76871. getHandPartMeshes(part: HandPart): AbstractMesh[];
  76872. /**
  76873. * Dispose this Hand object
  76874. */
  76875. dispose(): void;
  76876. }
  76877. /**
  76878. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  76879. */
  76880. export class WebXRHandTracking extends WebXRAbstractFeature {
  76881. /**
  76882. * options to use when constructing this feature
  76883. */
  76884. readonly options: IWebXRHandTrackingOptions;
  76885. private static _idCounter;
  76886. /**
  76887. * The module's name
  76888. */
  76889. static readonly Name: string;
  76890. /**
  76891. * The (Babylon) version of this module.
  76892. * This is an integer representing the implementation version.
  76893. * This number does not correspond to the WebXR specs version
  76894. */
  76895. static readonly Version: number;
  76896. /**
  76897. * This observable will notify registered observers when a new hand object was added and initialized
  76898. */
  76899. onHandAddedObservable: Observable<WebXRHand>;
  76900. /**
  76901. * This observable will notify its observers right before the hand object is disposed
  76902. */
  76903. onHandRemovedObservable: Observable<WebXRHand>;
  76904. private _hands;
  76905. /**
  76906. * Creates a new instance of the hit test feature
  76907. * @param _xrSessionManager an instance of WebXRSessionManager
  76908. * @param options options to use when constructing this feature
  76909. */
  76910. constructor(_xrSessionManager: WebXRSessionManager,
  76911. /**
  76912. * options to use when constructing this feature
  76913. */
  76914. options: IWebXRHandTrackingOptions);
  76915. /**
  76916. * Check if the needed objects are defined.
  76917. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  76918. */
  76919. isCompatible(): boolean;
  76920. /**
  76921. * attach this feature
  76922. * Will usually be called by the features manager
  76923. *
  76924. * @returns true if successful.
  76925. */
  76926. attach(): boolean;
  76927. /**
  76928. * detach this feature.
  76929. * Will usually be called by the features manager
  76930. *
  76931. * @returns true if successful.
  76932. */
  76933. detach(): boolean;
  76934. /**
  76935. * Dispose this feature and all of the resources attached
  76936. */
  76937. dispose(): void;
  76938. /**
  76939. * Get the hand object according to the controller id
  76940. * @param controllerId the controller id to which we want to get the hand
  76941. * @returns null if not found or the WebXRHand object if found
  76942. */
  76943. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  76944. /**
  76945. * Get a hand object according to the requested handedness
  76946. * @param handedness the handedness to request
  76947. * @returns null if not found or the WebXRHand object if found
  76948. */
  76949. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  76950. protected _onXRFrame(_xrFrame: XRFrame): void;
  76951. private _attachHand;
  76952. private _detachHand;
  76953. }
  76954. }
  76955. declare module BABYLON {
  76956. /**
  76957. * The motion controller class for all microsoft mixed reality controllers
  76958. */
  76959. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  76960. protected readonly _mapping: {
  76961. defaultButton: {
  76962. valueNodeName: string;
  76963. unpressedNodeName: string;
  76964. pressedNodeName: string;
  76965. };
  76966. defaultAxis: {
  76967. valueNodeName: string;
  76968. minNodeName: string;
  76969. maxNodeName: string;
  76970. };
  76971. buttons: {
  76972. "xr-standard-trigger": {
  76973. rootNodeName: string;
  76974. componentProperty: string;
  76975. states: string[];
  76976. };
  76977. "xr-standard-squeeze": {
  76978. rootNodeName: string;
  76979. componentProperty: string;
  76980. states: string[];
  76981. };
  76982. "xr-standard-touchpad": {
  76983. rootNodeName: string;
  76984. labelAnchorNodeName: string;
  76985. touchPointNodeName: string;
  76986. };
  76987. "xr-standard-thumbstick": {
  76988. rootNodeName: string;
  76989. componentProperty: string;
  76990. states: string[];
  76991. };
  76992. };
  76993. axes: {
  76994. "xr-standard-touchpad": {
  76995. "x-axis": {
  76996. rootNodeName: string;
  76997. };
  76998. "y-axis": {
  76999. rootNodeName: string;
  77000. };
  77001. };
  77002. "xr-standard-thumbstick": {
  77003. "x-axis": {
  77004. rootNodeName: string;
  77005. };
  77006. "y-axis": {
  77007. rootNodeName: string;
  77008. };
  77009. };
  77010. };
  77011. };
  77012. /**
  77013. * The base url used to load the left and right controller models
  77014. */
  77015. static MODEL_BASE_URL: string;
  77016. /**
  77017. * The name of the left controller model file
  77018. */
  77019. static MODEL_LEFT_FILENAME: string;
  77020. /**
  77021. * The name of the right controller model file
  77022. */
  77023. static MODEL_RIGHT_FILENAME: string;
  77024. profileId: string;
  77025. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  77026. protected _getFilenameAndPath(): {
  77027. filename: string;
  77028. path: string;
  77029. };
  77030. protected _getModelLoadingConstraints(): boolean;
  77031. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77032. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77033. protected _updateModel(): void;
  77034. }
  77035. }
  77036. declare module BABYLON {
  77037. /**
  77038. * The motion controller class for oculus touch (quest, rift).
  77039. * This class supports legacy mapping as well the standard xr mapping
  77040. */
  77041. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  77042. private _forceLegacyControllers;
  77043. private _modelRootNode;
  77044. /**
  77045. * The base url used to load the left and right controller models
  77046. */
  77047. static MODEL_BASE_URL: string;
  77048. /**
  77049. * The name of the left controller model file
  77050. */
  77051. static MODEL_LEFT_FILENAME: string;
  77052. /**
  77053. * The name of the right controller model file
  77054. */
  77055. static MODEL_RIGHT_FILENAME: string;
  77056. /**
  77057. * Base Url for the Quest controller model.
  77058. */
  77059. static QUEST_MODEL_BASE_URL: string;
  77060. profileId: string;
  77061. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  77062. protected _getFilenameAndPath(): {
  77063. filename: string;
  77064. path: string;
  77065. };
  77066. protected _getModelLoadingConstraints(): boolean;
  77067. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77068. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77069. protected _updateModel(): void;
  77070. /**
  77071. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  77072. * between the touch and touch 2.
  77073. */
  77074. private _isQuest;
  77075. }
  77076. }
  77077. declare module BABYLON {
  77078. /**
  77079. * The motion controller class for the standard HTC-Vive controllers
  77080. */
  77081. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  77082. private _modelRootNode;
  77083. /**
  77084. * The base url used to load the left and right controller models
  77085. */
  77086. static MODEL_BASE_URL: string;
  77087. /**
  77088. * File name for the controller model.
  77089. */
  77090. static MODEL_FILENAME: string;
  77091. profileId: string;
  77092. /**
  77093. * Create a new Vive motion controller object
  77094. * @param scene the scene to use to create this controller
  77095. * @param gamepadObject the corresponding gamepad object
  77096. * @param handedness the handedness of the controller
  77097. */
  77098. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  77099. protected _getFilenameAndPath(): {
  77100. filename: string;
  77101. path: string;
  77102. };
  77103. protected _getModelLoadingConstraints(): boolean;
  77104. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77105. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77106. protected _updateModel(): void;
  77107. }
  77108. }
  77109. declare module BABYLON {
  77110. /**
  77111. * A cursor which tracks a point on a path
  77112. */
  77113. export class PathCursor {
  77114. private path;
  77115. /**
  77116. * Stores path cursor callbacks for when an onchange event is triggered
  77117. */
  77118. private _onchange;
  77119. /**
  77120. * The value of the path cursor
  77121. */
  77122. value: number;
  77123. /**
  77124. * The animation array of the path cursor
  77125. */
  77126. animations: Animation[];
  77127. /**
  77128. * Initializes the path cursor
  77129. * @param path The path to track
  77130. */
  77131. constructor(path: Path2);
  77132. /**
  77133. * Gets the cursor point on the path
  77134. * @returns A point on the path cursor at the cursor location
  77135. */
  77136. getPoint(): Vector3;
  77137. /**
  77138. * Moves the cursor ahead by the step amount
  77139. * @param step The amount to move the cursor forward
  77140. * @returns This path cursor
  77141. */
  77142. moveAhead(step?: number): PathCursor;
  77143. /**
  77144. * Moves the cursor behind by the step amount
  77145. * @param step The amount to move the cursor back
  77146. * @returns This path cursor
  77147. */
  77148. moveBack(step?: number): PathCursor;
  77149. /**
  77150. * Moves the cursor by the step amount
  77151. * If the step amount is greater than one, an exception is thrown
  77152. * @param step The amount to move the cursor
  77153. * @returns This path cursor
  77154. */
  77155. move(step: number): PathCursor;
  77156. /**
  77157. * Ensures that the value is limited between zero and one
  77158. * @returns This path cursor
  77159. */
  77160. private ensureLimits;
  77161. /**
  77162. * Runs onchange callbacks on change (used by the animation engine)
  77163. * @returns This path cursor
  77164. */
  77165. private raiseOnChange;
  77166. /**
  77167. * Executes a function on change
  77168. * @param f A path cursor onchange callback
  77169. * @returns This path cursor
  77170. */
  77171. onchange(f: (cursor: PathCursor) => void): PathCursor;
  77172. }
  77173. }
  77174. declare module BABYLON {
  77175. /** @hidden */
  77176. export var blurPixelShader: {
  77177. name: string;
  77178. shader: string;
  77179. };
  77180. }
  77181. declare module BABYLON {
  77182. /** @hidden */
  77183. export var pointCloudVertexDeclaration: {
  77184. name: string;
  77185. shader: string;
  77186. };
  77187. }
  77188. // Mixins
  77189. interface Window {
  77190. mozIndexedDB: IDBFactory;
  77191. webkitIndexedDB: IDBFactory;
  77192. msIndexedDB: IDBFactory;
  77193. webkitURL: typeof URL;
  77194. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  77195. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  77196. WebGLRenderingContext: WebGLRenderingContext;
  77197. MSGesture: MSGesture;
  77198. CANNON: any;
  77199. AudioContext: AudioContext;
  77200. webkitAudioContext: AudioContext;
  77201. PointerEvent: any;
  77202. Math: Math;
  77203. Uint8Array: Uint8ArrayConstructor;
  77204. Float32Array: Float32ArrayConstructor;
  77205. mozURL: typeof URL;
  77206. msURL: typeof URL;
  77207. VRFrameData: any; // WebVR, from specs 1.1
  77208. DracoDecoderModule: any;
  77209. setImmediate(handler: (...args: any[]) => void): number;
  77210. }
  77211. interface HTMLCanvasElement {
  77212. requestPointerLock(): void;
  77213. msRequestPointerLock?(): void;
  77214. mozRequestPointerLock?(): void;
  77215. webkitRequestPointerLock?(): void;
  77216. /** Track wether a record is in progress */
  77217. isRecording: boolean;
  77218. /** Capture Stream method defined by some browsers */
  77219. captureStream(fps?: number): MediaStream;
  77220. }
  77221. interface CanvasRenderingContext2D {
  77222. msImageSmoothingEnabled: boolean;
  77223. }
  77224. interface MouseEvent {
  77225. mozMovementX: number;
  77226. mozMovementY: number;
  77227. webkitMovementX: number;
  77228. webkitMovementY: number;
  77229. msMovementX: number;
  77230. msMovementY: number;
  77231. }
  77232. interface Navigator {
  77233. mozGetVRDevices: (any: any) => any;
  77234. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  77235. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  77236. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  77237. webkitGetGamepads(): Gamepad[];
  77238. msGetGamepads(): Gamepad[];
  77239. webkitGamepads(): Gamepad[];
  77240. }
  77241. interface HTMLVideoElement {
  77242. mozSrcObject: any;
  77243. }
  77244. interface Math {
  77245. fround(x: number): number;
  77246. imul(a: number, b: number): number;
  77247. }
  77248. interface WebGLRenderingContext {
  77249. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  77250. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  77251. vertexAttribDivisor(index: number, divisor: number): void;
  77252. createVertexArray(): any;
  77253. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  77254. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  77255. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  77256. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  77257. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  77258. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  77259. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  77260. // Queries
  77261. createQuery(): WebGLQuery;
  77262. deleteQuery(query: WebGLQuery): void;
  77263. beginQuery(target: number, query: WebGLQuery): void;
  77264. endQuery(target: number): void;
  77265. getQueryParameter(query: WebGLQuery, pname: number): any;
  77266. getQuery(target: number, pname: number): any;
  77267. MAX_SAMPLES: number;
  77268. RGBA8: number;
  77269. READ_FRAMEBUFFER: number;
  77270. DRAW_FRAMEBUFFER: number;
  77271. UNIFORM_BUFFER: number;
  77272. HALF_FLOAT_OES: number;
  77273. RGBA16F: number;
  77274. RGBA32F: number;
  77275. R32F: number;
  77276. RG32F: number;
  77277. RGB32F: number;
  77278. R16F: number;
  77279. RG16F: number;
  77280. RGB16F: number;
  77281. RED: number;
  77282. RG: number;
  77283. R8: number;
  77284. RG8: number;
  77285. UNSIGNED_INT_24_8: number;
  77286. DEPTH24_STENCIL8: number;
  77287. MIN: number;
  77288. MAX: number;
  77289. /* Multiple Render Targets */
  77290. drawBuffers(buffers: number[]): void;
  77291. readBuffer(src: number): void;
  77292. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  77293. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  77294. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  77295. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  77296. // Occlusion Query
  77297. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  77298. ANY_SAMPLES_PASSED: number;
  77299. QUERY_RESULT_AVAILABLE: number;
  77300. QUERY_RESULT: number;
  77301. }
  77302. interface WebGLProgram {
  77303. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  77304. }
  77305. interface EXT_disjoint_timer_query {
  77306. QUERY_COUNTER_BITS_EXT: number;
  77307. TIME_ELAPSED_EXT: number;
  77308. TIMESTAMP_EXT: number;
  77309. GPU_DISJOINT_EXT: number;
  77310. QUERY_RESULT_EXT: number;
  77311. QUERY_RESULT_AVAILABLE_EXT: number;
  77312. queryCounterEXT(query: WebGLQuery, target: number): void;
  77313. createQueryEXT(): WebGLQuery;
  77314. beginQueryEXT(target: number, query: WebGLQuery): void;
  77315. endQueryEXT(target: number): void;
  77316. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  77317. deleteQueryEXT(query: WebGLQuery): void;
  77318. }
  77319. interface WebGLUniformLocation {
  77320. _currentState: any;
  77321. }
  77322. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  77323. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  77324. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  77325. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  77326. interface WebGLRenderingContext {
  77327. readonly RASTERIZER_DISCARD: number;
  77328. readonly DEPTH_COMPONENT24: number;
  77329. readonly TEXTURE_3D: number;
  77330. readonly TEXTURE_2D_ARRAY: number;
  77331. readonly TEXTURE_COMPARE_FUNC: number;
  77332. readonly TEXTURE_COMPARE_MODE: number;
  77333. readonly COMPARE_REF_TO_TEXTURE: number;
  77334. readonly TEXTURE_WRAP_R: number;
  77335. readonly HALF_FLOAT: number;
  77336. readonly RGB8: number;
  77337. readonly RED_INTEGER: number;
  77338. readonly RG_INTEGER: number;
  77339. readonly RGB_INTEGER: number;
  77340. readonly RGBA_INTEGER: number;
  77341. readonly R8_SNORM: number;
  77342. readonly RG8_SNORM: number;
  77343. readonly RGB8_SNORM: number;
  77344. readonly RGBA8_SNORM: number;
  77345. readonly R8I: number;
  77346. readonly RG8I: number;
  77347. readonly RGB8I: number;
  77348. readonly RGBA8I: number;
  77349. readonly R8UI: number;
  77350. readonly RG8UI: number;
  77351. readonly RGB8UI: number;
  77352. readonly RGBA8UI: number;
  77353. readonly R16I: number;
  77354. readonly RG16I: number;
  77355. readonly RGB16I: number;
  77356. readonly RGBA16I: number;
  77357. readonly R16UI: number;
  77358. readonly RG16UI: number;
  77359. readonly RGB16UI: number;
  77360. readonly RGBA16UI: number;
  77361. readonly R32I: number;
  77362. readonly RG32I: number;
  77363. readonly RGB32I: number;
  77364. readonly RGBA32I: number;
  77365. readonly R32UI: number;
  77366. readonly RG32UI: number;
  77367. readonly RGB32UI: number;
  77368. readonly RGBA32UI: number;
  77369. readonly RGB10_A2UI: number;
  77370. readonly R11F_G11F_B10F: number;
  77371. readonly RGB9_E5: number;
  77372. readonly RGB10_A2: number;
  77373. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  77374. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  77375. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  77376. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  77377. readonly DEPTH_COMPONENT32F: number;
  77378. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  77379. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  77380. 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;
  77381. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  77382. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  77383. readonly TRANSFORM_FEEDBACK: number;
  77384. readonly INTERLEAVED_ATTRIBS: number;
  77385. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  77386. createTransformFeedback(): WebGLTransformFeedback;
  77387. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  77388. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  77389. beginTransformFeedback(primitiveMode: number): void;
  77390. endTransformFeedback(): void;
  77391. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  77392. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77393. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77394. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77395. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  77396. }
  77397. interface ImageBitmap {
  77398. readonly width: number;
  77399. readonly height: number;
  77400. close(): void;
  77401. }
  77402. interface WebGLQuery extends WebGLObject {
  77403. }
  77404. declare var WebGLQuery: {
  77405. prototype: WebGLQuery;
  77406. new(): WebGLQuery;
  77407. };
  77408. interface WebGLSampler extends WebGLObject {
  77409. }
  77410. declare var WebGLSampler: {
  77411. prototype: WebGLSampler;
  77412. new(): WebGLSampler;
  77413. };
  77414. interface WebGLSync extends WebGLObject {
  77415. }
  77416. declare var WebGLSync: {
  77417. prototype: WebGLSync;
  77418. new(): WebGLSync;
  77419. };
  77420. interface WebGLTransformFeedback extends WebGLObject {
  77421. }
  77422. declare var WebGLTransformFeedback: {
  77423. prototype: WebGLTransformFeedback;
  77424. new(): WebGLTransformFeedback;
  77425. };
  77426. interface WebGLVertexArrayObject extends WebGLObject {
  77427. }
  77428. declare var WebGLVertexArrayObject: {
  77429. prototype: WebGLVertexArrayObject;
  77430. new(): WebGLVertexArrayObject;
  77431. };
  77432. // Type definitions for WebVR API
  77433. // Project: https://w3c.github.io/webvr/
  77434. // Definitions by: six a <https://github.com/lostfictions>
  77435. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  77436. interface VRDisplay extends EventTarget {
  77437. /**
  77438. * Dictionary of capabilities describing the VRDisplay.
  77439. */
  77440. readonly capabilities: VRDisplayCapabilities;
  77441. /**
  77442. * z-depth defining the far plane of the eye view frustum
  77443. * enables mapping of values in the render target depth
  77444. * attachment to scene coordinates. Initially set to 10000.0.
  77445. */
  77446. depthFar: number;
  77447. /**
  77448. * z-depth defining the near plane of the eye view frustum
  77449. * enables mapping of values in the render target depth
  77450. * attachment to scene coordinates. Initially set to 0.01.
  77451. */
  77452. depthNear: number;
  77453. /**
  77454. * An identifier for this distinct VRDisplay. Used as an
  77455. * association point in the Gamepad API.
  77456. */
  77457. readonly displayId: number;
  77458. /**
  77459. * A display name, a user-readable name identifying it.
  77460. */
  77461. readonly displayName: string;
  77462. readonly isConnected: boolean;
  77463. readonly isPresenting: boolean;
  77464. /**
  77465. * If this VRDisplay supports room-scale experiences, the optional
  77466. * stage attribute contains details on the room-scale parameters.
  77467. */
  77468. readonly stageParameters: VRStageParameters | null;
  77469. /**
  77470. * Passing the value returned by `requestAnimationFrame` to
  77471. * `cancelAnimationFrame` will unregister the callback.
  77472. * @param handle Define the hanle of the request to cancel
  77473. */
  77474. cancelAnimationFrame(handle: number): void;
  77475. /**
  77476. * Stops presenting to the VRDisplay.
  77477. * @returns a promise to know when it stopped
  77478. */
  77479. exitPresent(): Promise<void>;
  77480. /**
  77481. * Return the current VREyeParameters for the given eye.
  77482. * @param whichEye Define the eye we want the parameter for
  77483. * @returns the eye parameters
  77484. */
  77485. getEyeParameters(whichEye: string): VREyeParameters;
  77486. /**
  77487. * Populates the passed VRFrameData with the information required to render
  77488. * the current frame.
  77489. * @param frameData Define the data structure to populate
  77490. * @returns true if ok otherwise false
  77491. */
  77492. getFrameData(frameData: VRFrameData): boolean;
  77493. /**
  77494. * Get the layers currently being presented.
  77495. * @returns the list of VR layers
  77496. */
  77497. getLayers(): VRLayer[];
  77498. /**
  77499. * Return a VRPose containing the future predicted pose of the VRDisplay
  77500. * when the current frame will be presented. The value returned will not
  77501. * change until JavaScript has returned control to the browser.
  77502. *
  77503. * The VRPose will contain the position, orientation, velocity,
  77504. * and acceleration of each of these properties.
  77505. * @returns the pose object
  77506. */
  77507. getPose(): VRPose;
  77508. /**
  77509. * Return the current instantaneous pose of the VRDisplay, with no
  77510. * prediction applied.
  77511. * @returns the current instantaneous pose
  77512. */
  77513. getImmediatePose(): VRPose;
  77514. /**
  77515. * The callback passed to `requestAnimationFrame` will be called
  77516. * any time a new frame should be rendered. When the VRDisplay is
  77517. * presenting the callback will be called at the native refresh
  77518. * rate of the HMD. When not presenting this function acts
  77519. * identically to how window.requestAnimationFrame acts. Content should
  77520. * make no assumptions of frame rate or vsync behavior as the HMD runs
  77521. * asynchronously from other displays and at differing refresh rates.
  77522. * @param callback Define the eaction to run next frame
  77523. * @returns the request handle it
  77524. */
  77525. requestAnimationFrame(callback: FrameRequestCallback): number;
  77526. /**
  77527. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  77528. * Repeat calls while already presenting will update the VRLayers being displayed.
  77529. * @param layers Define the list of layer to present
  77530. * @returns a promise to know when the request has been fulfilled
  77531. */
  77532. requestPresent(layers: VRLayer[]): Promise<void>;
  77533. /**
  77534. * Reset the pose for this display, treating its current position and
  77535. * orientation as the "origin/zero" values. VRPose.position,
  77536. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  77537. * updated when calling resetPose(). This should be called in only
  77538. * sitting-space experiences.
  77539. */
  77540. resetPose(): void;
  77541. /**
  77542. * The VRLayer provided to the VRDisplay will be captured and presented
  77543. * in the HMD. Calling this function has the same effect on the source
  77544. * canvas as any other operation that uses its source image, and canvases
  77545. * created without preserveDrawingBuffer set to true will be cleared.
  77546. * @param pose Define the pose to submit
  77547. */
  77548. submitFrame(pose?: VRPose): void;
  77549. }
  77550. declare var VRDisplay: {
  77551. prototype: VRDisplay;
  77552. new(): VRDisplay;
  77553. };
  77554. interface VRLayer {
  77555. leftBounds?: number[] | Float32Array | null;
  77556. rightBounds?: number[] | Float32Array | null;
  77557. source?: HTMLCanvasElement | null;
  77558. }
  77559. interface VRDisplayCapabilities {
  77560. readonly canPresent: boolean;
  77561. readonly hasExternalDisplay: boolean;
  77562. readonly hasOrientation: boolean;
  77563. readonly hasPosition: boolean;
  77564. readonly maxLayers: number;
  77565. }
  77566. interface VREyeParameters {
  77567. /** @deprecated */
  77568. readonly fieldOfView: VRFieldOfView;
  77569. readonly offset: Float32Array;
  77570. readonly renderHeight: number;
  77571. readonly renderWidth: number;
  77572. }
  77573. interface VRFieldOfView {
  77574. readonly downDegrees: number;
  77575. readonly leftDegrees: number;
  77576. readonly rightDegrees: number;
  77577. readonly upDegrees: number;
  77578. }
  77579. interface VRFrameData {
  77580. readonly leftProjectionMatrix: Float32Array;
  77581. readonly leftViewMatrix: Float32Array;
  77582. readonly pose: VRPose;
  77583. readonly rightProjectionMatrix: Float32Array;
  77584. readonly rightViewMatrix: Float32Array;
  77585. readonly timestamp: number;
  77586. }
  77587. interface VRPose {
  77588. readonly angularAcceleration: Float32Array | null;
  77589. readonly angularVelocity: Float32Array | null;
  77590. readonly linearAcceleration: Float32Array | null;
  77591. readonly linearVelocity: Float32Array | null;
  77592. readonly orientation: Float32Array | null;
  77593. readonly position: Float32Array | null;
  77594. readonly timestamp: number;
  77595. }
  77596. interface VRStageParameters {
  77597. sittingToStandingTransform?: Float32Array;
  77598. sizeX?: number;
  77599. sizeY?: number;
  77600. }
  77601. interface Navigator {
  77602. getVRDisplays(): Promise<VRDisplay[]>;
  77603. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  77604. }
  77605. interface Window {
  77606. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  77607. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  77608. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  77609. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  77610. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  77611. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  77612. }
  77613. interface Gamepad {
  77614. readonly displayId: number;
  77615. }
  77616. /**
  77617. * Available session modes
  77618. */
  77619. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  77620. /**
  77621. * Reference space types
  77622. */
  77623. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  77624. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  77625. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  77626. /**
  77627. * Handedness types
  77628. */
  77629. type XRHandedness = "none" | "left" | "right";
  77630. /**
  77631. * InputSource target ray modes
  77632. */
  77633. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  77634. /**
  77635. * Eye types
  77636. */
  77637. type XREye = "none" | "left" | "right";
  77638. /**
  77639. * Type of XR events available
  77640. */
  77641. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  77642. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  77643. type XRPlaneSet = Set<XRPlane>;
  77644. type XRAnchorSet = Set<XRAnchor>;
  77645. type XREventHandler = (callback: any) => void;
  77646. interface XRLayer extends EventTarget {}
  77647. interface XRSessionInit {
  77648. optionalFeatures?: string[];
  77649. requiredFeatures?: string[];
  77650. }
  77651. interface XRSessionEvent extends Event {
  77652. readonly session: XRSession;
  77653. }
  77654. interface XRSystem {
  77655. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  77656. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  77657. }
  77658. interface XRViewport {
  77659. readonly x: number;
  77660. readonly y: number;
  77661. readonly width: number;
  77662. readonly height: number;
  77663. }
  77664. interface XRWebGLLayerInit {
  77665. antialias?: boolean;
  77666. depth?: boolean;
  77667. stencil?: boolean;
  77668. alpha?: boolean;
  77669. multiview?: boolean;
  77670. framebufferScaleFactor?: number;
  77671. }
  77672. declare class XRWebGLLayer {
  77673. static getNativeFramebufferScaleFactor(session: XRSession): number;
  77674. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  77675. readonly antialias: boolean;
  77676. readonly framebuffer: WebGLFramebuffer;
  77677. readonly framebufferWidth: number;
  77678. readonly framebufferHeight: number;
  77679. readonly ignoreDepthValues: boolean;
  77680. getViewport: (view: XRView) => XRViewport;
  77681. }
  77682. // tslint:disable-next-line no-empty-interface
  77683. interface XRSpace extends EventTarget {}
  77684. interface XRRenderState {
  77685. readonly baseLayer?: XRWebGLLayer;
  77686. readonly depthFar: number;
  77687. readonly depthNear: number;
  77688. readonly inlineVerticalFieldOfView?: number;
  77689. }
  77690. interface XRRenderStateInit extends XRRenderState {
  77691. baseLayer: XRWebGLLayer;
  77692. depthFar: number;
  77693. depthNear: number;
  77694. inlineVerticalFieldOfView?: number;
  77695. layers?: XRLayer[];
  77696. }
  77697. interface XRReferenceSpace extends XRSpace {
  77698. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  77699. onreset: XREventHandler;
  77700. }
  77701. interface XRBoundedReferenceSpace extends XRSpace {
  77702. readonly boundsGeometry: DOMPointReadOnly[];
  77703. }
  77704. interface XRInputSource {
  77705. readonly handedness: XRHandedness;
  77706. readonly targetRayMode: XRTargetRayMode;
  77707. readonly targetRaySpace: XRSpace;
  77708. readonly gripSpace?: XRSpace;
  77709. readonly gamepad?: Gamepad;
  77710. readonly profiles: Array<string>;
  77711. readonly hand?: XRHand;
  77712. }
  77713. interface XRPose {
  77714. readonly transform: XRRigidTransform;
  77715. readonly emulatedPosition: boolean;
  77716. }
  77717. interface XRFrame {
  77718. readonly session: XRSession;
  77719. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  77720. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  77721. // AR
  77722. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  77723. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  77724. // Anchors
  77725. trackedAnchors?: XRAnchorSet;
  77726. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  77727. // Planes
  77728. worldInformation?: {
  77729. detectedPlanes?: XRPlaneSet;
  77730. };
  77731. // Hand tracking
  77732. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  77733. }
  77734. interface XRInputSourceEvent extends Event {
  77735. readonly frame: XRFrame;
  77736. readonly inputSource: XRInputSource;
  77737. }
  77738. type XRInputSourceArray = XRInputSource[];
  77739. interface XRSession {
  77740. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  77741. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  77742. /**
  77743. * Returns a list of this session's XRInputSources, each representing an input device
  77744. * used to control the camera and/or scene.
  77745. */
  77746. readonly inputSources: Array<XRInputSource>;
  77747. /**
  77748. * object which contains options affecting how the imagery is rendered.
  77749. * This includes things such as the near and far clipping planes
  77750. */
  77751. readonly renderState: XRRenderState;
  77752. readonly visibilityState: XRVisibilityState;
  77753. /**
  77754. * Removes a callback from the animation frame painting callback from
  77755. * XRSession's set of animation frame rendering callbacks, given the
  77756. * identifying handle returned by a previous call to requestAnimationFrame().
  77757. */
  77758. cancelAnimationFrame: (handle: number) => void;
  77759. /**
  77760. * Ends the WebXR session. Returns a promise which resolves when the
  77761. * session has been shut down.
  77762. */
  77763. end(): Promise<void>;
  77764. /**
  77765. * Schedules the specified method to be called the next time the user agent
  77766. * is working on rendering an animation frame for the WebXR device. Returns an
  77767. * integer value which can be used to identify the request for the purposes of
  77768. * canceling the callback using cancelAnimationFrame(). This method is comparable
  77769. * to the Window.requestAnimationFrame() method.
  77770. */
  77771. requestAnimationFrame: XRFrameRequestCallback;
  77772. /**
  77773. * Requests that a new XRReferenceSpace of the specified type be created.
  77774. * Returns a promise which resolves with the XRReferenceSpace or
  77775. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  77776. * the requested space type isn't supported by the device.
  77777. */
  77778. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  77779. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  77780. onend: XREventHandler;
  77781. oninputsourceschange: XREventHandler;
  77782. onselect: XREventHandler;
  77783. onselectstart: XREventHandler;
  77784. onselectend: XREventHandler;
  77785. onsqueeze: XREventHandler;
  77786. onsqueezestart: XREventHandler;
  77787. onsqueezeend: XREventHandler;
  77788. onvisibilitychange: XREventHandler;
  77789. // hit test
  77790. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  77791. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  77792. // legacy AR hit test
  77793. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  77794. // legacy plane detection
  77795. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  77796. }
  77797. interface XRViewerPose extends XRPose {
  77798. readonly views: Array<XRView>;
  77799. }
  77800. declare class XRRigidTransform {
  77801. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  77802. position: DOMPointReadOnly;
  77803. orientation: DOMPointReadOnly;
  77804. matrix: Float32Array;
  77805. inverse: XRRigidTransform;
  77806. }
  77807. interface XRView {
  77808. readonly eye: XREye;
  77809. readonly projectionMatrix: Float32Array;
  77810. readonly transform: XRRigidTransform;
  77811. readonly recommendedViewportScale?: number;
  77812. requestViewportScale(scale: number): void;
  77813. }
  77814. interface XRInputSourceChangeEvent extends Event {
  77815. session: XRSession;
  77816. removed: Array<XRInputSource>;
  77817. added: Array<XRInputSource>;
  77818. }
  77819. // Experimental/Draft features
  77820. declare class XRRay {
  77821. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  77822. origin: DOMPointReadOnly;
  77823. direction: DOMPointReadOnly;
  77824. matrix: Float32Array;
  77825. }
  77826. declare enum XRHitTestTrackableType {
  77827. "point",
  77828. "plane",
  77829. "mesh",
  77830. }
  77831. interface XRHitResult {
  77832. hitMatrix: Float32Array;
  77833. }
  77834. interface XRTransientInputHitTestResult {
  77835. readonly inputSource: XRInputSource;
  77836. readonly results: Array<XRHitTestResult>;
  77837. }
  77838. interface XRHitTestResult {
  77839. getPose(baseSpace: XRSpace): XRPose | undefined;
  77840. // When anchor system is enabled
  77841. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  77842. }
  77843. interface XRHitTestSource {
  77844. cancel(): void;
  77845. }
  77846. interface XRTransientInputHitTestSource {
  77847. cancel(): void;
  77848. }
  77849. interface XRHitTestOptionsInit {
  77850. space: XRSpace;
  77851. entityTypes?: Array<XRHitTestTrackableType>;
  77852. offsetRay?: XRRay;
  77853. }
  77854. interface XRTransientInputHitTestOptionsInit {
  77855. profile: string;
  77856. entityTypes?: Array<XRHitTestTrackableType>;
  77857. offsetRay?: XRRay;
  77858. }
  77859. interface XRAnchor {
  77860. anchorSpace: XRSpace;
  77861. delete(): void;
  77862. }
  77863. interface XRPlane {
  77864. orientation: "Horizontal" | "Vertical";
  77865. planeSpace: XRSpace;
  77866. polygon: Array<DOMPointReadOnly>;
  77867. lastChangedTime: number;
  77868. }
  77869. interface XRJointSpace extends XRSpace {}
  77870. interface XRJointPose extends XRPose {
  77871. radius: number | undefined;
  77872. }
  77873. interface XRHand extends Iterable<XRJointSpace> {
  77874. readonly length: number;
  77875. [index: number]: XRJointSpace;
  77876. readonly WRIST: number;
  77877. readonly THUMB_METACARPAL: number;
  77878. readonly THUMB_PHALANX_PROXIMAL: number;
  77879. readonly THUMB_PHALANX_DISTAL: number;
  77880. readonly THUMB_PHALANX_TIP: number;
  77881. readonly INDEX_METACARPAL: number;
  77882. readonly INDEX_PHALANX_PROXIMAL: number;
  77883. readonly INDEX_PHALANX_INTERMEDIATE: number;
  77884. readonly INDEX_PHALANX_DISTAL: number;
  77885. readonly INDEX_PHALANX_TIP: number;
  77886. readonly MIDDLE_METACARPAL: number;
  77887. readonly MIDDLE_PHALANX_PROXIMAL: number;
  77888. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  77889. readonly MIDDLE_PHALANX_DISTAL: number;
  77890. readonly MIDDLE_PHALANX_TIP: number;
  77891. readonly RING_METACARPAL: number;
  77892. readonly RING_PHALANX_PROXIMAL: number;
  77893. readonly RING_PHALANX_INTERMEDIATE: number;
  77894. readonly RING_PHALANX_DISTAL: number;
  77895. readonly RING_PHALANX_TIP: number;
  77896. readonly LITTLE_METACARPAL: number;
  77897. readonly LITTLE_PHALANX_PROXIMAL: number;
  77898. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  77899. readonly LITTLE_PHALANX_DISTAL: number;
  77900. readonly LITTLE_PHALANX_TIP: number;
  77901. }
  77902. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  77903. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  77904. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  77905. interface XRSession {
  77906. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  77907. }
  77908. interface XRFrame {
  77909. featurePointCloud? : Array<number>;
  77910. }
  77911. /**
  77912. * @ignore
  77913. */
  77914. declare module BABYLON.GLTF2.Exporter {
  77915. }
  77916. /**
  77917. * @ignore
  77918. */
  77919. declare module BABYLON.GLTF1 {
  77920. }
  77921. declare module BABYLON.GUI {
  77922. /**
  77923. * Class used to specific a value and its associated unit
  77924. */
  77925. export class ValueAndUnit {
  77926. /** defines the unit to store */
  77927. unit: number;
  77928. /** defines a boolean indicating if the value can be negative */
  77929. negativeValueAllowed: boolean;
  77930. private _value;
  77931. private _originalUnit;
  77932. /**
  77933. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  77934. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77935. */
  77936. ignoreAdaptiveScaling: boolean;
  77937. /**
  77938. * Creates a new ValueAndUnit
  77939. * @param value defines the value to store
  77940. * @param unit defines the unit to store
  77941. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  77942. */
  77943. constructor(value: number,
  77944. /** defines the unit to store */
  77945. unit?: number,
  77946. /** defines a boolean indicating if the value can be negative */
  77947. negativeValueAllowed?: boolean);
  77948. /** Gets a boolean indicating if the value is a percentage */
  77949. get isPercentage(): boolean;
  77950. /** Gets a boolean indicating if the value is store as pixel */
  77951. get isPixel(): boolean;
  77952. /** Gets direct internal value */
  77953. get internalValue(): number;
  77954. /**
  77955. * Gets value as pixel
  77956. * @param host defines the root host
  77957. * @param refValue defines the reference value for percentages
  77958. * @returns the value as pixel
  77959. */
  77960. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  77961. /**
  77962. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  77963. * @param value defines the value to store
  77964. * @param unit defines the unit to store
  77965. * @returns the current ValueAndUnit
  77966. */
  77967. updateInPlace(value: number, unit?: number): ValueAndUnit;
  77968. /**
  77969. * Gets the value accordingly to its unit
  77970. * @param host defines the root host
  77971. * @returns the value
  77972. */
  77973. getValue(host: AdvancedDynamicTexture): number;
  77974. /**
  77975. * Gets a string representation of the value
  77976. * @param host defines the root host
  77977. * @param decimals defines an optional number of decimals to display
  77978. * @returns a string
  77979. */
  77980. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  77981. /**
  77982. * Store a value parsed from a string
  77983. * @param source defines the source string
  77984. * @returns true if the value was successfully parsed
  77985. */
  77986. fromString(source: string | number): boolean;
  77987. private static _Regex;
  77988. private static _UNITMODE_PERCENTAGE;
  77989. private static _UNITMODE_PIXEL;
  77990. /** UNITMODE_PERCENTAGE */
  77991. static get UNITMODE_PERCENTAGE(): number;
  77992. /** UNITMODE_PIXEL */
  77993. static get UNITMODE_PIXEL(): number;
  77994. }
  77995. }
  77996. declare module BABYLON.GUI {
  77997. /**
  77998. * Define a style used by control to automatically setup properties based on a template.
  77999. * Only support font related properties so far
  78000. */
  78001. export class Style implements BABYLON.IDisposable {
  78002. private _fontFamily;
  78003. private _fontStyle;
  78004. private _fontWeight;
  78005. /** @hidden */
  78006. _host: AdvancedDynamicTexture;
  78007. /** @hidden */
  78008. _fontSize: ValueAndUnit;
  78009. /**
  78010. * BABYLON.Observable raised when the style values are changed
  78011. */
  78012. onChangedObservable: BABYLON.Observable<Style>;
  78013. /**
  78014. * Creates a new style object
  78015. * @param host defines the AdvancedDynamicTexture which hosts this style
  78016. */
  78017. constructor(host: AdvancedDynamicTexture);
  78018. /**
  78019. * Gets or sets the font size
  78020. */
  78021. get fontSize(): string | number;
  78022. set fontSize(value: string | number);
  78023. /**
  78024. * Gets or sets the font family
  78025. */
  78026. get fontFamily(): string;
  78027. set fontFamily(value: string);
  78028. /**
  78029. * Gets or sets the font style
  78030. */
  78031. get fontStyle(): string;
  78032. set fontStyle(value: string);
  78033. /** Gets or sets font weight */
  78034. get fontWeight(): string;
  78035. set fontWeight(value: string);
  78036. /** Dispose all associated resources */
  78037. dispose(): void;
  78038. }
  78039. }
  78040. declare module BABYLON.GUI {
  78041. /**
  78042. * Class used to transport BABYLON.Vector2 information for pointer events
  78043. */
  78044. export class Vector2WithInfo extends BABYLON.Vector2 {
  78045. /** defines the current mouse button index */
  78046. buttonIndex: number;
  78047. /**
  78048. * Creates a new Vector2WithInfo
  78049. * @param source defines the vector2 data to transport
  78050. * @param buttonIndex defines the current mouse button index
  78051. */
  78052. constructor(source: BABYLON.Vector2,
  78053. /** defines the current mouse button index */
  78054. buttonIndex?: number);
  78055. }
  78056. /** Class used to provide 2D matrix features */
  78057. export class Matrix2D {
  78058. /** Gets the internal array of 6 floats used to store matrix data */
  78059. m: Float32Array;
  78060. /**
  78061. * Creates a new matrix
  78062. * @param m00 defines value for (0, 0)
  78063. * @param m01 defines value for (0, 1)
  78064. * @param m10 defines value for (1, 0)
  78065. * @param m11 defines value for (1, 1)
  78066. * @param m20 defines value for (2, 0)
  78067. * @param m21 defines value for (2, 1)
  78068. */
  78069. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  78070. /**
  78071. * Fills the matrix from direct values
  78072. * @param m00 defines value for (0, 0)
  78073. * @param m01 defines value for (0, 1)
  78074. * @param m10 defines value for (1, 0)
  78075. * @param m11 defines value for (1, 1)
  78076. * @param m20 defines value for (2, 0)
  78077. * @param m21 defines value for (2, 1)
  78078. * @returns the current modified matrix
  78079. */
  78080. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  78081. /**
  78082. * Gets matrix determinant
  78083. * @returns the determinant
  78084. */
  78085. determinant(): number;
  78086. /**
  78087. * Inverses the matrix and stores it in a target matrix
  78088. * @param result defines the target matrix
  78089. * @returns the current matrix
  78090. */
  78091. invertToRef(result: Matrix2D): Matrix2D;
  78092. /**
  78093. * Multiplies the current matrix with another one
  78094. * @param other defines the second operand
  78095. * @param result defines the target matrix
  78096. * @returns the current matrix
  78097. */
  78098. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  78099. /**
  78100. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  78101. * @param x defines the x coordinate to transform
  78102. * @param y defines the x coordinate to transform
  78103. * @param result defines the target vector2
  78104. * @returns the current matrix
  78105. */
  78106. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  78107. /**
  78108. * Creates an identity matrix
  78109. * @returns a new matrix
  78110. */
  78111. static Identity(): Matrix2D;
  78112. /**
  78113. * Creates a translation matrix and stores it in a target matrix
  78114. * @param x defines the x coordinate of the translation
  78115. * @param y defines the y coordinate of the translation
  78116. * @param result defines the target matrix
  78117. */
  78118. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  78119. /**
  78120. * Creates a scaling matrix and stores it in a target matrix
  78121. * @param x defines the x coordinate of the scaling
  78122. * @param y defines the y coordinate of the scaling
  78123. * @param result defines the target matrix
  78124. */
  78125. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  78126. /**
  78127. * Creates a rotation matrix and stores it in a target matrix
  78128. * @param angle defines the rotation angle
  78129. * @param result defines the target matrix
  78130. */
  78131. static RotationToRef(angle: number, result: Matrix2D): void;
  78132. private static _TempPreTranslationMatrix;
  78133. private static _TempPostTranslationMatrix;
  78134. private static _TempRotationMatrix;
  78135. private static _TempScalingMatrix;
  78136. private static _TempCompose0;
  78137. private static _TempCompose1;
  78138. private static _TempCompose2;
  78139. /**
  78140. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  78141. * @param tx defines the x coordinate of the translation
  78142. * @param ty defines the y coordinate of the translation
  78143. * @param angle defines the rotation angle
  78144. * @param scaleX defines the x coordinate of the scaling
  78145. * @param scaleY defines the y coordinate of the scaling
  78146. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  78147. * @param result defines the target matrix
  78148. */
  78149. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  78150. }
  78151. }
  78152. declare module BABYLON.GUI {
  78153. /**
  78154. * Class used to store 2D control sizes
  78155. */
  78156. export class Measure {
  78157. /** defines left coordinate */
  78158. left: number;
  78159. /** defines top coordinate */
  78160. top: number;
  78161. /** defines width dimension */
  78162. width: number;
  78163. /** defines height dimension */
  78164. height: number;
  78165. /**
  78166. * Creates a new measure
  78167. * @param left defines left coordinate
  78168. * @param top defines top coordinate
  78169. * @param width defines width dimension
  78170. * @param height defines height dimension
  78171. */
  78172. constructor(
  78173. /** defines left coordinate */
  78174. left: number,
  78175. /** defines top coordinate */
  78176. top: number,
  78177. /** defines width dimension */
  78178. width: number,
  78179. /** defines height dimension */
  78180. height: number);
  78181. /**
  78182. * Copy from another measure
  78183. * @param other defines the other measure to copy from
  78184. */
  78185. copyFrom(other: Measure): void;
  78186. /**
  78187. * Copy from a group of 4 floats
  78188. * @param left defines left coordinate
  78189. * @param top defines top coordinate
  78190. * @param width defines width dimension
  78191. * @param height defines height dimension
  78192. */
  78193. copyFromFloats(left: number, top: number, width: number, height: number): void;
  78194. /**
  78195. * Computes the axis aligned bounding box measure for two given measures
  78196. * @param a Input measure
  78197. * @param b Input measure
  78198. * @param result the resulting bounding measure
  78199. */
  78200. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  78201. /**
  78202. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  78203. * @param transform the matrix to transform the measure before computing the AABB
  78204. * @param addX number to add to left
  78205. * @param addY number to add to top
  78206. * @param addWidth number to add to width
  78207. * @param addHeight number to add to height
  78208. * @param result the resulting AABB
  78209. */
  78210. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  78211. /**
  78212. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  78213. * @param transform the matrix to transform the measure before computing the AABB
  78214. * @param result the resulting AABB
  78215. */
  78216. transformToRef(transform: Matrix2D, result: Measure): void;
  78217. /**
  78218. * Check equality between this measure and another one
  78219. * @param other defines the other measures
  78220. * @returns true if both measures are equals
  78221. */
  78222. isEqualsTo(other: Measure): boolean;
  78223. /**
  78224. * Creates an empty measure
  78225. * @returns a new measure
  78226. */
  78227. static Empty(): Measure;
  78228. }
  78229. }
  78230. declare module BABYLON.GUI {
  78231. /**
  78232. * Interface used to define a control that can receive focus
  78233. */
  78234. export interface IFocusableControl {
  78235. /**
  78236. * Function called when the control receives the focus
  78237. */
  78238. onFocus(): void;
  78239. /**
  78240. * Function called when the control loses the focus
  78241. */
  78242. onBlur(): void;
  78243. /**
  78244. * Function called to let the control handle keyboard events
  78245. * @param evt defines the current keyboard event
  78246. */
  78247. processKeyboard(evt: KeyboardEvent): void;
  78248. /**
  78249. * Function called to get the list of controls that should not steal the focus from this control
  78250. * @returns an array of controls
  78251. */
  78252. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  78253. }
  78254. /**
  78255. * Class used to create texture to support 2D GUI elements
  78256. * @see https://doc.babylonjs.com/how_to/gui
  78257. */
  78258. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  78259. private _isDirty;
  78260. private _renderObserver;
  78261. private _resizeObserver;
  78262. private _preKeyboardObserver;
  78263. private _pointerMoveObserver;
  78264. private _pointerObserver;
  78265. private _canvasPointerOutObserver;
  78266. private _canvasBlurObserver;
  78267. private _background;
  78268. /** @hidden */
  78269. _rootContainer: Container;
  78270. /** @hidden */
  78271. _lastPickedControl: Control;
  78272. /** @hidden */
  78273. _lastControlOver: {
  78274. [pointerId: number]: Control;
  78275. };
  78276. /** @hidden */
  78277. _lastControlDown: {
  78278. [pointerId: number]: Control;
  78279. };
  78280. /** @hidden */
  78281. _capturingControl: {
  78282. [pointerId: number]: Control;
  78283. };
  78284. /** @hidden */
  78285. _shouldBlockPointer: boolean;
  78286. /** @hidden */
  78287. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  78288. /** @hidden */
  78289. _linkedControls: Control[];
  78290. private _isFullscreen;
  78291. private _fullscreenViewport;
  78292. private _idealWidth;
  78293. private _idealHeight;
  78294. private _useSmallestIdeal;
  78295. private _renderAtIdealSize;
  78296. private _focusedControl;
  78297. private _blockNextFocusCheck;
  78298. private _renderScale;
  78299. private _rootElement;
  78300. private _cursorChanged;
  78301. private _defaultMousePointerId;
  78302. /** @hidden */
  78303. _numLayoutCalls: number;
  78304. /** Gets the number of layout calls made the last time the ADT has been rendered */
  78305. get numLayoutCalls(): number;
  78306. /** @hidden */
  78307. _numRenderCalls: number;
  78308. /** Gets the number of render calls made the last time the ADT has been rendered */
  78309. get numRenderCalls(): number;
  78310. /**
  78311. * Define type to string to ensure compatibility across browsers
  78312. * Safari doesn't support DataTransfer constructor
  78313. */
  78314. private _clipboardData;
  78315. /**
  78316. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  78317. */
  78318. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  78319. /**
  78320. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  78321. */
  78322. onControlPickedObservable: BABYLON.Observable<Control>;
  78323. /**
  78324. * BABYLON.Observable event triggered before layout is evaluated
  78325. */
  78326. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78327. /**
  78328. * BABYLON.Observable event triggered after the layout was evaluated
  78329. */
  78330. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78331. /**
  78332. * BABYLON.Observable event triggered before the texture is rendered
  78333. */
  78334. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78335. /**
  78336. * BABYLON.Observable event triggered after the texture was rendered
  78337. */
  78338. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78339. /**
  78340. * Gets or sets a boolean defining if alpha is stored as premultiplied
  78341. */
  78342. premulAlpha: boolean;
  78343. /**
  78344. * Gets or sets a boolean indicating that the canvas must be reverted on Y when updating the texture
  78345. */
  78346. applyYInversionOnUpdate: boolean;
  78347. /**
  78348. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  78349. * Useful when you want more antialiasing
  78350. */
  78351. get renderScale(): number;
  78352. set renderScale(value: number);
  78353. /** Gets or sets the background color */
  78354. get background(): string;
  78355. set background(value: string);
  78356. /**
  78357. * Gets or sets the ideal width used to design controls.
  78358. * The GUI will then rescale everything accordingly
  78359. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78360. */
  78361. get idealWidth(): number;
  78362. set idealWidth(value: number);
  78363. /**
  78364. * Gets or sets the ideal height used to design controls.
  78365. * The GUI will then rescale everything accordingly
  78366. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78367. */
  78368. get idealHeight(): number;
  78369. set idealHeight(value: number);
  78370. /**
  78371. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  78372. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78373. */
  78374. get useSmallestIdeal(): boolean;
  78375. set useSmallestIdeal(value: boolean);
  78376. /**
  78377. * Gets or sets a boolean indicating if adaptive scaling must be used
  78378. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78379. */
  78380. get renderAtIdealSize(): boolean;
  78381. set renderAtIdealSize(value: boolean);
  78382. /**
  78383. * Gets the ratio used when in "ideal mode"
  78384. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78385. * */
  78386. get idealRatio(): number;
  78387. /**
  78388. * Gets the underlying layer used to render the texture when in fullscreen mode
  78389. */
  78390. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  78391. /**
  78392. * Gets the root container control
  78393. */
  78394. get rootContainer(): Container;
  78395. /**
  78396. * Returns an array containing the root container.
  78397. * This is mostly used to let the Inspector introspects the ADT
  78398. * @returns an array containing the rootContainer
  78399. */
  78400. getChildren(): Array<Container>;
  78401. /**
  78402. * Will return all controls that are inside this texture
  78403. * @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
  78404. * @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
  78405. * @return all child controls
  78406. */
  78407. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  78408. /**
  78409. * Gets or sets the current focused control
  78410. */
  78411. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  78412. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  78413. /**
  78414. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  78415. */
  78416. get isForeground(): boolean;
  78417. set isForeground(value: boolean);
  78418. /**
  78419. * Gets or set information about clipboardData
  78420. */
  78421. get clipboardData(): string;
  78422. set clipboardData(value: string);
  78423. /**
  78424. * Creates a new AdvancedDynamicTexture
  78425. * @param name defines the name of the texture
  78426. * @param width defines the width of the texture
  78427. * @param height defines the height of the texture
  78428. * @param scene defines the hosting scene
  78429. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  78430. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  78431. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  78432. */
  78433. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number, invertY?: boolean);
  78434. /**
  78435. * Get the current class name of the texture useful for serialization or dynamic coding.
  78436. * @returns "AdvancedDynamicTexture"
  78437. */
  78438. getClassName(): string;
  78439. /**
  78440. * Function used to execute a function on all controls
  78441. * @param func defines the function to execute
  78442. * @param container defines the container where controls belong. If null the root container will be used
  78443. */
  78444. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  78445. private _useInvalidateRectOptimization;
  78446. /**
  78447. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  78448. */
  78449. get useInvalidateRectOptimization(): boolean;
  78450. set useInvalidateRectOptimization(value: boolean);
  78451. private _invalidatedRectangle;
  78452. /**
  78453. * Invalidates a rectangle area on the gui texture
  78454. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  78455. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  78456. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  78457. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  78458. */
  78459. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  78460. /**
  78461. * Marks the texture as dirty forcing a complete update
  78462. */
  78463. markAsDirty(): void;
  78464. /**
  78465. * Helper function used to create a new style
  78466. * @returns a new style
  78467. * @see https://doc.babylonjs.com/how_to/gui#styles
  78468. */
  78469. createStyle(): Style;
  78470. /**
  78471. * Adds a new control to the root container
  78472. * @param control defines the control to add
  78473. * @returns the current texture
  78474. */
  78475. addControl(control: Control): AdvancedDynamicTexture;
  78476. /**
  78477. * Removes a control from the root container
  78478. * @param control defines the control to remove
  78479. * @returns the current texture
  78480. */
  78481. removeControl(control: Control): AdvancedDynamicTexture;
  78482. /**
  78483. * Release all resources
  78484. */
  78485. dispose(): void;
  78486. private _onResize;
  78487. /** @hidden */
  78488. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  78489. /**
  78490. * Get screen coordinates for a vector3
  78491. * @param position defines the position to project
  78492. * @param worldMatrix defines the world matrix to use
  78493. * @returns the projected position
  78494. */
  78495. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  78496. /**
  78497. * Get screen coordinates for a vector3
  78498. * @param position defines the position to project
  78499. * @param worldMatrix defines the world matrix to use
  78500. * @returns the projected position with Z
  78501. */
  78502. getProjectedPositionWithZ(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector3;
  78503. private _checkUpdate;
  78504. private _clearMeasure;
  78505. private _render;
  78506. /** @hidden */
  78507. _changeCursor(cursor: string): void;
  78508. /** @hidden */
  78509. _registerLastControlDown(control: Control, pointerId: number): void;
  78510. private _doPicking;
  78511. /** @hidden */
  78512. _cleanControlAfterRemovalFromList(list: {
  78513. [pointerId: number]: Control;
  78514. }, control: Control): void;
  78515. /** @hidden */
  78516. _cleanControlAfterRemoval(control: Control): void;
  78517. /** Attach to all scene events required to support pointer events */
  78518. attach(): void;
  78519. /** @hidden */
  78520. private onClipboardCopy;
  78521. /** @hidden */
  78522. private onClipboardCut;
  78523. /** @hidden */
  78524. private onClipboardPaste;
  78525. /**
  78526. * Register the clipboard Events onto the canvas
  78527. */
  78528. registerClipboardEvents(): void;
  78529. /**
  78530. * Unregister the clipboard Events from the canvas
  78531. */
  78532. unRegisterClipboardEvents(): void;
  78533. /**
  78534. * Connect the texture to a hosting mesh to enable interactions
  78535. * @param mesh defines the mesh to attach to
  78536. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  78537. */
  78538. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  78539. /**
  78540. * Move the focus to a specific control
  78541. * @param control defines the control which will receive the focus
  78542. */
  78543. moveFocusToControl(control: IFocusableControl): void;
  78544. private _manageFocus;
  78545. private _attachToOnPointerOut;
  78546. private _attachToOnBlur;
  78547. /**
  78548. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  78549. * @param mesh defines the mesh which will receive the texture
  78550. * @param width defines the texture width (1024 by default)
  78551. * @param height defines the texture height (1024 by default)
  78552. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  78553. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  78554. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  78555. * @returns a new AdvancedDynamicTexture
  78556. */
  78557. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  78558. /**
  78559. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh) BUT do not create a new material for the mesh. You will be responsible for connecting the texture
  78560. * @param mesh defines the mesh which will receive the texture
  78561. * @param width defines the texture width (1024 by default)
  78562. * @param height defines the texture height (1024 by default)
  78563. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  78564. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  78565. * @returns a new AdvancedDynamicTexture
  78566. */
  78567. static CreateForMeshTexture(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  78568. /**
  78569. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  78570. * In this mode the texture will rely on a layer for its rendering.
  78571. * This allows it to be treated like any other layer.
  78572. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  78573. * LayerMask is set through advancedTexture.layer.layerMask
  78574. * @param name defines name for the texture
  78575. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  78576. * @param scene defines the hsoting scene
  78577. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  78578. * @returns a new AdvancedDynamicTexture
  78579. */
  78580. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  78581. }
  78582. }
  78583. declare module BABYLON.GUI {
  78584. /**
  78585. * Root class used for all 2D controls
  78586. * @see https://doc.babylonjs.com/how_to/gui#controls
  78587. */
  78588. export class Control {
  78589. /** defines the name of the control */
  78590. name?: string | undefined;
  78591. /**
  78592. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  78593. */
  78594. static AllowAlphaInheritance: boolean;
  78595. private _alpha;
  78596. private _alphaSet;
  78597. private _zIndex;
  78598. /** @hidden */
  78599. _host: AdvancedDynamicTexture;
  78600. /** Gets or sets the control parent */
  78601. parent: BABYLON.Nullable<Container>;
  78602. /** @hidden */
  78603. _currentMeasure: Measure;
  78604. private _fontFamily;
  78605. private _fontStyle;
  78606. private _fontWeight;
  78607. private _fontSize;
  78608. private _font;
  78609. /** @hidden */
  78610. _width: ValueAndUnit;
  78611. /** @hidden */
  78612. _height: ValueAndUnit;
  78613. /** @hidden */
  78614. protected _fontOffset: {
  78615. ascent: number;
  78616. height: number;
  78617. descent: number;
  78618. };
  78619. private _color;
  78620. private _style;
  78621. private _styleObserver;
  78622. /** @hidden */
  78623. protected _horizontalAlignment: number;
  78624. /** @hidden */
  78625. protected _verticalAlignment: number;
  78626. /** @hidden */
  78627. protected _isDirty: boolean;
  78628. /** @hidden */
  78629. protected _wasDirty: boolean;
  78630. /** @hidden */
  78631. _tempParentMeasure: Measure;
  78632. /** @hidden */
  78633. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  78634. /** @hidden */
  78635. protected _cachedParentMeasure: Measure;
  78636. private _paddingLeft;
  78637. private _paddingRight;
  78638. private _paddingTop;
  78639. private _paddingBottom;
  78640. /** @hidden */
  78641. _left: ValueAndUnit;
  78642. /** @hidden */
  78643. _top: ValueAndUnit;
  78644. private _scaleX;
  78645. private _scaleY;
  78646. private _rotation;
  78647. private _transformCenterX;
  78648. private _transformCenterY;
  78649. /** @hidden */
  78650. _transformMatrix: Matrix2D;
  78651. /** @hidden */
  78652. protected _invertTransformMatrix: Matrix2D;
  78653. /** @hidden */
  78654. protected _transformedPosition: BABYLON.Vector2;
  78655. private _isMatrixDirty;
  78656. private _cachedOffsetX;
  78657. private _cachedOffsetY;
  78658. private _isVisible;
  78659. private _isHighlighted;
  78660. /** @hidden */
  78661. _linkedMesh: BABYLON.Nullable<BABYLON.TransformNode>;
  78662. private _fontSet;
  78663. private _dummyVector2;
  78664. private _downCount;
  78665. private _enterCount;
  78666. private _doNotRender;
  78667. private _downPointerIds;
  78668. protected _isEnabled: boolean;
  78669. protected _disabledColor: string;
  78670. protected _disabledColorItem: string;
  78671. /** @hidden */
  78672. protected _rebuildLayout: boolean;
  78673. /** @hidden */
  78674. _customData: any;
  78675. /** @hidden */
  78676. _isClipped: boolean;
  78677. /** @hidden */
  78678. _automaticSize: boolean;
  78679. /** @hidden */
  78680. _tag: any;
  78681. /**
  78682. * 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
  78683. */
  78684. uniqueId: number;
  78685. /**
  78686. * Gets or sets an object used to store user defined information for the node
  78687. */
  78688. metadata: any;
  78689. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  78690. isHitTestVisible: boolean;
  78691. /** Gets or sets a boolean indicating if the control can block pointer events */
  78692. isPointerBlocker: boolean;
  78693. /** Gets or sets a boolean indicating if the control can be focusable */
  78694. isFocusInvisible: boolean;
  78695. /**
  78696. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  78697. * 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
  78698. */
  78699. clipChildren: boolean;
  78700. /**
  78701. * Gets or sets a boolean indicating that control content must be clipped
  78702. * 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
  78703. */
  78704. clipContent: boolean;
  78705. /**
  78706. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  78707. */
  78708. useBitmapCache: boolean;
  78709. private _cacheData;
  78710. private _shadowOffsetX;
  78711. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  78712. get shadowOffsetX(): number;
  78713. set shadowOffsetX(value: number);
  78714. private _shadowOffsetY;
  78715. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  78716. get shadowOffsetY(): number;
  78717. set shadowOffsetY(value: number);
  78718. private _shadowBlur;
  78719. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  78720. get shadowBlur(): number;
  78721. set shadowBlur(value: number);
  78722. private _shadowColor;
  78723. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  78724. get shadowColor(): string;
  78725. set shadowColor(value: string);
  78726. /** Gets or sets the cursor to use when the control is hovered */
  78727. hoverCursor: string;
  78728. /** @hidden */
  78729. protected _linkOffsetX: ValueAndUnit;
  78730. /** @hidden */
  78731. protected _linkOffsetY: ValueAndUnit;
  78732. /** Gets the control type name */
  78733. get typeName(): string;
  78734. /**
  78735. * Get the current class name of the control.
  78736. * @returns current class name
  78737. */
  78738. getClassName(): string;
  78739. /**
  78740. * An event triggered when pointer wheel is scrolled
  78741. */
  78742. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  78743. /**
  78744. * An event triggered when the pointer move over the control.
  78745. */
  78746. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  78747. /**
  78748. * An event triggered when the pointer move out of the control.
  78749. */
  78750. onPointerOutObservable: BABYLON.Observable<Control>;
  78751. /**
  78752. * An event triggered when the pointer taps the control
  78753. */
  78754. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  78755. /**
  78756. * An event triggered when pointer up
  78757. */
  78758. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  78759. /**
  78760. * An event triggered when a control is clicked on
  78761. */
  78762. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  78763. /**
  78764. * An event triggered when pointer enters the control
  78765. */
  78766. onPointerEnterObservable: BABYLON.Observable<Control>;
  78767. /**
  78768. * An event triggered when the control is marked as dirty
  78769. */
  78770. onDirtyObservable: BABYLON.Observable<Control>;
  78771. /**
  78772. * An event triggered before drawing the control
  78773. */
  78774. onBeforeDrawObservable: BABYLON.Observable<Control>;
  78775. /**
  78776. * An event triggered after the control was drawn
  78777. */
  78778. onAfterDrawObservable: BABYLON.Observable<Control>;
  78779. /**
  78780. * An event triggered when the control has been disposed
  78781. */
  78782. onDisposeObservable: BABYLON.Observable<Control>;
  78783. /**
  78784. * Get the hosting AdvancedDynamicTexture
  78785. */
  78786. get host(): AdvancedDynamicTexture;
  78787. /** Gets or set information about font offsets (used to render and align text) */
  78788. get fontOffset(): {
  78789. ascent: number;
  78790. height: number;
  78791. descent: number;
  78792. };
  78793. set fontOffset(offset: {
  78794. ascent: number;
  78795. height: number;
  78796. descent: number;
  78797. });
  78798. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  78799. get alpha(): number;
  78800. set alpha(value: number);
  78801. /**
  78802. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  78803. */
  78804. get isHighlighted(): boolean;
  78805. set isHighlighted(value: boolean);
  78806. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  78807. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78808. */
  78809. get scaleX(): number;
  78810. set scaleX(value: number);
  78811. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  78812. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78813. */
  78814. get scaleY(): number;
  78815. set scaleY(value: number);
  78816. /** Gets or sets the rotation angle (0 by default)
  78817. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78818. */
  78819. get rotation(): number;
  78820. set rotation(value: number);
  78821. /** Gets or sets the transformation center on Y axis (0 by default)
  78822. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78823. */
  78824. get transformCenterY(): number;
  78825. set transformCenterY(value: number);
  78826. /** Gets or sets the transformation center on X axis (0 by default)
  78827. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78828. */
  78829. get transformCenterX(): number;
  78830. set transformCenterX(value: number);
  78831. /**
  78832. * Gets or sets the horizontal alignment
  78833. * @see https://doc.babylonjs.com/how_to/gui#alignments
  78834. */
  78835. get horizontalAlignment(): number;
  78836. set horizontalAlignment(value: number);
  78837. /**
  78838. * Gets or sets the vertical alignment
  78839. * @see https://doc.babylonjs.com/how_to/gui#alignments
  78840. */
  78841. get verticalAlignment(): number;
  78842. set verticalAlignment(value: number);
  78843. /**
  78844. * Gets or sets a fixed ratio for this control.
  78845. * When different from 0, the ratio is used to compute the "second" dimension.
  78846. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  78847. * second dimension is computed as first dimension * fixedRatio
  78848. */
  78849. fixedRatio: number;
  78850. private _fixedRatioMasterIsWidth;
  78851. /**
  78852. * Gets or sets control width
  78853. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78854. */
  78855. get width(): string | number;
  78856. set width(value: string | number);
  78857. /**
  78858. * Gets or sets the control width in pixel
  78859. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78860. */
  78861. get widthInPixels(): number;
  78862. set widthInPixels(value: number);
  78863. /**
  78864. * Gets or sets control height
  78865. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78866. */
  78867. get height(): string | number;
  78868. set height(value: string | number);
  78869. /**
  78870. * Gets or sets control height in pixel
  78871. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78872. */
  78873. get heightInPixels(): number;
  78874. set heightInPixels(value: number);
  78875. /** Gets or set font family */
  78876. get fontFamily(): string;
  78877. set fontFamily(value: string);
  78878. /** Gets or sets font style */
  78879. get fontStyle(): string;
  78880. set fontStyle(value: string);
  78881. /** Gets or sets font weight */
  78882. get fontWeight(): string;
  78883. set fontWeight(value: string);
  78884. /**
  78885. * Gets or sets style
  78886. * @see https://doc.babylonjs.com/how_to/gui#styles
  78887. */
  78888. get style(): BABYLON.Nullable<Style>;
  78889. set style(value: BABYLON.Nullable<Style>);
  78890. /** @hidden */
  78891. get _isFontSizeInPercentage(): boolean;
  78892. /** Gets or sets font size in pixels */
  78893. get fontSizeInPixels(): number;
  78894. set fontSizeInPixels(value: number);
  78895. /** Gets or sets font size */
  78896. get fontSize(): string | number;
  78897. set fontSize(value: string | number);
  78898. /** Gets or sets foreground color */
  78899. get color(): string;
  78900. set color(value: string);
  78901. /** Gets or sets z index which is used to reorder controls on the z axis */
  78902. get zIndex(): number;
  78903. set zIndex(value: number);
  78904. /** Gets or sets a boolean indicating if the control can be rendered */
  78905. get notRenderable(): boolean;
  78906. set notRenderable(value: boolean);
  78907. /** Gets or sets a boolean indicating if the control is visible */
  78908. get isVisible(): boolean;
  78909. set isVisible(value: boolean);
  78910. /** Gets a boolean indicating that the control needs to update its rendering */
  78911. get isDirty(): boolean;
  78912. /**
  78913. * Gets the current linked mesh (or null if none)
  78914. */
  78915. get linkedMesh(): BABYLON.Nullable<BABYLON.TransformNode>;
  78916. /**
  78917. * Gets or sets a value indicating the padding to use on the left of the control
  78918. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78919. */
  78920. get paddingLeft(): string | number;
  78921. set paddingLeft(value: string | number);
  78922. /**
  78923. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  78924. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78925. */
  78926. get paddingLeftInPixels(): number;
  78927. set paddingLeftInPixels(value: number);
  78928. /**
  78929. * Gets or sets a value indicating the padding to use on the right of the control
  78930. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78931. */
  78932. get paddingRight(): string | number;
  78933. set paddingRight(value: string | number);
  78934. /**
  78935. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  78936. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78937. */
  78938. get paddingRightInPixels(): number;
  78939. set paddingRightInPixels(value: number);
  78940. /**
  78941. * Gets or sets a value indicating the padding to use on the top of the control
  78942. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78943. */
  78944. get paddingTop(): string | number;
  78945. set paddingTop(value: string | number);
  78946. /**
  78947. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  78948. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78949. */
  78950. get paddingTopInPixels(): number;
  78951. set paddingTopInPixels(value: number);
  78952. /**
  78953. * Gets or sets a value indicating the padding to use on the bottom of the control
  78954. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78955. */
  78956. get paddingBottom(): string | number;
  78957. set paddingBottom(value: string | number);
  78958. /**
  78959. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  78960. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78961. */
  78962. get paddingBottomInPixels(): number;
  78963. set paddingBottomInPixels(value: number);
  78964. /**
  78965. * Gets or sets a value indicating the left coordinate of the control
  78966. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78967. */
  78968. get left(): string | number;
  78969. set left(value: string | number);
  78970. /**
  78971. * Gets or sets a value indicating the left coordinate in pixels of the control
  78972. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78973. */
  78974. get leftInPixels(): number;
  78975. set leftInPixels(value: number);
  78976. /**
  78977. * Gets or sets a value indicating the top coordinate of the control
  78978. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78979. */
  78980. get top(): string | number;
  78981. set top(value: string | number);
  78982. /**
  78983. * Gets or sets a value indicating the top coordinate in pixels of the control
  78984. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78985. */
  78986. get topInPixels(): number;
  78987. set topInPixels(value: number);
  78988. /**
  78989. * Gets or sets a value indicating the offset on X axis to the linked mesh
  78990. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78991. */
  78992. get linkOffsetX(): string | number;
  78993. set linkOffsetX(value: string | number);
  78994. /**
  78995. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  78996. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78997. */
  78998. get linkOffsetXInPixels(): number;
  78999. set linkOffsetXInPixels(value: number);
  79000. /**
  79001. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  79002. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  79003. */
  79004. get linkOffsetY(): string | number;
  79005. set linkOffsetY(value: string | number);
  79006. /**
  79007. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  79008. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  79009. */
  79010. get linkOffsetYInPixels(): number;
  79011. set linkOffsetYInPixels(value: number);
  79012. /** Gets the center coordinate on X axis */
  79013. get centerX(): number;
  79014. /** Gets the center coordinate on Y axis */
  79015. get centerY(): number;
  79016. /** Gets or sets if control is Enabled*/
  79017. get isEnabled(): boolean;
  79018. set isEnabled(value: boolean);
  79019. /** Gets or sets background color of control if it's disabled*/
  79020. get disabledColor(): string;
  79021. set disabledColor(value: string);
  79022. /** Gets or sets front color of control if it's disabled*/
  79023. get disabledColorItem(): string;
  79024. set disabledColorItem(value: string);
  79025. /**
  79026. * Creates a new control
  79027. * @param name defines the name of the control
  79028. */
  79029. constructor(
  79030. /** defines the name of the control */
  79031. name?: string | undefined);
  79032. /** @hidden */
  79033. protected _getTypeName(): string;
  79034. /**
  79035. * Gets the first ascendant in the hierarchy of the given type
  79036. * @param className defines the required type
  79037. * @returns the ascendant or null if not found
  79038. */
  79039. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  79040. /** @hidden */
  79041. _resetFontCache(): void;
  79042. /**
  79043. * Determines if a container is an ascendant of the current control
  79044. * @param container defines the container to look for
  79045. * @returns true if the container is one of the ascendant of the control
  79046. */
  79047. isAscendant(container: Control): boolean;
  79048. /**
  79049. * Gets coordinates in local control space
  79050. * @param globalCoordinates defines the coordinates to transform
  79051. * @returns the new coordinates in local space
  79052. */
  79053. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  79054. /**
  79055. * Gets coordinates in local control space
  79056. * @param globalCoordinates defines the coordinates to transform
  79057. * @param result defines the target vector2 where to store the result
  79058. * @returns the current control
  79059. */
  79060. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  79061. /**
  79062. * Gets coordinates in parent local control space
  79063. * @param globalCoordinates defines the coordinates to transform
  79064. * @returns the new coordinates in parent local space
  79065. */
  79066. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  79067. /**
  79068. * Move the current control to a vector3 position projected onto the screen.
  79069. * @param position defines the target position
  79070. * @param scene defines the hosting scene
  79071. */
  79072. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  79073. /**
  79074. * Will store all controls that have this control as ascendant in a given array
  79075. * @param results defines the array where to store the descendants
  79076. * @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
  79077. * @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
  79078. */
  79079. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  79080. /**
  79081. * Will return all controls that have this control as ascendant
  79082. * @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
  79083. * @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
  79084. * @return all child controls
  79085. */
  79086. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  79087. /**
  79088. * Link current control with a target mesh
  79089. * @param mesh defines the mesh to link with
  79090. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  79091. */
  79092. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.TransformNode>): void;
  79093. /** @hidden */
  79094. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  79095. /** @hidden */
  79096. _offsetLeft(offset: number): void;
  79097. /** @hidden */
  79098. _offsetTop(offset: number): void;
  79099. /** @hidden */
  79100. _markMatrixAsDirty(): void;
  79101. /** @hidden */
  79102. _flagDescendantsAsMatrixDirty(): void;
  79103. /** @hidden */
  79104. _intersectsRect(rect: Measure): boolean;
  79105. /** @hidden */
  79106. protected invalidateRect(): void;
  79107. /** @hidden */
  79108. _markAsDirty(force?: boolean): void;
  79109. /** @hidden */
  79110. _markAllAsDirty(): void;
  79111. /** @hidden */
  79112. _link(host: AdvancedDynamicTexture): void;
  79113. /** @hidden */
  79114. protected _transform(context?: CanvasRenderingContext2D): void;
  79115. /** @hidden */
  79116. _renderHighlight(context: CanvasRenderingContext2D): void;
  79117. /** @hidden */
  79118. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  79119. /** @hidden */
  79120. protected _applyStates(context: CanvasRenderingContext2D): void;
  79121. /** @hidden */
  79122. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  79123. /** @hidden */
  79124. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79125. protected _evaluateClippingState(parentMeasure: Measure): void;
  79126. /** @hidden */
  79127. _measure(): void;
  79128. /** @hidden */
  79129. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79130. /** @hidden */
  79131. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79132. /** @hidden */
  79133. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79134. /** @hidden */
  79135. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  79136. private static _ClipMeasure;
  79137. private _tmpMeasureA;
  79138. private _clip;
  79139. /** @hidden */
  79140. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  79141. /** @hidden */
  79142. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79143. /**
  79144. * Tests if a given coordinates belong to the current control
  79145. * @param x defines x coordinate to test
  79146. * @param y defines y coordinate to test
  79147. * @returns true if the coordinates are inside the control
  79148. */
  79149. contains(x: number, y: number): boolean;
  79150. /** @hidden */
  79151. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79152. /** @hidden */
  79153. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  79154. /** @hidden */
  79155. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  79156. /** @hidden */
  79157. _onPointerOut(target: Control, pi: BABYLON.Nullable<BABYLON.PointerInfoBase>, force?: boolean): void;
  79158. /** @hidden */
  79159. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79160. /** @hidden */
  79161. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi?: BABYLON.PointerInfoBase): void;
  79162. /** @hidden */
  79163. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  79164. /** @hidden */
  79165. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  79166. /** @hidden */
  79167. _onCanvasBlur(): void;
  79168. /** @hidden */
  79169. _processObservables(type: number, x: number, y: number, pi: BABYLON.PointerInfoBase, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79170. private _prepareFont;
  79171. /** Releases associated resources */
  79172. dispose(): void;
  79173. private static _HORIZONTAL_ALIGNMENT_LEFT;
  79174. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  79175. private static _HORIZONTAL_ALIGNMENT_CENTER;
  79176. private static _VERTICAL_ALIGNMENT_TOP;
  79177. private static _VERTICAL_ALIGNMENT_BOTTOM;
  79178. private static _VERTICAL_ALIGNMENT_CENTER;
  79179. /** HORIZONTAL_ALIGNMENT_LEFT */
  79180. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  79181. /** HORIZONTAL_ALIGNMENT_RIGHT */
  79182. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  79183. /** HORIZONTAL_ALIGNMENT_CENTER */
  79184. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  79185. /** VERTICAL_ALIGNMENT_TOP */
  79186. static get VERTICAL_ALIGNMENT_TOP(): number;
  79187. /** VERTICAL_ALIGNMENT_BOTTOM */
  79188. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  79189. /** VERTICAL_ALIGNMENT_CENTER */
  79190. static get VERTICAL_ALIGNMENT_CENTER(): number;
  79191. private static _FontHeightSizes;
  79192. /** @hidden */
  79193. static _GetFontOffset(font: string): {
  79194. ascent: number;
  79195. height: number;
  79196. descent: number;
  79197. };
  79198. /**
  79199. * Creates a stack panel that can be used to render headers
  79200. * @param control defines the control to associate with the header
  79201. * @param text defines the text of the header
  79202. * @param size defines the size of the header
  79203. * @param options defines options used to configure the header
  79204. * @returns a new StackPanel
  79205. * @ignore
  79206. * @hidden
  79207. */
  79208. static AddHeader: (control: Control, text: string, size: string | number, options: {
  79209. isHorizontal: boolean;
  79210. controlFirst: boolean;
  79211. }) => any;
  79212. /** @hidden */
  79213. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  79214. }
  79215. }
  79216. declare module BABYLON.GUI {
  79217. /**
  79218. * Root class for 2D containers
  79219. * @see https://doc.babylonjs.com/how_to/gui#containers
  79220. */
  79221. export class Container extends Control {
  79222. name?: string | undefined;
  79223. /** @hidden */
  79224. _children: Control[];
  79225. /** @hidden */
  79226. protected _measureForChildren: Measure;
  79227. /** @hidden */
  79228. protected _background: string;
  79229. /** @hidden */
  79230. protected _adaptWidthToChildren: boolean;
  79231. /** @hidden */
  79232. protected _adaptHeightToChildren: boolean;
  79233. /**
  79234. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  79235. */
  79236. logLayoutCycleErrors: boolean;
  79237. /**
  79238. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  79239. */
  79240. maxLayoutCycle: number;
  79241. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  79242. get adaptHeightToChildren(): boolean;
  79243. set adaptHeightToChildren(value: boolean);
  79244. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  79245. get adaptWidthToChildren(): boolean;
  79246. set adaptWidthToChildren(value: boolean);
  79247. /** Gets or sets background color */
  79248. get background(): string;
  79249. set background(value: string);
  79250. /** Gets the list of children */
  79251. get children(): Control[];
  79252. /**
  79253. * Creates a new Container
  79254. * @param name defines the name of the container
  79255. */
  79256. constructor(name?: string | undefined);
  79257. protected _getTypeName(): string;
  79258. _flagDescendantsAsMatrixDirty(): void;
  79259. /**
  79260. * Gets a child using its name
  79261. * @param name defines the child name to look for
  79262. * @returns the child control if found
  79263. */
  79264. getChildByName(name: string): BABYLON.Nullable<Control>;
  79265. /**
  79266. * Gets a child using its type and its name
  79267. * @param name defines the child name to look for
  79268. * @param type defines the child type to look for
  79269. * @returns the child control if found
  79270. */
  79271. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  79272. /**
  79273. * Search for a specific control in children
  79274. * @param control defines the control to look for
  79275. * @returns true if the control is in child list
  79276. */
  79277. containsControl(control: Control): boolean;
  79278. /**
  79279. * Adds a new control to the current container
  79280. * @param control defines the control to add
  79281. * @returns the current container
  79282. */
  79283. addControl(control: BABYLON.Nullable<Control>): Container;
  79284. /**
  79285. * Removes all controls from the current container
  79286. * @returns the current container
  79287. */
  79288. clearControls(): Container;
  79289. /**
  79290. * Removes a control from the current container
  79291. * @param control defines the control to remove
  79292. * @returns the current container
  79293. */
  79294. removeControl(control: Control): Container;
  79295. /** @hidden */
  79296. _reOrderControl(control: Control): void;
  79297. /** @hidden */
  79298. _offsetLeft(offset: number): void;
  79299. /** @hidden */
  79300. _offsetTop(offset: number): void;
  79301. /** @hidden */
  79302. _markAllAsDirty(): void;
  79303. /** @hidden */
  79304. protected _localDraw(context: CanvasRenderingContext2D): void;
  79305. /** @hidden */
  79306. _link(host: AdvancedDynamicTexture): void;
  79307. /** @hidden */
  79308. protected _beforeLayout(): void;
  79309. /** @hidden */
  79310. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79311. /** @hidden */
  79312. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  79313. protected _postMeasure(): void;
  79314. /** @hidden */
  79315. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  79316. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  79317. /** @hidden */
  79318. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79319. /** @hidden */
  79320. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79321. /** Releases associated resources */
  79322. dispose(): void;
  79323. }
  79324. }
  79325. declare module BABYLON.GUI {
  79326. /** Class used to create rectangle container */
  79327. export class Rectangle extends Container {
  79328. name?: string | undefined;
  79329. private _thickness;
  79330. private _cornerRadius;
  79331. /** Gets or sets border thickness */
  79332. get thickness(): number;
  79333. set thickness(value: number);
  79334. /** Gets or sets the corner radius angle */
  79335. get cornerRadius(): number;
  79336. set cornerRadius(value: number);
  79337. /**
  79338. * Creates a new Rectangle
  79339. * @param name defines the control name
  79340. */
  79341. constructor(name?: string | undefined);
  79342. protected _getTypeName(): string;
  79343. protected _localDraw(context: CanvasRenderingContext2D): void;
  79344. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79345. private _drawRoundedRect;
  79346. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  79347. }
  79348. }
  79349. declare module BABYLON.GUI {
  79350. /**
  79351. * Enum that determines the text-wrapping mode to use.
  79352. */
  79353. export enum TextWrapping {
  79354. /**
  79355. * Clip the text when it's larger than Control.width; this is the default mode.
  79356. */
  79357. Clip = 0,
  79358. /**
  79359. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  79360. */
  79361. WordWrap = 1,
  79362. /**
  79363. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  79364. */
  79365. Ellipsis = 2
  79366. }
  79367. /**
  79368. * Class used to create text block control
  79369. */
  79370. export class TextBlock extends Control {
  79371. /**
  79372. * Defines the name of the control
  79373. */
  79374. name?: string | undefined;
  79375. private _text;
  79376. private _textWrapping;
  79377. private _textHorizontalAlignment;
  79378. private _textVerticalAlignment;
  79379. private _lines;
  79380. private _resizeToFit;
  79381. private _lineSpacing;
  79382. private _outlineWidth;
  79383. private _outlineColor;
  79384. private _underline;
  79385. private _lineThrough;
  79386. /**
  79387. * An event triggered after the text is changed
  79388. */
  79389. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  79390. /**
  79391. * An event triggered after the text was broken up into lines
  79392. */
  79393. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  79394. /**
  79395. * Function used to split a string into words. By default, a string is split at each space character found
  79396. */
  79397. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  79398. /**
  79399. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  79400. */
  79401. get lines(): any[];
  79402. /**
  79403. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  79404. */
  79405. get resizeToFit(): boolean;
  79406. /**
  79407. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  79408. */
  79409. set resizeToFit(value: boolean);
  79410. /**
  79411. * Gets or sets a boolean indicating if text must be wrapped
  79412. */
  79413. get textWrapping(): TextWrapping | boolean;
  79414. /**
  79415. * Gets or sets a boolean indicating if text must be wrapped
  79416. */
  79417. set textWrapping(value: TextWrapping | boolean);
  79418. /**
  79419. * Gets or sets text to display
  79420. */
  79421. get text(): string;
  79422. /**
  79423. * Gets or sets text to display
  79424. */
  79425. set text(value: string);
  79426. /**
  79427. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  79428. */
  79429. get textHorizontalAlignment(): number;
  79430. /**
  79431. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  79432. */
  79433. set textHorizontalAlignment(value: number);
  79434. /**
  79435. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  79436. */
  79437. get textVerticalAlignment(): number;
  79438. /**
  79439. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  79440. */
  79441. set textVerticalAlignment(value: number);
  79442. /**
  79443. * Gets or sets line spacing value
  79444. */
  79445. set lineSpacing(value: string | number);
  79446. /**
  79447. * Gets or sets line spacing value
  79448. */
  79449. get lineSpacing(): string | number;
  79450. /**
  79451. * Gets or sets outlineWidth of the text to display
  79452. */
  79453. get outlineWidth(): number;
  79454. /**
  79455. * Gets or sets outlineWidth of the text to display
  79456. */
  79457. set outlineWidth(value: number);
  79458. /**
  79459. * Gets or sets a boolean indicating that text must have underline
  79460. */
  79461. get underline(): boolean;
  79462. /**
  79463. * Gets or sets a boolean indicating that text must have underline
  79464. */
  79465. set underline(value: boolean);
  79466. /**
  79467. * Gets or sets an boolean indicating that text must be crossed out
  79468. */
  79469. get lineThrough(): boolean;
  79470. /**
  79471. * Gets or sets an boolean indicating that text must be crossed out
  79472. */
  79473. set lineThrough(value: boolean);
  79474. /**
  79475. * Gets or sets outlineColor of the text to display
  79476. */
  79477. get outlineColor(): string;
  79478. /**
  79479. * Gets or sets outlineColor of the text to display
  79480. */
  79481. set outlineColor(value: string);
  79482. /**
  79483. * Creates a new TextBlock object
  79484. * @param name defines the name of the control
  79485. * @param text defines the text to display (emptry string by default)
  79486. */
  79487. constructor(
  79488. /**
  79489. * Defines the name of the control
  79490. */
  79491. name?: string | undefined, text?: string);
  79492. protected _getTypeName(): string;
  79493. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79494. private _drawText;
  79495. /** @hidden */
  79496. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79497. protected _applyStates(context: CanvasRenderingContext2D): void;
  79498. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  79499. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  79500. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  79501. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  79502. protected _renderLines(context: CanvasRenderingContext2D): void;
  79503. /**
  79504. * Given a width constraint applied on the text block, find the expected height
  79505. * @returns expected height
  79506. */
  79507. computeExpectedHeight(): number;
  79508. dispose(): void;
  79509. }
  79510. }
  79511. declare module BABYLON.GUI {
  79512. /**
  79513. * Class used to create 2D images
  79514. */
  79515. export class Image extends Control {
  79516. name?: string | undefined;
  79517. private _workingCanvas;
  79518. private _domImage;
  79519. private _imageWidth;
  79520. private _imageHeight;
  79521. private _loaded;
  79522. private _stretch;
  79523. private _source;
  79524. private _autoScale;
  79525. private _sourceLeft;
  79526. private _sourceTop;
  79527. private _sourceWidth;
  79528. private _sourceHeight;
  79529. private _svgAttributesComputationCompleted;
  79530. private _isSVG;
  79531. private _cellWidth;
  79532. private _cellHeight;
  79533. private _cellId;
  79534. private _populateNinePatchSlicesFromImage;
  79535. private _sliceLeft;
  79536. private _sliceRight;
  79537. private _sliceTop;
  79538. private _sliceBottom;
  79539. private _detectPointerOnOpaqueOnly;
  79540. private _imageDataCache;
  79541. /**
  79542. * BABYLON.Observable notified when the content is loaded
  79543. */
  79544. onImageLoadedObservable: BABYLON.Observable<Image>;
  79545. /**
  79546. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  79547. */
  79548. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  79549. /**
  79550. * Gets a boolean indicating that the content is loaded
  79551. */
  79552. get isLoaded(): boolean;
  79553. /**
  79554. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  79555. */
  79556. get populateNinePatchSlicesFromImage(): boolean;
  79557. set populateNinePatchSlicesFromImage(value: boolean);
  79558. /**
  79559. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  79560. * Beware using this as this will comsume more memory as the image has to be stored twice
  79561. */
  79562. get detectPointerOnOpaqueOnly(): boolean;
  79563. set detectPointerOnOpaqueOnly(value: boolean);
  79564. /**
  79565. * Gets or sets the left value for slicing (9-patch)
  79566. */
  79567. get sliceLeft(): number;
  79568. set sliceLeft(value: number);
  79569. /**
  79570. * Gets or sets the right value for slicing (9-patch)
  79571. */
  79572. get sliceRight(): number;
  79573. set sliceRight(value: number);
  79574. /**
  79575. * Gets or sets the top value for slicing (9-patch)
  79576. */
  79577. get sliceTop(): number;
  79578. set sliceTop(value: number);
  79579. /**
  79580. * Gets or sets the bottom value for slicing (9-patch)
  79581. */
  79582. get sliceBottom(): number;
  79583. set sliceBottom(value: number);
  79584. /**
  79585. * Gets or sets the left coordinate in the source image
  79586. */
  79587. get sourceLeft(): number;
  79588. set sourceLeft(value: number);
  79589. /**
  79590. * Gets or sets the top coordinate in the source image
  79591. */
  79592. get sourceTop(): number;
  79593. set sourceTop(value: number);
  79594. /**
  79595. * Gets or sets the width to capture in the source image
  79596. */
  79597. get sourceWidth(): number;
  79598. set sourceWidth(value: number);
  79599. /**
  79600. * Gets or sets the height to capture in the source image
  79601. */
  79602. get sourceHeight(): number;
  79603. set sourceHeight(value: number);
  79604. /** Indicates if the format of the image is SVG */
  79605. get isSVG(): boolean;
  79606. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  79607. get svgAttributesComputationCompleted(): boolean;
  79608. /**
  79609. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  79610. * @see https://doc.babylonjs.com/how_to/gui#image
  79611. */
  79612. get autoScale(): boolean;
  79613. set autoScale(value: boolean);
  79614. /** Gets or sets the streching mode used by the image */
  79615. get stretch(): number;
  79616. set stretch(value: number);
  79617. /** @hidden */
  79618. _rotate90(n: number, preserveProperties?: boolean): Image;
  79619. private _handleRotationForSVGImage;
  79620. private _rotate90SourceProperties;
  79621. /**
  79622. * Gets or sets the internal DOM image used to render the control
  79623. */
  79624. set domImage(value: HTMLImageElement);
  79625. get domImage(): HTMLImageElement;
  79626. private _onImageLoaded;
  79627. private _extractNinePatchSliceDataFromImage;
  79628. /**
  79629. * Gets or sets image source url
  79630. */
  79631. set source(value: BABYLON.Nullable<string>);
  79632. /**
  79633. * Checks for svg document with icon id present
  79634. */
  79635. private _svgCheck;
  79636. /**
  79637. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  79638. * given external svg file and icon id
  79639. */
  79640. private _getSVGAttribs;
  79641. /**
  79642. * Gets or sets the cell width to use when animation sheet is enabled
  79643. * @see https://doc.babylonjs.com/how_to/gui#image
  79644. */
  79645. get cellWidth(): number;
  79646. set cellWidth(value: number);
  79647. /**
  79648. * Gets or sets the cell height to use when animation sheet is enabled
  79649. * @see https://doc.babylonjs.com/how_to/gui#image
  79650. */
  79651. get cellHeight(): number;
  79652. set cellHeight(value: number);
  79653. /**
  79654. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  79655. * @see https://doc.babylonjs.com/how_to/gui#image
  79656. */
  79657. get cellId(): number;
  79658. set cellId(value: number);
  79659. /**
  79660. * Creates a new Image
  79661. * @param name defines the control name
  79662. * @param url defines the image url
  79663. */
  79664. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  79665. /**
  79666. * Tests if a given coordinates belong to the current control
  79667. * @param x defines x coordinate to test
  79668. * @param y defines y coordinate to test
  79669. * @returns true if the coordinates are inside the control
  79670. */
  79671. contains(x: number, y: number): boolean;
  79672. protected _getTypeName(): string;
  79673. /** Force the control to synchronize with its content */
  79674. synchronizeSizeWithContent(): void;
  79675. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79676. private _prepareWorkingCanvasForOpaqueDetection;
  79677. private _drawImage;
  79678. _draw(context: CanvasRenderingContext2D): void;
  79679. private _renderCornerPatch;
  79680. private _renderNinePatch;
  79681. dispose(): void;
  79682. /** STRETCH_NONE */
  79683. static readonly STRETCH_NONE: number;
  79684. /** STRETCH_FILL */
  79685. static readonly STRETCH_FILL: number;
  79686. /** STRETCH_UNIFORM */
  79687. static readonly STRETCH_UNIFORM: number;
  79688. /** STRETCH_EXTEND */
  79689. static readonly STRETCH_EXTEND: number;
  79690. /** NINE_PATCH */
  79691. static readonly STRETCH_NINE_PATCH: number;
  79692. }
  79693. }
  79694. declare module BABYLON.GUI {
  79695. /**
  79696. * Class used to create 2D buttons
  79697. */
  79698. export class Button extends Rectangle {
  79699. name?: string | undefined;
  79700. /**
  79701. * Function called to generate a pointer enter animation
  79702. */
  79703. pointerEnterAnimation: () => void;
  79704. /**
  79705. * Function called to generate a pointer out animation
  79706. */
  79707. pointerOutAnimation: () => void;
  79708. /**
  79709. * Function called to generate a pointer down animation
  79710. */
  79711. pointerDownAnimation: () => void;
  79712. /**
  79713. * Function called to generate a pointer up animation
  79714. */
  79715. pointerUpAnimation: () => void;
  79716. /**
  79717. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  79718. */
  79719. delegatePickingToChildren: boolean;
  79720. private _image;
  79721. /**
  79722. * Returns the image part of the button (if any)
  79723. */
  79724. get image(): BABYLON.Nullable<Image>;
  79725. private _textBlock;
  79726. /**
  79727. * Returns the image part of the button (if any)
  79728. */
  79729. get textBlock(): BABYLON.Nullable<TextBlock>;
  79730. /**
  79731. * Creates a new Button
  79732. * @param name defines the name of the button
  79733. */
  79734. constructor(name?: string | undefined);
  79735. protected _getTypeName(): string;
  79736. /** @hidden */
  79737. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79738. /** @hidden */
  79739. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  79740. /** @hidden */
  79741. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  79742. /** @hidden */
  79743. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79744. /** @hidden */
  79745. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  79746. /**
  79747. * Creates a new button made with an image and a text
  79748. * @param name defines the name of the button
  79749. * @param text defines the text of the button
  79750. * @param imageUrl defines the url of the image
  79751. * @returns a new Button
  79752. */
  79753. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  79754. /**
  79755. * Creates a new button made with an image
  79756. * @param name defines the name of the button
  79757. * @param imageUrl defines the url of the image
  79758. * @returns a new Button
  79759. */
  79760. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  79761. /**
  79762. * Creates a new button made with a text
  79763. * @param name defines the name of the button
  79764. * @param text defines the text of the button
  79765. * @returns a new Button
  79766. */
  79767. static CreateSimpleButton(name: string, text: string): Button;
  79768. /**
  79769. * Creates a new button made with an image and a centered text
  79770. * @param name defines the name of the button
  79771. * @param text defines the text of the button
  79772. * @param imageUrl defines the url of the image
  79773. * @returns a new Button
  79774. */
  79775. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  79776. }
  79777. }
  79778. declare module BABYLON.GUI {
  79779. /**
  79780. * Class used to create a 2D stack panel container
  79781. */
  79782. export class StackPanel extends Container {
  79783. name?: string | undefined;
  79784. private _isVertical;
  79785. private _manualWidth;
  79786. private _manualHeight;
  79787. private _doNotTrackManualChanges;
  79788. /**
  79789. * Gets or sets a boolean indicating that layou warnings should be ignored
  79790. */
  79791. ignoreLayoutWarnings: boolean;
  79792. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  79793. get isVertical(): boolean;
  79794. set isVertical(value: boolean);
  79795. /**
  79796. * Gets or sets panel width.
  79797. * This value should not be set when in horizontal mode as it will be computed automatically
  79798. */
  79799. set width(value: string | number);
  79800. get width(): string | number;
  79801. /**
  79802. * Gets or sets panel height.
  79803. * This value should not be set when in vertical mode as it will be computed automatically
  79804. */
  79805. set height(value: string | number);
  79806. get height(): string | number;
  79807. /**
  79808. * Creates a new StackPanel
  79809. * @param name defines control name
  79810. */
  79811. constructor(name?: string | undefined);
  79812. protected _getTypeName(): string;
  79813. /** @hidden */
  79814. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79815. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79816. protected _postMeasure(): void;
  79817. }
  79818. }
  79819. declare module BABYLON.GUI {
  79820. /**
  79821. * Class used to represent a 2D checkbox
  79822. */
  79823. export class Checkbox extends Control {
  79824. name?: string | undefined;
  79825. private _isChecked;
  79826. private _background;
  79827. private _checkSizeRatio;
  79828. private _thickness;
  79829. /** Gets or sets border thickness */
  79830. get thickness(): number;
  79831. set thickness(value: number);
  79832. /**
  79833. * BABYLON.Observable raised when isChecked property changes
  79834. */
  79835. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  79836. /** Gets or sets a value indicating the ratio between overall size and check size */
  79837. get checkSizeRatio(): number;
  79838. set checkSizeRatio(value: number);
  79839. /** Gets or sets background color */
  79840. get background(): string;
  79841. set background(value: string);
  79842. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  79843. get isChecked(): boolean;
  79844. set isChecked(value: boolean);
  79845. /**
  79846. * Creates a new CheckBox
  79847. * @param name defines the control name
  79848. */
  79849. constructor(name?: string | undefined);
  79850. protected _getTypeName(): string;
  79851. /** @hidden */
  79852. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79853. /** @hidden */
  79854. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79855. /**
  79856. * Utility function to easily create a checkbox with a header
  79857. * @param title defines the label to use for the header
  79858. * @param onValueChanged defines the callback to call when value changes
  79859. * @returns a StackPanel containing the checkbox and a textBlock
  79860. */
  79861. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  79862. }
  79863. }
  79864. declare module BABYLON.GUI {
  79865. /**
  79866. * Class used to store key control properties
  79867. */
  79868. export class KeyPropertySet {
  79869. /** Width */
  79870. width?: string;
  79871. /** Height */
  79872. height?: string;
  79873. /** Left padding */
  79874. paddingLeft?: string;
  79875. /** Right padding */
  79876. paddingRight?: string;
  79877. /** Top padding */
  79878. paddingTop?: string;
  79879. /** Bottom padding */
  79880. paddingBottom?: string;
  79881. /** Foreground color */
  79882. color?: string;
  79883. /** Background color */
  79884. background?: string;
  79885. }
  79886. /**
  79887. * Class used to create virtual keyboard
  79888. */
  79889. export class VirtualKeyboard extends StackPanel {
  79890. /** BABYLON.Observable raised when a key is pressed */
  79891. onKeyPressObservable: BABYLON.Observable<string>;
  79892. /** Gets or sets default key button width */
  79893. defaultButtonWidth: string;
  79894. /** Gets or sets default key button height */
  79895. defaultButtonHeight: string;
  79896. /** Gets or sets default key button left padding */
  79897. defaultButtonPaddingLeft: string;
  79898. /** Gets or sets default key button right padding */
  79899. defaultButtonPaddingRight: string;
  79900. /** Gets or sets default key button top padding */
  79901. defaultButtonPaddingTop: string;
  79902. /** Gets or sets default key button bottom padding */
  79903. defaultButtonPaddingBottom: string;
  79904. /** Gets or sets default key button foreground color */
  79905. defaultButtonColor: string;
  79906. /** Gets or sets default key button background color */
  79907. defaultButtonBackground: string;
  79908. /** Gets or sets shift button foreground color */
  79909. shiftButtonColor: string;
  79910. /** Gets or sets shift button thickness*/
  79911. selectedShiftThickness: number;
  79912. /** Gets shift key state */
  79913. shiftState: number;
  79914. protected _getTypeName(): string;
  79915. private _createKey;
  79916. /**
  79917. * Adds a new row of keys
  79918. * @param keys defines the list of keys to add
  79919. * @param propertySets defines the associated property sets
  79920. */
  79921. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  79922. /**
  79923. * Set the shift key to a specific state
  79924. * @param shiftState defines the new shift state
  79925. */
  79926. applyShiftState(shiftState: number): void;
  79927. private _currentlyConnectedInputText;
  79928. private _connectedInputTexts;
  79929. private _onKeyPressObserver;
  79930. /** Gets the input text control currently attached to the keyboard */
  79931. get connectedInputText(): BABYLON.Nullable<InputText>;
  79932. /**
  79933. * Connects the keyboard with an input text control
  79934. *
  79935. * @param input defines the target control
  79936. */
  79937. connect(input: InputText): void;
  79938. /**
  79939. * Disconnects the keyboard from connected InputText controls
  79940. *
  79941. * @param input optionally defines a target control, otherwise all are disconnected
  79942. */
  79943. disconnect(input?: InputText): void;
  79944. private _removeConnectedInputObservables;
  79945. /**
  79946. * Release all resources
  79947. */
  79948. dispose(): void;
  79949. /**
  79950. * Creates a new keyboard using a default layout
  79951. *
  79952. * @param name defines control name
  79953. * @returns a new VirtualKeyboard
  79954. */
  79955. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  79956. }
  79957. }
  79958. declare module BABYLON.GUI {
  79959. /** @hidden */
  79960. export class TextWrapper {
  79961. private _text;
  79962. private _characters;
  79963. get text(): string;
  79964. set text(txt: string);
  79965. get length(): number;
  79966. removePart(idxStart: number, idxEnd: number, insertTxt?: string): void;
  79967. charAt(idx: number): string;
  79968. substr(from: number, length?: number): string;
  79969. substring(from: number, to?: number): string;
  79970. isWord(index: number): boolean;
  79971. }
  79972. }
  79973. declare module BABYLON.GUI {
  79974. /**
  79975. * Class used to create input text control
  79976. */
  79977. export class InputText extends Control implements IFocusableControl {
  79978. name?: string | undefined;
  79979. private _textWrapper;
  79980. private _placeholderText;
  79981. private _background;
  79982. private _focusedBackground;
  79983. private _focusedColor;
  79984. private _placeholderColor;
  79985. private _thickness;
  79986. private _margin;
  79987. private _autoStretchWidth;
  79988. private _maxWidth;
  79989. private _isFocused;
  79990. private _blinkTimeout;
  79991. private _blinkIsEven;
  79992. private _cursorOffset;
  79993. private _scrollLeft;
  79994. private _textWidth;
  79995. private _clickedCoordinate;
  79996. private _deadKey;
  79997. private _addKey;
  79998. private _currentKey;
  79999. private _isTextHighlightOn;
  80000. private _textHighlightColor;
  80001. private _highligherOpacity;
  80002. private _highlightedText;
  80003. private _startHighlightIndex;
  80004. private _endHighlightIndex;
  80005. private _cursorIndex;
  80006. private _onFocusSelectAll;
  80007. private _isPointerDown;
  80008. private _onClipboardObserver;
  80009. private _onPointerDblTapObserver;
  80010. /** @hidden */
  80011. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  80012. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  80013. promptMessage: string;
  80014. /** Force disable prompt on mobile device */
  80015. disableMobilePrompt: boolean;
  80016. /** BABYLON.Observable raised when the text changes */
  80017. onTextChangedObservable: BABYLON.Observable<InputText>;
  80018. /** BABYLON.Observable raised just before an entered character is to be added */
  80019. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  80020. /** BABYLON.Observable raised when the control gets the focus */
  80021. onFocusObservable: BABYLON.Observable<InputText>;
  80022. /** BABYLON.Observable raised when the control loses the focus */
  80023. onBlurObservable: BABYLON.Observable<InputText>;
  80024. /**Observable raised when the text is highlighted */
  80025. onTextHighlightObservable: BABYLON.Observable<InputText>;
  80026. /**Observable raised when copy event is triggered */
  80027. onTextCopyObservable: BABYLON.Observable<InputText>;
  80028. /** BABYLON.Observable raised when cut event is triggered */
  80029. onTextCutObservable: BABYLON.Observable<InputText>;
  80030. /** BABYLON.Observable raised when paste event is triggered */
  80031. onTextPasteObservable: BABYLON.Observable<InputText>;
  80032. /** BABYLON.Observable raised when a key event was processed */
  80033. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  80034. /** Gets or sets the maximum width allowed by the control */
  80035. get maxWidth(): string | number;
  80036. /** Gets the maximum width allowed by the control in pixels */
  80037. get maxWidthInPixels(): number;
  80038. set maxWidth(value: string | number);
  80039. /** Gets or sets the text highlighter transparency; default: 0.4 */
  80040. get highligherOpacity(): number;
  80041. set highligherOpacity(value: number);
  80042. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  80043. get onFocusSelectAll(): boolean;
  80044. set onFocusSelectAll(value: boolean);
  80045. /** Gets or sets the text hightlight color */
  80046. get textHighlightColor(): string;
  80047. set textHighlightColor(value: string);
  80048. /** Gets or sets control margin */
  80049. get margin(): string;
  80050. /** Gets control margin in pixels */
  80051. get marginInPixels(): number;
  80052. set margin(value: string);
  80053. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  80054. get autoStretchWidth(): boolean;
  80055. set autoStretchWidth(value: boolean);
  80056. /** Gets or sets border thickness */
  80057. get thickness(): number;
  80058. set thickness(value: number);
  80059. /** Gets or sets the background color when focused */
  80060. get focusedBackground(): string;
  80061. set focusedBackground(value: string);
  80062. /** Gets or sets the background color when focused */
  80063. get focusedColor(): string;
  80064. set focusedColor(value: string);
  80065. /** Gets or sets the background color */
  80066. get background(): string;
  80067. set background(value: string);
  80068. /** Gets or sets the placeholder color */
  80069. get placeholderColor(): string;
  80070. set placeholderColor(value: string);
  80071. /** Gets or sets the text displayed when the control is empty */
  80072. get placeholderText(): string;
  80073. set placeholderText(value: string);
  80074. /** Gets or sets the dead key flag */
  80075. get deadKey(): boolean;
  80076. set deadKey(flag: boolean);
  80077. /** Gets or sets the highlight text */
  80078. get highlightedText(): string;
  80079. set highlightedText(text: string);
  80080. /** Gets or sets if the current key should be added */
  80081. get addKey(): boolean;
  80082. set addKey(flag: boolean);
  80083. /** Gets or sets the value of the current key being entered */
  80084. get currentKey(): string;
  80085. set currentKey(key: string);
  80086. /** Gets or sets the text displayed in the control */
  80087. get text(): string;
  80088. set text(value: string);
  80089. private _textHasChanged;
  80090. /** Gets or sets control width */
  80091. get width(): string | number;
  80092. set width(value: string | number);
  80093. /**
  80094. * Creates a new InputText
  80095. * @param name defines the control name
  80096. * @param text defines the text of the control
  80097. */
  80098. constructor(name?: string | undefined, text?: string);
  80099. /** @hidden */
  80100. onBlur(): void;
  80101. /** @hidden */
  80102. onFocus(): void;
  80103. protected _getTypeName(): string;
  80104. /**
  80105. * Function called to get the list of controls that should not steal the focus from this control
  80106. * @returns an array of controls
  80107. */
  80108. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  80109. /** @hidden */
  80110. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  80111. /** @hidden */
  80112. private _updateValueFromCursorIndex;
  80113. /** @hidden */
  80114. private _processDblClick;
  80115. /** @hidden */
  80116. private _selectAllText;
  80117. /**
  80118. * Handles the keyboard event
  80119. * @param evt Defines the KeyboardEvent
  80120. */
  80121. processKeyboard(evt: KeyboardEvent): void;
  80122. /** @hidden */
  80123. private _onCopyText;
  80124. /** @hidden */
  80125. private _onCutText;
  80126. /** @hidden */
  80127. private _onPasteText;
  80128. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80129. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80130. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  80131. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  80132. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  80133. dispose(): void;
  80134. }
  80135. }
  80136. declare module BABYLON.GUI {
  80137. /**
  80138. * Class used to create a 2D grid container
  80139. */
  80140. export class Grid extends Container {
  80141. name?: string | undefined;
  80142. private _rowDefinitions;
  80143. private _columnDefinitions;
  80144. private _cells;
  80145. private _childControls;
  80146. /**
  80147. * Gets the number of columns
  80148. */
  80149. get columnCount(): number;
  80150. /**
  80151. * Gets the number of rows
  80152. */
  80153. get rowCount(): number;
  80154. /** Gets the list of children */
  80155. get children(): Control[];
  80156. /** Gets the list of cells (e.g. the containers) */
  80157. get cells(): {
  80158. [key: string]: Container;
  80159. };
  80160. /**
  80161. * Gets the definition of a specific row
  80162. * @param index defines the index of the row
  80163. * @returns the row definition
  80164. */
  80165. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  80166. /**
  80167. * Gets the definition of a specific column
  80168. * @param index defines the index of the column
  80169. * @returns the column definition
  80170. */
  80171. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  80172. /**
  80173. * Adds a new row to the grid
  80174. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  80175. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  80176. * @returns the current grid
  80177. */
  80178. addRowDefinition(height: number, isPixel?: boolean): Grid;
  80179. /**
  80180. * Adds a new column to the grid
  80181. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  80182. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  80183. * @returns the current grid
  80184. */
  80185. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  80186. /**
  80187. * Update a row definition
  80188. * @param index defines the index of the row to update
  80189. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  80190. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  80191. * @returns the current grid
  80192. */
  80193. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  80194. /**
  80195. * Update a column definition
  80196. * @param index defines the index of the column to update
  80197. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  80198. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  80199. * @returns the current grid
  80200. */
  80201. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  80202. /**
  80203. * Gets the list of children stored in a specific cell
  80204. * @param row defines the row to check
  80205. * @param column defines the column to check
  80206. * @returns the list of controls
  80207. */
  80208. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  80209. /**
  80210. * Gets a string representing the child cell info (row x column)
  80211. * @param child defines the control to get info from
  80212. * @returns a string containing the child cell info (row x column)
  80213. */
  80214. getChildCellInfo(child: Control): string;
  80215. private _removeCell;
  80216. private _offsetCell;
  80217. /**
  80218. * Remove a column definition at specified index
  80219. * @param index defines the index of the column to remove
  80220. * @returns the current grid
  80221. */
  80222. removeColumnDefinition(index: number): Grid;
  80223. /**
  80224. * Remove a row definition at specified index
  80225. * @param index defines the index of the row to remove
  80226. * @returns the current grid
  80227. */
  80228. removeRowDefinition(index: number): Grid;
  80229. /**
  80230. * Adds a new control to the current grid
  80231. * @param control defines the control to add
  80232. * @param row defines the row where to add the control (0 by default)
  80233. * @param column defines the column where to add the control (0 by default)
  80234. * @returns the current grid
  80235. */
  80236. addControl(control: Control, row?: number, column?: number): Grid;
  80237. /**
  80238. * Removes a control from the current container
  80239. * @param control defines the control to remove
  80240. * @returns the current container
  80241. */
  80242. removeControl(control: Control): Container;
  80243. /**
  80244. * Creates a new Grid
  80245. * @param name defines control name
  80246. */
  80247. constructor(name?: string | undefined);
  80248. protected _getTypeName(): string;
  80249. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  80250. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80251. _flagDescendantsAsMatrixDirty(): void;
  80252. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  80253. /** Releases associated resources */
  80254. dispose(): void;
  80255. }
  80256. }
  80257. declare module BABYLON.GUI {
  80258. /** Class used to create color pickers */
  80259. export class ColorPicker extends Control {
  80260. name?: string | undefined;
  80261. private static _Epsilon;
  80262. private _colorWheelCanvas;
  80263. private _value;
  80264. private _tmpColor;
  80265. private _pointerStartedOnSquare;
  80266. private _pointerStartedOnWheel;
  80267. private _squareLeft;
  80268. private _squareTop;
  80269. private _squareSize;
  80270. private _h;
  80271. private _s;
  80272. private _v;
  80273. private _lastPointerDownID;
  80274. /**
  80275. * BABYLON.Observable raised when the value changes
  80276. */
  80277. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  80278. /** Gets or sets the color of the color picker */
  80279. get value(): BABYLON.Color3;
  80280. set value(value: BABYLON.Color3);
  80281. /**
  80282. * Gets or sets control width
  80283. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  80284. */
  80285. get width(): string | number;
  80286. set width(value: string | number);
  80287. /**
  80288. * Gets or sets control height
  80289. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  80290. */
  80291. get height(): string | number;
  80292. /** Gets or sets control height */
  80293. set height(value: string | number);
  80294. /** Gets or sets control size */
  80295. get size(): string | number;
  80296. set size(value: string | number);
  80297. /**
  80298. * Creates a new ColorPicker
  80299. * @param name defines the control name
  80300. */
  80301. constructor(name?: string | undefined);
  80302. protected _getTypeName(): string;
  80303. /** @hidden */
  80304. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80305. private _updateSquareProps;
  80306. private _drawGradientSquare;
  80307. private _drawCircle;
  80308. private _createColorWheelCanvas;
  80309. /** @hidden */
  80310. _draw(context: CanvasRenderingContext2D): void;
  80311. private _pointerIsDown;
  80312. private _updateValueFromPointer;
  80313. private _isPointOnSquare;
  80314. private _isPointOnWheel;
  80315. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80316. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  80317. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  80318. _onCanvasBlur(): void;
  80319. /**
  80320. * This function expands the color picker by creating a color picker dialog with manual
  80321. * color value input and the ability to save colors into an array to be used later in
  80322. * subsequent launches of the dialogue.
  80323. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  80324. * @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.
  80325. * @returns picked color as a hex string and the saved colors array as hex strings.
  80326. */
  80327. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  80328. pickerWidth?: string;
  80329. pickerHeight?: string;
  80330. headerHeight?: string;
  80331. lastColor?: string;
  80332. swatchLimit?: number;
  80333. numSwatchesPerLine?: number;
  80334. savedColors?: Array<string>;
  80335. }): Promise<{
  80336. savedColors?: string[];
  80337. pickedColor: string;
  80338. }>;
  80339. }
  80340. }
  80341. declare module BABYLON.GUI {
  80342. /** Class used to create 2D ellipse containers */
  80343. export class Ellipse extends Container {
  80344. name?: string | undefined;
  80345. private _thickness;
  80346. /** Gets or sets border thickness */
  80347. get thickness(): number;
  80348. set thickness(value: number);
  80349. /**
  80350. * Creates a new Ellipse
  80351. * @param name defines the control name
  80352. */
  80353. constructor(name?: string | undefined);
  80354. protected _getTypeName(): string;
  80355. protected _localDraw(context: CanvasRenderingContext2D): void;
  80356. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80357. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  80358. }
  80359. }
  80360. declare module BABYLON.GUI {
  80361. /**
  80362. * Class used to create a password control
  80363. */
  80364. export class InputPassword extends InputText {
  80365. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  80366. }
  80367. }
  80368. declare module BABYLON.GUI {
  80369. /** Class used to render 2D lines */
  80370. export class Line extends Control {
  80371. name?: string | undefined;
  80372. private _lineWidth;
  80373. private _x1;
  80374. private _y1;
  80375. private _x2;
  80376. private _y2;
  80377. private _dash;
  80378. private _connectedControl;
  80379. private _connectedControlDirtyObserver;
  80380. /** Gets or sets the dash pattern */
  80381. get dash(): Array<number>;
  80382. set dash(value: Array<number>);
  80383. /** Gets or sets the control connected with the line end */
  80384. get connectedControl(): Control;
  80385. set connectedControl(value: Control);
  80386. /** Gets or sets start coordinates on X axis */
  80387. get x1(): string | number;
  80388. set x1(value: string | number);
  80389. /** Gets or sets start coordinates on Y axis */
  80390. get y1(): string | number;
  80391. set y1(value: string | number);
  80392. /** Gets or sets end coordinates on X axis */
  80393. get x2(): string | number;
  80394. set x2(value: string | number);
  80395. /** Gets or sets end coordinates on Y axis */
  80396. get y2(): string | number;
  80397. set y2(value: string | number);
  80398. /** Gets or sets line width */
  80399. get lineWidth(): number;
  80400. set lineWidth(value: number);
  80401. /** Gets or sets horizontal alignment */
  80402. set horizontalAlignment(value: number);
  80403. /** Gets or sets vertical alignment */
  80404. set verticalAlignment(value: number);
  80405. private get _effectiveX2();
  80406. private get _effectiveY2();
  80407. /**
  80408. * Creates a new Line
  80409. * @param name defines the control name
  80410. */
  80411. constructor(name?: string | undefined);
  80412. protected _getTypeName(): string;
  80413. _draw(context: CanvasRenderingContext2D): void;
  80414. _measure(): void;
  80415. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80416. /**
  80417. * Move one end of the line given 3D cartesian coordinates.
  80418. * @param position Targeted world position
  80419. * @param scene BABYLON.Scene
  80420. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  80421. */
  80422. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  80423. /**
  80424. * Move one end of the line to a position in screen absolute space.
  80425. * @param projectedPosition Position in screen absolute space (X, Y)
  80426. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  80427. */
  80428. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  80429. }
  80430. }
  80431. declare module BABYLON.GUI {
  80432. /**
  80433. * Class used to store a point for a MultiLine object.
  80434. * The point can be pure 2D coordinates, a mesh or a control
  80435. */
  80436. export class MultiLinePoint {
  80437. private _multiLine;
  80438. private _x;
  80439. private _y;
  80440. private _control;
  80441. private _mesh;
  80442. private _controlObserver;
  80443. private _meshObserver;
  80444. /** @hidden */
  80445. _point: BABYLON.Vector3;
  80446. /**
  80447. * Creates a new MultiLinePoint
  80448. * @param multiLine defines the source MultiLine object
  80449. */
  80450. constructor(multiLine: MultiLine);
  80451. /** Gets or sets x coordinate */
  80452. get x(): string | number;
  80453. set x(value: string | number);
  80454. /** Gets or sets y coordinate */
  80455. get y(): string | number;
  80456. set y(value: string | number);
  80457. /** Gets or sets the control associated with this point */
  80458. get control(): BABYLON.Nullable<Control>;
  80459. set control(value: BABYLON.Nullable<Control>);
  80460. /** Gets or sets the mesh associated with this point */
  80461. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  80462. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  80463. /** Resets links */
  80464. resetLinks(): void;
  80465. /**
  80466. * Gets a translation vector with Z component
  80467. * @returns the translation vector
  80468. */
  80469. translate(): BABYLON.Vector3;
  80470. private _translatePoint;
  80471. /** Release associated resources */
  80472. dispose(): void;
  80473. }
  80474. }
  80475. declare module BABYLON.GUI {
  80476. /**
  80477. * Class used to create multi line control
  80478. */
  80479. export class MultiLine extends Control {
  80480. name?: string | undefined;
  80481. private _lineWidth;
  80482. private _dash;
  80483. private _points;
  80484. private _minX;
  80485. private _minY;
  80486. private _maxX;
  80487. private _maxY;
  80488. /**
  80489. * Creates a new MultiLine
  80490. * @param name defines the control name
  80491. */
  80492. constructor(name?: string | undefined);
  80493. /** Gets or sets dash pattern */
  80494. get dash(): Array<number>;
  80495. set dash(value: Array<number>);
  80496. /**
  80497. * Gets point stored at specified index
  80498. * @param index defines the index to look for
  80499. * @returns the requested point if found
  80500. */
  80501. getAt(index: number): MultiLinePoint;
  80502. /** Function called when a point is updated */
  80503. onPointUpdate: () => void;
  80504. /**
  80505. * Adds new points to the point collection
  80506. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  80507. * @returns the list of created MultiLinePoint
  80508. */
  80509. add(...items: (AbstractMesh | Control | {
  80510. x: string | number;
  80511. y: string | number;
  80512. })[]): MultiLinePoint[];
  80513. /**
  80514. * Adds a new point to the point collection
  80515. * @param item defines the item (mesh, control or 2d coordiantes) to add
  80516. * @returns the created MultiLinePoint
  80517. */
  80518. push(item?: (AbstractMesh | Control | {
  80519. x: string | number;
  80520. y: string | number;
  80521. })): MultiLinePoint;
  80522. /**
  80523. * Remove a specific value or point from the active point collection
  80524. * @param value defines the value or point to remove
  80525. */
  80526. remove(value: number | MultiLinePoint): void;
  80527. /**
  80528. * Resets this object to initial state (no point)
  80529. */
  80530. reset(): void;
  80531. /**
  80532. * Resets all links
  80533. */
  80534. resetLinks(): void;
  80535. /** Gets or sets line width */
  80536. get lineWidth(): number;
  80537. set lineWidth(value: number);
  80538. set horizontalAlignment(value: number);
  80539. set verticalAlignment(value: number);
  80540. protected _getTypeName(): string;
  80541. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80542. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80543. _measure(): void;
  80544. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80545. dispose(): void;
  80546. }
  80547. }
  80548. declare module BABYLON.GUI {
  80549. /**
  80550. * Class used to create radio button controls
  80551. */
  80552. export class RadioButton extends Control {
  80553. name?: string | undefined;
  80554. private _isChecked;
  80555. private _background;
  80556. private _checkSizeRatio;
  80557. private _thickness;
  80558. /** Gets or sets border thickness */
  80559. get thickness(): number;
  80560. set thickness(value: number);
  80561. /** Gets or sets group name */
  80562. group: string;
  80563. /** BABYLON.Observable raised when isChecked is changed */
  80564. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  80565. /** Gets or sets a value indicating the ratio between overall size and check size */
  80566. get checkSizeRatio(): number;
  80567. set checkSizeRatio(value: number);
  80568. /** Gets or sets background color */
  80569. get background(): string;
  80570. set background(value: string);
  80571. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  80572. get isChecked(): boolean;
  80573. set isChecked(value: boolean);
  80574. /**
  80575. * Creates a new RadioButton
  80576. * @param name defines the control name
  80577. */
  80578. constructor(name?: string | undefined);
  80579. protected _getTypeName(): string;
  80580. _draw(context: CanvasRenderingContext2D): void;
  80581. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80582. /**
  80583. * Utility function to easily create a radio button with a header
  80584. * @param title defines the label to use for the header
  80585. * @param group defines the group to use for the radio button
  80586. * @param isChecked defines the initial state of the radio button
  80587. * @param onValueChanged defines the callback to call when value changes
  80588. * @returns a StackPanel containing the radio button and a textBlock
  80589. */
  80590. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  80591. }
  80592. }
  80593. declare module BABYLON.GUI {
  80594. /**
  80595. * Class used to create slider controls
  80596. */
  80597. export class BaseSlider extends Control {
  80598. name?: string | undefined;
  80599. protected _thumbWidth: ValueAndUnit;
  80600. private _minimum;
  80601. private _maximum;
  80602. private _value;
  80603. private _isVertical;
  80604. protected _barOffset: ValueAndUnit;
  80605. private _isThumbClamped;
  80606. protected _displayThumb: boolean;
  80607. private _step;
  80608. private _lastPointerDownID;
  80609. protected _effectiveBarOffset: number;
  80610. protected _renderLeft: number;
  80611. protected _renderTop: number;
  80612. protected _renderWidth: number;
  80613. protected _renderHeight: number;
  80614. protected _backgroundBoxLength: number;
  80615. protected _backgroundBoxThickness: number;
  80616. protected _effectiveThumbThickness: number;
  80617. /** BABYLON.Observable raised when the sldier value changes */
  80618. onValueChangedObservable: BABYLON.Observable<number>;
  80619. /** Gets or sets a boolean indicating if the thumb must be rendered */
  80620. get displayThumb(): boolean;
  80621. set displayThumb(value: boolean);
  80622. /** Gets or sets a step to apply to values (0 by default) */
  80623. get step(): number;
  80624. set step(value: number);
  80625. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  80626. get barOffset(): string | number;
  80627. /** Gets main bar offset in pixels*/
  80628. get barOffsetInPixels(): number;
  80629. set barOffset(value: string | number);
  80630. /** Gets or sets thumb width */
  80631. get thumbWidth(): string | number;
  80632. /** Gets thumb width in pixels */
  80633. get thumbWidthInPixels(): number;
  80634. set thumbWidth(value: string | number);
  80635. /** Gets or sets minimum value */
  80636. get minimum(): number;
  80637. set minimum(value: number);
  80638. /** Gets or sets maximum value */
  80639. get maximum(): number;
  80640. set maximum(value: number);
  80641. /** Gets or sets current value */
  80642. get value(): number;
  80643. set value(value: number);
  80644. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  80645. get isVertical(): boolean;
  80646. set isVertical(value: boolean);
  80647. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  80648. get isThumbClamped(): boolean;
  80649. set isThumbClamped(value: boolean);
  80650. /**
  80651. * Creates a new BaseSlider
  80652. * @param name defines the control name
  80653. */
  80654. constructor(name?: string | undefined);
  80655. protected _getTypeName(): string;
  80656. protected _getThumbPosition(): number;
  80657. protected _getThumbThickness(type: string): number;
  80658. protected _prepareRenderingData(type: string): void;
  80659. private _pointerIsDown;
  80660. /** @hidden */
  80661. protected _updateValueFromPointer(x: number, y: number): void;
  80662. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80663. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  80664. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  80665. _onCanvasBlur(): void;
  80666. }
  80667. }
  80668. declare module BABYLON.GUI {
  80669. /**
  80670. * Class used to create slider controls
  80671. */
  80672. export class Slider extends BaseSlider {
  80673. name?: string | undefined;
  80674. private _background;
  80675. private _borderColor;
  80676. private _thumbColor;
  80677. private _isThumbCircle;
  80678. protected _displayValueBar: boolean;
  80679. /** Gets or sets a boolean indicating if the value bar must be rendered */
  80680. get displayValueBar(): boolean;
  80681. set displayValueBar(value: boolean);
  80682. /** Gets or sets border color */
  80683. get borderColor(): string;
  80684. set borderColor(value: string);
  80685. /** Gets or sets background color */
  80686. get background(): string;
  80687. set background(value: string);
  80688. /** Gets or sets thumb's color */
  80689. get thumbColor(): string;
  80690. set thumbColor(value: string);
  80691. /** Gets or sets a boolean indicating if the thumb should be round or square */
  80692. get isThumbCircle(): boolean;
  80693. set isThumbCircle(value: boolean);
  80694. /**
  80695. * Creates a new Slider
  80696. * @param name defines the control name
  80697. */
  80698. constructor(name?: string | undefined);
  80699. protected _getTypeName(): string;
  80700. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80701. }
  80702. }
  80703. declare module BABYLON.GUI {
  80704. /** Class used to create a RadioGroup
  80705. * which contains groups of radio buttons
  80706. */
  80707. export class SelectorGroup {
  80708. /** name of SelectorGroup */
  80709. name: string;
  80710. private _groupPanel;
  80711. private _selectors;
  80712. private _groupHeader;
  80713. /**
  80714. * Creates a new SelectorGroup
  80715. * @param name of group, used as a group heading
  80716. */
  80717. constructor(
  80718. /** name of SelectorGroup */
  80719. name: string);
  80720. /** Gets the groupPanel of the SelectorGroup */
  80721. get groupPanel(): StackPanel;
  80722. /** Gets the selectors array */
  80723. get selectors(): StackPanel[];
  80724. /** Gets and sets the group header */
  80725. get header(): string;
  80726. set header(label: string);
  80727. /** @hidden */
  80728. private _addGroupHeader;
  80729. /** @hidden*/
  80730. _getSelector(selectorNb: number): StackPanel | undefined;
  80731. /** Removes the selector at the given position
  80732. * @param selectorNb the position of the selector within the group
  80733. */
  80734. removeSelector(selectorNb: number): void;
  80735. }
  80736. /** Class used to create a CheckboxGroup
  80737. * which contains groups of checkbox buttons
  80738. */
  80739. export class CheckboxGroup extends SelectorGroup {
  80740. /** Adds a checkbox as a control
  80741. * @param text is the label for the selector
  80742. * @param func is the function called when the Selector is checked
  80743. * @param checked is true when Selector is checked
  80744. */
  80745. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  80746. /** @hidden */
  80747. _setSelectorLabel(selectorNb: number, label: string): void;
  80748. /** @hidden */
  80749. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80750. /** @hidden */
  80751. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80752. /** @hidden */
  80753. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80754. }
  80755. /** Class used to create a RadioGroup
  80756. * which contains groups of radio buttons
  80757. */
  80758. export class RadioGroup extends SelectorGroup {
  80759. private _selectNb;
  80760. /** Adds a radio button as a control
  80761. * @param label is the label for the selector
  80762. * @param func is the function called when the Selector is checked
  80763. * @param checked is true when Selector is checked
  80764. */
  80765. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  80766. /** @hidden */
  80767. _setSelectorLabel(selectorNb: number, label: string): void;
  80768. /** @hidden */
  80769. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80770. /** @hidden */
  80771. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80772. /** @hidden */
  80773. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80774. }
  80775. /** Class used to create a SliderGroup
  80776. * which contains groups of slider buttons
  80777. */
  80778. export class SliderGroup extends SelectorGroup {
  80779. /**
  80780. * Adds a slider to the SelectorGroup
  80781. * @param label is the label for the SliderBar
  80782. * @param func is the function called when the Slider moves
  80783. * @param unit is a string describing the units used, eg degrees or metres
  80784. * @param min is the minimum value for the Slider
  80785. * @param max is the maximum value for the Slider
  80786. * @param value is the start value for the Slider between min and max
  80787. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  80788. */
  80789. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  80790. /** @hidden */
  80791. _setSelectorLabel(selectorNb: number, label: string): void;
  80792. /** @hidden */
  80793. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80794. /** @hidden */
  80795. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80796. /** @hidden */
  80797. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80798. }
  80799. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  80800. * @see https://doc.babylonjs.com/how_to/selector
  80801. */
  80802. export class SelectionPanel extends Rectangle {
  80803. /** name of SelectionPanel */
  80804. name: string;
  80805. /** an array of SelectionGroups */
  80806. groups: SelectorGroup[];
  80807. private _panel;
  80808. private _buttonColor;
  80809. private _buttonBackground;
  80810. private _headerColor;
  80811. private _barColor;
  80812. private _barHeight;
  80813. private _spacerHeight;
  80814. private _labelColor;
  80815. private _groups;
  80816. private _bars;
  80817. /**
  80818. * Creates a new SelectionPanel
  80819. * @param name of SelectionPanel
  80820. * @param groups is an array of SelectionGroups
  80821. */
  80822. constructor(
  80823. /** name of SelectionPanel */
  80824. name: string,
  80825. /** an array of SelectionGroups */
  80826. groups?: SelectorGroup[]);
  80827. protected _getTypeName(): string;
  80828. /** Gets the (stack) panel of the SelectionPanel */
  80829. get panel(): StackPanel;
  80830. /** Gets or sets the headerColor */
  80831. get headerColor(): string;
  80832. set headerColor(color: string);
  80833. private _setHeaderColor;
  80834. /** Gets or sets the button color */
  80835. get buttonColor(): string;
  80836. set buttonColor(color: string);
  80837. private _setbuttonColor;
  80838. /** Gets or sets the label color */
  80839. get labelColor(): string;
  80840. set labelColor(color: string);
  80841. private _setLabelColor;
  80842. /** Gets or sets the button background */
  80843. get buttonBackground(): string;
  80844. set buttonBackground(color: string);
  80845. private _setButtonBackground;
  80846. /** Gets or sets the color of separator bar */
  80847. get barColor(): string;
  80848. set barColor(color: string);
  80849. private _setBarColor;
  80850. /** Gets or sets the height of separator bar */
  80851. get barHeight(): string;
  80852. set barHeight(value: string);
  80853. private _setBarHeight;
  80854. /** Gets or sets the height of spacers*/
  80855. get spacerHeight(): string;
  80856. set spacerHeight(value: string);
  80857. private _setSpacerHeight;
  80858. /** Adds a bar between groups */
  80859. private _addSpacer;
  80860. /** Add a group to the selection panel
  80861. * @param group is the selector group to add
  80862. */
  80863. addGroup(group: SelectorGroup): void;
  80864. /** Remove the group from the given position
  80865. * @param groupNb is the position of the group in the list
  80866. */
  80867. removeGroup(groupNb: number): void;
  80868. /** Change a group header label
  80869. * @param label is the new group header label
  80870. * @param groupNb is the number of the group to relabel
  80871. * */
  80872. setHeaderName(label: string, groupNb: number): void;
  80873. /** Change selector label to the one given
  80874. * @param label is the new selector label
  80875. * @param groupNb is the number of the groupcontaining the selector
  80876. * @param selectorNb is the number of the selector within a group to relabel
  80877. * */
  80878. relabel(label: string, groupNb: number, selectorNb: number): void;
  80879. /** For a given group position remove the selector at the given position
  80880. * @param groupNb is the number of the group to remove the selector from
  80881. * @param selectorNb is the number of the selector within the group
  80882. */
  80883. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  80884. /** For a given group position of correct type add a checkbox button
  80885. * @param groupNb is the number of the group to remove the selector from
  80886. * @param label is the label for the selector
  80887. * @param func is the function called when the Selector is checked
  80888. * @param checked is true when Selector is checked
  80889. */
  80890. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  80891. /** For a given group position of correct type add a radio button
  80892. * @param groupNb is the number of the group to remove the selector from
  80893. * @param label is the label for the selector
  80894. * @param func is the function called when the Selector is checked
  80895. * @param checked is true when Selector is checked
  80896. */
  80897. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  80898. /**
  80899. * For a given slider group add a slider
  80900. * @param groupNb is the number of the group to add the slider to
  80901. * @param label is the label for the Slider
  80902. * @param func is the function called when the Slider moves
  80903. * @param unit is a string describing the units used, eg degrees or metres
  80904. * @param min is the minimum value for the Slider
  80905. * @param max is the maximum value for the Slider
  80906. * @param value is the start value for the Slider between min and max
  80907. * @param onVal is the function used to format the value displayed, eg radians to degrees
  80908. */
  80909. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  80910. }
  80911. }
  80912. declare module BABYLON.GUI {
  80913. /**
  80914. * Class used to hold a the container for ScrollViewer
  80915. * @hidden
  80916. */
  80917. export class _ScrollViewerWindow extends Container {
  80918. parentClientWidth: number;
  80919. parentClientHeight: number;
  80920. private _freezeControls;
  80921. private _parentMeasure;
  80922. private _oldLeft;
  80923. private _oldTop;
  80924. get freezeControls(): boolean;
  80925. set freezeControls(value: boolean);
  80926. private _bucketWidth;
  80927. private _bucketHeight;
  80928. private _buckets;
  80929. private _bucketLen;
  80930. get bucketWidth(): number;
  80931. get bucketHeight(): number;
  80932. setBucketSizes(width: number, height: number): void;
  80933. private _useBuckets;
  80934. private _makeBuckets;
  80935. private _dispatchInBuckets;
  80936. private _updateMeasures;
  80937. private _updateChildrenMeasures;
  80938. private _restoreMeasures;
  80939. /**
  80940. * Creates a new ScrollViewerWindow
  80941. * @param name of ScrollViewerWindow
  80942. */
  80943. constructor(name?: string);
  80944. protected _getTypeName(): string;
  80945. /** @hidden */
  80946. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80947. /** @hidden */
  80948. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  80949. private _scrollChildren;
  80950. private _scrollChildrenWithBuckets;
  80951. /** @hidden */
  80952. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  80953. protected _postMeasure(): void;
  80954. }
  80955. }
  80956. declare module BABYLON.GUI {
  80957. /**
  80958. * Class used to create slider controls
  80959. */
  80960. export class ScrollBar extends BaseSlider {
  80961. name?: string | undefined;
  80962. private _background;
  80963. private _borderColor;
  80964. private _tempMeasure;
  80965. /** Gets or sets border color */
  80966. get borderColor(): string;
  80967. set borderColor(value: string);
  80968. /** Gets or sets background color */
  80969. get background(): string;
  80970. set background(value: string);
  80971. /**
  80972. * Creates a new Slider
  80973. * @param name defines the control name
  80974. */
  80975. constructor(name?: string | undefined);
  80976. protected _getTypeName(): string;
  80977. protected _getThumbThickness(): number;
  80978. _draw(context: CanvasRenderingContext2D): void;
  80979. private _first;
  80980. private _originX;
  80981. private _originY;
  80982. /** @hidden */
  80983. protected _updateValueFromPointer(x: number, y: number): void;
  80984. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80985. }
  80986. }
  80987. declare module BABYLON.GUI {
  80988. /**
  80989. * Class used to create slider controls
  80990. */
  80991. export class ImageScrollBar extends BaseSlider {
  80992. name?: string | undefined;
  80993. private _backgroundBaseImage;
  80994. private _backgroundImage;
  80995. private _thumbImage;
  80996. private _thumbBaseImage;
  80997. private _thumbLength;
  80998. private _thumbHeight;
  80999. private _barImageHeight;
  81000. private _tempMeasure;
  81001. /** Number of 90° rotation to apply on the images when in vertical mode */
  81002. num90RotationInVerticalMode: number;
  81003. /**
  81004. * Gets or sets the image used to render the background for horizontal bar
  81005. */
  81006. get backgroundImage(): Image;
  81007. set backgroundImage(value: Image);
  81008. /**
  81009. * Gets or sets the image used to render the thumb
  81010. */
  81011. get thumbImage(): Image;
  81012. set thumbImage(value: Image);
  81013. /**
  81014. * Gets or sets the length of the thumb
  81015. */
  81016. get thumbLength(): number;
  81017. set thumbLength(value: number);
  81018. /**
  81019. * Gets or sets the height of the thumb
  81020. */
  81021. get thumbHeight(): number;
  81022. set thumbHeight(value: number);
  81023. /**
  81024. * Gets or sets the height of the bar image
  81025. */
  81026. get barImageHeight(): number;
  81027. set barImageHeight(value: number);
  81028. /**
  81029. * Creates a new ImageScrollBar
  81030. * @param name defines the control name
  81031. */
  81032. constructor(name?: string | undefined);
  81033. protected _getTypeName(): string;
  81034. protected _getThumbThickness(): number;
  81035. _draw(context: CanvasRenderingContext2D): void;
  81036. private _first;
  81037. private _originX;
  81038. private _originY;
  81039. /** @hidden */
  81040. protected _updateValueFromPointer(x: number, y: number): void;
  81041. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  81042. }
  81043. }
  81044. declare module BABYLON.GUI {
  81045. /**
  81046. * Class used to hold a viewer window and sliders in a grid
  81047. */
  81048. export class ScrollViewer extends Rectangle {
  81049. private _grid;
  81050. private _horizontalBarSpace;
  81051. private _verticalBarSpace;
  81052. private _dragSpace;
  81053. private _horizontalBar;
  81054. private _verticalBar;
  81055. private _barColor;
  81056. private _barBackground;
  81057. private _barImage;
  81058. private _horizontalBarImage;
  81059. private _verticalBarImage;
  81060. private _barBackgroundImage;
  81061. private _horizontalBarBackgroundImage;
  81062. private _verticalBarBackgroundImage;
  81063. private _barSize;
  81064. private _window;
  81065. private _pointerIsOver;
  81066. private _wheelPrecision;
  81067. private _onWheelObserver;
  81068. private _clientWidth;
  81069. private _clientHeight;
  81070. private _useImageBar;
  81071. private _thumbLength;
  81072. private _thumbHeight;
  81073. private _barImageHeight;
  81074. private _horizontalBarImageHeight;
  81075. private _verticalBarImageHeight;
  81076. private _oldWindowContentsWidth;
  81077. private _oldWindowContentsHeight;
  81078. /**
  81079. * Gets the horizontal scrollbar
  81080. */
  81081. get horizontalBar(): ScrollBar | ImageScrollBar;
  81082. /**
  81083. * Gets the vertical scrollbar
  81084. */
  81085. get verticalBar(): ScrollBar | ImageScrollBar;
  81086. /**
  81087. * Adds a new control to the current container
  81088. * @param control defines the control to add
  81089. * @returns the current container
  81090. */
  81091. addControl(control: BABYLON.Nullable<Control>): Container;
  81092. /**
  81093. * Removes a control from the current container
  81094. * @param control defines the control to remove
  81095. * @returns the current container
  81096. */
  81097. removeControl(control: Control): Container;
  81098. /** Gets the list of children */
  81099. get children(): Control[];
  81100. _flagDescendantsAsMatrixDirty(): void;
  81101. /**
  81102. * Freezes or unfreezes the controls in the window.
  81103. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  81104. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  81105. */
  81106. get freezeControls(): boolean;
  81107. set freezeControls(value: boolean);
  81108. /** Gets the bucket width */
  81109. get bucketWidth(): number;
  81110. /** Gets the bucket height */
  81111. get bucketHeight(): number;
  81112. /**
  81113. * Sets the bucket sizes.
  81114. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  81115. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  81116. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  81117. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  81118. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  81119. * used), that's why it is not enabled by default.
  81120. * @param width width of the bucket
  81121. * @param height height of the bucket
  81122. */
  81123. setBucketSizes(width: number, height: number): void;
  81124. private _forceHorizontalBar;
  81125. private _forceVerticalBar;
  81126. /**
  81127. * Forces the horizontal scroll bar to be displayed
  81128. */
  81129. get forceHorizontalBar(): boolean;
  81130. set forceHorizontalBar(value: boolean);
  81131. /**
  81132. * Forces the vertical scroll bar to be displayed
  81133. */
  81134. get forceVerticalBar(): boolean;
  81135. set forceVerticalBar(value: boolean);
  81136. /**
  81137. * Creates a new ScrollViewer
  81138. * @param name of ScrollViewer
  81139. */
  81140. constructor(name?: string, isImageBased?: boolean);
  81141. /** Reset the scroll viewer window to initial size */
  81142. resetWindow(): void;
  81143. protected _getTypeName(): string;
  81144. private _buildClientSizes;
  81145. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  81146. protected _postMeasure(): void;
  81147. /**
  81148. * Gets or sets the mouse wheel precision
  81149. * from 0 to 1 with a default value of 0.05
  81150. * */
  81151. get wheelPrecision(): number;
  81152. set wheelPrecision(value: number);
  81153. /** Gets or sets the scroll bar container background color */
  81154. get scrollBackground(): string;
  81155. set scrollBackground(color: string);
  81156. /** Gets or sets the bar color */
  81157. get barColor(): string;
  81158. set barColor(color: string);
  81159. /** Gets or sets the bar image */
  81160. get thumbImage(): Image;
  81161. set thumbImage(value: Image);
  81162. /** Gets or sets the horizontal bar image */
  81163. get horizontalThumbImage(): Image;
  81164. set horizontalThumbImage(value: Image);
  81165. /** Gets or sets the vertical bar image */
  81166. get verticalThumbImage(): Image;
  81167. set verticalThumbImage(value: Image);
  81168. /** Gets or sets the size of the bar */
  81169. get barSize(): number;
  81170. set barSize(value: number);
  81171. /** Gets or sets the length of the thumb */
  81172. get thumbLength(): number;
  81173. set thumbLength(value: number);
  81174. /** Gets or sets the height of the thumb */
  81175. get thumbHeight(): number;
  81176. set thumbHeight(value: number);
  81177. /** Gets or sets the height of the bar image */
  81178. get barImageHeight(): number;
  81179. set barImageHeight(value: number);
  81180. /** Gets or sets the height of the horizontal bar image */
  81181. get horizontalBarImageHeight(): number;
  81182. set horizontalBarImageHeight(value: number);
  81183. /** Gets or sets the height of the vertical bar image */
  81184. get verticalBarImageHeight(): number;
  81185. set verticalBarImageHeight(value: number);
  81186. /** Gets or sets the bar background */
  81187. get barBackground(): string;
  81188. set barBackground(color: string);
  81189. /** Gets or sets the bar background image */
  81190. get barImage(): Image;
  81191. set barImage(value: Image);
  81192. /** Gets or sets the horizontal bar background image */
  81193. get horizontalBarImage(): Image;
  81194. set horizontalBarImage(value: Image);
  81195. /** Gets or sets the vertical bar background image */
  81196. get verticalBarImage(): Image;
  81197. set verticalBarImage(value: Image);
  81198. private _setWindowPosition;
  81199. /** @hidden */
  81200. private _updateScroller;
  81201. _link(host: AdvancedDynamicTexture): void;
  81202. /** @hidden */
  81203. private _addBar;
  81204. /** @hidden */
  81205. private _attachWheel;
  81206. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  81207. /** Releases associated resources */
  81208. dispose(): void;
  81209. }
  81210. }
  81211. declare module BABYLON.GUI {
  81212. /** Class used to render a grid */
  81213. export class DisplayGrid extends Control {
  81214. name?: string | undefined;
  81215. private _cellWidth;
  81216. private _cellHeight;
  81217. private _minorLineTickness;
  81218. private _minorLineColor;
  81219. private _majorLineTickness;
  81220. private _majorLineColor;
  81221. private _majorLineFrequency;
  81222. private _background;
  81223. private _displayMajorLines;
  81224. private _displayMinorLines;
  81225. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  81226. get displayMinorLines(): boolean;
  81227. set displayMinorLines(value: boolean);
  81228. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  81229. get displayMajorLines(): boolean;
  81230. set displayMajorLines(value: boolean);
  81231. /** Gets or sets background color (Black by default) */
  81232. get background(): string;
  81233. set background(value: string);
  81234. /** Gets or sets the width of each cell (20 by default) */
  81235. get cellWidth(): number;
  81236. set cellWidth(value: number);
  81237. /** Gets or sets the height of each cell (20 by default) */
  81238. get cellHeight(): number;
  81239. set cellHeight(value: number);
  81240. /** Gets or sets the tickness of minor lines (1 by default) */
  81241. get minorLineTickness(): number;
  81242. set minorLineTickness(value: number);
  81243. /** Gets or sets the color of minor lines (DarkGray by default) */
  81244. get minorLineColor(): string;
  81245. set minorLineColor(value: string);
  81246. /** Gets or sets the tickness of major lines (2 by default) */
  81247. get majorLineTickness(): number;
  81248. set majorLineTickness(value: number);
  81249. /** Gets or sets the color of major lines (White by default) */
  81250. get majorLineColor(): string;
  81251. set majorLineColor(value: string);
  81252. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  81253. get majorLineFrequency(): number;
  81254. set majorLineFrequency(value: number);
  81255. /**
  81256. * Creates a new GridDisplayRectangle
  81257. * @param name defines the control name
  81258. */
  81259. constructor(name?: string | undefined);
  81260. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  81261. protected _getTypeName(): string;
  81262. }
  81263. }
  81264. declare module BABYLON.GUI {
  81265. /**
  81266. * Class used to create slider controls based on images
  81267. */
  81268. export class ImageBasedSlider extends BaseSlider {
  81269. name?: string | undefined;
  81270. private _backgroundImage;
  81271. private _thumbImage;
  81272. private _valueBarImage;
  81273. private _tempMeasure;
  81274. get displayThumb(): boolean;
  81275. set displayThumb(value: boolean);
  81276. /**
  81277. * Gets or sets the image used to render the background
  81278. */
  81279. get backgroundImage(): Image;
  81280. set backgroundImage(value: Image);
  81281. /**
  81282. * Gets or sets the image used to render the value bar
  81283. */
  81284. get valueBarImage(): Image;
  81285. set valueBarImage(value: Image);
  81286. /**
  81287. * Gets or sets the image used to render the thumb
  81288. */
  81289. get thumbImage(): Image;
  81290. set thumbImage(value: Image);
  81291. /**
  81292. * Creates a new ImageBasedSlider
  81293. * @param name defines the control name
  81294. */
  81295. constructor(name?: string | undefined);
  81296. protected _getTypeName(): string;
  81297. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  81298. }
  81299. }
  81300. declare module BABYLON.GUI {
  81301. /**
  81302. * Forcing an export so that this code will execute
  81303. * @hidden
  81304. */
  81305. const name = "Statics";
  81306. }
  81307. declare module BABYLON.GUI {
  81308. /**
  81309. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  81310. */
  81311. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  81312. /**
  81313. * Define the instrumented AdvancedDynamicTexture.
  81314. */
  81315. texture: AdvancedDynamicTexture;
  81316. private _captureRenderTime;
  81317. private _renderTime;
  81318. private _captureLayoutTime;
  81319. private _layoutTime;
  81320. private _onBeginRenderObserver;
  81321. private _onEndRenderObserver;
  81322. private _onBeginLayoutObserver;
  81323. private _onEndLayoutObserver;
  81324. /**
  81325. * Gets the perf counter used to capture render time
  81326. */
  81327. get renderTimeCounter(): BABYLON.PerfCounter;
  81328. /**
  81329. * Gets the perf counter used to capture layout time
  81330. */
  81331. get layoutTimeCounter(): BABYLON.PerfCounter;
  81332. /**
  81333. * Enable or disable the render time capture
  81334. */
  81335. get captureRenderTime(): boolean;
  81336. set captureRenderTime(value: boolean);
  81337. /**
  81338. * Enable or disable the layout time capture
  81339. */
  81340. get captureLayoutTime(): boolean;
  81341. set captureLayoutTime(value: boolean);
  81342. /**
  81343. * Instantiates a new advanced dynamic texture instrumentation.
  81344. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  81345. * @param texture Defines the AdvancedDynamicTexture to instrument
  81346. */
  81347. constructor(
  81348. /**
  81349. * Define the instrumented AdvancedDynamicTexture.
  81350. */
  81351. texture: AdvancedDynamicTexture);
  81352. /**
  81353. * Dispose and release associated resources.
  81354. */
  81355. dispose(): void;
  81356. }
  81357. }
  81358. declare module BABYLON.GUI {
  81359. /**
  81360. * Class used to load GUI via XML.
  81361. */
  81362. export class XmlLoader {
  81363. private _nodes;
  81364. private _nodeTypes;
  81365. private _isLoaded;
  81366. private _objectAttributes;
  81367. private _parentClass;
  81368. /**
  81369. * Create a new xml loader
  81370. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  81371. */
  81372. constructor(parentClass?: null);
  81373. private _getChainElement;
  81374. private _getClassAttribute;
  81375. private _createGuiElement;
  81376. private _parseGrid;
  81377. private _parseElement;
  81378. private _prepareSourceElement;
  81379. private _parseElementsFromSource;
  81380. private _parseXml;
  81381. /**
  81382. * Gets if the loading has finished.
  81383. * @returns whether the loading has finished or not
  81384. */
  81385. isLoaded(): boolean;
  81386. /**
  81387. * Gets a loaded node / control by id.
  81388. * @param id the Controls id set in the xml
  81389. * @returns element of type Control
  81390. */
  81391. getNodeById(id: string): any;
  81392. /**
  81393. * Gets all loaded nodes / controls
  81394. * @returns Array of controls
  81395. */
  81396. getNodes(): any;
  81397. /**
  81398. * Initiates the xml layout loading
  81399. * @param xmlFile defines the xml layout to load
  81400. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  81401. * @param callback defines the callback called on layout load.
  81402. */
  81403. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  81404. }
  81405. }
  81406. declare module BABYLON.GUI {
  81407. /**
  81408. * Class used to create containers for controls
  81409. */
  81410. export class Container3D extends Control3D {
  81411. private _blockLayout;
  81412. /**
  81413. * Gets the list of child controls
  81414. */
  81415. protected _children: Control3D[];
  81416. /**
  81417. * Gets the list of child controls
  81418. */
  81419. get children(): Array<Control3D>;
  81420. /**
  81421. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  81422. * This is helpful to optimize layout operation when adding multiple children in a row
  81423. */
  81424. get blockLayout(): boolean;
  81425. set blockLayout(value: boolean);
  81426. /**
  81427. * Creates a new container
  81428. * @param name defines the container name
  81429. */
  81430. constructor(name?: string);
  81431. /**
  81432. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  81433. * @returns the current container
  81434. */
  81435. updateLayout(): Container3D;
  81436. /**
  81437. * Gets a boolean indicating if the given control is in the children of this control
  81438. * @param control defines the control to check
  81439. * @returns true if the control is in the child list
  81440. */
  81441. containsControl(control: Control3D): boolean;
  81442. /**
  81443. * Adds a control to the children of this control
  81444. * @param control defines the control to add
  81445. * @returns the current container
  81446. */
  81447. addControl(control: Control3D): Container3D;
  81448. /**
  81449. * This function will be called everytime a new control is added
  81450. */
  81451. protected _arrangeChildren(): void;
  81452. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  81453. /**
  81454. * Removes a control from the children of this control
  81455. * @param control defines the control to remove
  81456. * @returns the current container
  81457. */
  81458. removeControl(control: Control3D): Container3D;
  81459. protected _getTypeName(): string;
  81460. /**
  81461. * Releases all associated resources
  81462. */
  81463. dispose(): void;
  81464. /** Control rotation will remain unchanged */
  81465. static readonly UNSET_ORIENTATION: number;
  81466. /** Control will rotate to make it look at sphere central axis */
  81467. static readonly FACEORIGIN_ORIENTATION: number;
  81468. /** Control will rotate to make it look back at sphere central axis */
  81469. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  81470. /** Control will rotate to look at z axis (0, 0, 1) */
  81471. static readonly FACEFORWARD_ORIENTATION: number;
  81472. /** Control will rotate to look at negative z axis (0, 0, -1) */
  81473. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  81474. }
  81475. }
  81476. declare module BABYLON.GUI {
  81477. /**
  81478. * Class used to manage 3D user interface
  81479. * @see https://doc.babylonjs.com/how_to/gui3d
  81480. */
  81481. export class GUI3DManager implements BABYLON.IDisposable {
  81482. private _scene;
  81483. private _sceneDisposeObserver;
  81484. private _utilityLayer;
  81485. private _rootContainer;
  81486. private _pointerObserver;
  81487. private _pointerOutObserver;
  81488. /** @hidden */
  81489. _lastPickedControl: Control3D;
  81490. /** @hidden */
  81491. _lastControlOver: {
  81492. [pointerId: number]: Control3D;
  81493. };
  81494. /** @hidden */
  81495. _lastControlDown: {
  81496. [pointerId: number]: Control3D;
  81497. };
  81498. /**
  81499. * BABYLON.Observable raised when the point picked by the pointer events changed
  81500. */
  81501. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  81502. /** @hidden */
  81503. _sharedMaterials: {
  81504. [key: string]: BABYLON.Material;
  81505. };
  81506. /** Gets the hosting scene */
  81507. get scene(): BABYLON.Scene;
  81508. /** Gets associated utility layer */
  81509. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  81510. /**
  81511. * Creates a new GUI3DManager
  81512. * @param scene
  81513. */
  81514. constructor(scene?: BABYLON.Scene);
  81515. private _handlePointerOut;
  81516. private _doPicking;
  81517. /**
  81518. * Gets the root container
  81519. */
  81520. get rootContainer(): Container3D;
  81521. /**
  81522. * Gets a boolean indicating if the given control is in the root child list
  81523. * @param control defines the control to check
  81524. * @returns true if the control is in the root child list
  81525. */
  81526. containsControl(control: Control3D): boolean;
  81527. /**
  81528. * Adds a control to the root child list
  81529. * @param control defines the control to add
  81530. * @returns the current manager
  81531. */
  81532. addControl(control: Control3D): GUI3DManager;
  81533. /**
  81534. * Removes a control from the root child list
  81535. * @param control defines the control to remove
  81536. * @returns the current container
  81537. */
  81538. removeControl(control: Control3D): GUI3DManager;
  81539. /**
  81540. * Releases all associated resources
  81541. */
  81542. dispose(): void;
  81543. }
  81544. }
  81545. declare module BABYLON.GUI {
  81546. /**
  81547. * Class used to transport BABYLON.Vector3 information for pointer events
  81548. */
  81549. export class Vector3WithInfo extends BABYLON.Vector3 {
  81550. /** defines the current mouse button index */
  81551. buttonIndex: number;
  81552. /**
  81553. * Creates a new Vector3WithInfo
  81554. * @param source defines the vector3 data to transport
  81555. * @param buttonIndex defines the current mouse button index
  81556. */
  81557. constructor(source: BABYLON.Vector3,
  81558. /** defines the current mouse button index */
  81559. buttonIndex?: number);
  81560. }
  81561. }
  81562. declare module BABYLON.GUI {
  81563. /**
  81564. * Class used as base class for controls
  81565. */
  81566. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  81567. /** Defines the control name */
  81568. name?: string | undefined;
  81569. /** @hidden */
  81570. _host: GUI3DManager;
  81571. private _node;
  81572. private _downCount;
  81573. private _enterCount;
  81574. private _downPointerIds;
  81575. private _isVisible;
  81576. /** Gets or sets the control position in world space */
  81577. get position(): BABYLON.Vector3;
  81578. set position(value: BABYLON.Vector3);
  81579. /** Gets or sets the control scaling in world space */
  81580. get scaling(): BABYLON.Vector3;
  81581. set scaling(value: BABYLON.Vector3);
  81582. /** Callback used to start pointer enter animation */
  81583. pointerEnterAnimation: () => void;
  81584. /** Callback used to start pointer out animation */
  81585. pointerOutAnimation: () => void;
  81586. /** Callback used to start pointer down animation */
  81587. pointerDownAnimation: () => void;
  81588. /** Callback used to start pointer up animation */
  81589. pointerUpAnimation: () => void;
  81590. /**
  81591. * An event triggered when the pointer move over the control
  81592. */
  81593. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  81594. /**
  81595. * An event triggered when the pointer move out of the control
  81596. */
  81597. onPointerOutObservable: BABYLON.Observable<Control3D>;
  81598. /**
  81599. * An event triggered when the pointer taps the control
  81600. */
  81601. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  81602. /**
  81603. * An event triggered when pointer is up
  81604. */
  81605. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  81606. /**
  81607. * An event triggered when a control is clicked on (with a mouse)
  81608. */
  81609. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  81610. /**
  81611. * An event triggered when pointer enters the control
  81612. */
  81613. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  81614. /**
  81615. * Gets or sets the parent container
  81616. */
  81617. parent: BABYLON.Nullable<Container3D>;
  81618. private _behaviors;
  81619. /**
  81620. * Gets the list of attached behaviors
  81621. * @see https://doc.babylonjs.com/features/behaviour
  81622. */
  81623. get behaviors(): BABYLON.Behavior<Control3D>[];
  81624. /**
  81625. * Attach a behavior to the control
  81626. * @see https://doc.babylonjs.com/features/behaviour
  81627. * @param behavior defines the behavior to attach
  81628. * @returns the current control
  81629. */
  81630. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  81631. /**
  81632. * Remove an attached behavior
  81633. * @see https://doc.babylonjs.com/features/behaviour
  81634. * @param behavior defines the behavior to attach
  81635. * @returns the current control
  81636. */
  81637. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  81638. /**
  81639. * Gets an attached behavior by name
  81640. * @param name defines the name of the behavior to look for
  81641. * @see https://doc.babylonjs.com/features/behaviour
  81642. * @returns null if behavior was not found else the requested behavior
  81643. */
  81644. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  81645. /** Gets or sets a boolean indicating if the control is visible */
  81646. get isVisible(): boolean;
  81647. set isVisible(value: boolean);
  81648. /**
  81649. * Creates a new control
  81650. * @param name defines the control name
  81651. */
  81652. constructor(
  81653. /** Defines the control name */
  81654. name?: string | undefined);
  81655. /**
  81656. * Gets a string representing the class name
  81657. */
  81658. get typeName(): string;
  81659. /**
  81660. * Get the current class name of the control.
  81661. * @returns current class name
  81662. */
  81663. getClassName(): string;
  81664. protected _getTypeName(): string;
  81665. /**
  81666. * Gets the transform node used by this control
  81667. */
  81668. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  81669. /**
  81670. * Gets the mesh used to render this control
  81671. */
  81672. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  81673. /**
  81674. * Link the control as child of the given node
  81675. * @param node defines the node to link to. Use null to unlink the control
  81676. * @returns the current control
  81677. */
  81678. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  81679. /** @hidden **/
  81680. _prepareNode(scene: BABYLON.Scene): void;
  81681. /**
  81682. * Node creation.
  81683. * Can be overriden by children
  81684. * @param scene defines the scene where the node must be attached
  81685. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  81686. */
  81687. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  81688. /**
  81689. * Affect a material to the given mesh
  81690. * @param mesh defines the mesh which will represent the control
  81691. */
  81692. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81693. /** @hidden */
  81694. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  81695. /** @hidden */
  81696. _onPointerEnter(target: Control3D): boolean;
  81697. /** @hidden */
  81698. _onPointerOut(target: Control3D): void;
  81699. /** @hidden */
  81700. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  81701. /** @hidden */
  81702. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  81703. /** @hidden */
  81704. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  81705. /** @hidden */
  81706. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  81707. /** @hidden */
  81708. _disposeNode(): void;
  81709. /**
  81710. * Releases all associated resources
  81711. */
  81712. dispose(): void;
  81713. }
  81714. }
  81715. declare module BABYLON.GUI {
  81716. /**
  81717. * Class used as a root to all buttons
  81718. */
  81719. export class AbstractButton3D extends Control3D {
  81720. /**
  81721. * Creates a new button
  81722. * @param name defines the control name
  81723. */
  81724. constructor(name?: string);
  81725. protected _getTypeName(): string;
  81726. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81727. }
  81728. }
  81729. declare module BABYLON.GUI {
  81730. /**
  81731. * Class used to create a button in 3D
  81732. */
  81733. export class Button3D extends AbstractButton3D {
  81734. /** @hidden */
  81735. protected _currentMaterial: BABYLON.Material;
  81736. private _facadeTexture;
  81737. private _content;
  81738. private _contentResolution;
  81739. private _contentScaleRatio;
  81740. /**
  81741. * Gets or sets the texture resolution used to render content (512 by default)
  81742. */
  81743. get contentResolution(): BABYLON.int;
  81744. set contentResolution(value: BABYLON.int);
  81745. /**
  81746. * Gets or sets the texture scale ratio used to render content (2 by default)
  81747. */
  81748. get contentScaleRatio(): number;
  81749. set contentScaleRatio(value: number);
  81750. protected _disposeFacadeTexture(): void;
  81751. protected _resetContent(): void;
  81752. /**
  81753. * Creates a new button
  81754. * @param name defines the control name
  81755. */
  81756. constructor(name?: string);
  81757. /**
  81758. * Gets or sets the GUI 2D content used to display the button's facade
  81759. */
  81760. get content(): Control;
  81761. set content(value: Control);
  81762. /**
  81763. * Apply the facade texture (created from the content property).
  81764. * This function can be overloaded by child classes
  81765. * @param facadeTexture defines the AdvancedDynamicTexture to use
  81766. */
  81767. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  81768. protected _getTypeName(): string;
  81769. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81770. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81771. /**
  81772. * Releases all associated resources
  81773. */
  81774. dispose(): void;
  81775. }
  81776. }
  81777. declare module BABYLON.GUI {
  81778. /**
  81779. * Abstract class used to create a container panel deployed on the surface of a volume
  81780. */
  81781. export abstract class VolumeBasedPanel extends Container3D {
  81782. private _columns;
  81783. private _rows;
  81784. private _rowThenColum;
  81785. private _orientation;
  81786. protected _cellWidth: number;
  81787. protected _cellHeight: number;
  81788. /**
  81789. * Gets or sets the distance between elements
  81790. */
  81791. margin: number;
  81792. /**
  81793. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  81794. * | Value | Type | Description |
  81795. * | ----- | ----------------------------------- | ----------- |
  81796. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  81797. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  81798. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  81799. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  81800. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  81801. */
  81802. get orientation(): number;
  81803. set orientation(value: number);
  81804. /**
  81805. * Gets or sets the number of columns requested (10 by default).
  81806. * The panel will automatically compute the number of rows based on number of child controls.
  81807. */
  81808. get columns(): BABYLON.int;
  81809. set columns(value: BABYLON.int);
  81810. /**
  81811. * Gets or sets a the number of rows requested.
  81812. * The panel will automatically compute the number of columns based on number of child controls.
  81813. */
  81814. get rows(): BABYLON.int;
  81815. set rows(value: BABYLON.int);
  81816. /**
  81817. * Creates new VolumeBasedPanel
  81818. */
  81819. constructor();
  81820. protected _arrangeChildren(): void;
  81821. /** Child classes must implement this function to provide correct control positioning */
  81822. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81823. /** Child classes can implement this function to provide additional processing */
  81824. protected _finalProcessing(): void;
  81825. }
  81826. }
  81827. declare module BABYLON.GUI {
  81828. /**
  81829. * Class used to create a container panel deployed on the surface of a cylinder
  81830. */
  81831. export class CylinderPanel extends VolumeBasedPanel {
  81832. private _radius;
  81833. /**
  81834. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  81835. */
  81836. get radius(): BABYLON.float;
  81837. set radius(value: BABYLON.float);
  81838. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81839. private _cylindricalMapping;
  81840. }
  81841. }
  81842. declare module BABYLON.GUI {
  81843. /** @hidden */
  81844. export var fluentVertexShader: {
  81845. name: string;
  81846. shader: string;
  81847. };
  81848. }
  81849. declare module BABYLON.GUI {
  81850. /** @hidden */
  81851. export var fluentPixelShader: {
  81852. name: string;
  81853. shader: string;
  81854. };
  81855. }
  81856. declare module BABYLON.GUI {
  81857. /** @hidden */
  81858. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  81859. INNERGLOW: boolean;
  81860. BORDER: boolean;
  81861. HOVERLIGHT: boolean;
  81862. TEXTURE: boolean;
  81863. constructor();
  81864. }
  81865. /**
  81866. * Class used to render controls with fluent desgin
  81867. */
  81868. export class FluentMaterial extends BABYLON.PushMaterial {
  81869. /**
  81870. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  81871. */
  81872. innerGlowColorIntensity: number;
  81873. /**
  81874. * Gets or sets the inner glow color (white by default)
  81875. */
  81876. innerGlowColor: BABYLON.Color3;
  81877. /**
  81878. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  81879. */
  81880. albedoColor: BABYLON.Color3;
  81881. /**
  81882. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  81883. */
  81884. renderBorders: boolean;
  81885. /**
  81886. * Gets or sets border width (default is 0.5)
  81887. */
  81888. borderWidth: number;
  81889. /**
  81890. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  81891. */
  81892. edgeSmoothingValue: number;
  81893. /**
  81894. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  81895. */
  81896. borderMinValue: number;
  81897. /**
  81898. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  81899. */
  81900. renderHoverLight: boolean;
  81901. /**
  81902. * Gets or sets the radius used to render the hover light (default is 1.0)
  81903. */
  81904. hoverRadius: number;
  81905. /**
  81906. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  81907. */
  81908. hoverColor: BABYLON.Color4;
  81909. /**
  81910. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  81911. */
  81912. hoverPosition: BABYLON.Vector3;
  81913. private _albedoTexture;
  81914. /** Gets or sets the texture to use for albedo color */
  81915. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  81916. /**
  81917. * Creates a new Fluent material
  81918. * @param name defines the name of the material
  81919. * @param scene defines the hosting scene
  81920. */
  81921. constructor(name: string, scene: BABYLON.Scene);
  81922. needAlphaBlending(): boolean;
  81923. needAlphaTesting(): boolean;
  81924. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81925. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81926. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81927. getActiveTextures(): BABYLON.BaseTexture[];
  81928. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81929. dispose(forceDisposeEffect?: boolean): void;
  81930. clone(name: string): FluentMaterial;
  81931. serialize(): any;
  81932. getClassName(): string;
  81933. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  81934. }
  81935. }
  81936. declare module BABYLON.GUI {
  81937. /**
  81938. * Class used to create a holographic button in 3D
  81939. */
  81940. export class HolographicButton extends Button3D {
  81941. private _backPlate;
  81942. private _textPlate;
  81943. private _frontPlate;
  81944. private _text;
  81945. private _imageUrl;
  81946. private _shareMaterials;
  81947. private _frontMaterial;
  81948. private _backMaterial;
  81949. private _plateMaterial;
  81950. private _pickedPointObserver;
  81951. private _tooltipFade;
  81952. private _tooltipTextBlock;
  81953. private _tooltipTexture;
  81954. private _tooltipMesh;
  81955. private _tooltipHoverObserver;
  81956. private _tooltipOutObserver;
  81957. private _disposeTooltip;
  81958. /**
  81959. * Rendering ground id of all the mesh in the button
  81960. */
  81961. set renderingGroupId(id: number);
  81962. get renderingGroupId(): number;
  81963. /**
  81964. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  81965. */
  81966. set tooltipText(text: BABYLON.Nullable<string>);
  81967. get tooltipText(): BABYLON.Nullable<string>;
  81968. /**
  81969. * Gets or sets text for the button
  81970. */
  81971. get text(): string;
  81972. set text(value: string);
  81973. /**
  81974. * Gets or sets the image url for the button
  81975. */
  81976. get imageUrl(): string;
  81977. set imageUrl(value: string);
  81978. /**
  81979. * Gets the back material used by this button
  81980. */
  81981. get backMaterial(): FluentMaterial;
  81982. /**
  81983. * Gets the front material used by this button
  81984. */
  81985. get frontMaterial(): FluentMaterial;
  81986. /**
  81987. * Gets the plate material used by this button
  81988. */
  81989. get plateMaterial(): BABYLON.StandardMaterial;
  81990. /**
  81991. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  81992. */
  81993. get shareMaterials(): boolean;
  81994. /**
  81995. * Creates a new button
  81996. * @param name defines the control name
  81997. */
  81998. constructor(name?: string, shareMaterials?: boolean);
  81999. protected _getTypeName(): string;
  82000. private _rebuildContent;
  82001. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  82002. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  82003. private _createBackMaterial;
  82004. private _createFrontMaterial;
  82005. private _createPlateMaterial;
  82006. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  82007. /**
  82008. * Releases all associated resources
  82009. */
  82010. dispose(): void;
  82011. }
  82012. }
  82013. declare module BABYLON.GUI {
  82014. /**
  82015. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  82016. */
  82017. export class MeshButton3D extends Button3D {
  82018. /** @hidden */
  82019. protected _currentMesh: BABYLON.Mesh;
  82020. /**
  82021. * Creates a new 3D button based on a mesh
  82022. * @param mesh mesh to become a 3D button
  82023. * @param name defines the control name
  82024. */
  82025. constructor(mesh: BABYLON.Mesh, name?: string);
  82026. protected _getTypeName(): string;
  82027. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  82028. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  82029. }
  82030. }
  82031. declare module BABYLON.GUI {
  82032. /**
  82033. * Class used to create a container panel deployed on the surface of a plane
  82034. */
  82035. export class PlanePanel extends VolumeBasedPanel {
  82036. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  82037. }
  82038. }
  82039. declare module BABYLON.GUI {
  82040. /**
  82041. * Class used to create a container panel where items get randomized planar mapping
  82042. */
  82043. export class ScatterPanel extends VolumeBasedPanel {
  82044. private _iteration;
  82045. /**
  82046. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  82047. */
  82048. get iteration(): BABYLON.float;
  82049. set iteration(value: BABYLON.float);
  82050. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  82051. private _scatterMapping;
  82052. protected _finalProcessing(): void;
  82053. }
  82054. }
  82055. declare module BABYLON.GUI {
  82056. /**
  82057. * Class used to create a container panel deployed on the surface of a sphere
  82058. */
  82059. export class SpherePanel extends VolumeBasedPanel {
  82060. private _radius;
  82061. /**
  82062. * Gets or sets the radius of the sphere where to project controls (5 by default)
  82063. */
  82064. get radius(): BABYLON.float;
  82065. set radius(value: BABYLON.float);
  82066. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  82067. private _sphericalMapping;
  82068. }
  82069. }
  82070. declare module BABYLON.GUI {
  82071. /**
  82072. * Class used to create a stack panel in 3D on XY plane
  82073. */
  82074. export class StackPanel3D extends Container3D {
  82075. private _isVertical;
  82076. /**
  82077. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  82078. */
  82079. get isVertical(): boolean;
  82080. set isVertical(value: boolean);
  82081. /**
  82082. * Gets or sets the distance between elements
  82083. */
  82084. margin: number;
  82085. /**
  82086. * Creates new StackPanel
  82087. * @param isVertical
  82088. */
  82089. constructor(isVertical?: boolean);
  82090. protected _arrangeChildren(): void;
  82091. }
  82092. }
  82093. declare module BABYLON {
  82094. /**
  82095. * Configuration for glTF validation
  82096. */
  82097. export interface IGLTFValidationConfiguration {
  82098. /**
  82099. * The url of the glTF validator.
  82100. */
  82101. url: string;
  82102. }
  82103. /**
  82104. * glTF validation
  82105. */
  82106. export class GLTFValidation {
  82107. /**
  82108. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  82109. */
  82110. static Configuration: IGLTFValidationConfiguration;
  82111. private static _LoadScriptPromise;
  82112. /**
  82113. * Validate a glTF asset using the glTF-Validator.
  82114. * @param data The JSON of a glTF or the array buffer of a binary glTF
  82115. * @param rootUrl The root url for the glTF
  82116. * @param fileName The file name for the glTF
  82117. * @param getExternalResource The callback to get external resources for the glTF validator
  82118. * @returns A promise that resolves with the glTF validation results once complete
  82119. */
  82120. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  82121. }
  82122. }
  82123. declare module BABYLON {
  82124. /**
  82125. * Mode that determines the coordinate system to use.
  82126. */
  82127. export enum GLTFLoaderCoordinateSystemMode {
  82128. /**
  82129. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  82130. */
  82131. AUTO = 0,
  82132. /**
  82133. * Sets the useRightHandedSystem flag on the scene.
  82134. */
  82135. FORCE_RIGHT_HANDED = 1
  82136. }
  82137. /**
  82138. * Mode that determines what animations will start.
  82139. */
  82140. export enum GLTFLoaderAnimationStartMode {
  82141. /**
  82142. * No animation will start.
  82143. */
  82144. NONE = 0,
  82145. /**
  82146. * The first animation will start.
  82147. */
  82148. FIRST = 1,
  82149. /**
  82150. * All animations will start.
  82151. */
  82152. ALL = 2
  82153. }
  82154. /**
  82155. * Interface that contains the data for the glTF asset.
  82156. */
  82157. export interface IGLTFLoaderData {
  82158. /**
  82159. * The object that represents the glTF JSON.
  82160. */
  82161. json: Object;
  82162. /**
  82163. * The BIN chunk of a binary glTF.
  82164. */
  82165. bin: Nullable<IDataBuffer>;
  82166. }
  82167. /**
  82168. * Interface for extending the loader.
  82169. */
  82170. export interface IGLTFLoaderExtension {
  82171. /**
  82172. * The name of this extension.
  82173. */
  82174. readonly name: string;
  82175. /**
  82176. * Defines whether this extension is enabled.
  82177. */
  82178. enabled: boolean;
  82179. /**
  82180. * Defines the order of this extension.
  82181. * The loader sorts the extensions using these values when loading.
  82182. */
  82183. order?: number;
  82184. }
  82185. /**
  82186. * Loader state.
  82187. */
  82188. export enum GLTFLoaderState {
  82189. /**
  82190. * The asset is loading.
  82191. */
  82192. LOADING = 0,
  82193. /**
  82194. * The asset is ready for rendering.
  82195. */
  82196. READY = 1,
  82197. /**
  82198. * The asset is completely loaded.
  82199. */
  82200. COMPLETE = 2
  82201. }
  82202. /** @hidden */
  82203. export interface IGLTFLoader extends IDisposable {
  82204. readonly state: Nullable<GLTFLoaderState>;
  82205. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<ISceneLoaderAsyncResult>;
  82206. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  82207. }
  82208. /**
  82209. * File loader for loading glTF files into a scene.
  82210. */
  82211. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  82212. /** @hidden */
  82213. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  82214. /** @hidden */
  82215. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  82216. /**
  82217. * Raised when the asset has been parsed
  82218. */
  82219. onParsedObservable: Observable<IGLTFLoaderData>;
  82220. private _onParsedObserver;
  82221. /**
  82222. * Raised when the asset has been parsed
  82223. */
  82224. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  82225. /**
  82226. * 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.
  82227. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  82228. * Defaults to true.
  82229. * @hidden
  82230. */
  82231. static IncrementalLoading: boolean;
  82232. /**
  82233. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  82234. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  82235. * @hidden
  82236. */
  82237. static HomogeneousCoordinates: boolean;
  82238. /**
  82239. * The coordinate system mode. Defaults to AUTO.
  82240. */
  82241. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  82242. /**
  82243. * The animation start mode. Defaults to FIRST.
  82244. */
  82245. animationStartMode: GLTFLoaderAnimationStartMode;
  82246. /**
  82247. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  82248. */
  82249. compileMaterials: boolean;
  82250. /**
  82251. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  82252. */
  82253. useClipPlane: boolean;
  82254. /**
  82255. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  82256. */
  82257. compileShadowGenerators: boolean;
  82258. /**
  82259. * Defines if the Alpha blended materials are only applied as coverage.
  82260. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  82261. * If true, no extra effects are applied to transparent pixels.
  82262. */
  82263. transparencyAsCoverage: boolean;
  82264. /**
  82265. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  82266. * Enabling will disable offline support and glTF validator.
  82267. * Defaults to false.
  82268. */
  82269. useRangeRequests: boolean;
  82270. /**
  82271. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  82272. */
  82273. createInstances: boolean;
  82274. /**
  82275. * Defines if the loader should always compute the bounding boxes of meshes and not use the min/max values from the position accessor. Defaults to false.
  82276. */
  82277. alwaysComputeBoundingBox: boolean;
  82278. /**
  82279. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  82280. */
  82281. loadAllMaterials: boolean;
  82282. /**
  82283. * Function called before loading a url referenced by the asset.
  82284. */
  82285. preprocessUrlAsync: (url: string) => Promise<string>;
  82286. /**
  82287. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  82288. * Note that the observable is raised as soon as the mesh object is created, meaning some data may not have been setup yet for this mesh (vertex data, morph targets, material, ...)
  82289. */
  82290. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  82291. private _onMeshLoadedObserver;
  82292. /**
  82293. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  82294. * Note that the callback is called as soon as the mesh object is created, meaning some data may not have been setup yet for this mesh (vertex data, morph targets, material, ...)
  82295. */
  82296. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  82297. /**
  82298. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  82299. */
  82300. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  82301. private _onTextureLoadedObserver;
  82302. /**
  82303. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  82304. */
  82305. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  82306. /**
  82307. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  82308. */
  82309. readonly onMaterialLoadedObservable: Observable<Material>;
  82310. private _onMaterialLoadedObserver;
  82311. /**
  82312. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  82313. */
  82314. set onMaterialLoaded(callback: (material: Material) => void);
  82315. /**
  82316. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  82317. */
  82318. readonly onCameraLoadedObservable: Observable<Camera>;
  82319. private _onCameraLoadedObserver;
  82320. /**
  82321. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  82322. */
  82323. set onCameraLoaded(callback: (camera: Camera) => void);
  82324. /**
  82325. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  82326. * For assets with LODs, raised when all of the LODs are complete.
  82327. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  82328. */
  82329. readonly onCompleteObservable: Observable<void>;
  82330. private _onCompleteObserver;
  82331. /**
  82332. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  82333. * For assets with LODs, raised when all of the LODs are complete.
  82334. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  82335. */
  82336. set onComplete(callback: () => void);
  82337. /**
  82338. * Observable raised when an error occurs.
  82339. */
  82340. readonly onErrorObservable: Observable<any>;
  82341. private _onErrorObserver;
  82342. /**
  82343. * Callback raised when an error occurs.
  82344. */
  82345. set onError(callback: (reason: any) => void);
  82346. /**
  82347. * Observable raised after the loader is disposed.
  82348. */
  82349. readonly onDisposeObservable: Observable<void>;
  82350. private _onDisposeObserver;
  82351. /**
  82352. * Callback raised after the loader is disposed.
  82353. */
  82354. set onDispose(callback: () => void);
  82355. /**
  82356. * Observable raised after a loader extension is created.
  82357. * Set additional options for a loader extension in this event.
  82358. */
  82359. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  82360. private _onExtensionLoadedObserver;
  82361. /**
  82362. * Callback raised after a loader extension is created.
  82363. */
  82364. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  82365. /**
  82366. * Defines if the loader logging is enabled.
  82367. */
  82368. get loggingEnabled(): boolean;
  82369. set loggingEnabled(value: boolean);
  82370. /**
  82371. * Defines if the loader should capture performance counters.
  82372. */
  82373. get capturePerformanceCounters(): boolean;
  82374. set capturePerformanceCounters(value: boolean);
  82375. /**
  82376. * Defines if the loader should validate the asset.
  82377. */
  82378. validate: boolean;
  82379. /**
  82380. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  82381. */
  82382. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  82383. private _onValidatedObserver;
  82384. /**
  82385. * Callback raised after a loader extension is created.
  82386. */
  82387. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  82388. private _loader;
  82389. private _progressCallback?;
  82390. private _requests;
  82391. private static magicBase64Encoded;
  82392. /**
  82393. * Name of the loader ("gltf")
  82394. */
  82395. name: string;
  82396. /** @hidden */
  82397. extensions: ISceneLoaderPluginExtensions;
  82398. /**
  82399. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  82400. */
  82401. dispose(): void;
  82402. /** @hidden */
  82403. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  82404. /** @hidden */
  82405. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  82406. /** @hidden */
  82407. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  82408. /** @hidden */
  82409. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  82410. /** @hidden */
  82411. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  82412. /** @hidden */
  82413. canDirectLoad(data: string): boolean;
  82414. /** @hidden */
  82415. directLoad(scene: Scene, data: string): Promise<any>;
  82416. /**
  82417. * The callback that allows custom handling of the root url based on the response url.
  82418. * @param rootUrl the original root url
  82419. * @param responseURL the response url if available
  82420. * @returns the new root url
  82421. */
  82422. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  82423. /** @hidden */
  82424. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  82425. /**
  82426. * The loader state or null if the loader is not active.
  82427. */
  82428. get loaderState(): Nullable<GLTFLoaderState>;
  82429. /**
  82430. * Returns a promise that resolves when the asset is completely loaded.
  82431. * @returns a promise that resolves when the asset is completely loaded.
  82432. */
  82433. whenCompleteAsync(): Promise<void>;
  82434. /** @hidden */
  82435. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  82436. /** @hidden */
  82437. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  82438. private _onProgress;
  82439. private _validate;
  82440. private _getLoader;
  82441. private _parseJson;
  82442. private _unpackBinaryAsync;
  82443. private _unpackBinaryV1Async;
  82444. private _unpackBinaryV2Async;
  82445. private static _parseVersion;
  82446. private static _compareVersion;
  82447. private static readonly _logSpaces;
  82448. private _logIndentLevel;
  82449. private _loggingEnabled;
  82450. /** @hidden */
  82451. _log: (message: string) => void;
  82452. /** @hidden */
  82453. _logOpen(message: string): void;
  82454. /** @hidden */
  82455. _logClose(): void;
  82456. private _logEnabled;
  82457. private _logDisabled;
  82458. private _capturePerformanceCounters;
  82459. /** @hidden */
  82460. _startPerformanceCounter: (counterName: string) => void;
  82461. /** @hidden */
  82462. _endPerformanceCounter: (counterName: string) => void;
  82463. private _startPerformanceCounterEnabled;
  82464. private _startPerformanceCounterDisabled;
  82465. private _endPerformanceCounterEnabled;
  82466. private _endPerformanceCounterDisabled;
  82467. }
  82468. }
  82469. declare module BABYLON.GLTF1 {
  82470. /**
  82471. * Enums
  82472. * @hidden
  82473. */
  82474. export enum EComponentType {
  82475. BYTE = 5120,
  82476. UNSIGNED_BYTE = 5121,
  82477. SHORT = 5122,
  82478. UNSIGNED_SHORT = 5123,
  82479. FLOAT = 5126
  82480. }
  82481. /** @hidden */
  82482. export enum EShaderType {
  82483. FRAGMENT = 35632,
  82484. VERTEX = 35633
  82485. }
  82486. /** @hidden */
  82487. export enum EParameterType {
  82488. BYTE = 5120,
  82489. UNSIGNED_BYTE = 5121,
  82490. SHORT = 5122,
  82491. UNSIGNED_SHORT = 5123,
  82492. INT = 5124,
  82493. UNSIGNED_INT = 5125,
  82494. FLOAT = 5126,
  82495. FLOAT_VEC2 = 35664,
  82496. FLOAT_VEC3 = 35665,
  82497. FLOAT_VEC4 = 35666,
  82498. INT_VEC2 = 35667,
  82499. INT_VEC3 = 35668,
  82500. INT_VEC4 = 35669,
  82501. BOOL = 35670,
  82502. BOOL_VEC2 = 35671,
  82503. BOOL_VEC3 = 35672,
  82504. BOOL_VEC4 = 35673,
  82505. FLOAT_MAT2 = 35674,
  82506. FLOAT_MAT3 = 35675,
  82507. FLOAT_MAT4 = 35676,
  82508. SAMPLER_2D = 35678
  82509. }
  82510. /** @hidden */
  82511. export enum ETextureWrapMode {
  82512. CLAMP_TO_EDGE = 33071,
  82513. MIRRORED_REPEAT = 33648,
  82514. REPEAT = 10497
  82515. }
  82516. /** @hidden */
  82517. export enum ETextureFilterType {
  82518. NEAREST = 9728,
  82519. LINEAR = 9728,
  82520. NEAREST_MIPMAP_NEAREST = 9984,
  82521. LINEAR_MIPMAP_NEAREST = 9985,
  82522. NEAREST_MIPMAP_LINEAR = 9986,
  82523. LINEAR_MIPMAP_LINEAR = 9987
  82524. }
  82525. /** @hidden */
  82526. export enum ETextureFormat {
  82527. ALPHA = 6406,
  82528. RGB = 6407,
  82529. RGBA = 6408,
  82530. LUMINANCE = 6409,
  82531. LUMINANCE_ALPHA = 6410
  82532. }
  82533. /** @hidden */
  82534. export enum ECullingType {
  82535. FRONT = 1028,
  82536. BACK = 1029,
  82537. FRONT_AND_BACK = 1032
  82538. }
  82539. /** @hidden */
  82540. export enum EBlendingFunction {
  82541. ZERO = 0,
  82542. ONE = 1,
  82543. SRC_COLOR = 768,
  82544. ONE_MINUS_SRC_COLOR = 769,
  82545. DST_COLOR = 774,
  82546. ONE_MINUS_DST_COLOR = 775,
  82547. SRC_ALPHA = 770,
  82548. ONE_MINUS_SRC_ALPHA = 771,
  82549. DST_ALPHA = 772,
  82550. ONE_MINUS_DST_ALPHA = 773,
  82551. CONSTANT_COLOR = 32769,
  82552. ONE_MINUS_CONSTANT_COLOR = 32770,
  82553. CONSTANT_ALPHA = 32771,
  82554. ONE_MINUS_CONSTANT_ALPHA = 32772,
  82555. SRC_ALPHA_SATURATE = 776
  82556. }
  82557. /** @hidden */
  82558. export interface IGLTFProperty {
  82559. extensions?: {
  82560. [key: string]: any;
  82561. };
  82562. extras?: Object;
  82563. }
  82564. /** @hidden */
  82565. export interface IGLTFChildRootProperty extends IGLTFProperty {
  82566. name?: string;
  82567. }
  82568. /** @hidden */
  82569. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  82570. bufferView: string;
  82571. byteOffset: number;
  82572. byteStride: number;
  82573. count: number;
  82574. type: string;
  82575. componentType: EComponentType;
  82576. max?: number[];
  82577. min?: number[];
  82578. name?: string;
  82579. }
  82580. /** @hidden */
  82581. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  82582. buffer: string;
  82583. byteOffset: number;
  82584. byteLength: number;
  82585. byteStride: number;
  82586. target?: number;
  82587. }
  82588. /** @hidden */
  82589. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  82590. uri: string;
  82591. byteLength?: number;
  82592. type?: string;
  82593. }
  82594. /** @hidden */
  82595. export interface IGLTFShader extends IGLTFChildRootProperty {
  82596. uri: string;
  82597. type: EShaderType;
  82598. }
  82599. /** @hidden */
  82600. export interface IGLTFProgram extends IGLTFChildRootProperty {
  82601. attributes: string[];
  82602. fragmentShader: string;
  82603. vertexShader: string;
  82604. }
  82605. /** @hidden */
  82606. export interface IGLTFTechniqueParameter {
  82607. type: number;
  82608. count?: number;
  82609. semantic?: string;
  82610. node?: string;
  82611. value?: number | boolean | string | Array<any>;
  82612. source?: string;
  82613. babylonValue?: any;
  82614. }
  82615. /** @hidden */
  82616. export interface IGLTFTechniqueCommonProfile {
  82617. lightingModel: string;
  82618. texcoordBindings: Object;
  82619. parameters?: Array<any>;
  82620. }
  82621. /** @hidden */
  82622. export interface IGLTFTechniqueStatesFunctions {
  82623. blendColor?: number[];
  82624. blendEquationSeparate?: number[];
  82625. blendFuncSeparate?: number[];
  82626. colorMask: boolean[];
  82627. cullFace: number[];
  82628. }
  82629. /** @hidden */
  82630. export interface IGLTFTechniqueStates {
  82631. enable: number[];
  82632. functions: IGLTFTechniqueStatesFunctions;
  82633. }
  82634. /** @hidden */
  82635. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  82636. parameters: {
  82637. [key: string]: IGLTFTechniqueParameter;
  82638. };
  82639. program: string;
  82640. attributes: {
  82641. [key: string]: string;
  82642. };
  82643. uniforms: {
  82644. [key: string]: string;
  82645. };
  82646. states: IGLTFTechniqueStates;
  82647. }
  82648. /** @hidden */
  82649. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  82650. technique?: string;
  82651. values: string[];
  82652. }
  82653. /** @hidden */
  82654. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  82655. attributes: {
  82656. [key: string]: string;
  82657. };
  82658. indices: string;
  82659. material: string;
  82660. mode?: number;
  82661. }
  82662. /** @hidden */
  82663. export interface IGLTFMesh extends IGLTFChildRootProperty {
  82664. primitives: IGLTFMeshPrimitive[];
  82665. }
  82666. /** @hidden */
  82667. export interface IGLTFImage extends IGLTFChildRootProperty {
  82668. uri: string;
  82669. }
  82670. /** @hidden */
  82671. export interface IGLTFSampler extends IGLTFChildRootProperty {
  82672. magFilter?: number;
  82673. minFilter?: number;
  82674. wrapS?: number;
  82675. wrapT?: number;
  82676. }
  82677. /** @hidden */
  82678. export interface IGLTFTexture extends IGLTFChildRootProperty {
  82679. sampler: string;
  82680. source: string;
  82681. format?: ETextureFormat;
  82682. internalFormat?: ETextureFormat;
  82683. target?: number;
  82684. type?: number;
  82685. babylonTexture?: Texture;
  82686. }
  82687. /** @hidden */
  82688. export interface IGLTFAmbienLight {
  82689. color?: number[];
  82690. }
  82691. /** @hidden */
  82692. export interface IGLTFDirectionalLight {
  82693. color?: number[];
  82694. }
  82695. /** @hidden */
  82696. export interface IGLTFPointLight {
  82697. color?: number[];
  82698. constantAttenuation?: number;
  82699. linearAttenuation?: number;
  82700. quadraticAttenuation?: number;
  82701. }
  82702. /** @hidden */
  82703. export interface IGLTFSpotLight {
  82704. color?: number[];
  82705. constantAttenuation?: number;
  82706. fallOfAngle?: number;
  82707. fallOffExponent?: number;
  82708. linearAttenuation?: number;
  82709. quadraticAttenuation?: number;
  82710. }
  82711. /** @hidden */
  82712. export interface IGLTFLight extends IGLTFChildRootProperty {
  82713. type: string;
  82714. }
  82715. /** @hidden */
  82716. export interface IGLTFCameraOrthographic {
  82717. xmag: number;
  82718. ymag: number;
  82719. zfar: number;
  82720. znear: number;
  82721. }
  82722. /** @hidden */
  82723. export interface IGLTFCameraPerspective {
  82724. aspectRatio: number;
  82725. yfov: number;
  82726. zfar: number;
  82727. znear: number;
  82728. }
  82729. /** @hidden */
  82730. export interface IGLTFCamera extends IGLTFChildRootProperty {
  82731. type: string;
  82732. }
  82733. /** @hidden */
  82734. export interface IGLTFAnimationChannelTarget {
  82735. id: string;
  82736. path: string;
  82737. }
  82738. /** @hidden */
  82739. export interface IGLTFAnimationChannel {
  82740. sampler: string;
  82741. target: IGLTFAnimationChannelTarget;
  82742. }
  82743. /** @hidden */
  82744. export interface IGLTFAnimationSampler {
  82745. input: string;
  82746. output: string;
  82747. interpolation?: string;
  82748. }
  82749. /** @hidden */
  82750. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  82751. channels?: IGLTFAnimationChannel[];
  82752. parameters?: {
  82753. [key: string]: string;
  82754. };
  82755. samplers?: {
  82756. [key: string]: IGLTFAnimationSampler;
  82757. };
  82758. }
  82759. /** @hidden */
  82760. export interface IGLTFNodeInstanceSkin {
  82761. skeletons: string[];
  82762. skin: string;
  82763. meshes: string[];
  82764. }
  82765. /** @hidden */
  82766. export interface IGLTFSkins extends IGLTFChildRootProperty {
  82767. bindShapeMatrix: number[];
  82768. inverseBindMatrices: string;
  82769. jointNames: string[];
  82770. babylonSkeleton?: Skeleton;
  82771. }
  82772. /** @hidden */
  82773. export interface IGLTFNode extends IGLTFChildRootProperty {
  82774. camera?: string;
  82775. children: string[];
  82776. skin?: string;
  82777. jointName?: string;
  82778. light?: string;
  82779. matrix: number[];
  82780. mesh?: string;
  82781. meshes?: string[];
  82782. rotation?: number[];
  82783. scale?: number[];
  82784. translation?: number[];
  82785. babylonNode?: Node;
  82786. }
  82787. /** @hidden */
  82788. export interface IGLTFScene extends IGLTFChildRootProperty {
  82789. nodes: string[];
  82790. }
  82791. /** @hidden */
  82792. export interface IGLTFRuntime {
  82793. extensions: {
  82794. [key: string]: any;
  82795. };
  82796. accessors: {
  82797. [key: string]: IGLTFAccessor;
  82798. };
  82799. buffers: {
  82800. [key: string]: IGLTFBuffer;
  82801. };
  82802. bufferViews: {
  82803. [key: string]: IGLTFBufferView;
  82804. };
  82805. meshes: {
  82806. [key: string]: IGLTFMesh;
  82807. };
  82808. lights: {
  82809. [key: string]: IGLTFLight;
  82810. };
  82811. cameras: {
  82812. [key: string]: IGLTFCamera;
  82813. };
  82814. nodes: {
  82815. [key: string]: IGLTFNode;
  82816. };
  82817. images: {
  82818. [key: string]: IGLTFImage;
  82819. };
  82820. textures: {
  82821. [key: string]: IGLTFTexture;
  82822. };
  82823. shaders: {
  82824. [key: string]: IGLTFShader;
  82825. };
  82826. programs: {
  82827. [key: string]: IGLTFProgram;
  82828. };
  82829. samplers: {
  82830. [key: string]: IGLTFSampler;
  82831. };
  82832. techniques: {
  82833. [key: string]: IGLTFTechnique;
  82834. };
  82835. materials: {
  82836. [key: string]: IGLTFMaterial;
  82837. };
  82838. animations: {
  82839. [key: string]: IGLTFAnimation;
  82840. };
  82841. skins: {
  82842. [key: string]: IGLTFSkins;
  82843. };
  82844. currentScene?: Object;
  82845. scenes: {
  82846. [key: string]: IGLTFScene;
  82847. };
  82848. extensionsUsed: string[];
  82849. extensionsRequired?: string[];
  82850. buffersCount: number;
  82851. shaderscount: number;
  82852. scene: Scene;
  82853. rootUrl: string;
  82854. loadedBufferCount: number;
  82855. loadedBufferViews: {
  82856. [name: string]: ArrayBufferView;
  82857. };
  82858. loadedShaderCount: number;
  82859. importOnlyMeshes: boolean;
  82860. importMeshesNames?: string[];
  82861. dummyNodes: Node[];
  82862. forAssetContainer: boolean;
  82863. }
  82864. /** @hidden */
  82865. export interface INodeToRoot {
  82866. bone: Bone;
  82867. node: IGLTFNode;
  82868. id: string;
  82869. }
  82870. /** @hidden */
  82871. export interface IJointNode {
  82872. node: IGLTFNode;
  82873. id: string;
  82874. }
  82875. }
  82876. declare module BABYLON.GLTF1 {
  82877. /**
  82878. * Utils functions for GLTF
  82879. * @hidden
  82880. */
  82881. export class GLTFUtils {
  82882. /**
  82883. * Sets the given "parameter" matrix
  82884. * @param scene: the Scene object
  82885. * @param source: the source node where to pick the matrix
  82886. * @param parameter: the GLTF technique parameter
  82887. * @param uniformName: the name of the shader's uniform
  82888. * @param shaderMaterial: the shader material
  82889. */
  82890. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  82891. /**
  82892. * Sets the given "parameter" matrix
  82893. * @param shaderMaterial: the shader material
  82894. * @param uniform: the name of the shader's uniform
  82895. * @param value: the value of the uniform
  82896. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  82897. */
  82898. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  82899. /**
  82900. * Returns the wrap mode of the texture
  82901. * @param mode: the mode value
  82902. */
  82903. static GetWrapMode(mode: number): number;
  82904. /**
  82905. * Returns the byte stride giving an accessor
  82906. * @param accessor: the GLTF accessor objet
  82907. */
  82908. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  82909. /**
  82910. * Returns the texture filter mode giving a mode value
  82911. * @param mode: the filter mode value
  82912. */
  82913. static GetTextureFilterMode(mode: number): ETextureFilterType;
  82914. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  82915. /**
  82916. * Returns a buffer from its accessor
  82917. * @param gltfRuntime: the GLTF runtime
  82918. * @param accessor: the GLTF accessor
  82919. */
  82920. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  82921. /**
  82922. * Decodes a buffer view into a string
  82923. * @param view: the buffer view
  82924. */
  82925. static DecodeBufferToText(view: ArrayBufferView): string;
  82926. /**
  82927. * Returns the default material of gltf. Related to
  82928. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  82929. * @param scene: the Babylon.js scene
  82930. */
  82931. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  82932. private static _DefaultMaterial;
  82933. }
  82934. }
  82935. declare module BABYLON.GLTF1 {
  82936. /**
  82937. * Implementation of the base glTF spec
  82938. * @hidden
  82939. */
  82940. export class GLTFLoaderBase {
  82941. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  82942. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  82943. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  82944. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  82945. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  82946. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  82947. }
  82948. /**
  82949. * glTF V1 Loader
  82950. * @hidden
  82951. */
  82952. export class GLTFLoader implements IGLTFLoader {
  82953. static Extensions: {
  82954. [name: string]: GLTFLoaderExtension;
  82955. };
  82956. static RegisterExtension(extension: GLTFLoaderExtension): void;
  82957. state: Nullable<GLTFLoaderState>;
  82958. dispose(): void;
  82959. private _importMeshAsync;
  82960. /**
  82961. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  82962. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  82963. * @param scene the scene the meshes should be added to
  82964. * @param forAssetContainer defines if the entities must be stored in the scene
  82965. * @param data gltf data containing information of the meshes in a loaded file
  82966. * @param rootUrl root url to load from
  82967. * @param onProgress event that fires when loading progress has occured
  82968. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  82969. */
  82970. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<ISceneLoaderAsyncResult>;
  82971. private _loadAsync;
  82972. /**
  82973. * Imports all objects from a loaded gltf file and adds them to the scene
  82974. * @param scene the scene the objects should be added to
  82975. * @param data gltf data containing information of the meshes in a loaded file
  82976. * @param rootUrl root url to load from
  82977. * @param onProgress event that fires when loading progress has occured
  82978. * @returns a promise which completes when objects have been loaded to the scene
  82979. */
  82980. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  82981. private _loadShadersAsync;
  82982. private _loadBuffersAsync;
  82983. private _createNodes;
  82984. }
  82985. /** @hidden */
  82986. export abstract class GLTFLoaderExtension {
  82987. private _name;
  82988. constructor(name: string);
  82989. get name(): string;
  82990. /**
  82991. * Defines an override for loading the runtime
  82992. * Return true to stop further extensions from loading the runtime
  82993. */
  82994. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  82995. /**
  82996. * Defines an onverride for creating gltf runtime
  82997. * Return true to stop further extensions from creating the runtime
  82998. */
  82999. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  83000. /**
  83001. * Defines an override for loading buffers
  83002. * Return true to stop further extensions from loading this buffer
  83003. */
  83004. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  83005. /**
  83006. * Defines an override for loading texture buffers
  83007. * Return true to stop further extensions from loading this texture data
  83008. */
  83009. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  83010. /**
  83011. * Defines an override for creating textures
  83012. * Return true to stop further extensions from loading this texture
  83013. */
  83014. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  83015. /**
  83016. * Defines an override for loading shader strings
  83017. * Return true to stop further extensions from loading this shader data
  83018. */
  83019. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  83020. /**
  83021. * Defines an override for loading materials
  83022. * Return true to stop further extensions from loading this material
  83023. */
  83024. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  83025. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  83026. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  83027. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  83028. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  83029. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  83030. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  83031. private static LoadTextureBufferAsync;
  83032. private static CreateTextureAsync;
  83033. private static ApplyExtensions;
  83034. }
  83035. }
  83036. declare module BABYLON.GLTF1 {
  83037. /** @hidden */
  83038. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  83039. private _bin;
  83040. constructor();
  83041. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  83042. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  83043. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  83044. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  83045. }
  83046. }
  83047. declare module BABYLON.GLTF1 {
  83048. /** @hidden */
  83049. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  83050. constructor();
  83051. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  83052. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  83053. private _loadTexture;
  83054. }
  83055. }
  83056. declare module BABYLON.GLTF2.Loader {
  83057. /**
  83058. * Loader interface with an index field.
  83059. */
  83060. export interface IArrayItem {
  83061. /**
  83062. * The index of this item in the array.
  83063. */
  83064. index: number;
  83065. }
  83066. /**
  83067. * Loader interface with additional members.
  83068. */
  83069. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  83070. /** @hidden */
  83071. _data?: Promise<ArrayBufferView>;
  83072. /** @hidden */
  83073. _babylonVertexBuffer?: Promise<VertexBuffer>;
  83074. }
  83075. /**
  83076. * Loader interface with additional members.
  83077. */
  83078. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  83079. }
  83080. /** @hidden */
  83081. export interface _IAnimationSamplerData {
  83082. input: Float32Array;
  83083. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  83084. output: Float32Array;
  83085. }
  83086. /**
  83087. * Loader interface with additional members.
  83088. */
  83089. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  83090. /** @hidden */
  83091. _data?: Promise<_IAnimationSamplerData>;
  83092. }
  83093. /**
  83094. * Loader interface with additional members.
  83095. */
  83096. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  83097. channels: IAnimationChannel[];
  83098. samplers: IAnimationSampler[];
  83099. /** @hidden */
  83100. _babylonAnimationGroup?: AnimationGroup;
  83101. }
  83102. /**
  83103. * Loader interface with additional members.
  83104. */
  83105. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  83106. /** @hidden */
  83107. _data?: Promise<ArrayBufferView>;
  83108. }
  83109. /**
  83110. * Loader interface with additional members.
  83111. */
  83112. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  83113. /** @hidden */
  83114. _data?: Promise<ArrayBufferView>;
  83115. /** @hidden */
  83116. _babylonBuffer?: Promise<Buffer>;
  83117. }
  83118. /**
  83119. * Loader interface with additional members.
  83120. */
  83121. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  83122. }
  83123. /**
  83124. * Loader interface with additional members.
  83125. */
  83126. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  83127. /** @hidden */
  83128. _data?: Promise<ArrayBufferView>;
  83129. }
  83130. /**
  83131. * Loader interface with additional members.
  83132. */
  83133. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  83134. }
  83135. /**
  83136. * Loader interface with additional members.
  83137. */
  83138. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  83139. }
  83140. /**
  83141. * Loader interface with additional members.
  83142. */
  83143. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  83144. baseColorTexture?: ITextureInfo;
  83145. metallicRoughnessTexture?: ITextureInfo;
  83146. }
  83147. /**
  83148. * Loader interface with additional members.
  83149. */
  83150. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  83151. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  83152. normalTexture?: IMaterialNormalTextureInfo;
  83153. occlusionTexture?: IMaterialOcclusionTextureInfo;
  83154. emissiveTexture?: ITextureInfo;
  83155. /** @hidden */
  83156. _data?: {
  83157. [babylonDrawMode: number]: {
  83158. babylonMaterial: Material;
  83159. babylonMeshes: AbstractMesh[];
  83160. promise: Promise<void>;
  83161. };
  83162. };
  83163. }
  83164. /**
  83165. * Loader interface with additional members.
  83166. */
  83167. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  83168. primitives: IMeshPrimitive[];
  83169. }
  83170. /**
  83171. * Loader interface with additional members.
  83172. */
  83173. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  83174. /** @hidden */
  83175. _instanceData?: {
  83176. babylonSourceMesh: Mesh;
  83177. promise: Promise<any>;
  83178. };
  83179. }
  83180. /**
  83181. * Loader interface with additional members.
  83182. */
  83183. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  83184. /**
  83185. * The parent glTF node.
  83186. */
  83187. parent?: INode;
  83188. /** @hidden */
  83189. _babylonTransformNode?: TransformNode;
  83190. /** @hidden */
  83191. _primitiveBabylonMeshes?: AbstractMesh[];
  83192. /** @hidden */
  83193. _babylonBones?: Bone[];
  83194. /** @hidden */
  83195. _numMorphTargets?: number;
  83196. }
  83197. /** @hidden */
  83198. export interface _ISamplerData {
  83199. noMipMaps: boolean;
  83200. samplingMode: number;
  83201. wrapU: number;
  83202. wrapV: number;
  83203. }
  83204. /**
  83205. * Loader interface with additional members.
  83206. */
  83207. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  83208. /** @hidden */
  83209. _data?: _ISamplerData;
  83210. }
  83211. /**
  83212. * Loader interface with additional members.
  83213. */
  83214. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  83215. }
  83216. /**
  83217. * Loader interface with additional members.
  83218. */
  83219. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  83220. /** @hidden */
  83221. _data?: {
  83222. babylonSkeleton: Skeleton;
  83223. promise: Promise<void>;
  83224. };
  83225. }
  83226. /**
  83227. * Loader interface with additional members.
  83228. */
  83229. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  83230. /** @hidden */
  83231. _textureInfo: ITextureInfo;
  83232. }
  83233. /**
  83234. * Loader interface with additional members.
  83235. */
  83236. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  83237. /** false or undefined if the texture holds color data (true if data are roughness, normal, ...) */
  83238. nonColorData?: boolean;
  83239. }
  83240. /**
  83241. * Loader interface with additional members.
  83242. */
  83243. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  83244. accessors?: IAccessor[];
  83245. animations?: IAnimation[];
  83246. buffers?: IBuffer[];
  83247. bufferViews?: IBufferView[];
  83248. cameras?: ICamera[];
  83249. images?: IImage[];
  83250. materials?: IMaterial[];
  83251. meshes?: IMesh[];
  83252. nodes?: INode[];
  83253. samplers?: ISampler[];
  83254. scenes?: IScene[];
  83255. skins?: ISkin[];
  83256. textures?: ITexture[];
  83257. }
  83258. }
  83259. declare module BABYLON.GLTF2 {
  83260. /**
  83261. * Interface for a glTF loader extension.
  83262. */
  83263. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  83264. /**
  83265. * Called after the loader state changes to LOADING.
  83266. */
  83267. onLoading?(): void;
  83268. /**
  83269. * Called after the loader state changes to READY.
  83270. */
  83271. onReady?(): void;
  83272. /**
  83273. * Define this method to modify the default behavior when loading scenes.
  83274. * @param context The context when loading the asset
  83275. * @param scene The glTF scene property
  83276. * @returns A promise that resolves when the load is complete or null if not handled
  83277. */
  83278. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  83279. /**
  83280. * Define this method to modify the default behavior when loading nodes.
  83281. * @param context The context when loading the asset
  83282. * @param node The glTF node property
  83283. * @param assign A function called synchronously after parsing the glTF properties
  83284. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  83285. */
  83286. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83287. /**
  83288. * Define this method to modify the default behavior when loading cameras.
  83289. * @param context The context when loading the asset
  83290. * @param camera The glTF camera property
  83291. * @param assign A function called synchronously after parsing the glTF properties
  83292. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  83293. */
  83294. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  83295. /**
  83296. * @hidden
  83297. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  83298. * @param context The context when loading the asset
  83299. * @param primitive The glTF mesh primitive property
  83300. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  83301. */
  83302. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  83303. /**
  83304. * @hidden
  83305. * Define this method to modify the default behavior when loading data for mesh primitives.
  83306. * @param context The context when loading the asset
  83307. * @param name The mesh name when loading the asset
  83308. * @param node The glTF node when loading the asset
  83309. * @param mesh The glTF mesh when loading the asset
  83310. * @param primitive The glTF mesh primitive property
  83311. * @param assign A function called synchronously after parsing the glTF properties
  83312. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  83313. */
  83314. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  83315. /**
  83316. * @hidden
  83317. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  83318. * @param context The context when loading the asset
  83319. * @param material The glTF material property
  83320. * @param assign A function called synchronously after parsing the glTF properties
  83321. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  83322. */
  83323. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  83324. /**
  83325. * Define this method to modify the default behavior when creating materials.
  83326. * @param context The context when loading the asset
  83327. * @param material The glTF material property
  83328. * @param babylonDrawMode The draw mode for the Babylon material
  83329. * @returns The Babylon material or null if not handled
  83330. */
  83331. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  83332. /**
  83333. * Define this method to modify the default behavior when loading material properties.
  83334. * @param context The context when loading the asset
  83335. * @param material The glTF material property
  83336. * @param babylonMaterial The Babylon material
  83337. * @returns A promise that resolves when the load is complete or null if not handled
  83338. */
  83339. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83340. /**
  83341. * Define this method to modify the default behavior when loading texture infos.
  83342. * @param context The context when loading the asset
  83343. * @param textureInfo The glTF texture info property
  83344. * @param assign A function called synchronously after parsing the glTF properties
  83345. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  83346. */
  83347. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83348. /**
  83349. * @hidden
  83350. * Define this method to modify the default behavior when loading textures.
  83351. * @param context The context when loading the asset
  83352. * @param texture The glTF texture property
  83353. * @param assign A function called synchronously after parsing the glTF properties
  83354. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  83355. */
  83356. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83357. /**
  83358. * Define this method to modify the default behavior when loading animations.
  83359. * @param context The context when loading the asset
  83360. * @param animation The glTF animation property
  83361. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  83362. */
  83363. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  83364. /**
  83365. * @hidden
  83366. * Define this method to modify the default behavior when loading skins.
  83367. * @param context The context when loading the asset
  83368. * @param node The glTF node property
  83369. * @param skin The glTF skin property
  83370. * @returns A promise that resolves when the load is complete or null if not handled
  83371. */
  83372. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  83373. /**
  83374. * @hidden
  83375. * Define this method to modify the default behavior when loading uris.
  83376. * @param context The context when loading the asset
  83377. * @param property The glTF property associated with the uri
  83378. * @param uri The uri to load
  83379. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  83380. */
  83381. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  83382. /**
  83383. * Define this method to modify the default behavior when loading buffer views.
  83384. * @param context The context when loading the asset
  83385. * @param bufferView The glTF buffer view property
  83386. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  83387. */
  83388. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  83389. /**
  83390. * Define this method to modify the default behavior when loading buffers.
  83391. * @param context The context when loading the asset
  83392. * @param buffer The glTF buffer property
  83393. * @param byteOffset The byte offset to load
  83394. * @param byteLength The byte length to load
  83395. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  83396. */
  83397. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  83398. }
  83399. }
  83400. declare module BABYLON.GLTF2 {
  83401. /**
  83402. * Helper class for working with arrays when loading the glTF asset
  83403. */
  83404. export class ArrayItem {
  83405. /**
  83406. * Gets an item from the given array.
  83407. * @param context The context when loading the asset
  83408. * @param array The array to get the item from
  83409. * @param index The index to the array
  83410. * @returns The array item
  83411. */
  83412. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  83413. /**
  83414. * Assign an `index` field to each item of the given array.
  83415. * @param array The array of items
  83416. */
  83417. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  83418. }
  83419. /**
  83420. * The glTF 2.0 loader
  83421. */
  83422. export class GLTFLoader implements IGLTFLoader {
  83423. /** @hidden */
  83424. _completePromises: Promise<any>[];
  83425. /** @hidden */
  83426. _forAssetContainer: boolean;
  83427. /** Storage */
  83428. _babylonLights: Light[];
  83429. /** @hidden */
  83430. _disableInstancedMesh: number;
  83431. private _disposed;
  83432. private _parent;
  83433. private _state;
  83434. private _extensions;
  83435. private _rootUrl;
  83436. private _fileName;
  83437. private _uniqueRootUrl;
  83438. private _gltf;
  83439. private _bin;
  83440. private _babylonScene;
  83441. private _rootBabylonMesh;
  83442. private _defaultBabylonMaterialData;
  83443. private static _RegisteredExtensions;
  83444. /**
  83445. * The default glTF sampler.
  83446. */
  83447. static readonly DefaultSampler: ISampler;
  83448. /**
  83449. * Registers a loader extension.
  83450. * @param name The name of the loader extension.
  83451. * @param factory The factory function that creates the loader extension.
  83452. */
  83453. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  83454. /**
  83455. * Unregisters a loader extension.
  83456. * @param name The name of the loader extension.
  83457. * @returns A boolean indicating whether the extension has been unregistered
  83458. */
  83459. static UnregisterExtension(name: string): boolean;
  83460. /**
  83461. * The loader state.
  83462. */
  83463. get state(): Nullable<GLTFLoaderState>;
  83464. /**
  83465. * The object that represents the glTF JSON.
  83466. */
  83467. get gltf(): IGLTF;
  83468. /**
  83469. * The BIN chunk of a binary glTF.
  83470. */
  83471. get bin(): Nullable<IDataBuffer>;
  83472. /**
  83473. * The parent file loader.
  83474. */
  83475. get parent(): GLTFFileLoader;
  83476. /**
  83477. * The Babylon scene when loading the asset.
  83478. */
  83479. get babylonScene(): Scene;
  83480. /**
  83481. * The root Babylon mesh when loading the asset.
  83482. */
  83483. get rootBabylonMesh(): Mesh;
  83484. /** @hidden */
  83485. constructor(parent: GLTFFileLoader);
  83486. /** @hidden */
  83487. dispose(): void;
  83488. /** @hidden */
  83489. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  83490. /** @hidden */
  83491. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  83492. private _loadAsync;
  83493. private _loadData;
  83494. private _setupData;
  83495. private _loadExtensions;
  83496. private _checkExtensions;
  83497. private _setState;
  83498. private _createRootNode;
  83499. /**
  83500. * Loads a glTF scene.
  83501. * @param context The context when loading the asset
  83502. * @param scene The glTF scene property
  83503. * @returns A promise that resolves when the load is complete
  83504. */
  83505. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  83506. private _forEachPrimitive;
  83507. private _getGeometries;
  83508. private _getMeshes;
  83509. private _getTransformNodes;
  83510. private _getSkeletons;
  83511. private _getAnimationGroups;
  83512. private _startAnimations;
  83513. /**
  83514. * Loads a glTF node.
  83515. * @param context The context when loading the asset
  83516. * @param node The glTF node property
  83517. * @param assign A function called synchronously after parsing the glTF properties
  83518. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  83519. */
  83520. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  83521. private _loadMeshAsync;
  83522. /**
  83523. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  83524. * @param context The context when loading the asset
  83525. * @param name The mesh name when loading the asset
  83526. * @param node The glTF node when loading the asset
  83527. * @param mesh The glTF mesh when loading the asset
  83528. * @param primitive The glTF mesh primitive property
  83529. * @param assign A function called synchronously after parsing the glTF properties
  83530. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  83531. */
  83532. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  83533. private _loadVertexDataAsync;
  83534. private _createMorphTargets;
  83535. private _loadMorphTargetsAsync;
  83536. private _loadMorphTargetVertexDataAsync;
  83537. private static _LoadTransform;
  83538. private _loadSkinAsync;
  83539. private _loadBones;
  83540. private _loadBone;
  83541. private _loadSkinInverseBindMatricesDataAsync;
  83542. private _updateBoneMatrices;
  83543. private _getNodeMatrix;
  83544. /**
  83545. * Loads a glTF camera.
  83546. * @param context The context when loading the asset
  83547. * @param camera The glTF camera property
  83548. * @param assign A function called synchronously after parsing the glTF properties
  83549. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  83550. */
  83551. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  83552. private _loadAnimationsAsync;
  83553. /**
  83554. * Loads a glTF animation.
  83555. * @param context The context when loading the asset
  83556. * @param animation The glTF animation property
  83557. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  83558. */
  83559. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  83560. /**
  83561. * @hidden Loads a glTF animation channel.
  83562. * @param context The context when loading the asset
  83563. * @param animationContext The context of the animation when loading the asset
  83564. * @param animation The glTF animation property
  83565. * @param channel The glTF animation channel property
  83566. * @param babylonAnimationGroup The babylon animation group property
  83567. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  83568. * @returns A void promise when the channel load is complete
  83569. */
  83570. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  83571. private _loadAnimationSamplerAsync;
  83572. private _loadBufferAsync;
  83573. /**
  83574. * Loads a glTF buffer view.
  83575. * @param context The context when loading the asset
  83576. * @param bufferView The glTF buffer view property
  83577. * @returns A promise that resolves with the loaded data when the load is complete
  83578. */
  83579. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  83580. private _loadAccessorAsync;
  83581. /** @hidden */
  83582. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  83583. private _loadIndicesAccessorAsync;
  83584. private _loadVertexBufferViewAsync;
  83585. private _loadVertexAccessorAsync;
  83586. private _loadMaterialMetallicRoughnessPropertiesAsync;
  83587. /** @hidden */
  83588. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  83589. private _createDefaultMaterial;
  83590. /**
  83591. * Creates a Babylon material from a glTF material.
  83592. * @param context The context when loading the asset
  83593. * @param material The glTF material property
  83594. * @param babylonDrawMode The draw mode for the Babylon material
  83595. * @returns The Babylon material
  83596. */
  83597. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  83598. /**
  83599. * Loads properties from a glTF material into a Babylon material.
  83600. * @param context The context when loading the asset
  83601. * @param material The glTF material property
  83602. * @param babylonMaterial The Babylon material
  83603. * @returns A promise that resolves when the load is complete
  83604. */
  83605. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  83606. /**
  83607. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  83608. * @param context The context when loading the asset
  83609. * @param material The glTF material property
  83610. * @param babylonMaterial The Babylon material
  83611. * @returns A promise that resolves when the load is complete
  83612. */
  83613. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  83614. /**
  83615. * Loads the alpha properties from a glTF material into a Babylon material.
  83616. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  83617. * @param context The context when loading the asset
  83618. * @param material The glTF material property
  83619. * @param babylonMaterial The Babylon material
  83620. */
  83621. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  83622. /**
  83623. * Loads a glTF texture info.
  83624. * @param context The context when loading the asset
  83625. * @param textureInfo The glTF texture info property
  83626. * @param assign A function called synchronously after parsing the glTF properties
  83627. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  83628. */
  83629. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  83630. /** @hidden */
  83631. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  83632. /** @hidden */
  83633. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void, textureLoaderOptions?: any): Promise<BaseTexture>;
  83634. private _loadSampler;
  83635. /**
  83636. * Loads a glTF image.
  83637. * @param context The context when loading the asset
  83638. * @param image The glTF image property
  83639. * @returns A promise that resolves with the loaded data when the load is complete
  83640. */
  83641. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  83642. /**
  83643. * Loads a glTF uri.
  83644. * @param context The context when loading the asset
  83645. * @param property The glTF property associated with the uri
  83646. * @param uri The base64 or relative uri
  83647. * @returns A promise that resolves with the loaded data when the load is complete
  83648. */
  83649. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  83650. /**
  83651. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  83652. * @param babylonObject the Babylon object with metadata
  83653. * @param pointer the JSON pointer
  83654. */
  83655. static AddPointerMetadata(babylonObject: {
  83656. metadata: any;
  83657. }, pointer: string): void;
  83658. private static _GetTextureWrapMode;
  83659. private static _GetTextureSamplingMode;
  83660. private static _GetTypedArrayConstructor;
  83661. private static _GetTypedArray;
  83662. private static _GetNumComponents;
  83663. private static _ValidateUri;
  83664. /** @hidden */
  83665. static _GetDrawMode(context: string, mode: number | undefined): number;
  83666. private _compileMaterialsAsync;
  83667. private _compileShadowGeneratorsAsync;
  83668. private _forEachExtensions;
  83669. private _applyExtensions;
  83670. private _extensionsOnLoading;
  83671. private _extensionsOnReady;
  83672. private _extensionsLoadSceneAsync;
  83673. private _extensionsLoadNodeAsync;
  83674. private _extensionsLoadCameraAsync;
  83675. private _extensionsLoadVertexDataAsync;
  83676. private _extensionsLoadMeshPrimitiveAsync;
  83677. private _extensionsLoadMaterialAsync;
  83678. private _extensionsCreateMaterial;
  83679. private _extensionsLoadMaterialPropertiesAsync;
  83680. private _extensionsLoadTextureInfoAsync;
  83681. private _extensionsLoadTextureAsync;
  83682. private _extensionsLoadAnimationAsync;
  83683. private _extensionsLoadSkinAsync;
  83684. private _extensionsLoadUriAsync;
  83685. private _extensionsLoadBufferViewAsync;
  83686. private _extensionsLoadBufferAsync;
  83687. /**
  83688. * Helper method called by a loader extension to load an glTF extension.
  83689. * @param context The context when loading the asset
  83690. * @param property The glTF property to load the extension from
  83691. * @param extensionName The name of the extension to load
  83692. * @param actionAsync The action to run
  83693. * @returns The promise returned by actionAsync or null if the extension does not exist
  83694. */
  83695. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  83696. /**
  83697. * Helper method called by a loader extension to load a glTF extra.
  83698. * @param context The context when loading the asset
  83699. * @param property The glTF property to load the extra from
  83700. * @param extensionName The name of the extension to load
  83701. * @param actionAsync The action to run
  83702. * @returns The promise returned by actionAsync or null if the extra does not exist
  83703. */
  83704. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  83705. /**
  83706. * Checks for presence of an extension.
  83707. * @param name The name of the extension to check
  83708. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  83709. */
  83710. isExtensionUsed(name: string): boolean;
  83711. /**
  83712. * Increments the indentation level and logs a message.
  83713. * @param message The message to log
  83714. */
  83715. logOpen(message: string): void;
  83716. /**
  83717. * Decrements the indentation level.
  83718. */
  83719. logClose(): void;
  83720. /**
  83721. * Logs a message
  83722. * @param message The message to log
  83723. */
  83724. log(message: string): void;
  83725. /**
  83726. * Starts a performance counter.
  83727. * @param counterName The name of the performance counter
  83728. */
  83729. startPerformanceCounter(counterName: string): void;
  83730. /**
  83731. * Ends a performance counter.
  83732. * @param counterName The name of the performance counter
  83733. */
  83734. endPerformanceCounter(counterName: string): void;
  83735. }
  83736. }
  83737. declare module BABYLON.GLTF2.Loader.Extensions {
  83738. /** @hidden */
  83739. interface IEXTLightsImageBased_LightImageBased {
  83740. _babylonTexture?: BaseTexture;
  83741. _loaded?: Promise<void>;
  83742. }
  83743. /**
  83744. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  83745. */
  83746. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  83747. /**
  83748. * The name of this extension.
  83749. */
  83750. readonly name: string;
  83751. /**
  83752. * Defines whether this extension is enabled.
  83753. */
  83754. enabled: boolean;
  83755. private _loader;
  83756. private _lights?;
  83757. /** @hidden */
  83758. constructor(loader: GLTFLoader);
  83759. /** @hidden */
  83760. dispose(): void;
  83761. /** @hidden */
  83762. onLoading(): void;
  83763. /** @hidden */
  83764. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83765. private _loadLightAsync;
  83766. }
  83767. }
  83768. declare module BABYLON.GLTF2.Loader.Extensions {
  83769. /**
  83770. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  83771. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  83772. * !!! Experimental Extension Subject to Changes !!!
  83773. */
  83774. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  83775. /**
  83776. * The name of this extension.
  83777. */
  83778. readonly name: string;
  83779. /**
  83780. * Defines whether this extension is enabled.
  83781. */
  83782. enabled: boolean;
  83783. private _loader;
  83784. /** @hidden */
  83785. constructor(loader: GLTFLoader);
  83786. /** @hidden */
  83787. dispose(): void;
  83788. /** @hidden */
  83789. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83790. }
  83791. }
  83792. declare module BABYLON.GLTF2.Loader.Extensions {
  83793. /**
  83794. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  83795. */
  83796. export class EXT_texture_webp implements IGLTFLoaderExtension {
  83797. /** The name of this extension. */
  83798. readonly name: string;
  83799. /** Defines whether this extension is enabled. */
  83800. enabled: boolean;
  83801. private _loader;
  83802. /** @hidden */
  83803. constructor(loader: GLTFLoader);
  83804. /** @hidden */
  83805. dispose(): void;
  83806. /** @hidden */
  83807. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83808. }
  83809. }
  83810. declare module BABYLON.GLTF2.Loader.Extensions {
  83811. /**
  83812. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  83813. */
  83814. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  83815. /**
  83816. * The name of this extension.
  83817. */
  83818. readonly name: string;
  83819. /**
  83820. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  83821. */
  83822. dracoCompression?: DracoCompression;
  83823. /**
  83824. * Defines whether this extension is enabled.
  83825. */
  83826. enabled: boolean;
  83827. private _loader;
  83828. /** @hidden */
  83829. constructor(loader: GLTFLoader);
  83830. /** @hidden */
  83831. dispose(): void;
  83832. /** @hidden */
  83833. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  83834. }
  83835. }
  83836. declare module BABYLON.GLTF2.Loader.Extensions {
  83837. /**
  83838. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  83839. */
  83840. export class KHR_lights implements IGLTFLoaderExtension {
  83841. /**
  83842. * The name of this extension.
  83843. */
  83844. readonly name: string;
  83845. /**
  83846. * Defines whether this extension is enabled.
  83847. */
  83848. enabled: boolean;
  83849. private _loader;
  83850. private _lights?;
  83851. /** @hidden */
  83852. constructor(loader: GLTFLoader);
  83853. /** @hidden */
  83854. dispose(): void;
  83855. /** @hidden */
  83856. onLoading(): void;
  83857. /** @hidden */
  83858. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83859. }
  83860. }
  83861. declare module BABYLON.GLTF2.Loader.Extensions {
  83862. /**
  83863. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  83864. */
  83865. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  83866. /**
  83867. * The name of this extension.
  83868. */
  83869. readonly name: string;
  83870. /**
  83871. * Defines whether this extension is enabled.
  83872. */
  83873. enabled: boolean;
  83874. /**
  83875. * Defines a number that determines the order the extensions are applied.
  83876. */
  83877. order: number;
  83878. private _loader;
  83879. /** @hidden */
  83880. constructor(loader: GLTFLoader);
  83881. /** @hidden */
  83882. dispose(): void;
  83883. /** @hidden */
  83884. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83885. private _loadSpecularGlossinessPropertiesAsync;
  83886. }
  83887. }
  83888. declare module BABYLON.GLTF2.Loader.Extensions {
  83889. /**
  83890. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  83891. */
  83892. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  83893. /**
  83894. * The name of this extension.
  83895. */
  83896. readonly name: string;
  83897. /**
  83898. * Defines whether this extension is enabled.
  83899. */
  83900. enabled: boolean;
  83901. /**
  83902. * Defines a number that determines the order the extensions are applied.
  83903. */
  83904. order: number;
  83905. private _loader;
  83906. /** @hidden */
  83907. constructor(loader: GLTFLoader);
  83908. /** @hidden */
  83909. dispose(): void;
  83910. /** @hidden */
  83911. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83912. private _loadUnlitPropertiesAsync;
  83913. }
  83914. }
  83915. declare module BABYLON.GLTF2.Loader.Extensions {
  83916. /**
  83917. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md)
  83918. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  83919. */
  83920. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  83921. /**
  83922. * The name of this extension.
  83923. */
  83924. readonly name: string;
  83925. /**
  83926. * Defines whether this extension is enabled.
  83927. */
  83928. enabled: boolean;
  83929. /**
  83930. * Defines a number that determines the order the extensions are applied.
  83931. */
  83932. order: number;
  83933. private _loader;
  83934. /** @hidden */
  83935. constructor(loader: GLTFLoader);
  83936. /** @hidden */
  83937. dispose(): void;
  83938. /** @hidden */
  83939. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83940. private _loadClearCoatPropertiesAsync;
  83941. }
  83942. }
  83943. declare module BABYLON.GLTF2.Loader.Extensions {
  83944. /**
  83945. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  83946. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  83947. * !!! Experimental Extension Subject to Changes !!!
  83948. */
  83949. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  83950. /**
  83951. * The name of this extension.
  83952. */
  83953. readonly name: string;
  83954. /**
  83955. * Defines whether this extension is enabled.
  83956. */
  83957. enabled: boolean;
  83958. /**
  83959. * Defines a number that determines the order the extensions are applied.
  83960. */
  83961. order: number;
  83962. private _loader;
  83963. /** @hidden */
  83964. constructor(loader: GLTFLoader);
  83965. /** @hidden */
  83966. dispose(): void;
  83967. /** @hidden */
  83968. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83969. private _loadSheenPropertiesAsync;
  83970. }
  83971. }
  83972. declare module BABYLON.GLTF2.Loader.Extensions {
  83973. /**
  83974. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  83975. * !!! Experimental Extension Subject to Changes !!!
  83976. */
  83977. export class KHR_materials_specular implements IGLTFLoaderExtension {
  83978. /**
  83979. * The name of this extension.
  83980. */
  83981. readonly name: string;
  83982. /**
  83983. * Defines whether this extension is enabled.
  83984. */
  83985. enabled: boolean;
  83986. /**
  83987. * Defines a number that determines the order the extensions are applied.
  83988. */
  83989. order: number;
  83990. private _loader;
  83991. /** @hidden */
  83992. constructor(loader: GLTFLoader);
  83993. /** @hidden */
  83994. dispose(): void;
  83995. /** @hidden */
  83996. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83997. private _loadSpecularPropertiesAsync;
  83998. }
  83999. }
  84000. declare module BABYLON.GLTF2.Loader.Extensions {
  84001. /**
  84002. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  84003. * !!! Experimental Extension Subject to Changes !!!
  84004. */
  84005. export class KHR_materials_ior implements IGLTFLoaderExtension {
  84006. /**
  84007. * Default ior Value from the spec.
  84008. */
  84009. private static readonly _DEFAULT_IOR;
  84010. /**
  84011. * The name of this extension.
  84012. */
  84013. readonly name: string;
  84014. /**
  84015. * Defines whether this extension is enabled.
  84016. */
  84017. enabled: boolean;
  84018. /**
  84019. * Defines a number that determines the order the extensions are applied.
  84020. */
  84021. order: number;
  84022. private _loader;
  84023. /** @hidden */
  84024. constructor(loader: GLTFLoader);
  84025. /** @hidden */
  84026. dispose(): void;
  84027. /** @hidden */
  84028. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84029. private _loadIorPropertiesAsync;
  84030. }
  84031. }
  84032. declare module BABYLON.GLTF2.Loader.Extensions {
  84033. /**
  84034. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  84035. * !!! Experimental Extension Subject to Changes !!!
  84036. */
  84037. export class KHR_materials_variants implements IGLTFLoaderExtension {
  84038. /**
  84039. * The name of this extension.
  84040. */
  84041. readonly name: string;
  84042. /**
  84043. * Defines whether this extension is enabled.
  84044. */
  84045. enabled: boolean;
  84046. private _loader;
  84047. private _variants?;
  84048. /** @hidden */
  84049. constructor(loader: GLTFLoader);
  84050. /** @hidden */
  84051. dispose(): void;
  84052. /**
  84053. * Gets the list of available variant names for this asset.
  84054. * @param rootMesh The glTF root mesh
  84055. * @returns the list of all the variant names for this model
  84056. */
  84057. static GetAvailableVariants(rootMesh: Mesh): string[];
  84058. /**
  84059. * Gets the list of available variant names for this asset.
  84060. * @param rootMesh The glTF root mesh
  84061. * @returns the list of all the variant names for this model
  84062. */
  84063. getAvailableVariants(rootMesh: Mesh): string[];
  84064. /**
  84065. * Select a variant given a variant name or a list of variant names.
  84066. * @param rootMesh The glTF root mesh
  84067. * @param variantName The variant name(s) to select.
  84068. */
  84069. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  84070. /**
  84071. * Select a variant given a variant name or a list of variant names.
  84072. * @param rootMesh The glTF root mesh
  84073. * @param variantName The variant name(s) to select.
  84074. */
  84075. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  84076. /**
  84077. * Reset back to the original before selecting a variant.
  84078. * @param rootMesh The glTF root mesh
  84079. */
  84080. static Reset(rootMesh: Mesh): void;
  84081. /**
  84082. * Reset back to the original before selecting a variant.
  84083. * @param rootMesh The glTF root mesh
  84084. */
  84085. reset(rootMesh: Mesh): void;
  84086. /**
  84087. * Gets the last selected variant name(s) or null if original.
  84088. * @param rootMesh The glTF root mesh
  84089. * @returns The selected variant name(s).
  84090. */
  84091. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  84092. /**
  84093. * Gets the last selected variant name(s) or null if original.
  84094. * @param rootMesh The glTF root mesh
  84095. * @returns The selected variant name(s).
  84096. */
  84097. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  84098. private static _GetExtensionMetadata;
  84099. /** @hidden */
  84100. onLoading(): void;
  84101. /** @hidden */
  84102. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  84103. }
  84104. }
  84105. declare module BABYLON.GLTF2.Loader.Extensions {
  84106. /**
  84107. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  84108. * !!! Experimental Extension Subject to Changes !!!
  84109. */
  84110. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  84111. /**
  84112. * The name of this extension.
  84113. */
  84114. readonly name: string;
  84115. /**
  84116. * Defines whether this extension is enabled.
  84117. */
  84118. enabled: boolean;
  84119. /**
  84120. * Defines a number that determines the order the extensions are applied.
  84121. */
  84122. order: number;
  84123. private _loader;
  84124. /** @hidden */
  84125. constructor(loader: GLTFLoader);
  84126. /** @hidden */
  84127. dispose(): void;
  84128. /** @hidden */
  84129. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84130. private _loadTransparentPropertiesAsync;
  84131. }
  84132. }
  84133. declare module BABYLON.GLTF2.Loader.Extensions {
  84134. /**
  84135. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1825)
  84136. * !!! Experimental Extension Subject to Changes !!!
  84137. */
  84138. export class KHR_materials_translucency implements IGLTFLoaderExtension {
  84139. /**
  84140. * The name of this extension.
  84141. */
  84142. readonly name: string;
  84143. /**
  84144. * Defines whether this extension is enabled.
  84145. */
  84146. enabled: boolean;
  84147. /**
  84148. * Defines a number that determines the order the extensions are applied.
  84149. */
  84150. order: number;
  84151. private _loader;
  84152. /** @hidden */
  84153. constructor(loader: GLTFLoader);
  84154. /** @hidden */
  84155. dispose(): void;
  84156. /** @hidden */
  84157. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84158. private _loadTranslucentPropertiesAsync;
  84159. }
  84160. }
  84161. declare module BABYLON.GLTF2.Loader.Extensions {
  84162. /**
  84163. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  84164. */
  84165. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  84166. /**
  84167. * The name of this extension.
  84168. */
  84169. readonly name: string;
  84170. /**
  84171. * Defines whether this extension is enabled.
  84172. */
  84173. enabled: boolean;
  84174. /** @hidden */
  84175. constructor(loader: GLTFLoader);
  84176. /** @hidden */
  84177. dispose(): void;
  84178. }
  84179. }
  84180. declare module BABYLON.GLTF2.Loader.Extensions {
  84181. /**
  84182. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  84183. * !!! Experimental Extension Subject to Changes !!!
  84184. */
  84185. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  84186. /** The name of this extension. */
  84187. readonly name: string;
  84188. /** Defines whether this extension is enabled. */
  84189. enabled: boolean;
  84190. private _loader;
  84191. /** @hidden */
  84192. constructor(loader: GLTFLoader);
  84193. /** @hidden */
  84194. dispose(): void;
  84195. /** @hidden */
  84196. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  84197. }
  84198. }
  84199. declare module BABYLON.GLTF2.Loader.Extensions {
  84200. /**
  84201. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  84202. */
  84203. export class KHR_texture_transform implements IGLTFLoaderExtension {
  84204. /**
  84205. * The name of this extension.
  84206. */
  84207. readonly name: string;
  84208. /**
  84209. * Defines whether this extension is enabled.
  84210. */
  84211. enabled: boolean;
  84212. private _loader;
  84213. /** @hidden */
  84214. constructor(loader: GLTFLoader);
  84215. /** @hidden */
  84216. dispose(): void;
  84217. /** @hidden */
  84218. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  84219. }
  84220. }
  84221. declare module BABYLON.GLTF2.Loader.Extensions {
  84222. /**
  84223. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  84224. */
  84225. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  84226. /**
  84227. * The name of this extension.
  84228. */
  84229. readonly name: string;
  84230. /**
  84231. * Defines whether this extension is enabled.
  84232. */
  84233. enabled: boolean;
  84234. private _loader;
  84235. private _clips;
  84236. private _emitters;
  84237. /** @hidden */
  84238. constructor(loader: GLTFLoader);
  84239. /** @hidden */
  84240. dispose(): void;
  84241. /** @hidden */
  84242. onLoading(): void;
  84243. /** @hidden */
  84244. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  84245. /** @hidden */
  84246. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  84247. /** @hidden */
  84248. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  84249. private _loadClipAsync;
  84250. private _loadEmitterAsync;
  84251. private _getEventAction;
  84252. private _loadAnimationEventAsync;
  84253. }
  84254. }
  84255. declare module BABYLON.GLTF2.Loader.Extensions {
  84256. /**
  84257. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  84258. */
  84259. export class MSFT_lod implements IGLTFLoaderExtension {
  84260. /**
  84261. * The name of this extension.
  84262. */
  84263. readonly name: string;
  84264. /**
  84265. * Defines whether this extension is enabled.
  84266. */
  84267. enabled: boolean;
  84268. /**
  84269. * Defines a number that determines the order the extensions are applied.
  84270. */
  84271. order: number;
  84272. /**
  84273. * Maximum number of LODs to load, starting from the lowest LOD.
  84274. */
  84275. maxLODsToLoad: number;
  84276. /**
  84277. * Observable raised when all node LODs of one level are loaded.
  84278. * The event data is the index of the loaded LOD starting from zero.
  84279. * Dispose the loader to cancel the loading of the next level of LODs.
  84280. */
  84281. onNodeLODsLoadedObservable: Observable<number>;
  84282. /**
  84283. * Observable raised when all material LODs of one level are loaded.
  84284. * The event data is the index of the loaded LOD starting from zero.
  84285. * Dispose the loader to cancel the loading of the next level of LODs.
  84286. */
  84287. onMaterialLODsLoadedObservable: Observable<number>;
  84288. private _loader;
  84289. private _bufferLODs;
  84290. private _nodeIndexLOD;
  84291. private _nodeSignalLODs;
  84292. private _nodePromiseLODs;
  84293. private _nodeBufferLODs;
  84294. private _materialIndexLOD;
  84295. private _materialSignalLODs;
  84296. private _materialPromiseLODs;
  84297. private _materialBufferLODs;
  84298. /** @hidden */
  84299. constructor(loader: GLTFLoader);
  84300. /** @hidden */
  84301. dispose(): void;
  84302. /** @hidden */
  84303. onReady(): void;
  84304. /** @hidden */
  84305. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  84306. /** @hidden */
  84307. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  84308. /** @hidden */
  84309. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  84310. /** @hidden */
  84311. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  84312. /** @hidden */
  84313. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  84314. private _loadBufferLOD;
  84315. /**
  84316. * Gets an array of LOD properties from lowest to highest.
  84317. */
  84318. private _getLODs;
  84319. private _disposeTransformNode;
  84320. private _disposeMaterials;
  84321. }
  84322. }
  84323. declare module BABYLON.GLTF2.Loader.Extensions {
  84324. /** @hidden */
  84325. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  84326. readonly name: string;
  84327. enabled: boolean;
  84328. private _loader;
  84329. constructor(loader: GLTFLoader);
  84330. dispose(): void;
  84331. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84332. }
  84333. }
  84334. declare module BABYLON.GLTF2.Loader.Extensions {
  84335. /** @hidden */
  84336. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  84337. readonly name: string;
  84338. enabled: boolean;
  84339. private _loader;
  84340. constructor(loader: GLTFLoader);
  84341. dispose(): void;
  84342. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84343. }
  84344. }
  84345. declare module BABYLON.GLTF2.Loader.Extensions {
  84346. /**
  84347. * Store glTF extras (if present) in BJS objects' metadata
  84348. */
  84349. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  84350. /**
  84351. * The name of this extension.
  84352. */
  84353. readonly name: string;
  84354. /**
  84355. * Defines whether this extension is enabled.
  84356. */
  84357. enabled: boolean;
  84358. private _loader;
  84359. private _assignExtras;
  84360. /** @hidden */
  84361. constructor(loader: GLTFLoader);
  84362. /** @hidden */
  84363. dispose(): void;
  84364. /** @hidden */
  84365. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  84366. /** @hidden */
  84367. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  84368. /** @hidden */
  84369. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  84370. }
  84371. }
  84372. declare module BABYLON {
  84373. /**
  84374. * Class reading and parsing the MTL file bundled with the obj file.
  84375. */
  84376. export class MTLFileLoader {
  84377. /**
  84378. * Invert Y-Axis of referenced textures on load
  84379. */
  84380. static INVERT_TEXTURE_Y: boolean;
  84381. /**
  84382. * All material loaded from the mtl will be set here
  84383. */
  84384. materials: StandardMaterial[];
  84385. /**
  84386. * This function will read the mtl file and create each material described inside
  84387. * This function could be improve by adding :
  84388. * -some component missing (Ni, Tf...)
  84389. * -including the specific options available
  84390. *
  84391. * @param scene defines the scene the material will be created in
  84392. * @param data defines the mtl data to parse
  84393. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  84394. * @param forAssetContainer defines if the material should be registered in the scene
  84395. */
  84396. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  84397. /**
  84398. * Gets the texture for the material.
  84399. *
  84400. * If the material is imported from input file,
  84401. * We sanitize the url to ensure it takes the textre from aside the material.
  84402. *
  84403. * @param rootUrl The root url to load from
  84404. * @param value The value stored in the mtl
  84405. * @return The Texture
  84406. */
  84407. private static _getTexture;
  84408. }
  84409. }
  84410. declare module BABYLON {
  84411. /**
  84412. * Options for loading OBJ/MTL files
  84413. */
  84414. type MeshLoadOptions = {
  84415. /**
  84416. * Defines if UVs are optimized by default during load.
  84417. */
  84418. OptimizeWithUV: boolean;
  84419. /**
  84420. * Defines custom scaling of UV coordinates of loaded meshes.
  84421. */
  84422. UVScaling: Vector2;
  84423. /**
  84424. * Invert model on y-axis (does a model scaling inversion)
  84425. */
  84426. InvertY: boolean;
  84427. /**
  84428. * Invert Y-Axis of referenced textures on load
  84429. */
  84430. InvertTextureY: boolean;
  84431. /**
  84432. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  84433. */
  84434. ImportVertexColors: boolean;
  84435. /**
  84436. * Compute the normals for the model, even if normals are present in the file.
  84437. */
  84438. ComputeNormals: boolean;
  84439. /**
  84440. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  84441. */
  84442. SkipMaterials: boolean;
  84443. /**
  84444. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  84445. */
  84446. MaterialLoadingFailsSilently: boolean;
  84447. };
  84448. /**
  84449. * OBJ file type loader.
  84450. * This is a babylon scene loader plugin.
  84451. */
  84452. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  84453. /**
  84454. * Defines if UVs are optimized by default during load.
  84455. */
  84456. static OPTIMIZE_WITH_UV: boolean;
  84457. /**
  84458. * Invert model on y-axis (does a model scaling inversion)
  84459. */
  84460. static INVERT_Y: boolean;
  84461. /**
  84462. * Invert Y-Axis of referenced textures on load
  84463. */
  84464. static get INVERT_TEXTURE_Y(): boolean;
  84465. static set INVERT_TEXTURE_Y(value: boolean);
  84466. /**
  84467. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  84468. */
  84469. static IMPORT_VERTEX_COLORS: boolean;
  84470. /**
  84471. * Compute the normals for the model, even if normals are present in the file.
  84472. */
  84473. static COMPUTE_NORMALS: boolean;
  84474. /**
  84475. * Defines custom scaling of UV coordinates of loaded meshes.
  84476. */
  84477. static UV_SCALING: Vector2;
  84478. /**
  84479. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  84480. */
  84481. static SKIP_MATERIALS: boolean;
  84482. /**
  84483. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  84484. *
  84485. * Defaults to true for backwards compatibility.
  84486. */
  84487. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  84488. /**
  84489. * Defines the name of the plugin.
  84490. */
  84491. name: string;
  84492. /**
  84493. * Defines the extension the plugin is able to load.
  84494. */
  84495. extensions: string;
  84496. /** @hidden */
  84497. obj: RegExp;
  84498. /** @hidden */
  84499. group: RegExp;
  84500. /** @hidden */
  84501. mtllib: RegExp;
  84502. /** @hidden */
  84503. usemtl: RegExp;
  84504. /** @hidden */
  84505. smooth: RegExp;
  84506. /** @hidden */
  84507. vertexPattern: RegExp;
  84508. /** @hidden */
  84509. normalPattern: RegExp;
  84510. /** @hidden */
  84511. uvPattern: RegExp;
  84512. /** @hidden */
  84513. facePattern1: RegExp;
  84514. /** @hidden */
  84515. facePattern2: RegExp;
  84516. /** @hidden */
  84517. facePattern3: RegExp;
  84518. /** @hidden */
  84519. facePattern4: RegExp;
  84520. /** @hidden */
  84521. facePattern5: RegExp;
  84522. private _forAssetContainer;
  84523. private _meshLoadOptions;
  84524. /**
  84525. * Creates loader for .OBJ files
  84526. *
  84527. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  84528. */
  84529. constructor(meshLoadOptions?: MeshLoadOptions);
  84530. private static get currentMeshLoadOptions();
  84531. /**
  84532. * Calls synchronously the MTL file attached to this obj.
  84533. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  84534. * Without this function materials are not displayed in the first frame (but displayed after).
  84535. * In consequence it is impossible to get material information in your HTML file
  84536. *
  84537. * @param url The URL of the MTL file
  84538. * @param rootUrl
  84539. * @param onSuccess Callback function to be called when the MTL file is loaded
  84540. * @private
  84541. */
  84542. private _loadMTL;
  84543. /**
  84544. * Instantiates a OBJ file loader plugin.
  84545. * @returns the created plugin
  84546. */
  84547. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  84548. /**
  84549. * If the data string can be loaded directly.
  84550. *
  84551. * @param data string containing the file data
  84552. * @returns if the data can be loaded directly
  84553. */
  84554. canDirectLoad(data: string): boolean;
  84555. /**
  84556. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  84557. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  84558. * @param scene the scene the meshes should be added to
  84559. * @param data the OBJ data to load
  84560. * @param rootUrl root url to load from
  84561. * @param onProgress event that fires when loading progress has occured
  84562. * @param fileName Defines the name of the file to load
  84563. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  84564. */
  84565. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  84566. /**
  84567. * Imports all objects from the loaded OBJ data and adds them to the scene
  84568. * @param scene the scene the objects should be added to
  84569. * @param data the OBJ data to load
  84570. * @param rootUrl root url to load from
  84571. * @param onProgress event that fires when loading progress has occured
  84572. * @param fileName Defines the name of the file to load
  84573. * @returns a promise which completes when objects have been loaded to the scene
  84574. */
  84575. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  84576. /**
  84577. * Load into an asset container.
  84578. * @param scene The scene to load into
  84579. * @param data The data to import
  84580. * @param rootUrl The root url for scene and resources
  84581. * @param onProgress The callback when the load progresses
  84582. * @param fileName Defines the name of the file to load
  84583. * @returns The loaded asset container
  84584. */
  84585. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  84586. /**
  84587. * Read the OBJ file and create an Array of meshes.
  84588. * Each mesh contains all information given by the OBJ and the MTL file.
  84589. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  84590. *
  84591. * @param meshesNames
  84592. * @param scene Scene The scene where are displayed the data
  84593. * @param data String The content of the obj file
  84594. * @param rootUrl String The path to the folder
  84595. * @returns Array<AbstractMesh>
  84596. * @private
  84597. */
  84598. private _parseSolid;
  84599. }
  84600. }
  84601. declare module BABYLON {
  84602. /**
  84603. * STL file type loader.
  84604. * This is a babylon scene loader plugin.
  84605. */
  84606. export class STLFileLoader implements ISceneLoaderPlugin {
  84607. /** @hidden */
  84608. solidPattern: RegExp;
  84609. /** @hidden */
  84610. facetsPattern: RegExp;
  84611. /** @hidden */
  84612. normalPattern: RegExp;
  84613. /** @hidden */
  84614. vertexPattern: RegExp;
  84615. /**
  84616. * Defines the name of the plugin.
  84617. */
  84618. name: string;
  84619. /**
  84620. * Defines the extensions the stl loader is able to load.
  84621. * force data to come in as an ArrayBuffer
  84622. * we'll convert to string if it looks like it's an ASCII .stl
  84623. */
  84624. extensions: ISceneLoaderPluginExtensions;
  84625. /**
  84626. * Import meshes into a scene.
  84627. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  84628. * @param scene The scene to import into
  84629. * @param data The data to import
  84630. * @param rootUrl The root url for scene and resources
  84631. * @param meshes The meshes array to import into
  84632. * @param particleSystems The particle systems array to import into
  84633. * @param skeletons The skeletons array to import into
  84634. * @param onError The callback when import fails
  84635. * @returns True if successful or false otherwise
  84636. */
  84637. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  84638. /**
  84639. * Load into a scene.
  84640. * @param scene The scene to load into
  84641. * @param data The data to import
  84642. * @param rootUrl The root url for scene and resources
  84643. * @param onError The callback when import fails
  84644. * @returns true if successful or false otherwise
  84645. */
  84646. load(scene: Scene, data: any, rootUrl: string): boolean;
  84647. /**
  84648. * Load into an asset container.
  84649. * @param scene The scene to load into
  84650. * @param data The data to import
  84651. * @param rootUrl The root url for scene and resources
  84652. * @param onError The callback when import fails
  84653. * @returns The loaded asset container
  84654. */
  84655. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  84656. private _isBinary;
  84657. private _parseBinary;
  84658. private _parseASCII;
  84659. }
  84660. }
  84661. declare module BABYLON {
  84662. /**
  84663. * Class for generating OBJ data from a Babylon scene.
  84664. */
  84665. export class OBJExport {
  84666. /**
  84667. * Exports the geometry of a Mesh array in .OBJ file format (text)
  84668. * @param mesh defines the list of meshes to serialize
  84669. * @param materials defines if materials should be exported
  84670. * @param matlibname defines the name of the associated mtl file
  84671. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  84672. * @returns the OBJ content
  84673. */
  84674. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  84675. /**
  84676. * Exports the material(s) of a mesh in .MTL file format (text)
  84677. * @param mesh defines the mesh to extract the material from
  84678. * @returns the mtl content
  84679. */
  84680. static MTL(mesh: Mesh): string;
  84681. }
  84682. }
  84683. declare module BABYLON {
  84684. /** @hidden */
  84685. export var __IGLTFExporterExtension: number;
  84686. /**
  84687. * Interface for extending the exporter
  84688. * @hidden
  84689. */
  84690. export interface IGLTFExporterExtension {
  84691. /**
  84692. * The name of this extension
  84693. */
  84694. readonly name: string;
  84695. /**
  84696. * Defines whether this extension is enabled
  84697. */
  84698. enabled: boolean;
  84699. /**
  84700. * Defines whether this extension is required
  84701. */
  84702. required: boolean;
  84703. }
  84704. }
  84705. declare module BABYLON.GLTF2.Exporter {
  84706. /** @hidden */
  84707. export var __IGLTFExporterExtensionV2: number;
  84708. /**
  84709. * Interface for a glTF exporter extension
  84710. * @hidden
  84711. */
  84712. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  84713. /**
  84714. * Define this method to modify the default behavior before exporting a texture
  84715. * @param context The context when loading the asset
  84716. * @param babylonTexture The Babylon.js texture
  84717. * @param mimeType The mime-type of the generated image
  84718. * @returns A promise that resolves with the exported texture
  84719. */
  84720. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  84721. /**
  84722. * Define this method to get notified when a texture info is created
  84723. * @param context The context when loading the asset
  84724. * @param textureInfo The glTF texture info
  84725. * @param babylonTexture The Babylon.js texture
  84726. */
  84727. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  84728. /**
  84729. * Define this method to modify the default behavior when exporting texture info
  84730. * @param context The context when loading the asset
  84731. * @param meshPrimitive glTF mesh primitive
  84732. * @param babylonSubMesh Babylon submesh
  84733. * @param binaryWriter glTF serializer binary writer instance
  84734. * @returns nullable IMeshPrimitive promise
  84735. */
  84736. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  84737. /**
  84738. * Define this method to modify the default behavior when exporting a node
  84739. * @param context The context when exporting the node
  84740. * @param node glTF node
  84741. * @param babylonNode BabylonJS node
  84742. * @returns nullable INode promise
  84743. */
  84744. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84745. [key: number]: number;
  84746. }): Promise<Nullable<INode>>;
  84747. /**
  84748. * Define this method to modify the default behavior when exporting a material
  84749. * @param material glTF material
  84750. * @param babylonMaterial BabylonJS material
  84751. * @returns nullable IMaterial promise
  84752. */
  84753. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  84754. /**
  84755. * Define this method to return additional textures to export from a material
  84756. * @param material glTF material
  84757. * @param babylonMaterial BabylonJS material
  84758. * @returns List of textures
  84759. */
  84760. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  84761. /** Gets a boolean indicating that this extension was used */
  84762. wasUsed: boolean;
  84763. /** Gets a boolean indicating that this extension is required for the file to work */
  84764. required: boolean;
  84765. /**
  84766. * Called after the exporter state changes to EXPORTING
  84767. */
  84768. onExporting?(): void;
  84769. }
  84770. }
  84771. declare module BABYLON.GLTF2.Exporter {
  84772. /**
  84773. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  84774. * @hidden
  84775. */
  84776. export class _GLTFMaterialExporter {
  84777. /**
  84778. * Represents the dielectric specular values for R, G and B
  84779. */
  84780. private static readonly _DielectricSpecular;
  84781. /**
  84782. * Allows the maximum specular power to be defined for material calculations
  84783. */
  84784. private static readonly _MaxSpecularPower;
  84785. /**
  84786. * Mapping to store textures
  84787. */
  84788. private _textureMap;
  84789. /**
  84790. * Numeric tolerance value
  84791. */
  84792. private static readonly _Epsilon;
  84793. /**
  84794. * Reference to the glTF Exporter
  84795. */
  84796. private _exporter;
  84797. constructor(exporter: _Exporter);
  84798. /**
  84799. * Specifies if two colors are approximately equal in value
  84800. * @param color1 first color to compare to
  84801. * @param color2 second color to compare to
  84802. * @param epsilon threshold value
  84803. */
  84804. private static FuzzyEquals;
  84805. /**
  84806. * Gets the materials from a Babylon scene and converts them to glTF materials
  84807. * @param scene babylonjs scene
  84808. * @param mimeType texture mime type
  84809. * @param images array of images
  84810. * @param textures array of textures
  84811. * @param materials array of materials
  84812. * @param imageData mapping of texture names to base64 textures
  84813. * @param hasTextureCoords specifies if texture coordinates are present on the material
  84814. */
  84815. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  84816. /**
  84817. * Makes a copy of the glTF material without the texture parameters
  84818. * @param originalMaterial original glTF material
  84819. * @returns glTF material without texture parameters
  84820. */
  84821. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  84822. /**
  84823. * Specifies if the material has any texture parameters present
  84824. * @param material glTF Material
  84825. * @returns boolean specifying if texture parameters are present
  84826. */
  84827. _hasTexturesPresent(material: IMaterial): boolean;
  84828. /**
  84829. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  84830. * @param babylonStandardMaterial
  84831. * @returns glTF Metallic Roughness Material representation
  84832. */
  84833. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  84834. /**
  84835. * Computes the metallic factor
  84836. * @param diffuse diffused value
  84837. * @param specular specular value
  84838. * @param oneMinusSpecularStrength one minus the specular strength
  84839. * @returns metallic value
  84840. */
  84841. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  84842. /**
  84843. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  84844. * @param glTFMaterial glTF material
  84845. * @param babylonMaterial Babylon material
  84846. */
  84847. private static _SetAlphaMode;
  84848. /**
  84849. * Converts a Babylon Standard Material to a glTF Material
  84850. * @param babylonStandardMaterial BJS Standard Material
  84851. * @param mimeType mime type to use for the textures
  84852. * @param images array of glTF image interfaces
  84853. * @param textures array of glTF texture interfaces
  84854. * @param materials array of glTF material interfaces
  84855. * @param imageData map of image file name to data
  84856. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84857. */
  84858. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84859. private _finishMaterial;
  84860. /**
  84861. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  84862. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  84863. * @param mimeType mime type to use for the textures
  84864. * @param images array of glTF image interfaces
  84865. * @param textures array of glTF texture interfaces
  84866. * @param materials array of glTF material interfaces
  84867. * @param imageData map of image file name to data
  84868. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84869. */
  84870. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84871. /**
  84872. * Converts an image typed array buffer to a base64 image
  84873. * @param buffer typed array buffer
  84874. * @param width width of the image
  84875. * @param height height of the image
  84876. * @param mimeType mimetype of the image
  84877. * @returns base64 image string
  84878. */
  84879. private _createBase64FromCanvasAsync;
  84880. /**
  84881. * Generates a white texture based on the specified width and height
  84882. * @param width width of the texture in pixels
  84883. * @param height height of the texture in pixels
  84884. * @param scene babylonjs scene
  84885. * @returns white texture
  84886. */
  84887. private _createWhiteTexture;
  84888. /**
  84889. * 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
  84890. * @param texture1 first texture to resize
  84891. * @param texture2 second texture to resize
  84892. * @param scene babylonjs scene
  84893. * @returns resized textures or null
  84894. */
  84895. private _resizeTexturesToSameDimensions;
  84896. /**
  84897. * Converts an array of pixels to a Float32Array
  84898. * Throws an error if the pixel format is not supported
  84899. * @param pixels - array buffer containing pixel values
  84900. * @returns Float32 of pixels
  84901. */
  84902. private _convertPixelArrayToFloat32;
  84903. /**
  84904. * Convert Specular Glossiness Textures to Metallic Roughness
  84905. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  84906. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  84907. * @param diffuseTexture texture used to store diffuse information
  84908. * @param specularGlossinessTexture texture used to store specular and glossiness information
  84909. * @param factors specular glossiness material factors
  84910. * @param mimeType the mime type to use for the texture
  84911. * @returns pbr metallic roughness interface or null
  84912. */
  84913. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  84914. /**
  84915. * Converts specular glossiness material properties to metallic roughness
  84916. * @param specularGlossiness interface with specular glossiness material properties
  84917. * @returns interface with metallic roughness material properties
  84918. */
  84919. private _convertSpecularGlossinessToMetallicRoughness;
  84920. /**
  84921. * Calculates the surface reflectance, independent of lighting conditions
  84922. * @param color Color source to calculate brightness from
  84923. * @returns number representing the perceived brightness, or zero if color is undefined
  84924. */
  84925. private _getPerceivedBrightness;
  84926. /**
  84927. * Returns the maximum color component value
  84928. * @param color
  84929. * @returns maximum color component value, or zero if color is null or undefined
  84930. */
  84931. private _getMaxComponent;
  84932. /**
  84933. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  84934. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84935. * @param mimeType mime type to use for the textures
  84936. * @param images array of glTF image interfaces
  84937. * @param textures array of glTF texture interfaces
  84938. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  84939. * @param imageData map of image file name to data
  84940. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84941. * @returns glTF PBR Metallic Roughness factors
  84942. */
  84943. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  84944. private _getGLTFTextureSampler;
  84945. private _getGLTFTextureWrapMode;
  84946. private _getGLTFTextureWrapModesSampler;
  84947. /**
  84948. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  84949. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84950. * @param mimeType mime type to use for the textures
  84951. * @param images array of glTF image interfaces
  84952. * @param textures array of glTF texture interfaces
  84953. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  84954. * @param imageData map of image file name to data
  84955. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84956. * @returns glTF PBR Metallic Roughness factors
  84957. */
  84958. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  84959. /**
  84960. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  84961. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84962. * @param mimeType mime type to use for the textures
  84963. * @param images array of glTF image interfaces
  84964. * @param textures array of glTF texture interfaces
  84965. * @param materials array of glTF material interfaces
  84966. * @param imageData map of image file name to data
  84967. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84968. */
  84969. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84970. private setMetallicRoughnessPbrMaterial;
  84971. private getPixelsFromTexture;
  84972. /**
  84973. * Extracts a texture from a Babylon texture into file data and glTF data
  84974. * @param babylonTexture Babylon texture to extract
  84975. * @param mimeType Mime Type of the babylonTexture
  84976. * @return glTF texture info, or null if the texture format is not supported
  84977. */
  84978. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  84979. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  84980. /**
  84981. * Builds a texture from base64 string
  84982. * @param base64Texture base64 texture string
  84983. * @param baseTextureName Name to use for the texture
  84984. * @param mimeType image mime type for the texture
  84985. * @param images array of images
  84986. * @param textures array of textures
  84987. * @param imageData map of image data
  84988. * @returns glTF texture info, or null if the texture format is not supported
  84989. */
  84990. private _getTextureInfoFromBase64;
  84991. }
  84992. }
  84993. declare module BABYLON {
  84994. /**
  84995. * Class for holding and downloading glTF file data
  84996. */
  84997. export class GLTFData {
  84998. /**
  84999. * Object which contains the file name as the key and its data as the value
  85000. */
  85001. glTFFiles: {
  85002. [fileName: string]: string | Blob;
  85003. };
  85004. /**
  85005. * Initializes the glTF file object
  85006. */
  85007. constructor();
  85008. /**
  85009. * Downloads the glTF data as files based on their names and data
  85010. */
  85011. downloadFiles(): void;
  85012. }
  85013. }
  85014. declare module BABYLON {
  85015. /**
  85016. * Holds a collection of exporter options and parameters
  85017. */
  85018. export interface IExportOptions {
  85019. /**
  85020. * Function which indicates whether a babylon node should be exported or not
  85021. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  85022. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  85023. */
  85024. shouldExportNode?(node: Node): boolean;
  85025. /**
  85026. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  85027. * @param metadata source metadata to read from
  85028. * @returns the data to store to glTF node extras
  85029. */
  85030. metadataSelector?(metadata: any): any;
  85031. /**
  85032. * The sample rate to bake animation curves
  85033. */
  85034. animationSampleRate?: number;
  85035. /**
  85036. * Begin serialization without waiting for the scene to be ready
  85037. */
  85038. exportWithoutWaitingForScene?: boolean;
  85039. /**
  85040. * Indicates if coordinate system swapping root nodes should be included in export
  85041. */
  85042. includeCoordinateSystemConversionNodes?: boolean;
  85043. }
  85044. /**
  85045. * Class for generating glTF data from a Babylon scene.
  85046. */
  85047. export class GLTF2Export {
  85048. /**
  85049. * Exports the geometry of the scene to .gltf file format asynchronously
  85050. * @param scene Babylon scene with scene hierarchy information
  85051. * @param filePrefix File prefix to use when generating the glTF file
  85052. * @param options Exporter options
  85053. * @returns Returns an object with a .gltf file and associates texture names
  85054. * as keys and their data and paths as values
  85055. */
  85056. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  85057. private static _PreExportAsync;
  85058. private static _PostExportAsync;
  85059. /**
  85060. * Exports the geometry of the scene to .glb file format asychronously
  85061. * @param scene Babylon scene with scene hierarchy information
  85062. * @param filePrefix File prefix to use when generating glb file
  85063. * @param options Exporter options
  85064. * @returns Returns an object with a .glb filename as key and data as value
  85065. */
  85066. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  85067. }
  85068. }
  85069. declare module BABYLON.GLTF2.Exporter {
  85070. /**
  85071. * @hidden
  85072. */
  85073. export class _GLTFUtilities {
  85074. /**
  85075. * Creates a buffer view based on the supplied arguments
  85076. * @param bufferIndex index value of the specified buffer
  85077. * @param byteOffset byte offset value
  85078. * @param byteLength byte length of the bufferView
  85079. * @param byteStride byte distance between conequential elements
  85080. * @param name name of the buffer view
  85081. * @returns bufferView for glTF
  85082. */
  85083. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  85084. /**
  85085. * Creates an accessor based on the supplied arguments
  85086. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  85087. * @param name The name of the accessor
  85088. * @param type The type of the accessor
  85089. * @param componentType The datatype of components in the attribute
  85090. * @param count The number of attributes referenced by this accessor
  85091. * @param byteOffset The offset relative to the start of the bufferView in bytes
  85092. * @param min Minimum value of each component in this attribute
  85093. * @param max Maximum value of each component in this attribute
  85094. * @returns accessor for glTF
  85095. */
  85096. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  85097. /**
  85098. * Calculates the minimum and maximum values of an array of position floats
  85099. * @param positions Positions array of a mesh
  85100. * @param vertexStart Starting vertex offset to calculate min and max values
  85101. * @param vertexCount Number of vertices to check for min and max values
  85102. * @returns min number array and max number array
  85103. */
  85104. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  85105. min: number[];
  85106. max: number[];
  85107. };
  85108. /**
  85109. * Converts a new right-handed Vector3
  85110. * @param vector vector3 array
  85111. * @returns right-handed Vector3
  85112. */
  85113. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  85114. /**
  85115. * Converts a Vector3 to right-handed
  85116. * @param vector Vector3 to convert to right-handed
  85117. */
  85118. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  85119. /**
  85120. * Converts a three element number array to right-handed
  85121. * @param vector number array to convert to right-handed
  85122. */
  85123. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  85124. /**
  85125. * Converts a new right-handed Vector3
  85126. * @param vector vector3 array
  85127. * @returns right-handed Vector3
  85128. */
  85129. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  85130. /**
  85131. * Converts a Vector3 to right-handed
  85132. * @param vector Vector3 to convert to right-handed
  85133. */
  85134. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  85135. /**
  85136. * Converts a three element number array to right-handed
  85137. * @param vector number array to convert to right-handed
  85138. */
  85139. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  85140. /**
  85141. * Converts a Vector4 to right-handed
  85142. * @param vector Vector4 to convert to right-handed
  85143. */
  85144. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  85145. /**
  85146. * Converts a Vector4 to right-handed
  85147. * @param vector Vector4 to convert to right-handed
  85148. */
  85149. static _GetRightHandedArray4FromRef(vector: number[]): void;
  85150. /**
  85151. * Converts a Quaternion to right-handed
  85152. * @param quaternion Source quaternion to convert to right-handed
  85153. */
  85154. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  85155. /**
  85156. * Converts a Quaternion to right-handed
  85157. * @param quaternion Source quaternion to convert to right-handed
  85158. */
  85159. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  85160. static _NormalizeTangentFromRef(tangent: Vector4): void;
  85161. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  85162. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  85163. }
  85164. }
  85165. declare module BABYLON.GLTF2.Exporter {
  85166. /**
  85167. * Converts Babylon Scene into glTF 2.0.
  85168. * @hidden
  85169. */
  85170. export class _Exporter {
  85171. /**
  85172. * Stores the glTF to export
  85173. */
  85174. _glTF: IGLTF;
  85175. /**
  85176. * Stores all generated buffer views, which represents views into the main glTF buffer data
  85177. */
  85178. _bufferViews: IBufferView[];
  85179. /**
  85180. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  85181. */
  85182. _accessors: IAccessor[];
  85183. /**
  85184. * Stores all the generated nodes, which contains transform and/or mesh information per node
  85185. */
  85186. _nodes: INode[];
  85187. /**
  85188. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  85189. */
  85190. private _scenes;
  85191. /**
  85192. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  85193. */
  85194. private _meshes;
  85195. /**
  85196. * Stores all the generated material information, which represents the appearance of each primitive
  85197. */
  85198. _materials: IMaterial[];
  85199. _materialMap: {
  85200. [materialID: number]: number;
  85201. };
  85202. /**
  85203. * Stores all the generated texture information, which is referenced by glTF materials
  85204. */
  85205. _textures: ITexture[];
  85206. /**
  85207. * Stores all the generated image information, which is referenced by glTF textures
  85208. */
  85209. _images: IImage[];
  85210. /**
  85211. * Stores all the texture samplers
  85212. */
  85213. _samplers: ISampler[];
  85214. /**
  85215. * Stores all the generated glTF skins
  85216. */
  85217. _skins: ISkin[];
  85218. /**
  85219. * Stores all the generated animation samplers, which is referenced by glTF animations
  85220. */
  85221. /**
  85222. * Stores the animations for glTF models
  85223. */
  85224. private _animations;
  85225. /**
  85226. * Stores the total amount of bytes stored in the glTF buffer
  85227. */
  85228. private _totalByteLength;
  85229. /**
  85230. * Stores a reference to the Babylon scene containing the source geometry and material information
  85231. */
  85232. _babylonScene: Scene;
  85233. /**
  85234. * Stores a map of the image data, where the key is the file name and the value
  85235. * is the image data
  85236. */
  85237. _imageData: {
  85238. [fileName: string]: {
  85239. data: Uint8Array;
  85240. mimeType: ImageMimeType;
  85241. };
  85242. };
  85243. protected _orderedImageData: Array<{
  85244. data: Uint8Array;
  85245. mimeType: ImageMimeType;
  85246. }>;
  85247. /**
  85248. * Stores a map of the unique id of a node to its index in the node array
  85249. */
  85250. _nodeMap: {
  85251. [key: number]: number;
  85252. };
  85253. /**
  85254. * Specifies if the source Babylon scene was left handed, and needed conversion.
  85255. */
  85256. _convertToRightHandedSystem: boolean;
  85257. /**
  85258. * Specifies if a Babylon node should be converted to right-handed on export
  85259. */
  85260. _convertToRightHandedSystemMap: {
  85261. [nodeId: number]: boolean;
  85262. };
  85263. _includeCoordinateSystemConversionNodes: boolean;
  85264. /**
  85265. * Baked animation sample rate
  85266. */
  85267. private _animationSampleRate;
  85268. private _options;
  85269. private _localEngine;
  85270. _glTFMaterialExporter: _GLTFMaterialExporter;
  85271. private _extensions;
  85272. private static _ExtensionNames;
  85273. private static _ExtensionFactories;
  85274. private _applyExtension;
  85275. private _applyExtensions;
  85276. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  85277. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  85278. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  85279. [key: number]: number;
  85280. }): Promise<Nullable<INode>>;
  85281. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  85282. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  85283. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  85284. private _forEachExtensions;
  85285. private _extensionsOnExporting;
  85286. /**
  85287. * Load glTF serializer extensions
  85288. */
  85289. private _loadExtensions;
  85290. /**
  85291. * Creates a glTF Exporter instance, which can accept optional exporter options
  85292. * @param babylonScene Babylon scene object
  85293. * @param options Options to modify the behavior of the exporter
  85294. */
  85295. constructor(babylonScene: Scene, options?: IExportOptions);
  85296. dispose(): void;
  85297. /**
  85298. * Registers a glTF exporter extension
  85299. * @param name Name of the extension to export
  85300. * @param factory The factory function that creates the exporter extension
  85301. */
  85302. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  85303. /**
  85304. * Un-registers an exporter extension
  85305. * @param name The name fo the exporter extension
  85306. * @returns A boolean indicating whether the extension has been un-registered
  85307. */
  85308. static UnregisterExtension(name: string): boolean;
  85309. /**
  85310. * Lazy load a local engine
  85311. */
  85312. _getLocalEngine(): Engine;
  85313. private reorderIndicesBasedOnPrimitiveMode;
  85314. /**
  85315. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  85316. * clock-wise during export to glTF
  85317. * @param submesh BabylonJS submesh
  85318. * @param primitiveMode Primitive mode of the mesh
  85319. * @param sideOrientation the winding order of the submesh
  85320. * @param vertexBufferKind The type of vertex attribute
  85321. * @param meshAttributeArray The vertex attribute data
  85322. * @param byteOffset The offset to the binary data
  85323. * @param binaryWriter The binary data for the glTF file
  85324. * @param convertToRightHandedSystem Converts the values to right-handed
  85325. */
  85326. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  85327. /**
  85328. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  85329. * clock-wise during export to glTF
  85330. * @param submesh BabylonJS submesh
  85331. * @param primitiveMode Primitive mode of the mesh
  85332. * @param sideOrientation the winding order of the submesh
  85333. * @param vertexBufferKind The type of vertex attribute
  85334. * @param meshAttributeArray The vertex attribute data
  85335. * @param byteOffset The offset to the binary data
  85336. * @param binaryWriter The binary data for the glTF file
  85337. * @param convertToRightHandedSystem Converts the values to right-handed
  85338. */
  85339. private reorderTriangleFillMode;
  85340. /**
  85341. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  85342. * clock-wise during export to glTF
  85343. * @param submesh BabylonJS submesh
  85344. * @param primitiveMode Primitive mode of the mesh
  85345. * @param sideOrientation the winding order of the submesh
  85346. * @param vertexBufferKind The type of vertex attribute
  85347. * @param meshAttributeArray The vertex attribute data
  85348. * @param byteOffset The offset to the binary data
  85349. * @param binaryWriter The binary data for the glTF file
  85350. * @param convertToRightHandedSystem Converts the values to right-handed
  85351. */
  85352. private reorderTriangleStripDrawMode;
  85353. /**
  85354. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  85355. * clock-wise during export to glTF
  85356. * @param submesh BabylonJS submesh
  85357. * @param primitiveMode Primitive mode of the mesh
  85358. * @param sideOrientation the winding order of the submesh
  85359. * @param vertexBufferKind The type of vertex attribute
  85360. * @param meshAttributeArray The vertex attribute data
  85361. * @param byteOffset The offset to the binary data
  85362. * @param binaryWriter The binary data for the glTF file
  85363. * @param convertToRightHandedSystem Converts the values to right-handed
  85364. */
  85365. private reorderTriangleFanMode;
  85366. /**
  85367. * Writes the vertex attribute data to binary
  85368. * @param vertices The vertices to write to the binary writer
  85369. * @param byteOffset The offset into the binary writer to overwrite binary data
  85370. * @param vertexAttributeKind The vertex attribute type
  85371. * @param meshAttributeArray The vertex attribute data
  85372. * @param binaryWriter The writer containing the binary data
  85373. * @param convertToRightHandedSystem Converts the values to right-handed
  85374. */
  85375. private writeVertexAttributeData;
  85376. /**
  85377. * Writes mesh attribute data to a data buffer
  85378. * Returns the bytelength of the data
  85379. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  85380. * @param meshAttributeArray Array containing the attribute data
  85381. * @param byteStride Specifies the space between data
  85382. * @param binaryWriter The buffer to write the binary data to
  85383. * @param convertToRightHandedSystem Converts the values to right-handed
  85384. */
  85385. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  85386. /**
  85387. * Writes mesh attribute data to a data buffer
  85388. * Returns the bytelength of the data
  85389. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  85390. * @param meshAttributeArray Array containing the attribute data
  85391. * @param byteStride Specifies the space between data
  85392. * @param binaryWriter The buffer to write the binary data to
  85393. * @param convertToRightHandedSystem Converts the values to right-handed
  85394. */
  85395. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  85396. /**
  85397. * Generates glTF json data
  85398. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  85399. * @param glTFPrefix Text to use when prefixing a glTF file
  85400. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  85401. * @returns json data as string
  85402. */
  85403. private generateJSON;
  85404. /**
  85405. * Generates data for .gltf and .bin files based on the glTF prefix string
  85406. * @param glTFPrefix Text to use when prefixing a glTF file
  85407. * @param dispose Dispose the exporter
  85408. * @returns GLTFData with glTF file data
  85409. */
  85410. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  85411. /**
  85412. * Creates a binary buffer for glTF
  85413. * @returns array buffer for binary data
  85414. */
  85415. private _generateBinaryAsync;
  85416. /**
  85417. * Pads the number to a multiple of 4
  85418. * @param num number to pad
  85419. * @returns padded number
  85420. */
  85421. private _getPadding;
  85422. /**
  85423. * @hidden
  85424. */
  85425. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  85426. /**
  85427. * Sets the TRS for each node
  85428. * @param node glTF Node for storing the transformation data
  85429. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  85430. * @param convertToRightHandedSystem Converts the values to right-handed
  85431. */
  85432. private setNodeTransformation;
  85433. private getVertexBufferFromMesh;
  85434. /**
  85435. * Creates a bufferview based on the vertices type for the Babylon mesh
  85436. * @param kind Indicates the type of vertices data
  85437. * @param componentType Indicates the numerical type used to store the data
  85438. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  85439. * @param binaryWriter The buffer to write the bufferview data to
  85440. * @param convertToRightHandedSystem Converts the values to right-handed
  85441. */
  85442. private createBufferViewKind;
  85443. /**
  85444. * Creates a bufferview based on the vertices type for the Babylon mesh
  85445. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  85446. * @param babylonMorphTarget the morph target to be exported
  85447. * @param binaryWriter The buffer to write the bufferview data to
  85448. * @param convertToRightHandedSystem Converts the values to right-handed
  85449. */
  85450. private setMorphTargetAttributes;
  85451. /**
  85452. * The primitive mode of the Babylon mesh
  85453. * @param babylonMesh The BabylonJS mesh
  85454. */
  85455. private getMeshPrimitiveMode;
  85456. /**
  85457. * Sets the primitive mode of the glTF mesh primitive
  85458. * @param meshPrimitive glTF mesh primitive
  85459. * @param primitiveMode The primitive mode
  85460. */
  85461. private setPrimitiveMode;
  85462. /**
  85463. * Sets the vertex attribute accessor based of the glTF mesh primitive
  85464. * @param meshPrimitive glTF mesh primitive
  85465. * @param attributeKind vertex attribute
  85466. * @returns boolean specifying if uv coordinates are present
  85467. */
  85468. private setAttributeKind;
  85469. /**
  85470. * Sets data for the primitive attributes of each submesh
  85471. * @param mesh glTF Mesh object to store the primitive attribute information
  85472. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  85473. * @param binaryWriter Buffer to write the attribute data to
  85474. * @param convertToRightHandedSystem Converts the values to right-handed
  85475. */
  85476. private setPrimitiveAttributesAsync;
  85477. /**
  85478. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  85479. * @param node The node to check
  85480. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  85481. */
  85482. private isBabylonCoordinateSystemConvertingNode;
  85483. /**
  85484. * Creates a glTF scene based on the array of meshes
  85485. * Returns the the total byte offset
  85486. * @param babylonScene Babylon scene to get the mesh data from
  85487. * @param binaryWriter Buffer to write binary data to
  85488. */
  85489. private createSceneAsync;
  85490. /**
  85491. * Creates a mapping of Node unique id to node index and handles animations
  85492. * @param babylonScene Babylon Scene
  85493. * @param nodes Babylon transform nodes
  85494. * @param binaryWriter Buffer to write binary data to
  85495. * @returns Node mapping of unique id to index
  85496. */
  85497. private createNodeMapAndAnimationsAsync;
  85498. /**
  85499. * Creates a glTF node from a Babylon mesh
  85500. * @param babylonMesh Source Babylon mesh
  85501. * @param binaryWriter Buffer for storing geometry data
  85502. * @param convertToRightHandedSystem Converts the values to right-handed
  85503. * @param nodeMap Node mapping of unique id to glTF node index
  85504. * @returns glTF node
  85505. */
  85506. private createNodeAsync;
  85507. /**
  85508. * Creates a glTF skin from a Babylon skeleton
  85509. * @param babylonScene Babylon Scene
  85510. * @param nodes Babylon transform nodes
  85511. * @param binaryWriter Buffer to write binary data to
  85512. * @returns Node mapping of unique id to index
  85513. */
  85514. private createSkinsAsync;
  85515. }
  85516. /**
  85517. * @hidden
  85518. *
  85519. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  85520. */
  85521. export class _BinaryWriter {
  85522. /**
  85523. * Array buffer which stores all binary data
  85524. */
  85525. private _arrayBuffer;
  85526. /**
  85527. * View of the array buffer
  85528. */
  85529. private _dataView;
  85530. /**
  85531. * byte offset of data in array buffer
  85532. */
  85533. private _byteOffset;
  85534. /**
  85535. * Initialize binary writer with an initial byte length
  85536. * @param byteLength Initial byte length of the array buffer
  85537. */
  85538. constructor(byteLength: number);
  85539. /**
  85540. * Resize the array buffer to the specified byte length
  85541. * @param byteLength
  85542. */
  85543. private resizeBuffer;
  85544. /**
  85545. * Get an array buffer with the length of the byte offset
  85546. * @returns ArrayBuffer resized to the byte offset
  85547. */
  85548. getArrayBuffer(): ArrayBuffer;
  85549. /**
  85550. * Get the byte offset of the array buffer
  85551. * @returns byte offset
  85552. */
  85553. getByteOffset(): number;
  85554. /**
  85555. * Stores an UInt8 in the array buffer
  85556. * @param entry
  85557. * @param byteOffset If defined, specifies where to set the value as an offset.
  85558. */
  85559. setUInt8(entry: number, byteOffset?: number): void;
  85560. /**
  85561. * Stores an UInt16 in the array buffer
  85562. * @param entry
  85563. * @param byteOffset If defined, specifies where to set the value as an offset.
  85564. */
  85565. setUInt16(entry: number, byteOffset?: number): void;
  85566. /**
  85567. * Gets an UInt32 in the array buffer
  85568. * @param entry
  85569. * @param byteOffset If defined, specifies where to set the value as an offset.
  85570. */
  85571. getUInt32(byteOffset: number): number;
  85572. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  85573. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  85574. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  85575. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  85576. /**
  85577. * Stores a Float32 in the array buffer
  85578. * @param entry
  85579. */
  85580. setFloat32(entry: number, byteOffset?: number): void;
  85581. /**
  85582. * Stores an UInt32 in the array buffer
  85583. * @param entry
  85584. * @param byteOffset If defined, specifies where to set the value as an offset.
  85585. */
  85586. setUInt32(entry: number, byteOffset?: number): void;
  85587. }
  85588. }
  85589. declare module BABYLON.GLTF2.Exporter {
  85590. /**
  85591. * @hidden
  85592. * Interface to store animation data.
  85593. */
  85594. export interface _IAnimationData {
  85595. /**
  85596. * Keyframe data.
  85597. */
  85598. inputs: number[];
  85599. /**
  85600. * Value data.
  85601. */
  85602. outputs: number[][];
  85603. /**
  85604. * Animation interpolation data.
  85605. */
  85606. samplerInterpolation: AnimationSamplerInterpolation;
  85607. /**
  85608. * Minimum keyframe value.
  85609. */
  85610. inputsMin: number;
  85611. /**
  85612. * Maximum keyframe value.
  85613. */
  85614. inputsMax: number;
  85615. }
  85616. /**
  85617. * @hidden
  85618. */
  85619. export interface _IAnimationInfo {
  85620. /**
  85621. * The target channel for the animation
  85622. */
  85623. animationChannelTargetPath: AnimationChannelTargetPath;
  85624. /**
  85625. * The glTF accessor type for the data.
  85626. */
  85627. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  85628. /**
  85629. * Specifies if quaternions should be used.
  85630. */
  85631. useQuaternion: boolean;
  85632. }
  85633. /**
  85634. * @hidden
  85635. * Utility class for generating glTF animation data from BabylonJS.
  85636. */
  85637. export class _GLTFAnimation {
  85638. /**
  85639. * @ignore
  85640. *
  85641. * Creates glTF channel animation from BabylonJS animation.
  85642. * @param babylonTransformNode - BabylonJS mesh.
  85643. * @param animation - animation.
  85644. * @param animationChannelTargetPath - The target animation channel.
  85645. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  85646. * @param useQuaternion - Specifies if quaternions are used.
  85647. * @returns nullable IAnimationData
  85648. */
  85649. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  85650. private static _DeduceAnimationInfo;
  85651. /**
  85652. * @ignore
  85653. * Create node animations from the transform node animations
  85654. * @param babylonNode
  85655. * @param runtimeGLTFAnimation
  85656. * @param idleGLTFAnimations
  85657. * @param nodeMap
  85658. * @param nodes
  85659. * @param binaryWriter
  85660. * @param bufferViews
  85661. * @param accessors
  85662. * @param convertToRightHandedSystem
  85663. * @param animationSampleRate
  85664. */
  85665. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  85666. [key: number]: number;
  85667. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  85668. /**
  85669. * @ignore
  85670. * Create individual morph animations from the mesh's morph target animation tracks
  85671. * @param babylonNode
  85672. * @param runtimeGLTFAnimation
  85673. * @param idleGLTFAnimations
  85674. * @param nodeMap
  85675. * @param nodes
  85676. * @param binaryWriter
  85677. * @param bufferViews
  85678. * @param accessors
  85679. * @param convertToRightHandedSystem
  85680. * @param animationSampleRate
  85681. */
  85682. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  85683. [key: number]: number;
  85684. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  85685. /**
  85686. * @ignore
  85687. * Create node and morph animations from the animation groups
  85688. * @param babylonScene
  85689. * @param glTFAnimations
  85690. * @param nodeMap
  85691. * @param nodes
  85692. * @param binaryWriter
  85693. * @param bufferViews
  85694. * @param accessors
  85695. * @param convertToRightHandedSystemMap
  85696. * @param animationSampleRate
  85697. */
  85698. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  85699. [key: number]: number;
  85700. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  85701. [nodeId: number]: boolean;
  85702. }, animationSampleRate: number): void;
  85703. private static AddAnimation;
  85704. /**
  85705. * Create a baked animation
  85706. * @param babylonTransformNode BabylonJS mesh
  85707. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  85708. * @param animationChannelTargetPath animation target channel
  85709. * @param minFrame minimum animation frame
  85710. * @param maxFrame maximum animation frame
  85711. * @param fps frames per second of the animation
  85712. * @param inputs input key frames of the animation
  85713. * @param outputs output key frame data of the animation
  85714. * @param convertToRightHandedSystem converts the values to right-handed
  85715. * @param useQuaternion specifies if quaternions should be used
  85716. */
  85717. private static _CreateBakedAnimation;
  85718. private static _ConvertFactorToVector3OrQuaternion;
  85719. private static _SetInterpolatedValue;
  85720. /**
  85721. * Creates linear animation from the animation key frames
  85722. * @param babylonTransformNode BabylonJS mesh
  85723. * @param animation BabylonJS animation
  85724. * @param animationChannelTargetPath The target animation channel
  85725. * @param frameDelta The difference between the last and first frame of the animation
  85726. * @param inputs Array to store the key frame times
  85727. * @param outputs Array to store the key frame data
  85728. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  85729. * @param useQuaternion Specifies if quaternions are used in the animation
  85730. */
  85731. private static _CreateLinearOrStepAnimation;
  85732. /**
  85733. * Creates cubic spline animation from the animation key frames
  85734. * @param babylonTransformNode BabylonJS mesh
  85735. * @param animation BabylonJS animation
  85736. * @param animationChannelTargetPath The target animation channel
  85737. * @param frameDelta The difference between the last and first frame of the animation
  85738. * @param inputs Array to store the key frame times
  85739. * @param outputs Array to store the key frame data
  85740. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  85741. * @param useQuaternion Specifies if quaternions are used in the animation
  85742. */
  85743. private static _CreateCubicSplineAnimation;
  85744. private static _GetBasePositionRotationOrScale;
  85745. /**
  85746. * Adds a key frame value
  85747. * @param keyFrame
  85748. * @param animation
  85749. * @param outputs
  85750. * @param animationChannelTargetPath
  85751. * @param basePositionRotationOrScale
  85752. * @param convertToRightHandedSystem
  85753. * @param useQuaternion
  85754. */
  85755. private static _AddKeyframeValue;
  85756. /**
  85757. * Determine the interpolation based on the key frames
  85758. * @param keyFrames
  85759. * @param animationChannelTargetPath
  85760. * @param useQuaternion
  85761. */
  85762. private static _DeduceInterpolation;
  85763. /**
  85764. * Adds an input tangent or output tangent to the output data
  85765. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  85766. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  85767. * @param outputs The animation data by keyframe
  85768. * @param animationChannelTargetPath The target animation channel
  85769. * @param interpolation The interpolation type
  85770. * @param keyFrame The key frame with the animation data
  85771. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  85772. * @param useQuaternion Specifies if quaternions are used
  85773. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  85774. */
  85775. private static AddSplineTangent;
  85776. /**
  85777. * Get the minimum and maximum key frames' frame values
  85778. * @param keyFrames animation key frames
  85779. * @returns the minimum and maximum key frame value
  85780. */
  85781. private static calculateMinMaxKeyFrames;
  85782. }
  85783. }
  85784. declare module BABYLON.GLTF2.Exporter {
  85785. /** @hidden */
  85786. export var textureTransformPixelShader: {
  85787. name: string;
  85788. shader: string;
  85789. };
  85790. }
  85791. declare module BABYLON.GLTF2.Exporter.Extensions {
  85792. /**
  85793. * @hidden
  85794. */
  85795. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  85796. private _recordedTextures;
  85797. /** Name of this extension */
  85798. readonly name: string;
  85799. /** Defines whether this extension is enabled */
  85800. enabled: boolean;
  85801. /** Defines whether this extension is required */
  85802. required: boolean;
  85803. /** Reference to the glTF exporter */
  85804. private _wasUsed;
  85805. constructor(exporter: _Exporter);
  85806. dispose(): void;
  85807. /** @hidden */
  85808. get wasUsed(): boolean;
  85809. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  85810. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  85811. /**
  85812. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  85813. * @param babylonTexture
  85814. * @param offset
  85815. * @param rotation
  85816. * @param scale
  85817. * @param scene
  85818. */
  85819. private _textureTransformTextureAsync;
  85820. }
  85821. }
  85822. declare module BABYLON.GLTF2.Exporter.Extensions {
  85823. /**
  85824. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  85825. */
  85826. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  85827. /** The name of this extension. */
  85828. readonly name: string;
  85829. /** Defines whether this extension is enabled. */
  85830. enabled: boolean;
  85831. /** Defines whether this extension is required */
  85832. required: boolean;
  85833. /** Reference to the glTF exporter */
  85834. private _exporter;
  85835. private _lights;
  85836. /** @hidden */
  85837. constructor(exporter: _Exporter);
  85838. /** @hidden */
  85839. dispose(): void;
  85840. /** @hidden */
  85841. get wasUsed(): boolean;
  85842. /** @hidden */
  85843. onExporting(): void;
  85844. /**
  85845. * Define this method to modify the default behavior when exporting a node
  85846. * @param context The context when exporting the node
  85847. * @param node glTF node
  85848. * @param babylonNode BabylonJS node
  85849. * @param nodeMap Node mapping of unique id to glTF node index
  85850. * @returns nullable INode promise
  85851. */
  85852. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  85853. [key: number]: number;
  85854. }): Promise<Nullable<INode>>;
  85855. }
  85856. }
  85857. declare module BABYLON.GLTF2.Exporter.Extensions {
  85858. /**
  85859. * @hidden
  85860. */
  85861. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  85862. /** Name of this extension */
  85863. readonly name: string;
  85864. /** Defines whether this extension is enabled */
  85865. enabled: boolean;
  85866. /** Defines whether this extension is required */
  85867. required: boolean;
  85868. /** Reference to the glTF exporter */
  85869. private _textureInfos;
  85870. private _exportedTextures;
  85871. private _wasUsed;
  85872. constructor(exporter: _Exporter);
  85873. dispose(): void;
  85874. /** @hidden */
  85875. get wasUsed(): boolean;
  85876. private _getTextureIndex;
  85877. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  85878. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  85879. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  85880. }
  85881. }
  85882. declare module BABYLON.GLTF2.Exporter.Extensions {
  85883. /**
  85884. * @hidden
  85885. */
  85886. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  85887. /** Name of this extension */
  85888. readonly name: string;
  85889. /** Defines whether this extension is enabled */
  85890. enabled: boolean;
  85891. /** Defines whether this extension is required */
  85892. required: boolean;
  85893. private _wasUsed;
  85894. constructor(exporter: _Exporter);
  85895. /** @hidden */
  85896. get wasUsed(): boolean;
  85897. dispose(): void;
  85898. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  85899. }
  85900. }
  85901. declare module BABYLON {
  85902. /**
  85903. * Class for generating STL data from a Babylon scene.
  85904. */
  85905. export class STLExport {
  85906. /**
  85907. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  85908. * @param meshes list defines the mesh to serialize
  85909. * @param download triggers the automatic download of the file.
  85910. * @param fileName changes the downloads fileName.
  85911. * @param binary changes the STL to a binary type.
  85912. * @param isLittleEndian toggle for binary type exporter.
  85913. * @param doNotBakeTransform toggle if meshes transforms should be baked or not.
  85914. * @returns the STL as UTF8 string
  85915. */
  85916. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean, doNotBakeTransform?: boolean): any;
  85917. }
  85918. }
  85919. declare module "babylonjs-gltf2interface" {
  85920. export = BABYLON.GLTF2;
  85921. }
  85922. /**
  85923. * Module for glTF 2.0 Interface
  85924. */
  85925. declare module BABYLON.GLTF2 {
  85926. /**
  85927. * The datatype of the components in the attribute
  85928. */
  85929. const enum AccessorComponentType {
  85930. /**
  85931. * Byte
  85932. */
  85933. BYTE = 5120,
  85934. /**
  85935. * Unsigned Byte
  85936. */
  85937. UNSIGNED_BYTE = 5121,
  85938. /**
  85939. * Short
  85940. */
  85941. SHORT = 5122,
  85942. /**
  85943. * Unsigned Short
  85944. */
  85945. UNSIGNED_SHORT = 5123,
  85946. /**
  85947. * Unsigned Int
  85948. */
  85949. UNSIGNED_INT = 5125,
  85950. /**
  85951. * Float
  85952. */
  85953. FLOAT = 5126,
  85954. }
  85955. /**
  85956. * Specifies if the attirbute is a scalar, vector, or matrix
  85957. */
  85958. const enum AccessorType {
  85959. /**
  85960. * Scalar
  85961. */
  85962. SCALAR = "SCALAR",
  85963. /**
  85964. * Vector2
  85965. */
  85966. VEC2 = "VEC2",
  85967. /**
  85968. * Vector3
  85969. */
  85970. VEC3 = "VEC3",
  85971. /**
  85972. * Vector4
  85973. */
  85974. VEC4 = "VEC4",
  85975. /**
  85976. * Matrix2x2
  85977. */
  85978. MAT2 = "MAT2",
  85979. /**
  85980. * Matrix3x3
  85981. */
  85982. MAT3 = "MAT3",
  85983. /**
  85984. * Matrix4x4
  85985. */
  85986. MAT4 = "MAT4",
  85987. }
  85988. /**
  85989. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  85990. */
  85991. const enum AnimationChannelTargetPath {
  85992. /**
  85993. * Translation
  85994. */
  85995. TRANSLATION = "translation",
  85996. /**
  85997. * Rotation
  85998. */
  85999. ROTATION = "rotation",
  86000. /**
  86001. * Scale
  86002. */
  86003. SCALE = "scale",
  86004. /**
  86005. * Weights
  86006. */
  86007. WEIGHTS = "weights",
  86008. }
  86009. /**
  86010. * Interpolation algorithm
  86011. */
  86012. const enum AnimationSamplerInterpolation {
  86013. /**
  86014. * The animated values are linearly interpolated between keyframes
  86015. */
  86016. LINEAR = "LINEAR",
  86017. /**
  86018. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  86019. */
  86020. STEP = "STEP",
  86021. /**
  86022. * The animation's interpolation is computed using a cubic spline with specified tangents
  86023. */
  86024. CUBICSPLINE = "CUBICSPLINE",
  86025. }
  86026. /**
  86027. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  86028. */
  86029. const enum CameraType {
  86030. /**
  86031. * A perspective camera containing properties to create a perspective projection matrix
  86032. */
  86033. PERSPECTIVE = "perspective",
  86034. /**
  86035. * An orthographic camera containing properties to create an orthographic projection matrix
  86036. */
  86037. ORTHOGRAPHIC = "orthographic",
  86038. }
  86039. /**
  86040. * The mime-type of the image
  86041. */
  86042. const enum ImageMimeType {
  86043. /**
  86044. * JPEG Mime-type
  86045. */
  86046. JPEG = "image/jpeg",
  86047. /**
  86048. * PNG Mime-type
  86049. */
  86050. PNG = "image/png",
  86051. }
  86052. /**
  86053. * The alpha rendering mode of the material
  86054. */
  86055. const enum MaterialAlphaMode {
  86056. /**
  86057. * The alpha value is ignored and the rendered output is fully opaque
  86058. */
  86059. OPAQUE = "OPAQUE",
  86060. /**
  86061. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  86062. */
  86063. MASK = "MASK",
  86064. /**
  86065. * 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)
  86066. */
  86067. BLEND = "BLEND",
  86068. }
  86069. /**
  86070. * The type of the primitives to render
  86071. */
  86072. const enum MeshPrimitiveMode {
  86073. /**
  86074. * Points
  86075. */
  86076. POINTS = 0,
  86077. /**
  86078. * Lines
  86079. */
  86080. LINES = 1,
  86081. /**
  86082. * Line Loop
  86083. */
  86084. LINE_LOOP = 2,
  86085. /**
  86086. * Line Strip
  86087. */
  86088. LINE_STRIP = 3,
  86089. /**
  86090. * Triangles
  86091. */
  86092. TRIANGLES = 4,
  86093. /**
  86094. * Triangle Strip
  86095. */
  86096. TRIANGLE_STRIP = 5,
  86097. /**
  86098. * Triangle Fan
  86099. */
  86100. TRIANGLE_FAN = 6,
  86101. }
  86102. /**
  86103. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  86104. */
  86105. const enum TextureMagFilter {
  86106. /**
  86107. * Nearest
  86108. */
  86109. NEAREST = 9728,
  86110. /**
  86111. * Linear
  86112. */
  86113. LINEAR = 9729,
  86114. }
  86115. /**
  86116. * Minification filter. All valid values correspond to WebGL enums
  86117. */
  86118. const enum TextureMinFilter {
  86119. /**
  86120. * Nearest
  86121. */
  86122. NEAREST = 9728,
  86123. /**
  86124. * Linear
  86125. */
  86126. LINEAR = 9729,
  86127. /**
  86128. * Nearest Mip-Map Nearest
  86129. */
  86130. NEAREST_MIPMAP_NEAREST = 9984,
  86131. /**
  86132. * Linear Mipmap Nearest
  86133. */
  86134. LINEAR_MIPMAP_NEAREST = 9985,
  86135. /**
  86136. * Nearest Mipmap Linear
  86137. */
  86138. NEAREST_MIPMAP_LINEAR = 9986,
  86139. /**
  86140. * Linear Mipmap Linear
  86141. */
  86142. LINEAR_MIPMAP_LINEAR = 9987,
  86143. }
  86144. /**
  86145. * S (U) wrapping mode. All valid values correspond to WebGL enums
  86146. */
  86147. const enum TextureWrapMode {
  86148. /**
  86149. * Clamp to Edge
  86150. */
  86151. CLAMP_TO_EDGE = 33071,
  86152. /**
  86153. * Mirrored Repeat
  86154. */
  86155. MIRRORED_REPEAT = 33648,
  86156. /**
  86157. * Repeat
  86158. */
  86159. REPEAT = 10497,
  86160. }
  86161. /**
  86162. * glTF Property
  86163. */
  86164. interface IProperty {
  86165. /**
  86166. * Dictionary object with extension-specific objects
  86167. */
  86168. extensions?: {
  86169. [key: string]: any;
  86170. };
  86171. /**
  86172. * Application-Specific data
  86173. */
  86174. extras?: any;
  86175. }
  86176. /**
  86177. * glTF Child of Root Property
  86178. */
  86179. interface IChildRootProperty extends IProperty {
  86180. /**
  86181. * The user-defined name of this object
  86182. */
  86183. name?: string;
  86184. }
  86185. /**
  86186. * Indices of those attributes that deviate from their initialization value
  86187. */
  86188. interface IAccessorSparseIndices extends IProperty {
  86189. /**
  86190. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  86191. */
  86192. bufferView: number;
  86193. /**
  86194. * The offset relative to the start of the bufferView in bytes. Must be aligned
  86195. */
  86196. byteOffset?: number;
  86197. /**
  86198. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  86199. */
  86200. componentType: AccessorComponentType;
  86201. }
  86202. /**
  86203. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  86204. */
  86205. interface IAccessorSparseValues extends IProperty {
  86206. /**
  86207. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  86208. */
  86209. bufferView: number;
  86210. /**
  86211. * The offset relative to the start of the bufferView in bytes. Must be aligned
  86212. */
  86213. byteOffset?: number;
  86214. }
  86215. /**
  86216. * Sparse storage of attributes that deviate from their initialization value
  86217. */
  86218. interface IAccessorSparse extends IProperty {
  86219. /**
  86220. * The number of attributes encoded in this sparse accessor
  86221. */
  86222. count: number;
  86223. /**
  86224. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  86225. */
  86226. indices: IAccessorSparseIndices;
  86227. /**
  86228. * 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
  86229. */
  86230. values: IAccessorSparseValues;
  86231. }
  86232. /**
  86233. * 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
  86234. */
  86235. interface IAccessor extends IChildRootProperty {
  86236. /**
  86237. * The index of the bufferview
  86238. */
  86239. bufferView?: number;
  86240. /**
  86241. * The offset relative to the start of the bufferView in bytes
  86242. */
  86243. byteOffset?: number;
  86244. /**
  86245. * The datatype of components in the attribute
  86246. */
  86247. componentType: AccessorComponentType;
  86248. /**
  86249. * Specifies whether integer data values should be normalized
  86250. */
  86251. normalized?: boolean;
  86252. /**
  86253. * The number of attributes referenced by this accessor
  86254. */
  86255. count: number;
  86256. /**
  86257. * Specifies if the attribute is a scalar, vector, or matrix
  86258. */
  86259. type: AccessorType;
  86260. /**
  86261. * Maximum value of each component in this attribute
  86262. */
  86263. max?: number[];
  86264. /**
  86265. * Minimum value of each component in this attribute
  86266. */
  86267. min?: number[];
  86268. /**
  86269. * Sparse storage of attributes that deviate from their initialization value
  86270. */
  86271. sparse?: IAccessorSparse;
  86272. }
  86273. /**
  86274. * Targets an animation's sampler at a node's property
  86275. */
  86276. interface IAnimationChannel extends IProperty {
  86277. /**
  86278. * The index of a sampler in this animation used to compute the value for the target
  86279. */
  86280. sampler: number;
  86281. /**
  86282. * The index of the node and TRS property to target
  86283. */
  86284. target: IAnimationChannelTarget;
  86285. }
  86286. /**
  86287. * The index of the node and TRS property that an animation channel targets
  86288. */
  86289. interface IAnimationChannelTarget extends IProperty {
  86290. /**
  86291. * The index of the node to target
  86292. */
  86293. node: number;
  86294. /**
  86295. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  86296. */
  86297. path: AnimationChannelTargetPath;
  86298. }
  86299. /**
  86300. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  86301. */
  86302. interface IAnimationSampler extends IProperty {
  86303. /**
  86304. * The index of an accessor containing keyframe input values, e.g., time
  86305. */
  86306. input: number;
  86307. /**
  86308. * Interpolation algorithm
  86309. */
  86310. interpolation?: AnimationSamplerInterpolation;
  86311. /**
  86312. * The index of an accessor, containing keyframe output values
  86313. */
  86314. output: number;
  86315. }
  86316. /**
  86317. * A keyframe animation
  86318. */
  86319. interface IAnimation extends IChildRootProperty {
  86320. /**
  86321. * An array of channels, each of which targets an animation's sampler at a node's property
  86322. */
  86323. channels: IAnimationChannel[];
  86324. /**
  86325. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  86326. */
  86327. samplers: IAnimationSampler[];
  86328. }
  86329. /**
  86330. * Metadata about the glTF asset
  86331. */
  86332. interface IAsset extends IChildRootProperty {
  86333. /**
  86334. * A copyright message suitable for display to credit the content creator
  86335. */
  86336. copyright?: string;
  86337. /**
  86338. * Tool that generated this glTF model. Useful for debugging
  86339. */
  86340. generator?: string;
  86341. /**
  86342. * The glTF version that this asset targets
  86343. */
  86344. version: string;
  86345. /**
  86346. * The minimum glTF version that this asset targets
  86347. */
  86348. minVersion?: string;
  86349. }
  86350. /**
  86351. * A buffer points to binary geometry, animation, or skins
  86352. */
  86353. interface IBuffer extends IChildRootProperty {
  86354. /**
  86355. * 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
  86356. */
  86357. uri?: string;
  86358. /**
  86359. * The length of the buffer in bytes
  86360. */
  86361. byteLength: number;
  86362. }
  86363. /**
  86364. * A view into a buffer generally representing a subset of the buffer
  86365. */
  86366. interface IBufferView extends IChildRootProperty {
  86367. /**
  86368. * The index of the buffer
  86369. */
  86370. buffer: number;
  86371. /**
  86372. * The offset into the buffer in bytes
  86373. */
  86374. byteOffset?: number;
  86375. /**
  86376. * The lenth of the bufferView in bytes
  86377. */
  86378. byteLength: number;
  86379. /**
  86380. * The stride, in bytes
  86381. */
  86382. byteStride?: number;
  86383. }
  86384. /**
  86385. * An orthographic camera containing properties to create an orthographic projection matrix
  86386. */
  86387. interface ICameraOrthographic extends IProperty {
  86388. /**
  86389. * The floating-point horizontal magnification of the view. Must not be zero
  86390. */
  86391. xmag: number;
  86392. /**
  86393. * The floating-point vertical magnification of the view. Must not be zero
  86394. */
  86395. ymag: number;
  86396. /**
  86397. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  86398. */
  86399. zfar: number;
  86400. /**
  86401. * The floating-point distance to the near clipping plane
  86402. */
  86403. znear: number;
  86404. }
  86405. /**
  86406. * A perspective camera containing properties to create a perspective projection matrix
  86407. */
  86408. interface ICameraPerspective extends IProperty {
  86409. /**
  86410. * The floating-point aspect ratio of the field of view
  86411. */
  86412. aspectRatio?: number;
  86413. /**
  86414. * The floating-point vertical field of view in radians
  86415. */
  86416. yfov: number;
  86417. /**
  86418. * The floating-point distance to the far clipping plane
  86419. */
  86420. zfar?: number;
  86421. /**
  86422. * The floating-point distance to the near clipping plane
  86423. */
  86424. znear: number;
  86425. }
  86426. /**
  86427. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  86428. */
  86429. interface ICamera extends IChildRootProperty {
  86430. /**
  86431. * An orthographic camera containing properties to create an orthographic projection matrix
  86432. */
  86433. orthographic?: ICameraOrthographic;
  86434. /**
  86435. * A perspective camera containing properties to create a perspective projection matrix
  86436. */
  86437. perspective?: ICameraPerspective;
  86438. /**
  86439. * Specifies if the camera uses a perspective or orthographic projection
  86440. */
  86441. type: CameraType;
  86442. }
  86443. /**
  86444. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  86445. */
  86446. interface IImage extends IChildRootProperty {
  86447. /**
  86448. * 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
  86449. */
  86450. uri?: string;
  86451. /**
  86452. * The image's MIME type
  86453. */
  86454. mimeType?: ImageMimeType;
  86455. /**
  86456. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  86457. */
  86458. bufferView?: number;
  86459. }
  86460. /**
  86461. * Material Normal Texture Info
  86462. */
  86463. interface IMaterialNormalTextureInfo extends ITextureInfo {
  86464. /**
  86465. * The scalar multiplier applied to each normal vector of the normal texture
  86466. */
  86467. scale?: number;
  86468. }
  86469. /**
  86470. * Material Occlusion Texture Info
  86471. */
  86472. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  86473. /**
  86474. * A scalar multiplier controlling the amount of occlusion applied
  86475. */
  86476. strength?: number;
  86477. }
  86478. /**
  86479. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  86480. */
  86481. interface IMaterialPbrMetallicRoughness {
  86482. /**
  86483. * The material's base color factor
  86484. */
  86485. baseColorFactor?: number[];
  86486. /**
  86487. * The base color texture
  86488. */
  86489. baseColorTexture?: ITextureInfo;
  86490. /**
  86491. * The metalness of the material
  86492. */
  86493. metallicFactor?: number;
  86494. /**
  86495. * The roughness of the material
  86496. */
  86497. roughnessFactor?: number;
  86498. /**
  86499. * The metallic-roughness texture
  86500. */
  86501. metallicRoughnessTexture?: ITextureInfo;
  86502. }
  86503. /**
  86504. * The material appearance of a primitive
  86505. */
  86506. interface IMaterial extends IChildRootProperty {
  86507. /**
  86508. * 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
  86509. */
  86510. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  86511. /**
  86512. * The normal map texture
  86513. */
  86514. normalTexture?: IMaterialNormalTextureInfo;
  86515. /**
  86516. * The occlusion map texture
  86517. */
  86518. occlusionTexture?: IMaterialOcclusionTextureInfo;
  86519. /**
  86520. * The emissive map texture
  86521. */
  86522. emissiveTexture?: ITextureInfo;
  86523. /**
  86524. * 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
  86525. */
  86526. emissiveFactor?: number[];
  86527. /**
  86528. * The alpha rendering mode of the material
  86529. */
  86530. alphaMode?: MaterialAlphaMode;
  86531. /**
  86532. * The alpha cutoff value of the material
  86533. */
  86534. alphaCutoff?: number;
  86535. /**
  86536. * Specifies whether the material is double sided
  86537. */
  86538. doubleSided?: boolean;
  86539. }
  86540. /**
  86541. * Geometry to be rendered with the given material
  86542. */
  86543. interface IMeshPrimitive extends IProperty {
  86544. /**
  86545. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  86546. */
  86547. attributes: {
  86548. [name: string]: number;
  86549. };
  86550. /**
  86551. * The index of the accessor that contains the indices
  86552. */
  86553. indices?: number;
  86554. /**
  86555. * The index of the material to apply to this primitive when rendering
  86556. */
  86557. material?: number;
  86558. /**
  86559. * The type of primitives to render. All valid values correspond to WebGL enums
  86560. */
  86561. mode?: MeshPrimitiveMode;
  86562. /**
  86563. * 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
  86564. */
  86565. targets?: {
  86566. [name: string]: number;
  86567. }[];
  86568. }
  86569. /**
  86570. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  86571. */
  86572. interface IMesh extends IChildRootProperty {
  86573. /**
  86574. * An array of primitives, each defining geometry to be rendered with a material
  86575. */
  86576. primitives: IMeshPrimitive[];
  86577. /**
  86578. * Array of weights to be applied to the Morph Targets
  86579. */
  86580. weights?: number[];
  86581. }
  86582. /**
  86583. * A node in the node hierarchy
  86584. */
  86585. interface INode extends IChildRootProperty {
  86586. /**
  86587. * The index of the camera referenced by this node
  86588. */
  86589. camera?: number;
  86590. /**
  86591. * The indices of this node's children
  86592. */
  86593. children?: number[];
  86594. /**
  86595. * The index of the skin referenced by this node
  86596. */
  86597. skin?: number;
  86598. /**
  86599. * A floating-point 4x4 transformation matrix stored in column-major order
  86600. */
  86601. matrix?: number[];
  86602. /**
  86603. * The index of the mesh in this node
  86604. */
  86605. mesh?: number;
  86606. /**
  86607. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  86608. */
  86609. rotation?: number[];
  86610. /**
  86611. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  86612. */
  86613. scale?: number[];
  86614. /**
  86615. * The node's translation along the x, y, and z axes
  86616. */
  86617. translation?: number[];
  86618. /**
  86619. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  86620. */
  86621. weights?: number[];
  86622. }
  86623. /**
  86624. * Texture sampler properties for filtering and wrapping modes
  86625. */
  86626. interface ISampler extends IChildRootProperty {
  86627. /**
  86628. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  86629. */
  86630. magFilter?: TextureMagFilter;
  86631. /**
  86632. * Minification filter. All valid values correspond to WebGL enums
  86633. */
  86634. minFilter?: TextureMinFilter;
  86635. /**
  86636. * S (U) wrapping mode. All valid values correspond to WebGL enums
  86637. */
  86638. wrapS?: TextureWrapMode;
  86639. /**
  86640. * T (V) wrapping mode. All valid values correspond to WebGL enums
  86641. */
  86642. wrapT?: TextureWrapMode;
  86643. }
  86644. /**
  86645. * The root nodes of a scene
  86646. */
  86647. interface IScene extends IChildRootProperty {
  86648. /**
  86649. * The indices of each root node
  86650. */
  86651. nodes: number[];
  86652. }
  86653. /**
  86654. * Joints and matrices defining a skin
  86655. */
  86656. interface ISkin extends IChildRootProperty {
  86657. /**
  86658. * 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
  86659. */
  86660. inverseBindMatrices?: number;
  86661. /**
  86662. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  86663. */
  86664. skeleton?: number;
  86665. /**
  86666. * 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)
  86667. */
  86668. joints: number[];
  86669. }
  86670. /**
  86671. * A texture and its sampler
  86672. */
  86673. interface ITexture extends IChildRootProperty {
  86674. /**
  86675. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  86676. */
  86677. sampler?: number;
  86678. /**
  86679. * The index of the image used by this texture
  86680. */
  86681. source: number;
  86682. }
  86683. /**
  86684. * Reference to a texture
  86685. */
  86686. interface ITextureInfo extends IProperty {
  86687. /**
  86688. * The index of the texture
  86689. */
  86690. index: number;
  86691. /**
  86692. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  86693. */
  86694. texCoord?: number;
  86695. }
  86696. /**
  86697. * The root object for a glTF asset
  86698. */
  86699. interface IGLTF extends IProperty {
  86700. /**
  86701. * An array of accessors. An accessor is a typed view into a bufferView
  86702. */
  86703. accessors?: IAccessor[];
  86704. /**
  86705. * An array of keyframe animations
  86706. */
  86707. animations?: IAnimation[];
  86708. /**
  86709. * Metadata about the glTF asset
  86710. */
  86711. asset: IAsset;
  86712. /**
  86713. * An array of buffers. A buffer points to binary geometry, animation, or skins
  86714. */
  86715. buffers?: IBuffer[];
  86716. /**
  86717. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  86718. */
  86719. bufferViews?: IBufferView[];
  86720. /**
  86721. * An array of cameras
  86722. */
  86723. cameras?: ICamera[];
  86724. /**
  86725. * Names of glTF extensions used somewhere in this asset
  86726. */
  86727. extensionsUsed?: string[];
  86728. /**
  86729. * Names of glTF extensions required to properly load this asset
  86730. */
  86731. extensionsRequired?: string[];
  86732. /**
  86733. * An array of images. An image defines data used to create a texture
  86734. */
  86735. images?: IImage[];
  86736. /**
  86737. * An array of materials. A material defines the appearance of a primitive
  86738. */
  86739. materials?: IMaterial[];
  86740. /**
  86741. * An array of meshes. A mesh is a set of primitives to be rendered
  86742. */
  86743. meshes?: IMesh[];
  86744. /**
  86745. * An array of nodes
  86746. */
  86747. nodes?: INode[];
  86748. /**
  86749. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  86750. */
  86751. samplers?: ISampler[];
  86752. /**
  86753. * The index of the default scene
  86754. */
  86755. scene?: number;
  86756. /**
  86757. * An array of scenes
  86758. */
  86759. scenes?: IScene[];
  86760. /**
  86761. * An array of skins. A skin is defined by joints and matrices
  86762. */
  86763. skins?: ISkin[];
  86764. /**
  86765. * An array of textures
  86766. */
  86767. textures?: ITexture[];
  86768. }
  86769. /**
  86770. * The glTF validation results
  86771. * @ignore
  86772. */
  86773. interface IGLTFValidationResults {
  86774. info: {
  86775. generator: string;
  86776. hasAnimations: boolean;
  86777. hasDefaultScene: boolean;
  86778. hasMaterials: boolean;
  86779. hasMorphTargets: boolean;
  86780. hasSkins: boolean;
  86781. hasTextures: boolean;
  86782. maxAttributesUsed: number;
  86783. primitivesCount: number
  86784. };
  86785. issues: {
  86786. messages: Array<string>;
  86787. numErrors: number;
  86788. numHints: number;
  86789. numInfos: number;
  86790. numWarnings: number;
  86791. truncated: boolean
  86792. };
  86793. mimeType: string;
  86794. uri: string;
  86795. validatedAt: string;
  86796. validatorVersion: string;
  86797. }
  86798. /**
  86799. * The glTF validation options
  86800. */
  86801. interface IGLTFValidationOptions {
  86802. /** Uri to use */
  86803. uri?: string;
  86804. /** Function used to load external resources */
  86805. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  86806. /** Boolean indicating that we need to validate accessor data */
  86807. validateAccessorData?: boolean;
  86808. /** max number of issues allowed */
  86809. maxIssues?: number;
  86810. /** Ignored issues */
  86811. ignoredIssues?: Array<string>;
  86812. /** Value to override severy settings */
  86813. severityOverrides?: Object;
  86814. }
  86815. /**
  86816. * The glTF validator object
  86817. * @ignore
  86818. */
  86819. interface IGLTFValidator {
  86820. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  86821. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  86822. }
  86823. /**
  86824. * Interfaces from the EXT_lights_image_based extension
  86825. */
  86826. /** @hidden */
  86827. interface IEXTLightsImageBased_LightReferenceImageBased {
  86828. light: number;
  86829. }
  86830. /** @hidden */
  86831. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  86832. intensity: number;
  86833. rotation: number[];
  86834. specularImageSize: number;
  86835. specularImages: number[][];
  86836. irradianceCoefficients: number[][];
  86837. }
  86838. /** @hidden */
  86839. interface IEXTLightsImageBased {
  86840. lights: IEXTLightsImageBased_LightImageBased[];
  86841. }
  86842. /**
  86843. * Interfaces from the EXT_mesh_gpu_instancing extension
  86844. * !!! Experimental Extension Subject to Changes !!!
  86845. */
  86846. /** @hidden */
  86847. interface IEXTMeshGpuInstancing {
  86848. mesh?: number;
  86849. attributes: { [name: string]: number };
  86850. }
  86851. /**
  86852. * Interfaces from the KHR_draco_mesh_compression extension
  86853. */
  86854. /** @hidden */
  86855. interface IKHRDracoMeshCompression {
  86856. bufferView: number;
  86857. attributes: { [name: string]: number };
  86858. }
  86859. /**
  86860. * Interfaces from the KHR_lights_punctual extension
  86861. */
  86862. /** @hidden */
  86863. const enum IKHRLightsPunctual_LightType {
  86864. DIRECTIONAL = "directional",
  86865. POINT = "point",
  86866. SPOT = "spot"
  86867. }
  86868. /** @hidden */
  86869. interface IKHRLightsPunctual_LightReference {
  86870. light: number;
  86871. }
  86872. /** @hidden */
  86873. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  86874. type: IKHRLightsPunctual_LightType;
  86875. color?: number[];
  86876. intensity?: number;
  86877. range?: number;
  86878. spot?: {
  86879. innerConeAngle?: number;
  86880. outerConeAngle?: number;
  86881. };
  86882. }
  86883. /** @hidden */
  86884. interface IKHRLightsPunctual {
  86885. lights: IKHRLightsPunctual_Light[];
  86886. }
  86887. /**
  86888. * Interfaces from the KHR_materials_clearcoat extension
  86889. * !!! Experimental Extension Subject to Changes !!!
  86890. */
  86891. /** @hidden */
  86892. interface IKHRMaterialsClearcoat {
  86893. clearcoatFactor: number;
  86894. clearcoatTexture: ITextureInfo;
  86895. clearcoatRoughnessFactor: number;
  86896. clearcoatRoughnessTexture: ITextureInfo;
  86897. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  86898. }
  86899. /**
  86900. * Interfaces from the KHR_materials_ior extension
  86901. * !!! Experimental Extension Subject to Changes !!!
  86902. */
  86903. /** @hidden */
  86904. interface IKHRMaterialsIor {
  86905. ior: number;
  86906. }
  86907. /**
  86908. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  86909. */
  86910. /** @hidden */
  86911. interface IKHRMaterialsPbrSpecularGlossiness {
  86912. diffuseFactor: number[];
  86913. diffuseTexture: ITextureInfo;
  86914. specularFactor: number[];
  86915. glossinessFactor: number;
  86916. specularGlossinessTexture: ITextureInfo;
  86917. }
  86918. /**
  86919. * Interfaces from the KHR_materials_sheen extension
  86920. * !!! Experimental Extension Subject to Changes !!!
  86921. */
  86922. /** @hidden */
  86923. interface IKHRMaterialsSheen {
  86924. sheenColorFactor?: number[];
  86925. sheenColorTexture?: ITextureInfo;
  86926. sheenRoughnessFactor?: number;
  86927. sheenRoughnessTexture?: ITextureInfo;
  86928. }
  86929. /**
  86930. * Interfaces from the KHR_materials_specular extension
  86931. * !!! Experimental Extension Subject to Changes !!!
  86932. */
  86933. /** @hidden */
  86934. interface IKHRMaterialsSpecular {
  86935. specularFactor: number;
  86936. specularColorFactor: number[];
  86937. specularTexture: ITextureInfo;
  86938. }
  86939. /**
  86940. * Interfaces from the KHR_materials_transmission extension
  86941. * !!! Experimental Extension Subject to Changes !!!
  86942. */
  86943. /** @hidden */
  86944. interface IKHRMaterialsTransmission {
  86945. transmissionFactor?: number;
  86946. transmissionTexture?: ITextureInfo;
  86947. }
  86948. /**
  86949. * Interfaces from the KHR_materials_translucency extension
  86950. * !!! Experimental Extension Subject to Changes !!!
  86951. */
  86952. /** @hidden */
  86953. interface IKHRMaterialsTranslucency {
  86954. translucencyFactor?: number;
  86955. translucencyTexture?: ITextureInfo;
  86956. }
  86957. /**
  86958. * Interfaces from the KHR_materials_variants extension
  86959. * !!! Experimental Extension Subject to Changes !!!
  86960. */
  86961. /** @hidden */
  86962. interface IKHRMaterialVariants_Mapping extends IProperty {
  86963. mappings: Array<{
  86964. variants: number[];
  86965. material: number;
  86966. }>;
  86967. }
  86968. /** @hidden */
  86969. interface IKHRMaterialVariants_Variant extends IProperty {
  86970. name: string;
  86971. }
  86972. /** @hidden */
  86973. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  86974. variants: Array<IKHRMaterialVariants_Variant>;
  86975. }
  86976. /**
  86977. * Interfaces from the KHR_texture_basisu extension
  86978. * !!! Experimental Extension Subject to Changes !!!
  86979. */
  86980. /** @hidden */
  86981. interface IKHRTextureBasisU {
  86982. source: number;
  86983. }
  86984. /**
  86985. * Interfaces from the EXT_texture_webp extension
  86986. */
  86987. /** @hidden */
  86988. interface IEXTTextureWebP {
  86989. source: number;
  86990. }
  86991. /**
  86992. * Interfaces from the KHR_texture_transform extension
  86993. */
  86994. /** @hidden */
  86995. interface IKHRTextureTransform {
  86996. offset?: number[];
  86997. rotation?: number;
  86998. scale?: number[];
  86999. texCoord?: number;
  87000. }
  87001. /**
  87002. * Interfaces from the KHR_xmp extension
  87003. * !!! Experimental Extension Subject to Changes !!!
  87004. */
  87005. /** @hidden */
  87006. interface IKHRXmp_Data {
  87007. [key: string]: unknown;
  87008. }
  87009. /** @hidden */
  87010. interface IKHRXmp_Gltf {
  87011. packets: IKHRXmp_Data[];
  87012. }
  87013. /** @hidden */
  87014. interface IKHRXmp_Node {
  87015. packet: number;
  87016. }
  87017. /**
  87018. * Interfaces from the MSFT_audio_emitter extension
  87019. */
  87020. /** @hidden */
  87021. interface IMSFTAudioEmitter_ClipReference {
  87022. clip: number;
  87023. weight?: number;
  87024. }
  87025. /** @hidden */
  87026. interface IMSFTAudioEmitter_EmittersReference {
  87027. emitters: number[];
  87028. }
  87029. /** @hidden */
  87030. const enum IMSFTAudioEmitter_DistanceModel {
  87031. linear = "linear",
  87032. inverse = "inverse",
  87033. exponential = "exponential",
  87034. }
  87035. /** @hidden */
  87036. interface IMSFTAudioEmitter_Emitter {
  87037. name?: string;
  87038. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  87039. refDistance?: number;
  87040. maxDistance?: number;
  87041. rolloffFactor?: number;
  87042. innerAngle?: number;
  87043. outerAngle?: number;
  87044. loop?: boolean;
  87045. volume?: number;
  87046. clips: IMSFTAudioEmitter_ClipReference[];
  87047. }
  87048. /** @hidden */
  87049. const enum IMSFTAudioEmitter_AudioMimeType {
  87050. WAV = "audio/wav",
  87051. }
  87052. /** @hidden */
  87053. interface IMSFTAudioEmitter_Clip extends IProperty {
  87054. uri?: string;
  87055. bufferView?: number;
  87056. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  87057. }
  87058. /** @hidden */
  87059. const enum IMSFTAudioEmitter_AnimationEventAction {
  87060. play = "play",
  87061. pause = "pause",
  87062. stop = "stop",
  87063. }
  87064. /** @hidden */
  87065. interface IMSFTAudioEmitter_AnimationEvent {
  87066. action: IMSFTAudioEmitter_AnimationEventAction;
  87067. emitter: number;
  87068. time: number;
  87069. startOffset?: number;
  87070. }
  87071. /**
  87072. * Interfaces from the MSFT_lod extension
  87073. */
  87074. /** @hidden */
  87075. interface IMSFTLOD {
  87076. ids: number[];
  87077. }
  87078. }
  87079. declare module BABYLON {
  87080. /** @hidden */
  87081. export var cellPixelShader: {
  87082. name: string;
  87083. shader: string;
  87084. };
  87085. }
  87086. declare module BABYLON {
  87087. /** @hidden */
  87088. export var cellVertexShader: {
  87089. name: string;
  87090. shader: string;
  87091. };
  87092. }
  87093. declare module BABYLON {
  87094. export class CellMaterial extends BABYLON.PushMaterial {
  87095. private _diffuseTexture;
  87096. diffuseTexture: BABYLON.BaseTexture;
  87097. diffuseColor: BABYLON.Color3;
  87098. _computeHighLevel: boolean;
  87099. computeHighLevel: boolean;
  87100. private _disableLighting;
  87101. disableLighting: boolean;
  87102. private _maxSimultaneousLights;
  87103. maxSimultaneousLights: number;
  87104. constructor(name: string, scene: BABYLON.Scene);
  87105. needAlphaBlending(): boolean;
  87106. needAlphaTesting(): boolean;
  87107. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87108. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87109. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87110. getAnimatables(): BABYLON.IAnimatable[];
  87111. getActiveTextures(): BABYLON.BaseTexture[];
  87112. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87113. dispose(forceDisposeEffect?: boolean): void;
  87114. getClassName(): string;
  87115. clone(name: string): CellMaterial;
  87116. serialize(): any;
  87117. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  87118. }
  87119. }
  87120. declare module BABYLON {
  87121. export class CustomShaderStructure {
  87122. FragmentStore: string;
  87123. VertexStore: string;
  87124. constructor();
  87125. }
  87126. export class ShaderSpecialParts {
  87127. constructor();
  87128. Fragment_Begin: string;
  87129. Fragment_Definitions: string;
  87130. Fragment_MainBegin: string;
  87131. Fragment_Custom_Diffuse: string;
  87132. Fragment_Before_Lights: string;
  87133. Fragment_Before_Fog: string;
  87134. Fragment_Custom_Alpha: string;
  87135. Fragment_Before_FragColor: string;
  87136. Vertex_Begin: string;
  87137. Vertex_Definitions: string;
  87138. Vertex_MainBegin: string;
  87139. Vertex_Before_PositionUpdated: string;
  87140. Vertex_Before_NormalUpdated: string;
  87141. Vertex_After_WorldPosComputed: string;
  87142. Vertex_MainEnd: string;
  87143. }
  87144. export class CustomMaterial extends BABYLON.StandardMaterial {
  87145. static ShaderIndexer: number;
  87146. CustomParts: ShaderSpecialParts;
  87147. _isCreatedShader: boolean;
  87148. _createdShaderName: string;
  87149. _customUniform: string[];
  87150. _newUniforms: string[];
  87151. _newUniformInstances: {
  87152. [name: string]: any;
  87153. };
  87154. _newSamplerInstances: {
  87155. [name: string]: BABYLON.Texture;
  87156. };
  87157. _customAttributes: string[];
  87158. FragmentShader: string;
  87159. VertexShader: string;
  87160. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  87161. ReviewUniform(name: string, arr: string[]): string[];
  87162. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  87163. constructor(name: string, scene: BABYLON.Scene);
  87164. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  87165. AddAttribute(name: string): CustomMaterial;
  87166. Fragment_Begin(shaderPart: string): CustomMaterial;
  87167. Fragment_Definitions(shaderPart: string): CustomMaterial;
  87168. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  87169. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  87170. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  87171. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  87172. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  87173. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  87174. Vertex_Begin(shaderPart: string): CustomMaterial;
  87175. Vertex_Definitions(shaderPart: string): CustomMaterial;
  87176. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  87177. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  87178. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  87179. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  87180. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  87181. }
  87182. }
  87183. declare module BABYLON {
  87184. export class ShaderAlebdoParts {
  87185. constructor();
  87186. Fragment_Begin: string;
  87187. Fragment_Definitions: string;
  87188. Fragment_MainBegin: string;
  87189. Fragment_Custom_Albedo: string;
  87190. Fragment_Before_Lights: string;
  87191. Fragment_Custom_MetallicRoughness: string;
  87192. Fragment_Custom_MicroSurface: string;
  87193. Fragment_Before_Fog: string;
  87194. Fragment_Custom_Alpha: string;
  87195. Fragment_Before_FragColor: string;
  87196. Vertex_Begin: string;
  87197. Vertex_Definitions: string;
  87198. Vertex_MainBegin: string;
  87199. Vertex_Before_PositionUpdated: string;
  87200. Vertex_Before_NormalUpdated: string;
  87201. Vertex_After_WorldPosComputed: string;
  87202. Vertex_MainEnd: string;
  87203. }
  87204. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  87205. static ShaderIndexer: number;
  87206. CustomParts: ShaderAlebdoParts;
  87207. _isCreatedShader: boolean;
  87208. _createdShaderName: string;
  87209. _customUniform: string[];
  87210. _newUniforms: string[];
  87211. _newUniformInstances: {
  87212. [name: string]: any;
  87213. };
  87214. _newSamplerInstances: {
  87215. [name: string]: BABYLON.Texture;
  87216. };
  87217. _customAttributes: string[];
  87218. FragmentShader: string;
  87219. VertexShader: string;
  87220. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  87221. ReviewUniform(name: string, arr: string[]): string[];
  87222. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  87223. constructor(name: string, scene: BABYLON.Scene);
  87224. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  87225. AddAttribute(name: string): PBRCustomMaterial;
  87226. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  87227. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  87228. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  87229. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  87230. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  87231. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  87232. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  87233. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  87234. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  87235. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  87236. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  87237. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  87238. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  87239. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  87240. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  87241. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  87242. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  87243. }
  87244. }
  87245. declare module BABYLON {
  87246. /** @hidden */
  87247. export var firePixelShader: {
  87248. name: string;
  87249. shader: string;
  87250. };
  87251. }
  87252. declare module BABYLON {
  87253. /** @hidden */
  87254. export var fireVertexShader: {
  87255. name: string;
  87256. shader: string;
  87257. };
  87258. }
  87259. declare module BABYLON {
  87260. export class FireMaterial extends BABYLON.PushMaterial {
  87261. private _diffuseTexture;
  87262. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  87263. private _distortionTexture;
  87264. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  87265. private _opacityTexture;
  87266. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  87267. diffuseColor: BABYLON.Color3;
  87268. speed: number;
  87269. private _scaledDiffuse;
  87270. private _lastTime;
  87271. constructor(name: string, scene: BABYLON.Scene);
  87272. needAlphaBlending(): boolean;
  87273. needAlphaTesting(): boolean;
  87274. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87275. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87276. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87277. getAnimatables(): BABYLON.IAnimatable[];
  87278. getActiveTextures(): BABYLON.BaseTexture[];
  87279. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87280. getClassName(): string;
  87281. dispose(forceDisposeEffect?: boolean): void;
  87282. clone(name: string): FireMaterial;
  87283. serialize(): any;
  87284. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  87285. }
  87286. }
  87287. declare module BABYLON {
  87288. /** @hidden */
  87289. export var furPixelShader: {
  87290. name: string;
  87291. shader: string;
  87292. };
  87293. }
  87294. declare module BABYLON {
  87295. /** @hidden */
  87296. export var furVertexShader: {
  87297. name: string;
  87298. shader: string;
  87299. };
  87300. }
  87301. declare module BABYLON {
  87302. export class FurMaterial extends BABYLON.PushMaterial {
  87303. private _diffuseTexture;
  87304. diffuseTexture: BABYLON.BaseTexture;
  87305. private _heightTexture;
  87306. heightTexture: BABYLON.BaseTexture;
  87307. diffuseColor: BABYLON.Color3;
  87308. furLength: number;
  87309. furAngle: number;
  87310. furColor: BABYLON.Color3;
  87311. furOffset: number;
  87312. furSpacing: number;
  87313. furGravity: BABYLON.Vector3;
  87314. furSpeed: number;
  87315. furDensity: number;
  87316. furOcclusion: number;
  87317. furTexture: BABYLON.DynamicTexture;
  87318. private _disableLighting;
  87319. disableLighting: boolean;
  87320. private _maxSimultaneousLights;
  87321. maxSimultaneousLights: number;
  87322. highLevelFur: boolean;
  87323. _meshes: BABYLON.AbstractMesh[];
  87324. private _furTime;
  87325. constructor(name: string, scene: BABYLON.Scene);
  87326. get furTime(): number;
  87327. set furTime(furTime: number);
  87328. needAlphaBlending(): boolean;
  87329. needAlphaTesting(): boolean;
  87330. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87331. updateFur(): void;
  87332. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87333. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87334. getAnimatables(): BABYLON.IAnimatable[];
  87335. getActiveTextures(): BABYLON.BaseTexture[];
  87336. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87337. dispose(forceDisposeEffect?: boolean): void;
  87338. clone(name: string): FurMaterial;
  87339. serialize(): any;
  87340. getClassName(): string;
  87341. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  87342. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  87343. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  87344. }
  87345. }
  87346. declare module BABYLON {
  87347. /** @hidden */
  87348. export var gradientPixelShader: {
  87349. name: string;
  87350. shader: string;
  87351. };
  87352. }
  87353. declare module BABYLON {
  87354. /** @hidden */
  87355. export var gradientVertexShader: {
  87356. name: string;
  87357. shader: string;
  87358. };
  87359. }
  87360. declare module BABYLON {
  87361. export class GradientMaterial extends BABYLON.PushMaterial {
  87362. private _maxSimultaneousLights;
  87363. maxSimultaneousLights: number;
  87364. topColor: BABYLON.Color3;
  87365. topColorAlpha: number;
  87366. bottomColor: BABYLON.Color3;
  87367. bottomColorAlpha: number;
  87368. offset: number;
  87369. scale: number;
  87370. smoothness: number;
  87371. private _disableLighting;
  87372. disableLighting: boolean;
  87373. constructor(name: string, scene: BABYLON.Scene);
  87374. needAlphaBlending(): boolean;
  87375. needAlphaTesting(): boolean;
  87376. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87377. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87378. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87379. getAnimatables(): BABYLON.IAnimatable[];
  87380. dispose(forceDisposeEffect?: boolean): void;
  87381. clone(name: string): GradientMaterial;
  87382. serialize(): any;
  87383. getClassName(): string;
  87384. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  87385. }
  87386. }
  87387. declare module BABYLON {
  87388. /** @hidden */
  87389. export var gridPixelShader: {
  87390. name: string;
  87391. shader: string;
  87392. };
  87393. }
  87394. declare module BABYLON {
  87395. /** @hidden */
  87396. export var gridVertexShader: {
  87397. name: string;
  87398. shader: string;
  87399. };
  87400. }
  87401. declare module BABYLON {
  87402. /**
  87403. * The grid materials allows you to wrap any shape with a grid.
  87404. * Colors are customizable.
  87405. */
  87406. export class GridMaterial extends BABYLON.PushMaterial {
  87407. /**
  87408. * Main color of the grid (e.g. between lines)
  87409. */
  87410. mainColor: BABYLON.Color3;
  87411. /**
  87412. * Color of the grid lines.
  87413. */
  87414. lineColor: BABYLON.Color3;
  87415. /**
  87416. * The scale of the grid compared to unit.
  87417. */
  87418. gridRatio: number;
  87419. /**
  87420. * Allows setting an offset for the grid lines.
  87421. */
  87422. gridOffset: BABYLON.Vector3;
  87423. /**
  87424. * The frequency of thicker lines.
  87425. */
  87426. majorUnitFrequency: number;
  87427. /**
  87428. * The visibility of minor units in the grid.
  87429. */
  87430. minorUnitVisibility: number;
  87431. /**
  87432. * The grid opacity outside of the lines.
  87433. */
  87434. opacity: number;
  87435. /**
  87436. * Determine RBG output is premultiplied by alpha value.
  87437. */
  87438. preMultiplyAlpha: boolean;
  87439. private _opacityTexture;
  87440. opacityTexture: BABYLON.BaseTexture;
  87441. private _gridControl;
  87442. /**
  87443. * constructor
  87444. * @param name The name given to the material in order to identify it afterwards.
  87445. * @param scene The scene the material is used in.
  87446. */
  87447. constructor(name: string, scene: BABYLON.Scene);
  87448. /**
  87449. * Returns wehter or not the grid requires alpha blending.
  87450. */
  87451. needAlphaBlending(): boolean;
  87452. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  87453. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87454. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87455. /**
  87456. * Dispose the material and its associated resources.
  87457. * @param forceDisposeEffect will also dispose the used effect when true
  87458. */
  87459. dispose(forceDisposeEffect?: boolean): void;
  87460. clone(name: string): GridMaterial;
  87461. serialize(): any;
  87462. getClassName(): string;
  87463. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  87464. }
  87465. }
  87466. declare module BABYLON {
  87467. /** @hidden */
  87468. export var lavaPixelShader: {
  87469. name: string;
  87470. shader: string;
  87471. };
  87472. }
  87473. declare module BABYLON {
  87474. /** @hidden */
  87475. export var lavaVertexShader: {
  87476. name: string;
  87477. shader: string;
  87478. };
  87479. }
  87480. declare module BABYLON {
  87481. export class LavaMaterial extends BABYLON.PushMaterial {
  87482. private _diffuseTexture;
  87483. diffuseTexture: BABYLON.BaseTexture;
  87484. noiseTexture: BABYLON.BaseTexture;
  87485. fogColor: BABYLON.Color3;
  87486. speed: number;
  87487. movingSpeed: number;
  87488. lowFrequencySpeed: number;
  87489. fogDensity: number;
  87490. private _lastTime;
  87491. diffuseColor: BABYLON.Color3;
  87492. private _disableLighting;
  87493. disableLighting: boolean;
  87494. private _unlit;
  87495. unlit: boolean;
  87496. private _maxSimultaneousLights;
  87497. maxSimultaneousLights: number;
  87498. private _scaledDiffuse;
  87499. constructor(name: string, scene: BABYLON.Scene);
  87500. needAlphaBlending(): boolean;
  87501. needAlphaTesting(): boolean;
  87502. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87503. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87504. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87505. getAnimatables(): BABYLON.IAnimatable[];
  87506. getActiveTextures(): BABYLON.BaseTexture[];
  87507. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87508. dispose(forceDisposeEffect?: boolean): void;
  87509. clone(name: string): LavaMaterial;
  87510. serialize(): any;
  87511. getClassName(): string;
  87512. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  87513. }
  87514. }
  87515. declare module BABYLON {
  87516. /** @hidden */
  87517. export var mixPixelShader: {
  87518. name: string;
  87519. shader: string;
  87520. };
  87521. }
  87522. declare module BABYLON {
  87523. /** @hidden */
  87524. export var mixVertexShader: {
  87525. name: string;
  87526. shader: string;
  87527. };
  87528. }
  87529. declare module BABYLON {
  87530. export class MixMaterial extends BABYLON.PushMaterial {
  87531. /**
  87532. * Mix textures
  87533. */
  87534. private _mixTexture1;
  87535. mixTexture1: BABYLON.BaseTexture;
  87536. private _mixTexture2;
  87537. mixTexture2: BABYLON.BaseTexture;
  87538. /**
  87539. * Diffuse textures
  87540. */
  87541. private _diffuseTexture1;
  87542. diffuseTexture1: BABYLON.Texture;
  87543. private _diffuseTexture2;
  87544. diffuseTexture2: BABYLON.Texture;
  87545. private _diffuseTexture3;
  87546. diffuseTexture3: BABYLON.Texture;
  87547. private _diffuseTexture4;
  87548. diffuseTexture4: BABYLON.Texture;
  87549. private _diffuseTexture5;
  87550. diffuseTexture5: BABYLON.Texture;
  87551. private _diffuseTexture6;
  87552. diffuseTexture6: BABYLON.Texture;
  87553. private _diffuseTexture7;
  87554. diffuseTexture7: BABYLON.Texture;
  87555. private _diffuseTexture8;
  87556. diffuseTexture8: BABYLON.Texture;
  87557. /**
  87558. * Uniforms
  87559. */
  87560. diffuseColor: BABYLON.Color3;
  87561. specularColor: BABYLON.Color3;
  87562. specularPower: number;
  87563. private _disableLighting;
  87564. disableLighting: boolean;
  87565. private _maxSimultaneousLights;
  87566. maxSimultaneousLights: number;
  87567. constructor(name: string, scene: BABYLON.Scene);
  87568. needAlphaBlending(): boolean;
  87569. needAlphaTesting(): boolean;
  87570. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87571. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87572. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87573. getAnimatables(): BABYLON.IAnimatable[];
  87574. getActiveTextures(): BABYLON.BaseTexture[];
  87575. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87576. dispose(forceDisposeEffect?: boolean): void;
  87577. clone(name: string): MixMaterial;
  87578. serialize(): any;
  87579. getClassName(): string;
  87580. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  87581. }
  87582. }
  87583. declare module BABYLON {
  87584. /** @hidden */
  87585. export var normalPixelShader: {
  87586. name: string;
  87587. shader: string;
  87588. };
  87589. }
  87590. declare module BABYLON {
  87591. /** @hidden */
  87592. export var normalVertexShader: {
  87593. name: string;
  87594. shader: string;
  87595. };
  87596. }
  87597. declare module BABYLON {
  87598. export class NormalMaterial extends BABYLON.PushMaterial {
  87599. private _diffuseTexture;
  87600. diffuseTexture: BABYLON.BaseTexture;
  87601. diffuseColor: BABYLON.Color3;
  87602. private _disableLighting;
  87603. disableLighting: boolean;
  87604. private _maxSimultaneousLights;
  87605. maxSimultaneousLights: number;
  87606. constructor(name: string, scene: BABYLON.Scene);
  87607. needAlphaBlending(): boolean;
  87608. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  87609. needAlphaTesting(): boolean;
  87610. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87611. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87612. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87613. getAnimatables(): BABYLON.IAnimatable[];
  87614. getActiveTextures(): BABYLON.BaseTexture[];
  87615. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87616. dispose(forceDisposeEffect?: boolean): void;
  87617. clone(name: string): NormalMaterial;
  87618. serialize(): any;
  87619. getClassName(): string;
  87620. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  87621. }
  87622. }
  87623. declare module BABYLON {
  87624. /** @hidden */
  87625. export var shadowOnlyPixelShader: {
  87626. name: string;
  87627. shader: string;
  87628. };
  87629. }
  87630. declare module BABYLON {
  87631. /** @hidden */
  87632. export var shadowOnlyVertexShader: {
  87633. name: string;
  87634. shader: string;
  87635. };
  87636. }
  87637. declare module BABYLON {
  87638. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  87639. private _activeLight;
  87640. private _needAlphaBlending;
  87641. constructor(name: string, scene: BABYLON.Scene);
  87642. shadowColor: BABYLON.Color3;
  87643. needAlphaBlending(): boolean;
  87644. needAlphaTesting(): boolean;
  87645. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87646. get activeLight(): BABYLON.IShadowLight;
  87647. set activeLight(light: BABYLON.IShadowLight);
  87648. private _getFirstShadowLightForMesh;
  87649. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87650. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87651. clone(name: string): ShadowOnlyMaterial;
  87652. serialize(): any;
  87653. getClassName(): string;
  87654. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  87655. }
  87656. }
  87657. declare module BABYLON {
  87658. /** @hidden */
  87659. export var simplePixelShader: {
  87660. name: string;
  87661. shader: string;
  87662. };
  87663. }
  87664. declare module BABYLON {
  87665. /** @hidden */
  87666. export var simpleVertexShader: {
  87667. name: string;
  87668. shader: string;
  87669. };
  87670. }
  87671. declare module BABYLON {
  87672. export class SimpleMaterial extends BABYLON.PushMaterial {
  87673. private _diffuseTexture;
  87674. diffuseTexture: BABYLON.BaseTexture;
  87675. diffuseColor: BABYLON.Color3;
  87676. private _disableLighting;
  87677. disableLighting: boolean;
  87678. private _maxSimultaneousLights;
  87679. maxSimultaneousLights: number;
  87680. constructor(name: string, scene: BABYLON.Scene);
  87681. needAlphaBlending(): boolean;
  87682. needAlphaTesting(): boolean;
  87683. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87684. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87685. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87686. getAnimatables(): BABYLON.IAnimatable[];
  87687. getActiveTextures(): BABYLON.BaseTexture[];
  87688. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87689. dispose(forceDisposeEffect?: boolean): void;
  87690. clone(name: string): SimpleMaterial;
  87691. serialize(): any;
  87692. getClassName(): string;
  87693. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  87694. }
  87695. }
  87696. declare module BABYLON {
  87697. /** @hidden */
  87698. export var skyPixelShader: {
  87699. name: string;
  87700. shader: string;
  87701. };
  87702. }
  87703. declare module BABYLON {
  87704. /** @hidden */
  87705. export var skyVertexShader: {
  87706. name: string;
  87707. shader: string;
  87708. };
  87709. }
  87710. declare module BABYLON {
  87711. /**
  87712. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  87713. * @see https://doc.babylonjs.com/extensions/sky
  87714. */
  87715. export class SkyMaterial extends BABYLON.PushMaterial {
  87716. /**
  87717. * Defines the overall luminance of sky in interval ]0, 1[.
  87718. */
  87719. luminance: number;
  87720. /**
  87721. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  87722. */
  87723. turbidity: number;
  87724. /**
  87725. * Defines the sky appearance (light intensity).
  87726. */
  87727. rayleigh: number;
  87728. /**
  87729. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  87730. */
  87731. mieCoefficient: number;
  87732. /**
  87733. * Defines the amount of haze particles following the Mie scattering theory.
  87734. */
  87735. mieDirectionalG: number;
  87736. /**
  87737. * Defines the distance of the sun according to the active scene camera.
  87738. */
  87739. distance: number;
  87740. /**
  87741. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  87742. * "inclined".
  87743. */
  87744. inclination: number;
  87745. /**
  87746. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  87747. * an object direction and a reference direction.
  87748. */
  87749. azimuth: number;
  87750. /**
  87751. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  87752. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  87753. */
  87754. sunPosition: BABYLON.Vector3;
  87755. /**
  87756. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  87757. * .sunPosition property.
  87758. */
  87759. useSunPosition: boolean;
  87760. /**
  87761. * Defines an offset vector used to get a horizon offset.
  87762. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  87763. */
  87764. cameraOffset: BABYLON.Vector3;
  87765. private _cameraPosition;
  87766. /**
  87767. * Instantiates a new sky material.
  87768. * This material allows to create dynamic and texture free
  87769. * effects for skyboxes by taking care of the atmosphere state.
  87770. * @see https://doc.babylonjs.com/extensions/sky
  87771. * @param name Define the name of the material in the scene
  87772. * @param scene Define the scene the material belong to
  87773. */
  87774. constructor(name: string, scene: BABYLON.Scene);
  87775. /**
  87776. * Specifies if the material will require alpha blending
  87777. * @returns a boolean specifying if alpha blending is needed
  87778. */
  87779. needAlphaBlending(): boolean;
  87780. /**
  87781. * Specifies if this material should be rendered in alpha test mode
  87782. * @returns false as the sky material doesn't need alpha testing.
  87783. */
  87784. needAlphaTesting(): boolean;
  87785. /**
  87786. * Get the texture used for alpha test purpose.
  87787. * @returns null as the sky material has no texture.
  87788. */
  87789. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87790. /**
  87791. * Get if the submesh is ready to be used and all its information available.
  87792. * Child classes can use it to update shaders
  87793. * @param mesh defines the mesh to check
  87794. * @param subMesh defines which submesh to check
  87795. * @param useInstances specifies that instances should be used
  87796. * @returns a boolean indicating that the submesh is ready or not
  87797. */
  87798. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87799. /**
  87800. * Binds the submesh to this material by preparing the effect and shader to draw
  87801. * @param world defines the world transformation matrix
  87802. * @param mesh defines the mesh containing the submesh
  87803. * @param subMesh defines the submesh to bind the material to
  87804. */
  87805. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87806. /**
  87807. * Get the list of animatables in the material.
  87808. * @returns the list of animatables object used in the material
  87809. */
  87810. getAnimatables(): BABYLON.IAnimatable[];
  87811. /**
  87812. * Disposes the material
  87813. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87814. */
  87815. dispose(forceDisposeEffect?: boolean): void;
  87816. /**
  87817. * Makes a duplicate of the material, and gives it a new name
  87818. * @param name defines the new name for the duplicated material
  87819. * @returns the cloned material
  87820. */
  87821. clone(name: string): SkyMaterial;
  87822. /**
  87823. * Serializes this material in a JSON representation
  87824. * @returns the serialized material object
  87825. */
  87826. serialize(): any;
  87827. /**
  87828. * Gets the current class name of the material e.g. "SkyMaterial"
  87829. * Mainly use in serialization.
  87830. * @returns the class name
  87831. */
  87832. getClassName(): string;
  87833. /**
  87834. * Creates a sky material from parsed material data
  87835. * @param source defines the JSON representation of the material
  87836. * @param scene defines the hosting scene
  87837. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  87838. * @returns a new sky material
  87839. */
  87840. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  87841. }
  87842. }
  87843. declare module BABYLON {
  87844. /** @hidden */
  87845. export var terrainPixelShader: {
  87846. name: string;
  87847. shader: string;
  87848. };
  87849. }
  87850. declare module BABYLON {
  87851. /** @hidden */
  87852. export var terrainVertexShader: {
  87853. name: string;
  87854. shader: string;
  87855. };
  87856. }
  87857. declare module BABYLON {
  87858. export class TerrainMaterial extends BABYLON.PushMaterial {
  87859. private _mixTexture;
  87860. mixTexture: BABYLON.BaseTexture;
  87861. private _diffuseTexture1;
  87862. diffuseTexture1: BABYLON.Texture;
  87863. private _diffuseTexture2;
  87864. diffuseTexture2: BABYLON.Texture;
  87865. private _diffuseTexture3;
  87866. diffuseTexture3: BABYLON.Texture;
  87867. private _bumpTexture1;
  87868. bumpTexture1: BABYLON.Texture;
  87869. private _bumpTexture2;
  87870. bumpTexture2: BABYLON.Texture;
  87871. private _bumpTexture3;
  87872. bumpTexture3: BABYLON.Texture;
  87873. diffuseColor: BABYLON.Color3;
  87874. specularColor: BABYLON.Color3;
  87875. specularPower: number;
  87876. private _disableLighting;
  87877. disableLighting: boolean;
  87878. private _maxSimultaneousLights;
  87879. maxSimultaneousLights: number;
  87880. constructor(name: string, scene: BABYLON.Scene);
  87881. needAlphaBlending(): boolean;
  87882. needAlphaTesting(): boolean;
  87883. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87884. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87885. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87886. getAnimatables(): BABYLON.IAnimatable[];
  87887. getActiveTextures(): BABYLON.BaseTexture[];
  87888. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87889. dispose(forceDisposeEffect?: boolean): void;
  87890. clone(name: string): TerrainMaterial;
  87891. serialize(): any;
  87892. getClassName(): string;
  87893. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  87894. }
  87895. }
  87896. declare module BABYLON {
  87897. /** @hidden */
  87898. export var triplanarPixelShader: {
  87899. name: string;
  87900. shader: string;
  87901. };
  87902. }
  87903. declare module BABYLON {
  87904. /** @hidden */
  87905. export var triplanarVertexShader: {
  87906. name: string;
  87907. shader: string;
  87908. };
  87909. }
  87910. declare module BABYLON {
  87911. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  87912. mixTexture: BABYLON.BaseTexture;
  87913. private _diffuseTextureX;
  87914. diffuseTextureX: BABYLON.BaseTexture;
  87915. private _diffuseTextureY;
  87916. diffuseTextureY: BABYLON.BaseTexture;
  87917. private _diffuseTextureZ;
  87918. diffuseTextureZ: BABYLON.BaseTexture;
  87919. private _normalTextureX;
  87920. normalTextureX: BABYLON.BaseTexture;
  87921. private _normalTextureY;
  87922. normalTextureY: BABYLON.BaseTexture;
  87923. private _normalTextureZ;
  87924. normalTextureZ: BABYLON.BaseTexture;
  87925. tileSize: number;
  87926. diffuseColor: BABYLON.Color3;
  87927. specularColor: BABYLON.Color3;
  87928. specularPower: number;
  87929. private _disableLighting;
  87930. disableLighting: boolean;
  87931. private _maxSimultaneousLights;
  87932. maxSimultaneousLights: number;
  87933. constructor(name: string, scene: BABYLON.Scene);
  87934. needAlphaBlending(): boolean;
  87935. needAlphaTesting(): boolean;
  87936. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87937. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87938. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87939. getAnimatables(): BABYLON.IAnimatable[];
  87940. getActiveTextures(): BABYLON.BaseTexture[];
  87941. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87942. dispose(forceDisposeEffect?: boolean): void;
  87943. clone(name: string): TriPlanarMaterial;
  87944. serialize(): any;
  87945. getClassName(): string;
  87946. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  87947. }
  87948. }
  87949. declare module BABYLON {
  87950. /** @hidden */
  87951. export var waterPixelShader: {
  87952. name: string;
  87953. shader: string;
  87954. };
  87955. }
  87956. declare module BABYLON {
  87957. /** @hidden */
  87958. export var waterVertexShader: {
  87959. name: string;
  87960. shader: string;
  87961. };
  87962. }
  87963. declare module BABYLON {
  87964. export class WaterMaterial extends BABYLON.PushMaterial {
  87965. renderTargetSize: BABYLON.Vector2;
  87966. private _bumpTexture;
  87967. bumpTexture: BABYLON.BaseTexture;
  87968. diffuseColor: BABYLON.Color3;
  87969. specularColor: BABYLON.Color3;
  87970. specularPower: number;
  87971. private _disableLighting;
  87972. disableLighting: boolean;
  87973. private _maxSimultaneousLights;
  87974. maxSimultaneousLights: number;
  87975. /**
  87976. * Defines the wind force.
  87977. */
  87978. windForce: number;
  87979. /**
  87980. * Defines the direction of the wind in the plane (X, Z).
  87981. */
  87982. windDirection: BABYLON.Vector2;
  87983. /**
  87984. * Defines the height of the waves.
  87985. */
  87986. waveHeight: number;
  87987. /**
  87988. * Defines the bump height related to the bump map.
  87989. */
  87990. bumpHeight: number;
  87991. /**
  87992. * Defines wether or not: to add a smaller moving bump to less steady waves.
  87993. */
  87994. private _bumpSuperimpose;
  87995. bumpSuperimpose: boolean;
  87996. /**
  87997. * Defines wether or not color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  87998. */
  87999. private _fresnelSeparate;
  88000. fresnelSeparate: boolean;
  88001. /**
  88002. * Defines wether or not bump Wwves modify the reflection.
  88003. */
  88004. private _bumpAffectsReflection;
  88005. bumpAffectsReflection: boolean;
  88006. /**
  88007. * Defines the water color blended with the refraction (near).
  88008. */
  88009. waterColor: BABYLON.Color3;
  88010. /**
  88011. * Defines the blend factor related to the water color.
  88012. */
  88013. colorBlendFactor: number;
  88014. /**
  88015. * Defines the water color blended with the reflection (far).
  88016. */
  88017. waterColor2: BABYLON.Color3;
  88018. /**
  88019. * Defines the blend factor related to the water color (reflection, far).
  88020. */
  88021. colorBlendFactor2: number;
  88022. /**
  88023. * Defines the maximum length of a wave.
  88024. */
  88025. waveLength: number;
  88026. /**
  88027. * Defines the waves speed.
  88028. */
  88029. waveSpeed: number;
  88030. /**
  88031. * Defines the number of times waves are repeated. This is typically used to adjust waves count according to the ground's size where the material is applied on.
  88032. */
  88033. waveCount: number;
  88034. /**
  88035. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  88036. * will avoid calculating useless pixels in the pixel shader of the water material.
  88037. */
  88038. disableClipPlane: boolean;
  88039. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  88040. private _mesh;
  88041. private _refractionRTT;
  88042. private _reflectionRTT;
  88043. private _reflectionTransform;
  88044. private _lastTime;
  88045. private _lastDeltaTime;
  88046. private _useLogarithmicDepth;
  88047. private _waitingRenderList;
  88048. private _imageProcessingConfiguration;
  88049. private _imageProcessingObserver;
  88050. /**
  88051. * Gets a boolean indicating that current material needs to register RTT
  88052. */
  88053. get hasRenderTargetTextures(): boolean;
  88054. /**
  88055. * Constructor
  88056. */
  88057. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  88058. get useLogarithmicDepth(): boolean;
  88059. set useLogarithmicDepth(value: boolean);
  88060. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  88061. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  88062. addToRenderList(node: any): void;
  88063. enableRenderTargets(enable: boolean): void;
  88064. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  88065. get renderTargetsEnabled(): boolean;
  88066. needAlphaBlending(): boolean;
  88067. needAlphaTesting(): boolean;
  88068. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  88069. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  88070. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  88071. private _createRenderTargets;
  88072. getAnimatables(): BABYLON.IAnimatable[];
  88073. getActiveTextures(): BABYLON.BaseTexture[];
  88074. hasTexture(texture: BABYLON.BaseTexture): boolean;
  88075. dispose(forceDisposeEffect?: boolean): void;
  88076. clone(name: string): WaterMaterial;
  88077. serialize(): any;
  88078. getClassName(): string;
  88079. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  88080. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  88081. }
  88082. }
  88083. declare module BABYLON {
  88084. /** @hidden */
  88085. export var asciiartPixelShader: {
  88086. name: string;
  88087. shader: string;
  88088. };
  88089. }
  88090. declare module BABYLON {
  88091. /**
  88092. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  88093. *
  88094. * It basically takes care rendering the font front the given font size to a texture.
  88095. * This is used later on in the postprocess.
  88096. */
  88097. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  88098. private _font;
  88099. private _text;
  88100. private _charSize;
  88101. /**
  88102. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  88103. */
  88104. get charSize(): number;
  88105. /**
  88106. * Create a new instance of the Ascii Art FontTexture class
  88107. * @param name the name of the texture
  88108. * @param font the font to use, use the W3C CSS notation
  88109. * @param text the caracter set to use in the rendering.
  88110. * @param scene the scene that owns the texture
  88111. */
  88112. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  88113. /**
  88114. * Gets the max char width of a font.
  88115. * @param font the font to use, use the W3C CSS notation
  88116. * @return the max char width
  88117. */
  88118. private getFontWidth;
  88119. /**
  88120. * Gets the max char height of a font.
  88121. * @param font the font to use, use the W3C CSS notation
  88122. * @return the max char height
  88123. */
  88124. private getFontHeight;
  88125. /**
  88126. * Clones the current AsciiArtTexture.
  88127. * @return the clone of the texture.
  88128. */
  88129. clone(): AsciiArtFontTexture;
  88130. /**
  88131. * Parses a json object representing the texture and returns an instance of it.
  88132. * @param source the source JSON representation
  88133. * @param scene the scene to create the texture for
  88134. * @return the parsed texture
  88135. */
  88136. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  88137. }
  88138. /**
  88139. * Option available in the Ascii Art Post Process.
  88140. */
  88141. export interface IAsciiArtPostProcessOptions {
  88142. /**
  88143. * The font to use following the w3c font definition.
  88144. */
  88145. font?: string;
  88146. /**
  88147. * The character set to use in the postprocess.
  88148. */
  88149. characterSet?: string;
  88150. /**
  88151. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  88152. * This number is defined between 0 and 1;
  88153. */
  88154. mixToTile?: number;
  88155. /**
  88156. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  88157. * This number is defined between 0 and 1;
  88158. */
  88159. mixToNormal?: number;
  88160. }
  88161. /**
  88162. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  88163. *
  88164. * Simmply add it to your scene and let the nerd that lives in you have fun.
  88165. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  88166. */
  88167. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  88168. /**
  88169. * The font texture used to render the char in the post process.
  88170. */
  88171. private _asciiArtFontTexture;
  88172. /**
  88173. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  88174. * This number is defined between 0 and 1;
  88175. */
  88176. mixToTile: number;
  88177. /**
  88178. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  88179. * This number is defined between 0 and 1;
  88180. */
  88181. mixToNormal: number;
  88182. /**
  88183. * Instantiates a new Ascii Art Post Process.
  88184. * @param name the name to give to the postprocess
  88185. * @camera the camera to apply the post process to.
  88186. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  88187. */
  88188. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  88189. }
  88190. }
  88191. declare module BABYLON {
  88192. /** @hidden */
  88193. export var digitalrainPixelShader: {
  88194. name: string;
  88195. shader: string;
  88196. };
  88197. }
  88198. declare module BABYLON {
  88199. /**
  88200. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  88201. *
  88202. * It basically takes care rendering the font front the given font size to a texture.
  88203. * This is used later on in the postprocess.
  88204. */
  88205. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  88206. private _font;
  88207. private _text;
  88208. private _charSize;
  88209. /**
  88210. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  88211. */
  88212. get charSize(): number;
  88213. /**
  88214. * Create a new instance of the Digital Rain FontTexture class
  88215. * @param name the name of the texture
  88216. * @param font the font to use, use the W3C CSS notation
  88217. * @param text the caracter set to use in the rendering.
  88218. * @param scene the scene that owns the texture
  88219. */
  88220. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  88221. /**
  88222. * Gets the max char width of a font.
  88223. * @param font the font to use, use the W3C CSS notation
  88224. * @return the max char width
  88225. */
  88226. private getFontWidth;
  88227. /**
  88228. * Gets the max char height of a font.
  88229. * @param font the font to use, use the W3C CSS notation
  88230. * @return the max char height
  88231. */
  88232. private getFontHeight;
  88233. /**
  88234. * Clones the current DigitalRainFontTexture.
  88235. * @return the clone of the texture.
  88236. */
  88237. clone(): DigitalRainFontTexture;
  88238. /**
  88239. * Parses a json object representing the texture and returns an instance of it.
  88240. * @param source the source JSON representation
  88241. * @param scene the scene to create the texture for
  88242. * @return the parsed texture
  88243. */
  88244. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  88245. }
  88246. /**
  88247. * Option available in the Digital Rain Post Process.
  88248. */
  88249. export interface IDigitalRainPostProcessOptions {
  88250. /**
  88251. * The font to use following the w3c font definition.
  88252. */
  88253. font?: string;
  88254. /**
  88255. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  88256. * This number is defined between 0 and 1;
  88257. */
  88258. mixToTile?: number;
  88259. /**
  88260. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  88261. * This number is defined between 0 and 1;
  88262. */
  88263. mixToNormal?: number;
  88264. }
  88265. /**
  88266. * DigitalRainPostProcess helps rendering everithing in digital rain.
  88267. *
  88268. * Simmply add it to your scene and let the nerd that lives in you have fun.
  88269. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  88270. */
  88271. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  88272. /**
  88273. * The font texture used to render the char in the post process.
  88274. */
  88275. private _digitalRainFontTexture;
  88276. /**
  88277. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  88278. * This number is defined between 0 and 1;
  88279. */
  88280. mixToTile: number;
  88281. /**
  88282. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  88283. * This number is defined between 0 and 1;
  88284. */
  88285. mixToNormal: number;
  88286. /**
  88287. * Instantiates a new Digital Rain Post Process.
  88288. * @param name the name to give to the postprocess
  88289. * @camera the camera to apply the post process to.
  88290. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  88291. */
  88292. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  88293. }
  88294. }
  88295. declare module BABYLON {
  88296. /** @hidden */
  88297. export var brickProceduralTexturePixelShader: {
  88298. name: string;
  88299. shader: string;
  88300. };
  88301. }
  88302. declare module BABYLON {
  88303. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  88304. private _numberOfBricksHeight;
  88305. private _numberOfBricksWidth;
  88306. private _jointColor;
  88307. private _brickColor;
  88308. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88309. updateShaderUniforms(): void;
  88310. get numberOfBricksHeight(): number;
  88311. set numberOfBricksHeight(value: number);
  88312. get numberOfBricksWidth(): number;
  88313. set numberOfBricksWidth(value: number);
  88314. get jointColor(): BABYLON.Color3;
  88315. set jointColor(value: BABYLON.Color3);
  88316. get brickColor(): BABYLON.Color3;
  88317. set brickColor(value: BABYLON.Color3);
  88318. /**
  88319. * Serializes this brick procedural texture
  88320. * @returns a serialized brick procedural texture object
  88321. */
  88322. serialize(): any;
  88323. /**
  88324. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  88325. * @param parsedTexture defines parsed texture data
  88326. * @param scene defines the current scene
  88327. * @param rootUrl defines the root URL containing brick procedural texture information
  88328. * @returns a parsed Brick Procedural BABYLON.Texture
  88329. */
  88330. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  88331. }
  88332. }
  88333. declare module BABYLON {
  88334. /** @hidden */
  88335. export var cloudProceduralTexturePixelShader: {
  88336. name: string;
  88337. shader: string;
  88338. };
  88339. }
  88340. declare module BABYLON {
  88341. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  88342. private _skyColor;
  88343. private _cloudColor;
  88344. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88345. updateShaderUniforms(): void;
  88346. get skyColor(): BABYLON.Color4;
  88347. set skyColor(value: BABYLON.Color4);
  88348. get cloudColor(): BABYLON.Color4;
  88349. set cloudColor(value: BABYLON.Color4);
  88350. /**
  88351. * Serializes this cloud procedural texture
  88352. * @returns a serialized cloud procedural texture object
  88353. */
  88354. serialize(): any;
  88355. /**
  88356. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  88357. * @param parsedTexture defines parsed texture data
  88358. * @param scene defines the current scene
  88359. * @param rootUrl defines the root URL containing cloud procedural texture information
  88360. * @returns a parsed Cloud Procedural BABYLON.Texture
  88361. */
  88362. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  88363. }
  88364. }
  88365. declare module BABYLON {
  88366. /** @hidden */
  88367. export var fireProceduralTexturePixelShader: {
  88368. name: string;
  88369. shader: string;
  88370. };
  88371. }
  88372. declare module BABYLON {
  88373. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  88374. private _time;
  88375. private _speed;
  88376. private _autoGenerateTime;
  88377. private _fireColors;
  88378. private _alphaThreshold;
  88379. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88380. updateShaderUniforms(): void;
  88381. render(useCameraPostProcess?: boolean): void;
  88382. static get PurpleFireColors(): BABYLON.Color3[];
  88383. static get GreenFireColors(): BABYLON.Color3[];
  88384. static get RedFireColors(): BABYLON.Color3[];
  88385. static get BlueFireColors(): BABYLON.Color3[];
  88386. get autoGenerateTime(): boolean;
  88387. set autoGenerateTime(value: boolean);
  88388. get fireColors(): BABYLON.Color3[];
  88389. set fireColors(value: BABYLON.Color3[]);
  88390. get time(): number;
  88391. set time(value: number);
  88392. get speed(): BABYLON.Vector2;
  88393. set speed(value: BABYLON.Vector2);
  88394. get alphaThreshold(): number;
  88395. set alphaThreshold(value: number);
  88396. /**
  88397. * Serializes this fire procedural texture
  88398. * @returns a serialized fire procedural texture object
  88399. */
  88400. serialize(): any;
  88401. /**
  88402. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  88403. * @param parsedTexture defines parsed texture data
  88404. * @param scene defines the current scene
  88405. * @param rootUrl defines the root URL containing fire procedural texture information
  88406. * @returns a parsed Fire Procedural BABYLON.Texture
  88407. */
  88408. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  88409. }
  88410. }
  88411. declare module BABYLON {
  88412. /** @hidden */
  88413. export var grassProceduralTexturePixelShader: {
  88414. name: string;
  88415. shader: string;
  88416. };
  88417. }
  88418. declare module BABYLON {
  88419. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  88420. private _grassColors;
  88421. private _groundColor;
  88422. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88423. updateShaderUniforms(): void;
  88424. get grassColors(): BABYLON.Color3[];
  88425. set grassColors(value: BABYLON.Color3[]);
  88426. get groundColor(): BABYLON.Color3;
  88427. set groundColor(value: BABYLON.Color3);
  88428. /**
  88429. * Serializes this grass procedural texture
  88430. * @returns a serialized grass procedural texture object
  88431. */
  88432. serialize(): any;
  88433. /**
  88434. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  88435. * @param parsedTexture defines parsed texture data
  88436. * @param scene defines the current scene
  88437. * @param rootUrl defines the root URL containing grass procedural texture information
  88438. * @returns a parsed Grass Procedural BABYLON.Texture
  88439. */
  88440. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  88441. }
  88442. }
  88443. declare module BABYLON {
  88444. /** @hidden */
  88445. export var marbleProceduralTexturePixelShader: {
  88446. name: string;
  88447. shader: string;
  88448. };
  88449. }
  88450. declare module BABYLON {
  88451. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  88452. private _numberOfTilesHeight;
  88453. private _numberOfTilesWidth;
  88454. private _amplitude;
  88455. private _jointColor;
  88456. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88457. updateShaderUniforms(): void;
  88458. get numberOfTilesHeight(): number;
  88459. set numberOfTilesHeight(value: number);
  88460. get amplitude(): number;
  88461. set amplitude(value: number);
  88462. get numberOfTilesWidth(): number;
  88463. set numberOfTilesWidth(value: number);
  88464. get jointColor(): BABYLON.Color3;
  88465. set jointColor(value: BABYLON.Color3);
  88466. /**
  88467. * Serializes this marble procedural texture
  88468. * @returns a serialized marble procedural texture object
  88469. */
  88470. serialize(): any;
  88471. /**
  88472. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  88473. * @param parsedTexture defines parsed texture data
  88474. * @param scene defines the current scene
  88475. * @param rootUrl defines the root URL containing marble procedural texture information
  88476. * @returns a parsed Marble Procedural BABYLON.Texture
  88477. */
  88478. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  88479. }
  88480. }
  88481. declare module BABYLON {
  88482. /** @hidden */
  88483. export var normalMapProceduralTexturePixelShader: {
  88484. name: string;
  88485. shader: string;
  88486. };
  88487. }
  88488. declare module BABYLON {
  88489. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  88490. private _baseTexture;
  88491. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88492. updateShaderUniforms(): void;
  88493. render(useCameraPostProcess?: boolean): void;
  88494. resize(size: any, generateMipMaps: any): void;
  88495. get baseTexture(): BABYLON.Texture;
  88496. set baseTexture(texture: BABYLON.Texture);
  88497. /**
  88498. * Serializes this normal map procedural texture
  88499. * @returns a serialized normal map procedural texture object
  88500. */
  88501. serialize(): any;
  88502. /**
  88503. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  88504. * @param parsedTexture defines parsed texture data
  88505. * @param scene defines the current scene
  88506. * @param rootUrl defines the root URL containing normal map procedural texture information
  88507. * @returns a parsed Normal Map Procedural BABYLON.Texture
  88508. */
  88509. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  88510. }
  88511. }
  88512. declare module BABYLON {
  88513. /** @hidden */
  88514. export var perlinNoiseProceduralTexturePixelShader: {
  88515. name: string;
  88516. shader: string;
  88517. };
  88518. }
  88519. declare module BABYLON {
  88520. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  88521. time: number;
  88522. timeScale: number;
  88523. translationSpeed: number;
  88524. private _currentTranslation;
  88525. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88526. updateShaderUniforms(): void;
  88527. render(useCameraPostProcess?: boolean): void;
  88528. resize(size: any, generateMipMaps: any): void;
  88529. /**
  88530. * Serializes this perlin noise procedural texture
  88531. * @returns a serialized perlin noise procedural texture object
  88532. */
  88533. serialize(): any;
  88534. /**
  88535. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  88536. * @param parsedTexture defines parsed texture data
  88537. * @param scene defines the current scene
  88538. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  88539. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  88540. */
  88541. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  88542. }
  88543. }
  88544. declare module BABYLON {
  88545. /** @hidden */
  88546. export var roadProceduralTexturePixelShader: {
  88547. name: string;
  88548. shader: string;
  88549. };
  88550. }
  88551. declare module BABYLON {
  88552. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  88553. private _roadColor;
  88554. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88555. updateShaderUniforms(): void;
  88556. get roadColor(): BABYLON.Color3;
  88557. set roadColor(value: BABYLON.Color3);
  88558. /**
  88559. * Serializes this road procedural texture
  88560. * @returns a serialized road procedural texture object
  88561. */
  88562. serialize(): any;
  88563. /**
  88564. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  88565. * @param parsedTexture defines parsed texture data
  88566. * @param scene defines the current scene
  88567. * @param rootUrl defines the root URL containing road procedural texture information
  88568. * @returns a parsed Road Procedural BABYLON.Texture
  88569. */
  88570. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  88571. }
  88572. }
  88573. declare module BABYLON {
  88574. /** @hidden */
  88575. export var starfieldProceduralTexturePixelShader: {
  88576. name: string;
  88577. shader: string;
  88578. };
  88579. }
  88580. declare module BABYLON {
  88581. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  88582. private _time;
  88583. private _alpha;
  88584. private _beta;
  88585. private _zoom;
  88586. private _formuparam;
  88587. private _stepsize;
  88588. private _tile;
  88589. private _brightness;
  88590. private _darkmatter;
  88591. private _distfading;
  88592. private _saturation;
  88593. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88594. updateShaderUniforms(): void;
  88595. get time(): number;
  88596. set time(value: number);
  88597. get alpha(): number;
  88598. set alpha(value: number);
  88599. get beta(): number;
  88600. set beta(value: number);
  88601. get formuparam(): number;
  88602. set formuparam(value: number);
  88603. get stepsize(): number;
  88604. set stepsize(value: number);
  88605. get zoom(): number;
  88606. set zoom(value: number);
  88607. get tile(): number;
  88608. set tile(value: number);
  88609. get brightness(): number;
  88610. set brightness(value: number);
  88611. get darkmatter(): number;
  88612. set darkmatter(value: number);
  88613. get distfading(): number;
  88614. set distfading(value: number);
  88615. get saturation(): number;
  88616. set saturation(value: number);
  88617. /**
  88618. * Serializes this starfield procedural texture
  88619. * @returns a serialized starfield procedural texture object
  88620. */
  88621. serialize(): any;
  88622. /**
  88623. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  88624. * @param parsedTexture defines parsed texture data
  88625. * @param scene defines the current scene
  88626. * @param rootUrl defines the root URL containing startfield procedural texture information
  88627. * @returns a parsed Starfield Procedural BABYLON.Texture
  88628. */
  88629. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  88630. }
  88631. }
  88632. declare module BABYLON {
  88633. /** @hidden */
  88634. export var woodProceduralTexturePixelShader: {
  88635. name: string;
  88636. shader: string;
  88637. };
  88638. }
  88639. declare module BABYLON {
  88640. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  88641. private _ampScale;
  88642. private _woodColor;
  88643. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88644. updateShaderUniforms(): void;
  88645. get ampScale(): number;
  88646. set ampScale(value: number);
  88647. get woodColor(): BABYLON.Color3;
  88648. set woodColor(value: BABYLON.Color3);
  88649. /**
  88650. * Serializes this wood procedural texture
  88651. * @returns a serialized wood procedural texture object
  88652. */
  88653. serialize(): any;
  88654. /**
  88655. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  88656. * @param parsedTexture defines parsed texture data
  88657. * @param scene defines the current scene
  88658. * @param rootUrl defines the root URL containing wood procedural texture information
  88659. * @returns a parsed Wood Procedural BABYLON.Texture
  88660. */
  88661. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  88662. }
  88663. }